This project is read-only.

Fastest way to be a network gateway

Sep 13, 2011 at 10:12 AM

Hello.

I'm trying to use Pcap.Net to build a component like a network gateway, which link 2 different networks and do not touch any ip package.

i.e. I need to move packages from one nic to another. The mac address should be changed, but nothing else need to be touched.

What's the fastest way to build the packages for sending based on the received?

 

Thanks a lot.

Sep 14, 2011 at 2:37 PM
Edited Sep 14, 2011 at 2:40 PM

I found that there are many properties in Packet object which return a object based on class named like xxxDatagram. But when I use PacketBuilder to build a packet, I need some objects based on classes named like xxxLayer.

How to get the xxxLayer object from the xxxDatagram object?

Should I call ExtractLayer on all datagram object? or just call from one certain object?

Sep 16, 2011 at 9:11 AM

Hi scegg,

 

Yes, you should use ExtractLayer().

 

For example:

 

ILayer ethernet = packet.Ethernet.ExtractLayer();

ILayer payload = packet.Ethernet.Payload.ExtractLayer();

ethernet.Source = ...

ethernet.Destination = ...

Packet newPacket = PacketBuilder.Build(packet.Timestamp, ethernet, payload);

 

(I haven't checked this code for compilation, this is just to show you the idea).

 

I hope this helps,

Boaz.

Sep 16, 2011 at 11:30 AM

Thanks a lot.