NetworkInspector.Values 0.23.0

dotnet add package NetworkInspector.Values --version 0.23.0
                    
NuGet\Install-Package NetworkInspector.Values -Version 0.23.0
                    
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="NetworkInspector.Values" Version="0.23.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetworkInspector.Values" Version="0.23.0" />
                    
Directory.Packages.props
<PackageReference Include="NetworkInspector.Values" />
                    
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 NetworkInspector.Values --version 0.23.0
                    
#r "nuget: NetworkInspector.Values, 0.23.0"
                    
#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 NetworkInspector.Values@0.23.0
                    
#: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=NetworkInspector.Values&version=0.23.0
                    
Install as a Cake Addin
#tool nuget:?package=NetworkInspector.Values&version=0.23.0
                    
Install as a Cake Tool

NetworkInspector.Values

NuGet Downloads .NET 10 License: MIT

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, and ISpanParsable<T> let you format into and parse from spans without strings.
  • Stable text forms for logs and exports: IPv6 compressed as in RFC 5952 § 4.2 (upper case by default, lower case on request; no dotted IPv4 tail), colon-separated MAC, ISO-8601 timestamps with nanoseconds.
  • Address classification: broadcast, multicast, private, loopback, link-local, IPv4-mapped, and more; the group and local bits (IsMulticast, IsLocal) on both MacAddress and Eui64.
  • One family. Every type has IsZero, TryFromBytes and FromBytes, TryWrite for its big-endian byte form, and one integer of its full width (RawValue, AsNanos for Timestamp; UInt128 for IPv6Address and Uuid). All types except Timestamp also have ToBytes and ToBytesArray.
  • Nanosecond timestamps with TimeSpan arithmetic and the exact difference in nanoseconds (Timestamp.SubtractNanos); a TimeSpan counts 100 ns ticks, so a - b cuts below 100 ns.
  • 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) (48-bit value; a wider one throws), TryParse
IPv4Address 192.168.1.10 FromBytes, new(uint) (big-endian value), TryParse
IPv6Address 2001:DB8::1 (compressed, RFC 5952 § 4.2) FromBytes, new(ulong high, ulong low), new(UInt128), TryParse
Eui64 00:11:22:33:44:55:66:77 FromBytes, new(ulong), TryParse
Uuid 01020304-0506-0708-090A-0B0C0D0E0F10 FromBytes, new(ulong high, ulong low), new(UInt128), TryParse
Timestamp 2023-11-14T22:13:20.000000000Z FromNanos, FromMicros, FromMillis, FromSecs, FromBytes, Now, TryParse

Text output of MacAddress, Eui64, Uuid, and IPv6Address uses uppercase hex by default; TryParse accepts either case, also for the T and Z of a timestamp, and ignores space, tab, CR, and LF around the text. 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. IPv4Address.TryParse refuses an octet with a leading zero (010.0.0.1), because other tools read it as octal.

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. IPv4Address and Timestamp have no text options: every specifier other than the empty one throws FormatException.

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.FromSecs and the other factories throw OverflowException outside the representable range.
  • Validate external text with TryParse instead of catching exceptions.

Learn More

License

MIT License

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 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.23.0 0 11/26/2026
0.22.0 210 11/16/2026
0.21.0 212 11/10/2026
0.20.0 221 11/4/2026
0.19.0 228 10/29/2026
0.18.0 193 10/22/2026
0.17.0 175 10/17/2026
0.16.0 175 10/17/2026
0.15.0 179 10/9/2026
0.14.0 186 10/8/2026
0.13.0 181 9/27/2026
0.12.0 194 9/17/2026
0.11.0 511 9/10/2026
0.10.0 197 9/8/2026
0.9.0 191 9/2/2026
0.8.0 227 8/28/2026
0.7.0 196 8/27/2026
0.6.0 215 8/21/2026
0.5.0 215 7/11/2026
0.4.0 256 6/2/2026
Loading failed