Beskar.Networking.Transports.Udp 2.1.6

dotnet add package Beskar.Networking.Transports.Udp --version 2.1.6
                    
NuGet\Install-Package Beskar.Networking.Transports.Udp -Version 2.1.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Beskar.Networking.Transports.Udp" Version="2.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Beskar.Networking.Transports.Udp" Version="2.1.6" />
                    
Directory.Packages.props
<PackageReference Include="Beskar.Networking.Transports.Udp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Beskar.Networking.Transports.Udp --version 2.1.6
                    
#r "nuget: Beskar.Networking.Transports.Udp, 2.1.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Beskar.Networking.Transports.Udp@2.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Beskar.Networking.Transports.Udp&version=2.1.6
                    
Install as a Cake Addin
#tool nuget:?package=Beskar.Networking.Transports.Udp&version=2.1.6
                    
Install as a Cake Tool

<h1> <p align="center"> <img src="https://github.com/MarvinDrude/Beskar.Networking/blob/master/Resources/banner.png" alt="Logo" width="256" /> <br /> Beskar.Networking </p> </h1> <p align="center"> Fast, <code>.NET</code> native, high-performance, low-allocation networking library.<br/> Built for modern <code>C#</code> includes TCP, WebSockets, QUIC, UDP, UDS, Named Pipes, Memory, and MQTT.<br/> No external runtime dependencies besides <b>Beskar</b>.<br/><br/> <a href="#about">About</a> · <a href="#examples">Examples</a> · <a href="#documenation">Documentation</a> · <a href="#performance-benchmarks">Performance</a> · <a href="#key-aspects">Key Aspects</a> </p> <br/>


<br/>

Code Poetry Issues Repo Size License: MIT

About

Main reasons for why you should consider using Beskar.Networking for your next Networking or MQTT use case:

  • Made with passion and love for the craft.
  • Built for modern .NET using C# and designed to be highly performant, low-allocation, and easy to use.
  • Purposefully designed to be lightweight and flexible.
  • Performance-first approach with 100,000 - 10,800,000 messages/packets per second. (Depending on various factors)
  • Many simple or more advanced example projects demonstrating how to use Beskar.Networking across various transports.
  • Various Unit Tests to verify functionality and performance.
  • Active development and steady progress towards a full feature set.
  • MQTT V3 and V5 support. (Server and Client) – Over any transport supported by Beskar.
  • No external runtime dependencies besides .NET and Beskar.

NuGet packages overview

Package / Project Description NuGet Link
Beskar.Mqtt.Server High-performance, low-allocation MQTT broker/server support for v3.1.1 and v5.0 over any transport. NuGet Version
Beskar.Mqtt.Client Lightweight and efficient MQTT client supporting v3.1.1 and v5.0 over any transport. NuGet Version
Beskar.Networking.Resilient.Server High-performance, event-driven resilient server wrapper supporting keep-alives, handshakes, and custom framing over any transport. NuGet Version
Beskar.Networking.Resilient.Client High-performance resilient client wrapper supporting automatic reconnection, keep-alives, handshakes, and custom framing. NuGet Version
Beskar.Networking.Transports.Tcp High-performance, native TCP transport implementation supporting TLS. NuGet Version
Beskar.Networking.Transports.Ws WebSocket (WS/WSS) transport adapter wrapping custom framed duplex pipelines. NuGet Version
Beskar.Networking.Transports.Quic Multiplexed and secure QUIC transport implementation built on native .NET libraries. NuGet Version
Beskar.Networking.Transports.Udp High-performance, virtualized session-multiplexed UDP transport implementation. NuGet Version
Beskar.Networking.Transports.Uds Native Unix Domain Sockets (UDS) local transport implementation. NuGet Version
Beskar.Networking.Transports.NamedPipes Native local Inter-Process Communication (IPC) Named Pipes transport implementation. NuGet Version
Beskar.Networking.Transports.Memory Fast, zero-allocation local in-memory transport implementation for tests and local IPC. NuGet Version

API Overview

Beskar.Networking offers different levels of abstraction depending on your application needs:

Low-Level Transports

The core library features protocol-agnostic, low-level interfaces:

  • INetworkListener - The Server listener that accepts incoming connections and manages sessions.
  • INetworkClient - The client that initiates connections and manages sessions.
  • INetworkSession - Represents a single connection between a client and server.
  • INetworkStream - Provides transport-agnostic handling (supporting TCP, WebSockets, QUIC, UDP, UDS, Named Pipes, or Memory).

