Skip to content

Supplement to Packet.Net that adds connection tracking support

Notifications You must be signed in to change notification settings


Repository files navigation

NuGet Appveyor Build status .NET Core


A supplementary library to Packet.Net that provides classes to track and follow connections.

Connection following is supported for tcp connections but it should be straightfoward to add support for udp connections.


This library was developed for a commercial product to work with SharpPcap and Packet.Net to enable the processing of TCP data streams. Several people have asked about this kind of functionality in Packet.Net for some time and I wanted to Open Source it so others could make use of and learn from its implementation. This library should be a good foundation to build from and improve for people looking to implement connection oriented processing.

System diagram

PacketDotNet.Connections diagram


The license is GPLv3. If you are interested in licensing for commercial use please contact me at


See the Examples folder for a few examples such as:


Tracks tcp connections and accumulates the data sent/received.


Tracks tcp connections and shows when connections are created and shut down. ConnectionExample gif animation


Decodes http traffic sent through tcp connections and displays the http content. With the almost universal use of https this example may not be as useful as it would have been a few years ago.

Unit tests

Located in the UnitTest directory. Written in xUnit as xUnit is bundled with .NET.

Build and run either through VisualStudio or on the command line from the output directory like:

dotnet vstest UnitTest.dll

Output looks like:

$ dotnet vstest UnitTest.dll
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
tcpPacket.PayloadData.Length 0
HandleConnectionManagerOnConnectionFound c [TcpConnection: HasTimedOut=False, Flow[0] [TcpFlow address, port 37427], Flow[1] [TcpFlow address, port 2222]]
Connection found: <->
0 bytes in stream
measurement: <-> - [ConnectionTimes synTime '1299375314.196014s', synAckTime '1299375314.377115s', elapsed '00:00:00.1811010']
Connection found: <->
measurement: <-> - [ConnectionTimes synTime '1299375314.463864s', synAckTime '1299375314.680644s', elapsed '00:00:00.2167800']
Connection found: <->