IP header offset

Oct 17, 2012 at 9:24 PM

Some ethernet packets have ethernet_type different than 0800 (IP). for example 0x8100 ( or 33024 in decimal) for 802.1Q.

In that case there are 4 more bytes after the ethernet header and then you have the IP header. Is there any way to move ahead that number of bytes when the ethernet_type != 0x0800 ?

with this line I get  the ethernet type and could act upon the result:

ushort eth_type = (ushort)packet.Ethernet.EtherType;

but how can I "skip" those extra bytes so that I can get the actual IP header? I f I do this :

             IpV4Datagram ip = packet.Ethernet.IpV4;

my IP header starts 4 bytes before it is supposed to, giving me errors when parsing the packets.

txs a lot


Oct 19, 2012 at 8:41 AM

For the supported 802.1Q, you can use

   IpV4Datagram ip = packet.Ethernet.VLanTaggedFrame.IpV4


I hope this helps,



Oct 22, 2012 at 6:09 PM

txs a lot, it did the trick