These interfaces provide transport-agnostic handling (supporting TCP, WebSockets, QUIC, UDP, UDS, Named Pipes, or Memory). Because they are low-level, you are responsible for managing execution tasks yourself, such as starting your own accept loops, launching read/write tasks, and supervising session lifecycles.

Client Transport Optimization (Low-Level APIs) When instantiating TcpNetworkClient, WsNetworkClient, QuicNetworkClient, UdsNetworkClient, or NamedPipeNetworkClient directly with custom options (TcpTransportOptions, WsTransportOptions, QuicTransportOptions, UdsTransportOptions, NamedPipeTransportOptions), the default IoQueueCount is optimized for servers and defaults to Math.Min(Environment.ProcessorCount, 24).

For client-side applications, you should explicitly configure the option's IoQueueCount (e.g. options.StreamOptions.IoQueueCount = 1 and options.SocketOptions.IoQueueCount = 1) to 1. Since a client only manages a single connection, this prevents allocating unnecessary idle memory pools and thread queues, drastically reducing the unmanaged and pinned memory footprint.

For more details, see the Basics Documentation.

High-Level Managed APIs

For protocols like MQTT, or connection-resilient networking, Beskar.Networking provides fully managed implementations:

  • Fully Managed Broker & Client (MQTT): Pre-built wrappers that manage the connection, session, and stream states automatically.
  • Resilient Client & Server: Connection-resilient managed wrappers (ResilientClient<TFrame> and ResilientServer<TFrame>) that handle transient disconnect supervision, automatic pings/pongs (keep-alive), protocol control handshakes, custom challenge-response authentication, and pluggable framing protocol generation.
  • Event-Driven: Fully event-driven design with convenient events to react to incoming messages, client connections, and status updates, eliminating the need to write custom accept loops or pipeline plumbing.

For more details, see the Resilient Documentation and Mqtt Documentation.


Examples

We provide both basic and advanced example projects demonstrating how to use Beskar.Networking across various transports:

All examples: Root Folder

  • Simple Ping-Pong Message (Bare-metal): Demonstrates low-level server listener binding, client connection, and raw bidirectional message exchange using length-prefixed framing over System.IO.Pipelines using TCP.
  • Advanced Multi-Transport Chat Application: A complete chat application consisting of:
    • Common: Reusable packet serialization and custom packet framing utilities.
    • Server: Integrates a unified ChatServerBuilder to listen and accept chat sessions concurrently on TCP (9000), WebSockets (11000), and QUIC (12000).
    • Client: An interactive console application allowing users to connect via their choice of protocol (TCP/WS/QUIC), receive recent chat history, and chat in real-time under a random username.
  • MQTT Managed Examples: A set of projects demonstrating the high-level managed MQTT APIs:
    • Simple Publish-Subscribe: A complete pub-sub flow showing how to spin up an MQTT broker, connect a sensor client (publisher) and dashboard client (subscriber) over TCP using MQTT v5.0.
    • Generated Pub-Sub (Source Generator): Showcases how to use the high-performance MQTT Topic Source Generator to define compile-time validated topics and perform zero-allocation publishing using the generated byte[] format overloads.
    • Quality of Service (QoS) Levels: Demonstrates publishing and subscribing messages with different QoS levels (QoS 0: At Most Once, QoS 1: At Least Once, QoS 2: Exactly Once) using wildcard topic filters.
    • Authentication (v3 & v5 Challenges): Highlights both simple username/password validation for MQTT v3.1.1 and advanced challenge-response authentication for MQTT v5.0.
    • Client Reconnection & Event Handling: Shows how to register connection status events and implement custom auto-reconnection loops when connections are unexpectedly lost.
    • Disconnection Safety & Persistence: Demonstrates persistent sessions, server-side JSON serialization/restoration of retained messages, and client-side offline queuing (FIFO and Last Message Buffering) with crash safety.
    • Last Will and Testament (LWT): Shows how to configure client Will messages and verify that the server automatically delivers them upon ungraceful connection loss while ignoring them on graceful disconnects.
    • User Properties (Metadata): Demonstrates how to send and receive custom metadata headers (like trace context spans) using MQTT v5.0 User Properties.
    • Topic Aliases (Bandwidth Optimization): Illustrates how client and server negotiate and employ Topic Aliases to dramatically decrease packet sizes by substituting long topic paths with short integer codes.
  • Resilient Managed Examples: A set of projects demonstrating the high-level connection-resilient server and client wrappers:
    • Resilient Chat Application: A complete chat application using the resilient wrappers with default BeskarPacket framing and automated JSON serialization:
      • Common: Contains shared message payloads and a JSON ChatSerializer implementing IResilientSerializer.
      • Server: Integrates ResilientServer<BeskarPacket> to accept, track, and broadcast chat messages over TCP port 9000.
      • Client: Interactive chat client using ResilientClient<BeskarPacket> that reconnects and re-authenticates/joins automatically when connection is lost.
    • Simple Ping-Pong: Demonstrates basic ping-pong message exchange using ResilientServer and ResilientClient with default framing over TCP port 9001.
    • Authentication Challenge-Response: Highlights pre-handshake HMAC-SHA256 signature challenge-response authentication, showing both success and server-denial test cases on TCP port 9002.

