Skip to content

aneilmac/Netwintun

Repository files navigation

NetWintun NuGet Version License: MIT

NetWintun is an unofficial C# wrapper around the Wintun library.
Wintun is a minimal, high-performance TUN driver for Windows, providing userspace programs with a simple virtual network adapter for sending and receiving packets.


✨ Features


💡 Example Usage

Sending a packet

using var adapter = Adapter.Create("OfficeNet", "Wintun");
using var session = adapter.StartSession(Wintun.Constants.MaxRingCapacity);
session.SendPacket("Hello World"u8);

Receiving a packet

using var adapter = Adapter.Create("OfficeNet", "Wintun");
using var session = adapter.StartSession(Wintun.Constants.MinRingCapacity);

// Asynchronously wait for a packet
var packet = await session.ReceivePacketAsync();

// Or try to grab one immediately
if (session.TryReceivePacket(out var packet)) {
    Console.WriteLine($"Received {packet.Length} bytes");
}

Plugging into Microsoft.Extensions.Logging

using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
Wintun.SetLogger(loggerFactory.CreateLogger<Program>());

👉 Check out the full example program for a working demo.


🛠️ Building from Source

Prerequisites

Before building, unzip the prebuilt Wintun binaries into the /wintun directory:

/netwintun
 ├─ src/
 ├─ examples/
 └─ wintun/   <-- unzip here

📜 Licensing

The contents of the repository are "Copyright (c) 2025 aneilmac".

Source code: Licensed under the MIT License

The library requires usage of wintun.dll. The NetWintun nuget package includes prebuilt and signed Wintun binaries, which are distributed under the terms of the Prebuilt Binaries License. By using NetWintun via NuGet, you agree to the terms of the Wintun Prebuilt Binaries License.


About

Unofficial C# Wrapper around the Wintun library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages