This project is read-only.

IPv6 - handling packets

Nov 10, 2011 at 1:32 PM

Hi all,

I'm a newbie to the PCAP.NET library and even though I figured out most of it I still don't get quite right how the IPv4 vs IPv6 packet handling works so I would appreciate some help.

Let's say my C# PacketHandler function looks like:




private static void PacketHandler(Packet packet) {       �
IpV4Datagram ip = packet.Ethernet.IpV4;            
TcpDatagram tcp = ip.Tcp;          
HttpDatagram httpdgrm = ip.Tcp.Http;

string IPPayload = ip.Payload.ToString();
string TCPPayload = tcp.Payload.ToString();
string HTTPBody = (PcapDotNet.Packets.Http.HttpResponseLayer)httpdgrm.ExtractLayer().Body.ToString();
byte[] rawPayload = packet.Buffer;



Now, hypothetically speaking let's say my function receives an HTTP HTML response packet having the body content of just "THIS IS A TEST" for example.

Also, lets say the packet function runs on a computer with IPv4 public address.

As I have an IPv4 network I was able to test this and found out that all IPPayload, TCPPayload and HTTPBody string, as well as rawPayload byte array, when decoded to a human readable strings with UTF8 contain the "THIS IS A TEST" substring within them.

The real question is how would the function behave in the same scenario if it was running on a computer behind the IPv6 public address?

I assume that in this case, only the rawPayload byte array would contain "THIS IS A TEST" substring as all other strings in my code depend on the packet.Ethernet.IPv4 datagram. Am I right?

Thank you for taking the time to look into this.

Nov 11, 2011 at 7:44 PM

Hi ksarin,


Today, IPv6 protocol is not supported in Pcap.Net (there is an open issue you can vote for in the Issue Tracker).

This means that assuming you have HTTP over TCP over IPv6 over Ethernet, only the Ethernet part will be parsed well with Pcap.Net.

You can try and parse the Ethernet payload yourself, until IPv6 will be supported in Pcap.Net.


I hope this helps,