NetworkInspector.Values
0.20.0
dotnet add package NetworkInspector.Values --version 0.20.0
NuGet\Install-Package NetworkInspector.Values -Version 0.20.0
<PackageReference Include="NetworkInspector.Values" Version="0.20.0" />
<PackageVersion Include="NetworkInspector.Values" Version="0.20.0" />
<PackageReference Include="NetworkInspector.Values" />
paket add NetworkInspector.Values --version 0.20.0
#r "nuget: NetworkInspector.Values, 0.20.0"
#:package NetworkInspector.Values@0.20.0
#addin nuget:?package=NetworkInspector.Values&version=0.20.0
#tool nuget:?package=NetworkInspector.Values&version=0.20.0
NetworkInspector.Values
Small, fast value types for network identifiers and time: MacAddress, IPv4Address, IPv6Address, Eui64,
Uuid, and Timestamp. They are the value types of the whole NetworkInspector stack and work just as well on
their own.
Highlights
- Value semantics. Every type is a
readonly record struct: no allocation, equality and ordering built in (IEquatable<T>,IComparable<T>,<,>,<=,>=). - Allocation-free formatting and parsing.
ISpanFormattable,IUtf8SpanFormattable, andISpanParsable<T>let you format into and parse from spans without strings. - Stable text forms for logs and exports: RFC 5952 IPv6, colon-separated MAC, ISO-8601 timestamps with nanoseconds.
- Address classification: broadcast, multicast, private, loopback, link-local, IPv4-mapped, and more.
- Nanosecond timestamps with
TimeSpanarithmetic. - Standalone. No dependency on the rest of NetworkInspector.
Install
dotnet add package NetworkInspector.Values
Quick Start
using NetworkInspector.Values;
MacAddress mac = MacAddress.FromBytes([0x00, 0x1A, 0x2B, 0x3C, 0x4D, 0x5E]);
IPv4Address ip4 = IPv4Address.FromBytes([192, 168, 1, 10]);
if (!IPv6Address.TryParse("2001:db8::1", out IPv6Address ip6))
{
throw new FormatException("Invalid IPv6 address.");
}
Timestamp ts = Timestamp.FromSecs(1_700_000_000);
Console.WriteLine(mac); // 00:1A:2B:3C:4D:5E
Console.WriteLine(ip4); // 192.168.1.10
Console.WriteLine(ip6); // 2001:DB8::1
Console.WriteLine(ts); // 2023-11-14T22:13:20.000000000Z
Types
| Type | Text form | Create from |
|---|---|---|
MacAddress |
00:1A:2B:3C:4D:5E |
FromBytes, new(ulong) (lower 48 bits), TryParse |
IPv4Address |
192.168.1.10 |
FromBytes, new(uint) (big-endian value), TryParse |
IPv6Address |
2001:DB8::1 (RFC 5952) |
FromBytes, new(ulong high, ulong low), TryParse |
Eui64 |
00:11:22:33:44:55:66:77 |
FromBytes, TryParse |
Uuid |
01020304-0506-0708-090A-0B0C0D0E0F10 |
FromBytes, TryParse |
Timestamp |
2023-11-14T22:13:20.000000000Z |
FromNanos, FromMicros, FromMillis, FromSecs, Now |
Text output of MacAddress, Eui64, Uuid, and IPv6Address uses uppercase hex by default; TryParse accepts either case.
Lower case is a per-call choice (see "Choose The Letter Case"). Parse is available through the generic IParsable<T> /
ISpanParsable<T> interfaces; call TryParse directly for untrusted text.
Common Tasks
Classify Addresses
if (ip4.IsPrivate || ip4.IsLoopback)
{
Console.WriteLine("internal traffic");
}
Format Without Allocating
Span<char> buffer = stackalloc char[64];
if (ip6.TryFormat(buffer, out int written, default, null))
{
Console.Out.Write(buffer[..written]);
}
Choose The Letter Case
Upper case is the default, so existing exports and filters keep matching. Lower case (the spelling RFC 5952 recommends for
IPv6) is selected per call, with the HexCase enumeration or with the format specifier x; X and the empty format give
upper case. Any other specifier throws FormatException, so a specifier that would have no effect is never ignored silently.
string upper = mac.Format(); // "AB:CD:EF:01:23:45"
string lower = mac.Format(HexCase.Lower); // "ab:cd:ef:01:23:45"
string text = $"{ip6:x}"; // "2001:db8::1"
int written = uuid.FormatInto(buffer, HexCase.Lower);
Use As Keys
The types are equatable and comparable values, so they work as dictionary keys, in sorted sets, and in
ORDER BY-style reports without custom comparers.
Limits And Thread-Safety Notes
- Immutable values: safe to share across threads.
Timestamp.FromSecsand the other factories throwOverflowExceptionoutside the representable range.- Validate external text with
TryParseinstead of catching exceptions.
Learn More
License
| Product | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NetworkInspector.Values:
| Package | Downloads |
|---|---|
|
NetworkInspector.Core
High-performance protocol analysis stack for network packet dissection. Provides the core framework for protocol registration, field trees, packet parsing, and cross-packet indexing. Includes a Roslyn source generator for declarative protocol definitions. |
|
|
NetworkInspector.FrameBuilder
Typed, allocation-free frame-builder library for NetworkInspector. Compose protocol stacks and emit RFC-conformant wire frames with zero heap allocations on the hot path. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.20.0 | 139 | 11/4/2026 |
| 0.19.0 | 221 | 10/29/2026 |
| 0.18.0 | 177 | 10/22/2026 |
| 0.17.0 | 169 | 10/17/2026 |
| 0.16.0 | 167 | 10/17/2026 |
| 0.15.0 | 174 | 10/9/2026 |
| 0.14.0 | 181 | 10/8/2026 |
| 0.13.0 | 176 | 9/27/2026 |
| 0.12.0 | 190 | 9/17/2026 |
| 0.11.0 | 220 | 9/10/2026 |
| 0.10.0 | 195 | 9/8/2026 |
| 0.9.0 | 190 | 9/2/2026 |
| 0.8.0 | 223 | 8/28/2026 |
| 0.7.0 | 194 | 8/27/2026 |
| 0.6.0 | 209 | 8/21/2026 |
| 0.5.0 | 212 | 7/11/2026 |
| 0.4.0 | 253 | 6/2/2026 |
| 0.3.0 | 194 | 5/21/2026 |
| 0.2.0 | 191 | 5/19/2026 |