Skip to content

Latest commit

 

History

History
68 lines (49 loc) · 1.61 KB

README.md

File metadata and controls

68 lines (49 loc) · 1.61 KB

Code Coverage Nuget

Toimik.IpAddressEnumeration

.NET 8 C# IP Address enumerators.

Features

  • Enumerate IPv4 addresses in a sequential / staggered fashion
  • More to come ...

Quick Start

Installation

Package Manager

PM> Install-Package Toimik.IpAddressEnumeration

.NET CLI

> dotnet add package Toimik.IpAddressEnumeration

Usage

// Creates an enumerator of public IPv4 addresses that adopts a sequential approach
var enumerator = new SequentialV4IpAddressEnumerator();

// Creates an enumerator of public IPv4 addresses that adopts a staggered approach */
// var enumerator = new StaggeredV4IpAddressEnumerator();

var isForward = true;
var initialIpAddress = IPAddress.Parse("1.2.3.4");
var ipAddresses = enumerator.Enumerate(isForward, initialIpAddress);
foreach (IPAddress ipAddress in ipAddresses)
{
    Console.WriteLine(ipAddress);
}

 

Output

SequentialV4IpAddressEnumerator.cs

1.2.3.4
1.2.3.5
1.2.3.6
...

StaggeredV4IpAddressEnumerator.cs

The output is the decimal representation of the reversed binary representation of the incremented binary.

IP address Incremented binary
1.2.3.4    00100000.11000000.01000000.10000000  <- Original
129.2.3.4  00100000.11000000.01000000.10000001  <- Incremented by 1 bit
65.2.3.4   00100000.11000000.01000000.10000010  <- Incremented by another bit
...        ...