ZeroNetwork.Core
2.5.0
See the version list below for details.
dotnet add package ZeroNetwork.Core --version 2.5.0
NuGet\Install-Package ZeroNetwork.Core -Version 2.5.0
<PackageReference Include="ZeroNetwork.Core" Version="2.5.0" />
<PackageVersion Include="ZeroNetwork.Core" Version="2.5.0" />
<PackageReference Include="ZeroNetwork.Core" />
paket add ZeroNetwork.Core --version 2.5.0
#r "nuget: ZeroNetwork.Core, 2.5.0"
#:package ZeroNetwork.Core@2.5.0
#addin nuget:?package=ZeroNetwork.Core&version=2.5.0
#tool nuget:?package=ZeroNetwork.Core&version=2.5.0
ZeroNetwork
Architectural Standard: 100% Pure C# BCL, Zero External Dependencies, Multi-Targeting across
.NET 8.0,.NET Framework 4.6.2, and.NET Standard 2.0.
ZeroNetwork is an ultra-high-performance, sovereign .NET networking suite engineered for factory floor automation, IoT edge gateways, distributed industrial systems, and high-load ERP infrastructures. It provides an end-to-end networking stack from Layer 2 (Data Link & Hardware) all the way up to Layer 7 (HTTP REST, Real-Time SignalR/WebSocket, and High-Throughput Pub/Sub Bus) with ZERO external NuGet dependencies, eliminating assembly conflicts and DLL hell on legacy .NET Framework runtimes while maximizing throughput on modern .NET 8+.
ποΈ Comprehensive Architecture & OSI Model Mapping
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ZeroNetwork Architecture β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ€
β OSI Layer β Component β Key Highlights β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 7: Pub/Sub β InProcessZeroBus & TopicTrie β Wildcards (+, #), Zero-GCβ
β β IpcZeroBus β Microsecond Shared Memoryβ
β β ZeroPubSubHub β Remote WebSocket Bridge β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 7: RealTime β ZeroHubServer<THub> & ZeroHub β Pure C# Hub Protocol v1 β
β β ZeroSignalRClient β Pure C# Hub Client β
β β ZeroWebSocketServer β RFC 6455 Socket Server β
β β ZeroWebSocketClient β RFC 6455, Auto-Reconnect β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 7: HTTP β ZeroApiClient & Extensions β Zero-LOH Stream Pipeline β
β β ZeroHttpServer β Micro REST & Prometheus β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 4: Transportβ NetworkProbe & PortScanner β Zero-Leak TCP Handshake β
β β UdpMulticastClient & DnsProbe β IGMPv2/v3, Port 53 UDP β
β β NetworkThroughputMeter β Real-Time NIC Bandwidth β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 3: Network β IPNetwork & VirtualAdapterFilter β Allocation-Free CIDR β
β β Traceroute & PathMtuDiscovery β Hop Latency & Jumbo PMTU β
β β NetworkInfo & NetworkAdapterInfo β Deterministic NIC Select β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β Layer 2: DataLink β MacAddress & ArpTable β Blittable Struct, P/Invk β
β β ActiveArpScanner β Subnet Scanner (No ICMP) β
β β WakeOnLan β 102/108-byte Magic Pkt β
βββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ
π Key Capabilities
1. Layer 2: Data Link & Hardware Discovery
MacAddress: Blittable 6-byte struct with zero-allocation span formatting (Span<char>) and IEEE OUI vendor detection (VMware, VirtualBox, Hyper-V, Docker, QEMU).ArpTable: Fast IP $\leftrightarrow$ MAC resolution via Windows P/Invoke (IpHlpApi.dll) and Linux/proc/net/arp.ActiveArpScanner: High-speed parallel ARP sweep across CIDR subnets to detect 100% of live nodes even when ICMP/Ping is disabled by firewalls.WakeOnLan: Generates RFC standard 102-byte Magic Packets with support for 6-byteSecureOnpasswords (108-byte packets) for remote machine power-on.
2. Layer 3: Network & Topology Math
IPNetwork: Pure C# CIDR math (Parse,Contains,BroadcastAddress,Netmask,WildcardMask) with zero-allocation host iterators usingSpan<byte>.VirtualAdapterFilter: Hybrid heuristics and hardware vendor OUI detection that filters out virtual interfaces (VMware, VirtualBox, WSL, Hyper-V, Tailscale, ZeroTier, Docker).NetworkInfo&NetworkAdapterInfo: Deterministic physical NIC resolution on multi-homed systems.Traceroute: Hop-by-hop ICMP route inspection with latency profiling.PathMtuDiscovery: Binary search PMTU analyzer using Don't Fragment (DF) flags (verifying Jumbo Frames MTU 9000 for GigE Vision cameras).
3. Layer 4: Transport & Diagnostics
NetworkProbe: Hardened non-blocking TCP socket prober (IsPortOpenAsync) withLingerState(true, 0)socket abort ensuring zero socket handle leaks under heavy loads.PortScanner: Parallel bounded-concurrency TCP port and subnet scanner governed bySemaphoreSlimwith streamingAction<PortScanResult>callbacks.UdpMulticastClient: IGMPv2/v3 multicast group publisher and subscriber with physical network interface binding.DnsProbe: Fast UDP port 53 DNS client with sub-second timeout and reverse PTR record resolution.NetworkThroughputMeter: Real-time NIC bandwidth meter (Rx/Tx Mbps) with saturation alert thresholds.
4. Layer 7: Micro HTTP Server & REST Client
ZeroHttpServer: Micro HTTP/1.1 server running in pure C# without administrator privileges, URL ACLs, or IIS. Features regex REST routing and built-in/metrics(Prometheus) and/healthendpoints.ZeroApiClient: High-performance HTTP client utilizing stream-based direct JSON serialization (IZeroJsonSerializer) to eliminate Large Object Heap (LOH) allocations, combined with connection pooling and exponential backoff retry.ZeroHttpExtensions: Fluent string extensions (url.GetJsonAsync<T>(),url.PostJsonAsync<T>()) for clean, allocation-efficient HTTP consumption.
5. Layer 7: Real-Time Full-Duplex (WebSocket & SignalR Server/Client)
ZeroWebSocketServer: Pure C# BCL socket listener implementing the RFC 6455 WebSocket Server specification without administrative URL ACL privileges. Features automaticSec-WebSocket-Accepthandshake hashing, client-to-server frame unmasking, and high-performance text/binary broadcasting.ZeroWebSocketSession: Thread-safe per-client WebSocket session abstraction managing state, frame reassembly, and keep-alive ping/pong frames.ZeroHubServer<THub>: Sovereign, self-hosted ASP.NET Core SignalR Protocol v1 Hub Server. Features automatic JSON protocol handshake ({"protocol":"json","version":1}\x1e), typed RPC method dispatching with return value completions (type: 3), dynamic group management (AddToGroupAsync), client proxy routing (All,Caller,Others,Client,Group), and 15-second heartbeat ping.ZeroHub: Base class for enterprise business hubs providingClients,Context, andGroups.ZeroWebSocketClient: Resilient RFC 6455 WebSocket client built purely on BCLClientWebSocket. Includes thread-safe frame sending (SemaphoreSlim), automatic message reassembly for large payloads, configurable keep-alive heartbeat, and auto-reconnect with exponential backoff and random jitter.ZeroSignalRClient: Pure C# ASP.NET Core SignalR JSON Hub Client (Protocol v1) with 0 external dependencies (noMicrosoft.AspNetCore.SignalR.Clientbloat, eliminating DLL conflicts on .NET Framework 4.6.2). Supports automatic handshake, server-to-client callbacks (hub.On<T>), client invocations (hub.SendAsync,hub.InvokeAsync<T>), and keep-alive ping management.
6. Layer 7: High-Throughput Pub/Sub & Inter-Process Messaging
InProcessZeroBus: Ultra-fast, zero-allocation in-process message bus. Supports both strongly-typed events (PublishAsync<T>) and topic patterns with zero GC pressure on hot paths.TopicTrie: Thread-safe radix trie supporting MQTT-style wildcards (+for single level,#for multi-level) with Copy-On-Write subscriber collections for completely lock-free read dispatching.IpcZeroBus: Sub-microsecond cross-process Pub/Sub utilizing OS shared memory (ZeroMmfRingBuffer). Allows decoupled processes (e.g. C# SCADA and Python/C++ Vision/AI) to exchange frames and telemetry at hardware speed without socket overhead.ZeroPubSubHub: Out-of-the-box SignalR Hub bridging remote clients to the localInProcessZeroBus, enabling web browsers and remote desktop nodes to subscribe and publish to topics over WebSockets.
7. High-Performance BCL Superchargers & Industrial Engines
ZeroClock: Sub-10-nanosecond hardware timer engine via Windows QPC and CPU RDTSC, eliminating Windows OS 15.6ms timer quantum for precise SCADA telemetry.ZeroRadixSort: Linear-time $O(N)$ LSD Radix Sort for integers, longs, and IEEE-754 floats. Outperforms BCLArray.Sort($O(N \log N)$ Introsort) by 4x to 10x without branch mispredictions.ZeroXxHash3: 20-30 GB/sec 64-bit and 32-bit non-cryptographic hashing algorithm with near-zero collision variance, replacing standard BCLGetHashCode().ZeroRobinHoodMap<K, V>: Cache-friendly open-addressing hash table with flat contiguous array storage and Robin Hood displacement, eliminating heap node allocations.ZeroRecyclableStream: Recyclable pooled memory stream backed by rentedArrayPoolchunks, eliminating Large Object Heap (LOH) fragmentation.ZeroStateMachine<TState, TTrigger>: Deterministic, zero-allocation finite state machine for factory sequence automation with sub-5ns state transitions and audit logging.ZeroTelemetry: Autonomous metrics registry with atomic Counters, Gauges, and HDR Histograms (p50, p90, p99, p99.9), integrated withZeroHttpServer/metricsendpoint.
π Quick Start Examples
1. Active ARP Subnet Scanning (Bypass ICMP Firewalls)
using ZeroNetwork.Discovery;
// Scan /24 subnet for all active devices via Data Link ARP
var devices = await ActiveArpScanner.ScanSubnetAsync("192.168.1.0/24", timeoutMs: 300);
foreach (var device in devices)
{
Console.WriteLine($"IP: {device.IpAddress} | MAC: {device.MacAddress} | Vendor: {device.Vendor}");
}
2. High-Performance REST Client (Zero-LOH Stream Pipeline)
using ZeroNetwork.Http;
// Fluent API with automatic connection pooling and retry
var users = await "https://api.factory.local/users".GetJsonAsync<List<UserDto>>();
// Or using ZeroApiClient directly
using var client = new ZeroApiClient(new ZeroApiClientOptions
{
BaseAddress = new Uri("https://api.factory.local"),
MaxRetries = 3
});
var response = await client.PostJsonAsync<OrderRequest, OrderResult>("/orders", new OrderRequest { OrderId = 1001 });
3. Self-Hosted SignalR Hub Server with RPC & Groups
using ZeroNetwork.RealTime;
// 1. Declare business hub
public class TelemetryHub : ZeroHub
{
public async Task BroadcastAlarm(string machineId, string alert)
{
// Broadcast to all connected clients
await Clients.All.SendAsync("OnAlarm", machineId, alert);
}
public int ComputeThroughput(int unitsProduced, int rejects)
{
// Two-way RPC returning calculation result
return unitsProduced - rejects;
}
public async Task JoinLine(string lineId)
{
// Add caller to specific group
await Groups.AddToGroupAsync(Context.ConnectionId, lineId);
}
}
// 2. Start sovereign hub server (Port 8080)
using var server = new ZeroHubServer<TelemetryHub>(port: 8080);
server.Start();
4. Pure C# SignalR Hub Client (0 External Dependencies)
using ZeroNetwork.RealTime;
using var hub = new ZeroSignalRClient(new ZeroSignalROptions
{
HubUri = new Uri("ws://127.0.0.1:8080/hub/telemetry")
});
// Register server-to-client event listener
hub.On<string, string>("OnAlarm", (machineId, alert) =>
{
Console.WriteLine($"[ALERT] {machineId}: {alert}");
});
await hub.StartAsync();
// Invoke server hub RPC
int netYield = await hub.InvokeAsync<int>("ComputeThroughput", 1200, 45);
Console.WriteLine($"Net Yield: {netYield}");
5. High-Performance MQTT-Style In-Process Pub/Sub Bus
using ZeroNetwork.PubSub;
using var bus = new InProcessZeroBus();
// Subscribe using single-level '+' and multi-level '#' wildcards
using var sub = bus.SubscribeTopic("plants/+/line1/#", (topic, payload) =>
{
string message = Encoding.UTF8.GetString(payload.ToArray());
Console.WriteLine($"[{topic}] -> {message}");
});
// Publish topic event (zero GC allocation)
await bus.PublishTopicAsync("plants/hanoi/line1/press/temperature", Encoding.UTF8.GetBytes("78.5 C"));
6. Sub-Microsecond Cross-Process (IPC) Shared Memory Bus
using ZeroNetwork.PubSub;
// Shared memory IPC bus mapped across operating system processes
using var ipcBus = new IpcZeroBus("ZeroIpc_SCADA_Bus", capacity: 1024, slotSize: 65536, isListener: true);
ipcBus.SubscribeTopic("vision/inspection/+", (topic, data) =>
{
Console.WriteLine($"Received telemetry from external process on {topic} ({data.Length} bytes)");
});
// Fast publisher from another process
ipcBus.TryPublish("vision/inspection/cam1", Encoding.UTF8.GetBytes("OK: DefectCount=0"));
7. Resilient WebSocket Client (Auto-Reconnect & Keep-Alive)
using ZeroNetwork.RealTime;
var options = new ZeroWebSocketOptions
{
ServerUri = new Uri("ws://edge-gateway.local:8080/telemetry"),
AutoReconnect = true,
InitialReconnectDelay = TimeSpan.FromSeconds(1),
KeepAliveInterval = TimeSpan.FromSeconds(15)
};
using var ws = new ZeroWebSocketClient(options);
ws.MessageReceived += msg => Console.WriteLine($"Received: {msg}");
ws.Reconnected += () => Console.WriteLine("Connection restored!");
await ws.ConnectAsync();
await ws.SendJsonAsync(new { deviceId = "CNC-01", status = "ONLINE" });
8. Micro HTTP Server with Prometheus Metrics
using ZeroNetwork.Http;
using var server = new ZeroHttpServer(port: 9090, host: "0.0.0.0");
server.MapGet("/api/status", req => ZeroHttpResponse.Json("{\"status\":\"OK\"}"));
server.MapPost("/api/trigger", req => ZeroHttpResponse.Text("Triggered: " + req.Body));
server.Start();
// Automatic Prometheus endpoint available at: http://localhost:9090/metrics
// Health check available at: http://localhost:9090/health
β‘ BCL Optimization Benchmark Results (Before vs After)
The following empirical benchmarks demonstrate measured throughput and allocation deltas between standard .NET BCL methods and ZeroPlatform high-performance replacements:
| Hot-Path Area | Standard .NET BCL Method | ZeroPlatform Replacement | Measured Speedup & Allocation Delta |
|---|---|---|---|
| WebSocket Unmasking | Scalar XOR Loop (payload[i] ^= mask[i%4]) |
ZeroFastMask.ApplyMask (64-bit unrolled) |
9.95x Faster (144.3 MB/s β 1,435.5 MB/s) |
| WebSocket Handshake | SHA1.Create().ComputeHash() + Base64 |
ZeroSha1 + ZeroBase64 |
100% Zero-Alloc (1,604 ns + GC Heap β 0 Bytes Heap Alloc) |
| Base64 Encoding | Convert.ToBase64String(byte[]) |
ZeroBase64.Encode(Span<byte>, Span<char>) |
In-Place Span-to-Span, 0 string heap churn |
| UTF-8 Formatting | int.ToString(), Guid.ToString() |
ZeroUtf8.TryFormat |
Zero-Alloc (25 ns + String Heap β 0 Bytes Heap Alloc) |
| Lock-Free Queue | ConcurrentQueue<T> (Linked Segments) |
ZeroRingBuffer<T> (Vyukov MPMC Padded) |
2.27x Faster (11.2 M ops/sec β 25.4 M ops/sec) |
| Bit Counting | While-Loop Bit Scan | ZeroBitOps.TrailingZeroCount (De Bruijn / Hardware) |
O(1) Sub-Nanosecond across net8.0, net462, netstandard2.0 |
| Random Generation | System.Random (Knuth Subtractive) |
ZeroRandom (Xoshiro256** PRNG) |
Period 2^256 - 1, thread-local lock-free, passes BigCrush |
| Packet Deduplication | HashSet<string> (32-48 B/item) |
ZeroBloomFilter (Kirsch-Mitzenmacher + XxHash3) |
~95% RAM Saved, 0-alloc sub-microsecond query |
| Scoped Allocation | BCL GC Heap (14 collections / 1M) | ZeroArenaAllocator (Monotonic Bump + Scope) |
0 GC Collections, sub-nanosecond watermark reset |
| Delimiter Scanning | Sequential byte scanning / IndexOf |
ZeroVectorScan (SWAR 64-bit parallel word search) |
Accelerated Header Search, 0 allocation |
| Micro Critical Section | BCL lock (object) / Monitor |
ZeroSpinLock (Padded TTAS SpinLock) |
Sub-30ns Acquisition, 0 False Sharing |
π» Supported Platforms
| Framework | Target Support | Dependency Footprint |
|---|---|---|
| .NET 8.0+ | Native (net8.0) |
0 Dependencies |
| .NET Framework | Legacy WinForms / WPF (net462) |
0 Dependencies (BCL only) |
| .NET Standard | Universal Cross-Platform (netstandard2.0) |
0 Dependencies |
π License
MIT License Β© 2026 Phong VΓ΅ (kzxl). Part of the ZeroPlatform sovereign ecosystem.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.ValueTuple (>= 4.5.0)
- ZeroConcurrency (>= 1.3.0)
- ZeroPrimitives.Core (>= 1.5.0)
-
.NETStandard 2.0
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.ValueTuple (>= 4.5.0)
- ZeroConcurrency (>= 1.3.0)
- ZeroPrimitives.Core (>= 1.5.0)
-
net8.0
- ZeroConcurrency (>= 1.3.0)
- ZeroPrimitives.Core (>= 1.5.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ZeroNetwork.Core:
| Package | Downloads |
|---|---|
|
ZeroUI.Core
High-performance, zero-allocation core runtime and industrial automation infrastructure for .NET (SQLite Historian, Modbus TCP, Siemens S7, PackML, OEE, UiDispatcher, WorkerQueue). |
GitHub repositories
This package is not used by any popular GitHub repositories.