How to read and write ip packets

Hi to all!
I'm an Informatics Engineering student and I work into the networking Laboratory.
This is my problem:
I have a FreeBSD Computer in LAN with ather computer give web services.
I must develop an application that take an ip packet, rewrite an ip header and resend the new ip packet.

I found this web page where is learning how to use BPF to read ip packet.
Have you got other guide or advices (or the problem solution :p) to help me?
 
SirDice said:

Capturing and sending (your own formated packets) has nothing to do with sockets or their programming.

Palla said:
Hi to all!
I'm an Informatics Engineering student and I work into the networking Laboratory.
This is my problem:
I have a FreeBSD Computer in LAN with ather computer give web services.
I must develop an application that take an ip packet, rewrite an ip header and resend the new ip packet.

I found this web page where is learning how to use BPF to read ip packet.
Have you got other guide or advices (or the problem solution :p) to help me?

Well the link you linked yourself pretty much covers the mechanics of capturing/sending the packets via BPF mechanism that is very nice way to do it without writing your own kernel module. What other information are you missing?
 
expl said:
Capturing and sending (your own formated packets) has nothing to do with sockets or their programming.



Well the link you linked yourself pretty much covers the mechanics of capturing/sending the packets via BPF mechanism that is very nice way to do it without writing your own kernel module. What other information are you missing?

I'm not a FreeBSD user, so I would like to have some "ok" aboute the document I have linked.

Thank for your help
 
Well I am not sure what are you asking, but yes this would be most simple and correct way to do your assignment.
 
As far as I understand packet filters like pf and ipfw, which do Network Address/Port Translation (NAT/PAT) also rewrite packets. You could look at the source code how they exactly do it.
 
J65nko said:
As far as I understand packet filters like pf and ipfw, which do Network Address/Port Translation (NAT/PAT) also rewrite packets. You could look at the source code how they exactly do it.

They have their own custom kernel modules. I do not think thats a solution for a small assignment.
 
Back
Top