By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,680 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,680 IT Pros & Developers. It's quick & easy.

Packet manipulation in C

P: 8
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
Share this Question
Share on Google+
10 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
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

P: 8
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

P: 90
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
Expert Mod 2.5K+
P: 4,677
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

P: 8
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
Expert Mod 2.5K+
P: 4,677
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

P: 90
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
Expert Mod 2.5K+
P: 4,677
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

P: 8
hey..
ARUL thqs.....
but can u post the LINK an another time plzzz
Mar 14 '08 #10

sicarie
Expert Mod 2.5K+
P: 4,677
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

Post your reply

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