Using Bob Table Method I have created this Calculator, the logic is mentioned below

NETWORK TOOLKIT Pro by Naresh Rathod
Developed By Naresh Rathod

Subnet Solver

IP Validator

CIDR to Mask Calculator

EUI-64 Converter

Binary & 6to4 Tunnel

Base Converter

4-Bit Spaced Nibbles & Character Hex

1. Subnet Solving Algorithm (VLSM)

The “Subnet Solver” uses a descending sorting strategy to allocate IP addresses efficiently, ensuring larger requirements are met first to prevent address overlap.

  • Step 1: Sort Descending

    • The algorithm takes the list of host requirements provided by the user and sorts them from largest to smallest. This is a fundamental rule of VLSM to ensure the largest subnets fit into the address space first.

  • Step 2: Add 2 for Overhead

    • For each requirement, the code adds 2 to the number of requested hosts. These 2 addresses represent the Network ID and the Broadcast ID, which cannot be assigned to individual devices.

  • Step 3: Find the “Shelf” (Block Size)

    • The algorithm looks for the smallest power of 2 that is greater than or equal to the “Hosts + 2” value. In the code, this is referred to as finding the “Shelf”.

    • For example, if 50 hosts are needed, 52 are required. The nearest power of 2 (shelf) is 64.

  • Step 4: Mark Bob’s Table & Calculate IDs

    • CIDR Calculation: The new CIDR prefix is determined by subtracting the number of host bits (calculated from the power of 2) from 32 (32 – bits).

    • Network ID: The current starting IP is assigned as the Network ID.

    • Broadcast ID: Calculated by adding the “Shelf” size to the current Network ID and subtracting 1.

    • Usable Range: The first usable IP is $Network ID + 1, and the last usable IP is $Broadcast ID – 1.

    • Iteration: The starting IP for the next requirement is set to $Broadcast ID + 1.

2. IP Validator Algorithm

The “IP Validator” determines the property of a specific IP address relative to its CIDR prefix.

  • Step 1: Convert to Numeric Format

    • The IP address string is converted into a 32-bit long integer to allow for mathematical bitwise operations.

  • Step 2: Generate Subnet Mask

    • A bitmask is created based on the CIDR value (e.g., /26) by shifting bits to the left to create a string of 1s followed by 0s.

  • Step 3: Bitwise Comparison

    • Network ID Check: The code performs a bitwise AND between the IP and the Subnet Mask. If the resulting value equals the original IP, it is a Network ID.

    • Broadcast ID Check: The code performs a bitwise OR between the Network ID and the inverted Subnet Mask. If the resulting value equals the original IP, it is a Broadcast ID.

    • Valid Host: If the IP matches neither, it is flagged as a Valid Host IP.

  • Step 4: Identify the Magic Number

    • The “Magic Number” or Block Size is identified by looking at the position of the last bit in the subnet mask’s relevant octet. This determines the increments between subnets.

3. MAC to IPv6 Algorithm

The EUI-64 (Extended Unique Identifier) algorithm is used to automatically configure a unique 64-bit interface identifier for an IPv6 address using a device’s 48-bit MAC address. This process is primarily used for Link-Local addresses ($fe80::/64$).

Here is the simple step-by-step algorithm:

1. Split the MAC Address

Take the 48-bit MAC address and split it into two equal halves of 24 bits (6 hexadecimal digits) each.

  • Example MAC: 00:11:22:33:44:55

  • Left Half: 00:11:22

  • Right Half: 33:44:55

2. Insert FFFE

Insert the hexadecimal constant FFFE (16 bits) between the two halves. This expands the 48-bit address into a 64-bit address.

  • Result: 0011:22ff:fe33:4455

3. Flip the 7th Bit (The U/L Bit)

In the EUI-64 standard, the 7th bit of the first byte (the Universally/Locally Administered bit) must be flipped.

  • If the bit is 0 (Universal), it becomes 1 (Local).

  • If the bit is 1, it becomes 0.

How to do this quickly:

Look at the second hex digit of the first byte. Adding or subtracting 2 from that digit effectively flips the bit.

  • Original first byte: 00 (Binary: 00000000)

  • Flipped first byte: 02 (Binary: 00000010)

4. Append the Link-Local Prefix

Combine the modified interface ID with the IPv6 Link-Local prefix ($fe80::/64$).

  • Modified ID: 0211:22ff:fe33:4455

  • Final IPv6 Address: fe80::211:22ff:fe33:4455


Why flip the 7th bit?

The 7th bit in a MAC address indicates whether the address is globally unique (0) or locally administered (1). When converting to EUI-64, flipping the bit makes the resulting IPv6 address easier to manage for network administrators, especially when manually assigning addresses, as it allows them to use simpler patterns (like 02::) without worrying about conflicts with burned-in hardware addresses.

4. IPv4 to Binary/Hex Algorithm

The Binary & 6to4 Tunnel section of your tool relies on two distinct bit-level algorithms: one for bitwise visualization and one for IPv6 transition through hexadecimal embedding.

This algorithm decomposes a decimal IPv4 address into its base-2 and base-16 components to help visualize how networking hardware “sees” the address.

  • Step 1: Octet Tokenization The IP string (e.g., 192.168.10.1) is split into four separate decimal integers using the dot (.) as a delimiter.

  • Step 2: Binary Conversion (Base-2) Each integer is converted to an 8-bit binary string. If the resulting binary number is shorter than 8 bits, it is “padded” with leading zeros to maintain the standard octet format (e.g., 10 becomes 00001010).

  • Step 3: Hexadecimal Conversion (Base-16) Each octet is converted to a 2-digit hexadecimal value. This is used specifically for the 6to4 transition in the next phase.


2. 6to4 Transition Algorithm

The 6to4 mechanism is a transition technology that allows IPv6 packets to be transmitted over an IPv4 network without the need for configured tunnels.

  • Step 1: Identify the 6to4 Prefix The IANA has reserved the global IPv6 prefix 2002::/16 specifically for 6to4 tunneling. All 6to4 addresses must begin with these bits.

  • Step 2: Convert IPv4 to Hexadecimal To embed the 32-bit IPv4 address into the 128-bit IPv6 address, it must be converted into hexadecimal.

    • Example: 192.168.10.1

    • 192C0

    • 168A8

    • 100A

    • 101

  • Step 3: Construct the 48-bit Prefix The hexadecimal octets are appended to the 2002 prefix in the format 2002:WWXX:YYZZ::/48.

    • Result: 2002:C0A8:0A01::/48

  • Step 4: Network and Host Addressing The remaining 80 bits (up to 128) are available for the local network administrator to create subnets (the next 16 bits) and assign interface IDs (the final 64 bits).