Is it possible to create Packet from Byte[] ?

Apr 17, 2013 at 6:53 PM
Edited Apr 17, 2013 at 7:49 PM
i found a little tool that open Pcap file and because the Winpcap bug i think i can use this tool in order to put all the packets inside SendBuffer instead of do it with Pcapdot.Net method.
is it possible to create Packet from Byte[] ? (this tool use different Packet class but can return the packet in Byte[])
Apr 17, 2013 at 9:48 PM
you can write inside Packet.Buffer one byte at a time but you can't do Packet.Buffer = new byte[] {...}
this means that the buffer of your PcapDotNet packet has to be the same size of your byte array.
Apr 18, 2013 at 3:10 AM
can you show me an example how to do it ?
Apr 20, 2013 at 9:57 AM
Yes, you can create a Packet from a byte[] using the Packet constructor:
public Packet(byte[] data, DateTime timestamp, DataLinkKind dataLink)
public Packet(byte[] data, DateTime timestamp, IDataLink dataLink)
I hope this helps,

Apr 20, 2013 at 11:10 AM
Edited Apr 20, 2013 at 11:39 AM
when create the new packet from Byte[] how can i use the original packet Timestamp (this packet is Byte[]) instead of using DateTime.Now which cause the buffer to be transmitted fast ?
Apr 27, 2013 at 8:58 AM
If you have an original packet, you can pass it the timestamp using the Timestamp property:
public DateTime Timestamp