How to get data from TCPPacket using SharpPcap?

jM2.me picture jM2.me · Oct 5, 2011 · Viewed 7.2k times · Source

I need small sniffer for my report so I went with C# and SharpPcap.

packet = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
tcpPacket = TcpPacket.GetEncapsulated(packet);

I have raw packet with all packet data. Then I get Packet out of it with some info such as source/destination/protocol/etc. After that I get tcp packet out of that.

Now how do I get only actual packet data that software sent/received?

Answer

jM2.me picture jM2.me · Oct 5, 2011

Was simple enough.

packet.PayloadPacket.PayloadPacket.PayloadData