IPv4 Addressing Overview and Calculations
IPv4 Addressing Overview and Calculations
To determine if two devices are on the same IPv4 network segment, check whether their network addresses, derived from their respective IP addresses and subnet masks, match. For each device, convert its IP address and subnet mask to binary, perform a binary AND operation between them to isolate the network address. If both resulting network addresses are identical, the devices share the same network segment. For example, given IPs 201.37.16.19/19 and 201.38.16.19/19, convert to binary, apply AND with respective subnet masks, and compare the network addresses .
To calculate the network address for IP 192.168.3.55/23, first convert IP and subnet to binary: 192.168.3.55 is 11000000.10101000.00000011.00110111 and /23 subnet is 11111111.11111111.11111110.00000000. Perform a binary AND between them: - IP: 11000000.10101000.00000011.00110111 - Subnet: 11111111.11111111.11111110.00000000 - Network: 11000000.10101000.00000010.00000000, which converts back to 192.168.2.0 in dotted decimal .
To calculate the network address of an IPv4 address using a subnet mask, follow these steps: 1) Convert the IPv4 address to binary; 2) Convert the subnet mask to binary; 3) Align the IP address and the subnet mask bit for bit; 4) Apply the binary AND operation to each pair of bits. The result is the network address, where all host bits are set to 0. For example, given the IP address 167.199.170.82/27: - IP Address in binary: 10100111 11000111 10101010 01010010 - Subnet Mask in binary: 11111111 11111111 11111111 11100000 - Apply AND operation: Network Address = 10100111 11000111 10101010 01000000 in binary, which equals 167.199.170.64 in dotted decimal. This indicates the network the address belongs to .
IPv4 addresses are 32-bit numbers expressed in dotted decimal format, divided into 4 octets, each converted into a decimal between 0 and 255. IPv6 addresses, on the other hand, are 128-bit numbers written in hexadecimal format, divided into eight hextets, each consisting of four hex digits separated by colons. IPv4 uses dotted decimal and often accompanies a subnet mask in dotted decimal or slash notation, while IPv6 uses prefix length for subnetting .
IPv6 utilizes hexadecimal representation because of its larger address space, consisting of 128 bits, which makes binary and dotted decimal representations cumbersome and complex to manage. Hexadecimal simplifies the expression of these extensive addresses by condensing the 128 bits into eight groups (hextets) of four hex digits each. This format reduces the size of the address string and makes it more human-readable while maintaining efficiency for computer processing .
To calculate the number of usable host addresses in a network, use the formula 2^n - 2, where n is the number of host bits. Host bits are determined by subtracting the subnet prefix length from 32 (for IPv4). For example, if an IPv4 address is 167.199.170.82/27, the subnet mask leaves 5 host bits (32 total bits - 27 prefix bits = 5 host bits). The total number of addresses is 2^5 = 32, and the number of usable addresses is 2^5 - 2 = 30. These exclude the network and broadcast addresses .
The broadcast address is used to send a packet to all devices within the same network and represents the last address in that network range. To find the broadcast address, keep the network bits intact and change all host bits to 1s. For example, using the IP address 167.199.170.82/27: the network portion remains the same, while the host portion becomes all 1s (e.g., 10100111 11000111 10101010 01011111 in binary), resulting in a broadcast address of 167.199.170.95 in dotted decimal .
IPv4 has a 32-bit address space, which equates to approximately 4.3 billion possible unique addresses (2^32). In contrast, IPv6 uses a 128-bit address space, allowing for about 3.4 x 10^38 possible addresses (2^128), vastly expanding the address capacity. This increase is necessary to accommodate the growing demand for IP addresses due to the expansion of internet-connected devices and networks .
To convert a subnet mask from dotted decimal notation to prefix length, convert each octet of the subnet mask to binary, count the number of consecutive 1s from the left, and this count is the prefix length. For example: - 255.255.255.252 converts to binary as 11111111.11111111.11111111.11111100, which has 30 consecutive 1s, thus the prefix length is /30. - 255.255.0.0 converts to binary as 11111111.11111111.00000000.00000000, with 16 consecutive 1s, resulting in a /16 prefix length .
Usable host addresses are derived by identifying the address range between the network and broadcast addresses. The network address marks the beginning (all 0's on the host bits) and the broadcast address is the end (all 1's on the host bits). The first usable address is one more than the network address, and the last usable address is one less than the broadcast address. For example, with a network address of 167.199.170.64 and a broadcast address of 167.199.170.95 (/27), usable addresses range from 167.199.170.65 to 167.199.170.94 .