Documenation

You can find detailed documentation for Beskar.Networking here.

Or you can find examples directly here.

Performance Benchmarks

Engineered from the ground up for maximum throughput and minimum allocation overhead.

[!NOTE]
Computer Specs:<br/> CPU: AMD Ryzen 9 7950X3D, Memory: 64 GB DDR5

Method: Payload does not include protocol, Local Loopback Benchmark<br /> Note: Benchmarks are subject to change as the library evolves.

Transport / Protocol Clients Payload Size Throughput Bandwidth
TCP (No TLS) 20 128 bytes 10,805,651 packets/s 1,319.05 MB/s
TCP (No TLS) 20 512 bytes 7,355,303 packets/s 3,591.46 MB/s
WebSockets (WS) (No TLS) 20 128 bytes 10,784,817 packets/s 1,316.51 MB/s
WebSockets (WS) (No TLS) 20 512 bytes 6,968,596 packets/s 3,402.63 MB/s
QUIC 20 128 bytes 3,503,372 packets/s 427.66 MB/s
QUIC 20 512 bytes 954,711 packets/s 466.17 MB/s
MQTT (TCP - No TLS) 20 128 bytes 918,794.17 msg/s 112.16 MB/s
MQTT (TCP - No TLS) 20 512 bytes 674,086.45 msg/s 329.14 MB/s
UDP 20 128 bytes 3,480,517 packets/s 424.87 MB/s
UDP 20 512 bytes 801,432 packets/s 391.32 MB/s
Unix Domain Sockets (UDS) 20 128 bytes 11,993,784 packets/s 1,464.08 MB/s
Unix Domain Sockets (UDS) 20 512 bytes 9,487,101 packets/s 4,632.37 MB/s
Named Pipes 20 128 bytes 12,777,198 packets/s 1,559.72 MB/s
Named Pipes 20 512 bytes 5,739,487 packets/s 2,802.48 MB/s
Memory 20 128 bytes 8,388,522 packets/s 1,023.99 MB/s
Memory 20 512 bytes 7,728,970 packets/s 3,773.91 MB/s

Key Aspects

Beskar.Networking is a high-performance, low-allocation networking library built for modern .NET 10 using C#. It provides a unified, pipe-based interface abstraction (INetworkListener, INetworkClient, INetworkSession, INetworkStream) for building extremely fast network applications across multiple transport protocols.

  • Unified Abstractions: Write your network layer once and swap between TCP, WebSockets, QUIC, UDP, UDS, Named Pipes, or Memory dynamically.
  • Modern .NET 10 Stack: Heavily leverages System.IO.Pipelines (decoupling IO thread queues from application processing), Span<T>, ReadOnlySpan<T>, and direct memory pooling to achieve zero/near-zero allocations.
  • TLS/SSL Encryption: Full native SSL/TLS wrapping for TCP and WebSocket transports out of the box.
  • Non-blocking IO Queueing: Highly-optimized custom IO queues (like TcpIoQueueRegistry / TcpIoQueue) to handle asynchronous reading and writing concurrently.
  • Full MQTT:
  • Other Features: Additional features and capabilities that make this library unique and valuable.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Beskar.Networking.Transports.Udp:

Package Downloads
Beskar.Networking.Resilient.Server

High-performance, low-allocation event-driven highly-customizable Server over any transport.

Beskar.Networking.Resilient.Client

High-performance, low-allocation event-driven highly-customizable Resilient Client over any transport.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.6 35 8/6/2026
2.1.5 34 8/6/2026
2.1.4 41 8/6/2026
2.1.3 58 8/5/2026
2.1.2 111 7/25/2026
2.1.1 112 7/25/2026
2.1.0 119 7/25/2026
2.0.1 113 7/25/2026
2.0.0 116 7/25/2026
1.2.1 90 7/20/2026
1.2.0 96 7/20/2026
1.1.4 89 7/20/2026
1.1.3 92 7/19/2026