IP Addresses
The IP addresses are unique. An IPv4 address is a 32-bit address. An IPv6 address is a 128-bit address.
The address space of IPv4 is 2 32 or 4,294,967,296. The address space of IPv6 is 2 128
IPv4 Notations: 1. Binary Notation 2. Dotted Decimal Notation 3. HexaDecimal Notation
Binary Notation 01110101 10010101 00011101 11101010
Dotted-decimal notation
Hexadecimal Notation 0111 0101 1001 0101 0001 1101 1110 1010 75 95 1D EA 0x75951DEA
In classful addressing, the address space is divided into five classes: A, B, C, D, and E.
Finding the class in binary notation
Finding the address class
Finding the class in decimal notation
Netid and hostid
Unicast, Multicast, and Broadcast Addresses Unicast communication is one-to-one. Multicast communication is one-to-many. Broadcast communication is one-to-all.
Blocks in class A
Blocks in class B
Blocks in class C
Class D addresses are used for multicasting; there is only one block in this class.
Class E addresses are reserved for special purposes; most of the block is wasted.
Class Range Total # of Networks (blocks) N1 A 0.0.0.0 to 127.255.255.255 Netid : 1 Byte Hostid : 3 Byte B C D 128.0.0.0 to 191.255.255.255 Netid : 2 Byte Hostid : 2 Byte 192.0.0.0 to 223.255.255.255 Netid : 3 Byte Hostid : 1 Byte 224.0.0.0 to 239.255.255.255 Multicast address (Leftmost bit =0 from 1 byte (8-1 = 7)) 2 7 = 128 blocks (Leftmost two bit =10 from 2 byte (16-2 =14)) 2 14 = 16,384 blocks (Leftmost three bit =110 from 3 byte (24-3 =21)) 2 21 = 2,097,152 blocks (Leftmost Four bit =1110) = 1 block Host Address per Network N2 256 * 256 * 256 = 16,777,216 256 * 256 = 65,536 Total # of Address in each class N1*N2 2,147,483,648 1,073,741,824 256 536,870,912 2 28 = 268,435,456 268,435,456 E 240.0.0.0 to (Leftmost four bit = 1111) 2 28 268,435,456 255.255.255.255 =1 block = 268,435,456 Reserved for future use Total 2,113,666 2 32 =4,294,967,296
Network Addresses The network address is the first address in the block. The network address defines the network to the rest of the Internet. Given the network address, we can find the class of the address, the block, and the range of the addresses in the block
In classful addressing, the network address (the first address in the block) is the one that is assigned to the organization. Network address is not allocated to any physical device.
Given the network address 17.0.0.0, find the class, the block, and the range of the addresses. Solution The class is A because the first byte is between 0 and 127. The block has a netid of 17. The addresses range from 17.0.0.0 to 17.255.255.255.
Given the network address 220.34.76.0, find the class, the block, and the range of the addresses. Solution The class is C because the first byte is between 192 and 223. The block has a netid of 220.34.76. The addresses range from 220.34.76.0 to 220.34.76.255.
Mask A mask is a 32-bit binary number that gives the first address in the block (the network address) when bitwise ANDed with an address in the block.
Masking concept
The network address is the beginning address of each block. It can be found by applying the default mask to any of the addresses in the block (including itself). It retains the netid of the block and sets the hostid to zero. Class Network Mask / Default Mask A 255.0.0.0 B 255.255.0.0 C 255.255.255.0
Given the address 201.180.56.5 and the class C default mask, find the beginning address (network address). Solution The default mask is 255.255.255.0, which means that the first 3 bytes are preserved and the last byte is set to 0. The network address is 201.180.56.0.
Network addresses
Private Addresses A number of blocks in each class are assigned for private use. They are not recognized globally. These blocks are depicted in Table. Class Range Total# of Address A 10.0.0.0 to 10.255.255.255 256 * 256 * 256 = 16,777,216 B 172.16.0.0 to 172.31.255.255 16 * 256 * 256 = 1,048,576 B 169.254.0.0 to 169.254.255.255 256 * 256 =65,536 C 192.168.0.0 to 192.168.255.255 256*256 = 65,536
Three-level Addressing : Subnetting TWO-LEVEL HIERARCHY NETWORK HOST NUMBER THREE-LEVEL HIERARCHY NETWORK SUBNET HOST NUMBER
A network with three levels of hierarchy (subnetted)
Default mask and subnet mask
Example What is the subnetwork address if the destination address is 200.45.34.56 and the subnet mask is 255.255.240.0?
Solution 11001000 00101101 00100010 00111000 11111111 11111111 11110000 00000000 11001000 00101101 00100000 00000000 The subnetwork address is 200.45.32.0.
The number of subnets must be a power of 2.
Example A company is granted the site address 201.70.64.0 (class C). The company needs six subnets. Design the subnets. Solution The number of 1s in the default mask is 24 (class C).
Solution (Continued) The company needs six subnets. This number 6 is not a power of 2. The next number that is a power of 2 is 8 (2 3 ). We need 3 more 1s in the subnet mask. The total number of 1s in the subnet mask is 27 bits (24 + 3). The total number of 0s is 5 (32-27). The mask is
Solution (Continued) 11111111 11111111 11111111 11100000 or 255.255.255.224 The number of subnets is 8. The number of addresses in each subnet is 2 5 (5 is the number of 0s) or 32.
Subnetwork Subnetid (3 bits) Hostid (5 bits) Range 1 000 00000 to 11111 201.70.64.0 201.70.64.31 2 001 00000 to 11111 201.70.64.32 201.70.64.63 3 010 00000 to 11111 201.70.64.64 201.70.64.95 4 011 00000 to 11111 201.70.64.96 201.70.64.127 5 100 00000 to 11111 201.70.64.128 201.70.64.159 6 101 00000 to 11111 201.70.64.160 201.70.64.191 7 110 00000 to 11111 201.70.64.192 201.70.64.223 8 111 00000 to 11111 201.70.64.224 201.70.64.255
Example
Supernetting Supernetting combines multiple network addresses into a single network address In supernetting, bits from the network ID are borrowed to be used as the host ID. Supernetting decreases the number of networks an organization can have, but increases the number of hosts that can be on each network.
Comparison of subnet, default, and supernet masks
A supernetwork
Special Addresses Class Address Network Address Subnet work address Direct Broadcast Address E 255.255.255.255 Limited Broadcast Address B Loop Back Address 127.0.0.0 to 127.255.255.255 A 0.0.0.0 All Zero Address Purpose First address in block First address in a sub network Last address in block. used to send packet to all hosts in a specific network. Host used this address as a destination address, to send message to every other host machine. Loopbacks are used for testing. An IP loopback is application-level testing. Allows the node to send test packet to itself without generating network traffic. Reserved for communication when host needs to send an IPv4 packet but it does not know its own address. Used during bootstrap time.
Classless Addressing In classless addressing, the prefix defines the network and the suffix defines the host. The prefix length in classless addressing can be 1 to 32. There is only one condition on the number of addresses in a block; it must be a power of 2 (2, 4, 8,...).
Variable-length blocks
Slash notation
Slash notation is also called CIDR (Class less Inter Domain Routing) notation.
Example A small organization is given a block with the beginning address and the prefix length 205.16.37.24/29 (in slash notation). What is the range of the block? Solution The beginning address is 205.16.37.24. To find the last address we keep the first 29 bits and change the last 3 bits to 1s. Beginning:11001111 00010000 00100101 00011000 Ending : 11001111 00010000 00100101 00011111 There are only 8 addresses in this block.
length of the suffix is 32-29 or 3. So there are 2 3 = 8 addresses in this block. If the first address is 205.16.37.24, the last address is 205.16.37.31 (24 + 7 = 31).
A block in classes A, B, and C can easily be represented in slash notation as A.B.C.D/ n where n is either 8 (class A), 16 (class B), or 24 (class C).
Example What is the network address if one of the addresses is 167.199.170.82/27? Solution The prefix length is 27. we must keep the first 27 bits as is and change the remaining bits (32-27 = 5) to 0s. The last byte is 01010010. Changing the last 5 bits to 0s, we get 01000000 or 64. The network address is 167.199.170.64/27.
Prefix Length
Two Level Addressing In Class less addressing, the prefix defines the network and suffix defines host. Prefix = n bits suffix = 32 n bits Network Mask = First n bits set to 1s and rest of the bits set to 0s.
The number of addresses in the block = N = 2 32 n, n is prefix length First Address =(any address) AND (network mask) Last Address = keep n bits(prefix bits) as it is and set 32-n bits to 1s.
Example One of the addresses in a block is 110.23.120.24/20. Find the number of addresses, the first address and the last address in the block. Solution The prefix length is 20. Network Mask = 255.255.240.0 Number of address = 2 32-20 = 2 10 = 4096 First Address = 110.23.112.0/20 Last Address = 110.23.127.255/20
In classless addressing, the last address in the block does not necessarily end in 255.
Subnetting Three level hierarchy can be created using sub netting. Number of addresses in each sub network should be a power of 2.
Example An organization is granted the block 130.34.12.64/26. The organization needs to have four subnets. What are the subnet addresses and the range of addresses for each subnet? Solution The suffix length is 6 (32-26= 6). Total number of addresses in the block is 64 (2 6 ). 4 subnet require = 2 bits from suffix.
130.34.12.64/26 10000010 00100010 00001100 0100 0000 The subnet prefix is then /28. Subnet Last byte range 1 0100 0000 to 0100 1111 2 0101 0000 to 0101 1111 3 0110 0000 to 0110 1111 4 0111 0000 to 0111 1111 130.34.12.64/28 130.34.12.79/28 130.34.12.80/28 130.34.12.95/28 130.34.12.96/28 130.34.12.111/28 130.34.12.112/28 130.34.12.127/28
Example
Example The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet? (GATE 2007) (A)62 subnets and 262142 hosts. (B) 64 subnets and 262142 hosts. (C) 62 subnets and 1022 hosts. (D) 64 subnets and 1024 hosts.
Example The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP addresses could belong to this network? (GATE 2003) (A)172.57.88.62 and 172.56.87.233 (B) 10.35.28.2 and 10.35.29.4 (C) 191.203.31.87 and 191.234.31.88 (D) 128.8.129.43 and 128.8.161.55
Example GATE 2008 If a class B network on the Internet has a subnet mask of 255.255.248.0, what is the maximum number of hosts per subnet? (A)1022 (B) 1023 (C) 2046 (D) 2047 GATE 2012
Example Suppose computers A and B have IP addresses 10.105.1.113 and 10.105.1.91 respectively and they both use the same net mask N. Which of the values of N given below should not be used if A and B should belong to the same network? (GATE 2010) (A)255.255.255.0 (B) 255.255.255.128 (C) 255.255.255.192 (D) 255.255.255.224
NAT: Network Address Translation It provides mapping between the private and universal (public/live/global) addresses. It allows to use a set of private addresses for internal communication and set of global internet addresses for communication with the rest of the world.
NAT :