Packet.Net 0.4.0

High performance .NET assembly for dissecting and constructing network packets such as Ethernet, IP, TCP, UDP, etc.
Packet.Net is a high performance .NET assembly for constructing and dissecting network packets such as Ethernet, IP, UDP, TCP, etc.

Packet.Net started as a rewrite of the packet parser in SharpPcap with the goal of making a more consistent and better documented API.


The source code package, available via the Downloads link on the project page, contains an Examples/ directory. Below are some snippets that illustrate usage but are not intended to be complete.

Packet.Net can be used to create packets from scratch:

using PacketDotNet;

int sourcePort = 10;
int destinationPort = 20;
TcpPacket tcpPacket = new TcpPacket(sourcePort, destinationPort);

Many people will use Packet.Net in conjunction with existing data, either captured from the network via SharpPcap or Pcap.Net to decode packets:

using PacketDotNet;

// open the capture file
SharpPcap.LivePcapDevice dev = new SharpPcap.LivePcapDevice("SomeCapturedPackets.pcap");

// read a raw packet
rawPacket = dev.GetNextRawPacket();

// parse the packet
Packet p = Packet.ParsePacket((LinkLayers)rawPacket.LinkLayerType,
 new PosixTimeval(rawPacket.Timeval.Seconds,

// print out the packet contents

This program would produce output like:

 [EthernetPacket: 00234D5BF88B -> 00183F7775D1 proto=IpV4 (0x800) l=14][IPv4Packet: -> HeaderLength=5 Protocol=TCP TimeToLive=64][TCPPacket: SourcePort: 59038 -> DestinationPort: 443 ack[218134930 (0xd007992)]]

last updated on:
April 12th, 2010, 12:50 GMT
license type:
LGPL (GNU Lesser General Public License) 
developed by:
Chris Morgan
ROOT \ System \ Networking
Download Button

In a hurry? Add it to your Download Basket!

user rating



Rate it!

Add your review!