How to Convert Packet to TcpPacket?

406 Views Asked by At

I'm using PacketDotNet to resolving captured packets. In PacketDotNet0.12.0, it provides a method called GetEncapsulated.

TcpPacket tcppacket = TcpPacket.GetEncapsulated(this.packet); 

But now, I have to update PacketDotNet from version 0.12.0 to version 1.3.0.0. And the new version doesn't have TcpPacket.GetEncapsulated() method. I can not find any documentation about PacketDotNet or demos about it.

So I want to know how can I get a TcpPacket objct from a Packet object.

2

There are 2 best solutions below

0
Ramin Quliyev On BEST ANSWER

I think you can use

PacketDotNet.Packet.ParsePacket().Extract<T>() 

method

0
han zhu On

Here's the easiest way:

var tcpPacket = packet.Extract<PacketDotNet.TcpPacket>();//TcpPacket

var udpPacket= packet.Extract<PacketDotNet.UdpPacket>();//UdpPacket