VpnHood.Net.PacketTransports
9.1.874
dotnet add package VpnHood.Net.PacketTransports --version 9.1.874
NuGet\Install-Package VpnHood.Net.PacketTransports -Version 9.1.874
<PackageReference Include="VpnHood.Net.PacketTransports" Version="9.1.874" />
<PackageVersion Include="VpnHood.Net.PacketTransports" Version="9.1.874" />
<PackageReference Include="VpnHood.Net.PacketTransports" />
paket add VpnHood.Net.PacketTransports --version 9.1.874
#r "nuget: VpnHood.Net.PacketTransports, 9.1.874"
#:package VpnHood.Net.PacketTransports@9.1.874
#addin nuget:?package=VpnHood.Net.PacketTransports&version=9.1.874
#tool nuget:?package=VpnHood.Net.PacketTransports&version=9.1.874
VpnHood.Net.PacketTransports
Packet queues for .NET: a transport takes IP packets from many senders, queues them, and hands them to your code
on a sending loop of its own, while the packets your code reads go up through one event. It is how
VpnHood moves packets between its tunnels, its adapters and its TCP stack,
and works for any channel of VpnHood.Net.Packets packets: a device, a socket, a pipe.
dotnet add package VpnHood.Net.PacketTransports
How it works
IPacketTransportis the two-way contract:SendPacketQueuedandSendPacketQueuedAsyncqueue a packet to send, andPacketReceivedraises each packet received.- Derive from the base that fits how your channel writes:
PacketTransporthands over batches, up to the queue's capacity at a time;SinglePacketTransporthands over one packet at a time;PassthroughPacketTransporthas no queue: each packet goes on at once, on the sender's thread.
PacketTransportOptionssets the queue: its capacity, whether a send to a full queue waits for room (Blocking, up toBlockingTimeout) or drops the oldest packet, and whether the transport disposes each packet once sent (AutoDisposePackets).- A packet has one owner at a time. One sent to the transport is the transport's, whatever the outcome; one
raised by
PacketReceivedis the handler's, which forwards or disposes it, so attach one handler only. PacketStatcounts what is sent, received and dropped.FairPacketQueueis a send queue split into lanes by a hash of a packet's ports, so one flow that floods fills mostly its own lane.
Quick start
The examples below run as a test in CI
(PacketTransportsReadmeExampleTest.cs).
Their namespaces are System.Net, VpnHood.Net.Packets, VpnHood.Net.Packets.Extensions and
VpnHood.Net.PacketTransports.
A transport over your device
// A transport over your own device: the queue, its sending loop and the packet ownership come from the base.
public sealed class DeviceTransport() : PacketTransport(new PacketTransportOptions {
AutoDisposePackets = true, // the base disposes each packet once SendPacketsAsync returns
Blocking = false // a full queue drops its oldest packet instead of waiting for room
})
{
public List<string> Written { get; } = [];
// the sending loop hands over a batch at a time
protected override ValueTask SendPacketsAsync(IReadOnlyList<IpPacket> ipPackets)
{
foreach (var ipPacket in ipPackets)
Written.Add(ipPacket.ToString()); // write it to the device here
return default;
}
// what the device reads goes up through PacketReceived
public void OnDeviceRead(IpPacket ipPacket) => OnPacketReceived(ipPacket);
}
Send and receive
using var transport = new DeviceTransport();
// one handler, which owns each received packet: it forwards or disposes it
transport.PacketReceived += (_, ipPacket) => {
Console.WriteLine($"Received: {ipPacket}");
ipPacket.Dispose();
};
// a packet sent is the transport's from here, whatever the outcome
var packet = PacketBuilder.BuildUdp(
new IPEndPoint(IPAddress.Parse("10.0.0.2"), 5353),
new IPEndPoint(IPAddress.Parse("10.0.0.1"), 53),
"query"u8);
packet.UpdateAllChecksums();
transport.SendPacketQueued(packet);
Packages
VpnHood.Net.PacketTransports— the transportsVpnHood.Net.Packets— the packets they carry
Requires .NET 11.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- VpnHood.Net.Packets (>= 9.1.874)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on VpnHood.Net.PacketTransports:
| Package | Downloads |
|---|---|
|
VpnHood.Core.Tunneling
The tunnel between a VpnHood client and server, which both share: its requests, channels and streams, and the forwarding of a session's packets. |
|
|
VpnHood.Net.VpnAdapters.Abstractions
The VPN adapter contract: a virtual network interface whose packets a VPN reads and writes, the base class every platform's TUN adapter extends, and a null adapter. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.874 | 0 | 11/15/2026 |
| 9.1.864 | 226 | 11/3/2026 |
| 9.0.860 | 233 | 10/31/2026 |
| 9.0.859.16-prerelease | 200 | 10/30/2026 |
| 9.0.857 | 234 | 10/20/2026 |
| 9.0.856 | 225 | 10/19/2026 |
| 9.0.855 | 227 | 10/13/2026 |
| 8.2.853.11-prerelease | 220 | 10/5/2026 |
| 8.2.853 | 239 | 9/23/2026 |
| 8.2.852 | 227 | 9/23/2026 |