473,379 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Packet manipulation in C

i have written a code for packet capturing in "C".
now i need to save the packets and extract its payload from the packets.
once extracted i do some changes to the payload and reform the packet again.

i need a sample code or code for knowing what are the issues to be dealt while packet manipulation.


so if anybody will help me out with the code that would run on linux i would be glad to thank them....


waiting for ur reply..............
Mar 9 '08 #1
10 4115
sicarie
4,677 Expert Mod 4TB
Hmm, if you have the packet, I'm assuming you're using a library to do that. In that case, the library should have an API. This API will help you pull the payload and manipulate it as needed. The most common library is libpcap, is this what you are using?

What have you tried on this so far?
Mar 9 '08 #2
Hey thanks for replying...........


I have just begun this process of packet manipulation recently.
i am new to networking.ANd i do this coding on linux. i have found out some sample codes that provide me for packet capturing.

so some codes use LIBPCAP and some dont.

i have changed them a little bit for my understanding.

what i need to do is
1-i need to capture simultaneous packets
2-i need to extract payload from every packet.
3-in the mean time of manipulation, i need to save the part other than the payload.
4- once done with manipulation.
5-calculate CRC.repack the packet.
5-send it to other side.

this is what i am thinkin of doin.
but i am stuck at pckt capturing itself..

i would be happy if u help me out.
Mar 10 '08 #3
Hey thanks for replying...........


I have just begun this process of packet manipulation recently.
i am new to networking.ANd i do this coding on linux. i have found out some sample codes that provide me for packet capturing.

so some codes use LIBPCAP and some dont.

i have changed them a little bit for my understanding.

what i need to do is
1-i need to capture simultaneous packets
2-i need to extract payload from every packet.
3-in the mean time of manipulation, i need to save the part other than the payload.
4- once done with manipulation.
5-calculate CRC.repack the packet.
5-send it to other side.

this is what i am thinkin of doin.
but i am stuck at pckt capturing itself..

i would be happy if u help me out.
what is the error you get, while capturing packet?
Mar 10 '08 #4
sicarie
4,677 Expert Mod 4TB
Hey thanks for replying...........


I have just begun this process of packet manipulation recently.
i am new to networking.ANd i do this coding on linux. i have found out some sample codes that provide me for packet capturing.

so some codes use LIBPCAP and some dont.

i have changed them a little bit for my understanding.

but i am stuck at pckt capturing itself..

i would be happy if u help me out.
That's not what you said in the first post:

i have written a code for packet capturing in "C".
now i need to save the packets and extract its payload from the packets.
So you haven't started yet. You have heard of libpcap and (I'm guessing as you have seen others that don't use it) done some research on it.

Did you look at the project's hompage ? I got there by doing a google search of 'libpcap' - it was the first item returned.
Mar 10 '08 #5
i dont know where to start and.....
i want to have an idea of what to do once the packet is captured.
in the coding..
part...
as i am new to networking..im looking for a sample code that could help me out.
In writing a more stable code.
Mar 11 '08 #6
sicarie
4,677 Expert Mod 4TB
i dont know where to start and.....
i want to have an idea of what to do once the packet is captured.
in the coding..
part...
Ah, okay, so what we need to do is develop your algorithm. You know the basics of it:

capture packets
modify payload
resend packets

So at this point, you haven't decided on a library, you can still outline what you need to do with everything.

capture packets becomes:
open socket
begin listening on an interface

As you haven't said what you need to do to the payload, I can't help you with that algorithm, you'll have to come up with it yourself. Once you have your algorithm for how you are going to approach the problem, you should look at libpcap and the other libraries you have found, and see which one will allow you to listen and do the modifications you want the best.

as i am new to networking..im looking for a sample code that could help me out.
In writing a more stable code.
Nobody here is going to give you code, especially not when there is a tutorial of how to get started on the project's webpage. I suggested you read that for a reason.
Mar 11 '08 #7
i dont know where to start and.....
i want to have an idea of what to do once the packet is captured.
in the coding..
part...
as i am new to networking..im looking for a sample code that could help me out.
In writing a more stable code.
i hope this link help you to start.
Regards,
Arul
Mar 12 '08 #8
sicarie
4,677 Expert Mod 4TB
i hope this link help you to start.
Regards,
Arul
Arul-

When I clicked on your link, it took me to a SPAM SEO page. Please double-check your links before you post.
Mar 12 '08 #9
hey..
ARUL thqs.....
but can u post the LINK an another time plzzz
Mar 14 '08 #10
sicarie
4,677 Expert Mod 4TB
Seriously, you can find a bunch more code snippets by doing a Google search, you just have to put effort into it.

If you're not willing to put effort into it, you shouldn't be tackling a project like this.

Please also have a look at our Posting Guidelines which ask that you do things like search this site as well as search Google before posting.
Mar 15 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: QQ | last post by:
Hello I am a newbie on network programming. I am trying to receive a packet if((numbytes = recvfrom(udp_fd1, buf, MAXLEN-1, 0,(struct sockaddr*)&register_addr, &addr_len))==-1){ fprintf(stderr,...
4
by: Jonny | last post by:
Hi all, I am wondering if its possible to create a program to analyse tcp/ip packets over a network in c#? If so how? I have no idea where i would/should start. Any hints/tips/tricks much...
2
by: bobrics | last post by:
Hi, I would like to create a packet for a RAW socket transfer. Please let me know if this is the right approach. 1. First, I am creating a header structure where I store all the information I...
10
by: PH | last post by:
Hi guys! I need to get the remote EndPoint from when I receive packets when listening in a local port in my computer. I'm using UDP (connection-less) so I only bind the socket to my...
7
by: owolablo | last post by:
Hi, I'm writing a program that sends 1500 bytes of data at once, from the client to the server. However, the packet is broken down into 3 different segments of 500 each before getting to the...
1
by: visal | last post by:
hi Please help me.i am developing a java pgm to capture network packets using jpcap.i downloded jpcap and wpcap dll files. My pgm is: import jpcap.JpcapHandler; import jpcap.Jpcap; import...
3
by: nexus024 | last post by:
I am trying to write a program that will continuously sniff eth0 for a specific UDP packet thats being sent to a specific destination IP, alter the data of the packet, and finally transmit it to the...
1
by: sangith | last post by:
Hi, I tried the packet capture module program. I did a file transfer using ftp from this host to another server. But when I ran the program, it was just hanging off and it did not print the...
1
by: AngreGanon | last post by:
Hi all~ I've written a network program in C. This program catputures ARP request packet and reply wrong ARP packet. Hi. I've written a small program to learn to write in C. But unfortunately...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.