CE363 Data Communications & Networking Chapter 6 Network Layer: Logical Addressing
TCP/IP and OSI model APPLICATION APPLICATION PRESENTATION SESSION TRANSPORT NETWORK Host-Network TRANSPORT NETWORK DATA LINK PHYSICAL 2
Chapter 6 - Network Layer: Logical Addressing IPv4 ADDRESSES Address Space Address Notation Classful Addressing Classless Addressing Address Hierarchy Network Address Translation (NAT) NAT implementation NAT address translation ISP and NAT IPv6 ADDRESSES Address Space Address Notation 3
IPv4 ADDRESSES An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the Internet. Topics discussed in this section: Address Space Address Notations Classful Addressing Classless Addressing Network Address Translation (NAT) 4
IPv4 ADDRESSES IP Address Space The IPv4 address is 32 bits long. The IPv4 addresses are unique and universal. The address space of IPv4 is (2) 32 or 4,294,967,296 5
IP Address Notations IPv4 ADDRESSES The IP addresses are written using binary notation To make things easier, the addresses are usually written using dotted decimal notation 6
Example 1 Change the following IPv4 addresses from binary notation to dotted-decimal notation. Solution Replace each group of 8 bits with its equivalent decimal number and add dots for separation. 7
Example 2 Change the following IPv4 addresses from dotted-decimal notation to binary notation. Solution Replace each decimal number with its binary equivalent. 8
Example 3 Find the error in the following IPv4 addresses. Solution a. There must be no leading zero (045). b. There can be no more than four numbers. c. Each number needs to be less than or equal to 255. d. A mixture of binary notation and dotted-decimal notation is not allowed. 9
IPv4 ADDRESSES Classful Addressing In classful addressing, the address space is divided into five classes: A, B, C, D, and E. 10
IP Address Each IP address consists of 4 bytes, defining three fields : Class Type NetID (network identifier) HostID (host identifier) Class Type NetID HostID Network Classes IPv4 ADDRESSES Few networks, each with many hosts Medium # of networks, each with medium # of hosts Many networks, each with few hosts Send a packet to a selected group of hosts rather than to an individual host 11
IPv4 ADDRESSES Ranges of IP Addresses This allows for 2 7-2 (126) networks with 2 24 2 (16,777,214) hosts each; a total of over 2 billion addresses This allows for 2 14-2 (16,382) networks with 2 16 2 (65,534) hosts each; a total of over 1 billion addresses This allows for 2 21-2 (2,097,150) networks with 2 8 2 (254) hosts each; a total of over half a billion addresses 12
Example 4 Find the class of each address. a. 00000001 00001011 00001011 11101111 b. 11000001 10000011 00011011 11111111 c. 14.23.120.8 d. 252.5.15.111 Solution a. The first bit is 0. This is a class A address. b. The first 2 bits are 1; the third bit is 0. This is a class C address. c. The first byte is 14; the class is A. d. The first byte is 252; the class is E. 13
IPv4 ADDRESSES Number of blocks and block size in classful IPv4 addressing In classful addressing, a large part of the available addresses were wasted. Block in class A (and even some class B Blocks) are too large for any organization and blocks is class C is probably too small for many organizations. 14
IPv4 ADDRESSES Network Example A network address is the NetID with the host part set to 0s Any device connected to more than one networks (Router) must have more than one IP address. 15
IP Addresses Mask IPv4 ADDRESSES The mask can help us to find the netid and the hostid. For example, the mask for a class A address has eight 1s, which means the first 8 bits of any address in class A define the netid; the next 24 bits define the hostid. Default masks for classful addressing CIDR notation (slash notation): Classless Inter-Domain Routing. It shows the mask in the form /n format (e.g., /8, /16, /24). 16
IPv4 ADDRESSES Example: default subnet mask (class B) Network Host 180.10.84.20 10110100 00001010 01010100 00010100 255.255.0.0 11111111 11111111 00000000 00000000 10110100 01101100 00000000 00000000 180 10 0 0 * Router takes IP destination address and subnet Mask * Perform a logical AND operation * Routing decisions based on network number only 17
IPv4 ADDRESSES Subnetting Subnetting divides the addresses into several contiguous groups and assign each group to smaller networks (called subnets). 18
Using the new subnet mask IPv4 ADDRESSES * Router takes IP destination address and subnet Mask * Perform a logical AND operation * Routing decisions based on subnet number only Network subnet Host 180.10.84.20 10110100 00001010 010 10100 00010100 255.255.244.0 11111111 11111111 111 00000 00000000 10110100 01101100 010 00000 00000000 180 10 64 0 * subnet address = 180.10.64.0 19
Creating Class B subnets Suppose we have a class B network with address 180.10.0.0 and we want to create 6 subnets How? As mentioned earlier: IPv4 ADDRESSES IP address = <network number><main host number> The main host number is subdivided again into a network number and a host number: main host number = <subnet number><host number> For the above example, we need 3 bits to identify the subnet number The subnet mask : 11111111. 11111111. 11100000. 00000000 255. 255. 244. 0 20
The resulting subnets IPv4 ADDRESSES Subnet # Start Address 1 180.10.32.1 2 180.10.64.1 3 180.10.96.1 4 180.10.128.1 5 180.10.160.1 6 180.10.192.1 End Address 180.10.63.254 180.10.95.254 180.10.127.254 180.10.159.254 180.10.191.254 180.10.223.254 Subnet Mask 001 010 011 100 101 110 21
Classless Addresses IPv4 ADDRESSES Classless addresses overcomes address depletion and give more organizations access to the Internet. Classless addresses are granted in blocks. Internet authorities impose three restrictions on classless address blocks: 1. The addresses in a block must be contiguous, one after another. 2. The number of addresses in a block must be a power of 2 (1, 2, 4, 8,... ). 3. The first address must be evenly divisible by the number of addresses. 22
Example 5 A block of 16 addresses granted to a small organization The addresses are contiguous. The number of addresses is a power of 2 (16 = 2 4 ) The first address is divisible by 16 (3,440,387,360 divided by 16 results in 215,024,210). 23
Classless Addresses IPv4 ADDRESSES In IPv4 addressing, a block of addresses can be defined as x.y.z.t /n in which x.y.z.t defines one of the addresses and the /n defines the mask. 24
The first block address IPv4 ADDRESSES The first address in the block can be found by setting the rightmost 32 n bits to 0s. 25
Example 6 A block of addresses is granted to a small organization. One of the addresses is 205.16.37.39/28. What is the first address in the block? Solution The binary representation of the given address is 11001101 00010000 00100101 00100111 If we set 32 28 rightmost bits to 0, we get 11001101 00010000 00100101 00100000 or 205.16.37.32 26
The last block address IPv4 ADDRESSES The last address in the block can be found by setting the rightmost 32 n bits to 1s. 27
Example 7 Find the last address for the block in Example 6. Solution The binary representation of the given address is 11001101 00010000 00100101 00100111 If we set 32 28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111 or 205.16.37.47 28
Example 7(continued) The block of 16 addresses granted to a small organization The first address: 205.16.37.32 The last address: 205.16.37.47 29
The number of addresses IPv4 ADDRESSES The number of addresses in the block can be found by using the formula 2 32 n 30
Example 8 Find the number of addresses in Example 6. Solution The value of n is 28, which means that number of addresses is 2 32 28 = 2 4 = 16. 31
Example 9 Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32-bit binary (or 8-digit hexadecimal) number. This is particularly useful when we are writing a program to find these pieces of information. In Example 5 the /28 can be represented as follows (twenty-eight 1s and four 0s): 11111111 11111111 11111111 11110000 Find a. The first address b. The last address c. The number of addresses. 32
Example 9 (continued) Solution a. The first address can be found by ANDing the given addresses (205.16.37.39/28) with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise. The first address: 205.16.37.32 33
Example 9 (continued) b. The last address can be found by ORing the given addresses with the complement of the mask. ORing here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and each 0 to 1. The last address: 205.16.37.47 34
Example 9 (continued) c. The number of addresses can be found by complementing the mask, interpreting it as a decimal number, and adding 1 to it. 35
Example 9 (continued) The block of 16 addresses granted to a small organization 36
The Network Address IPv4 ADDRESSES The first address in a block is normally not assigned to any device; it is used as the network address that represents the organization to the rest of the world. 37
The Address Hierarchy IPv4 ADDRESSES Example: Two levels of hierarchy in an IPv4 address The n leftmost bits of the address x.y.z.t/n define the network (the prefix). The 32 n rightmost bits define the particular host to the network (the suffix). The IP address can define only two levels of hierarchy when not subnetted. 38
IPv4 ADDRESSES Two-Level Hierarchy: No Subnetting Each address in the block can be considered as a twolevel hierarchical structure: the leftmost n bits (prefix) define the network; the rightmost 32 n bits define the host. 39
IPv4 ADDRESSES Three-Level Hierarchy: Subnetting Subnetting creates small subblocks of addresses, each assigned to specific subnets. From the outside, the organization seems as one entity with one address and one mask. All messages are sent to the main router address that connects the organization to the rest of the Internet. The router routes the message to the appropriate subnets. Each subnet has its own subnet address and its own mask. 40
The Address Hierarchy IPv4 ADDRESSES Two level Hierarchy: No Subnetting NetID HostID Three-Level Hierarchy: Subnetting NetID SubNetID HostID 41
IPv4 ADDRESSES Three-Level Hierarchy: Example An organization is given the block 17.12.14.0/26 How many address in this block? The number of addresses in the block can be found by using the formula 2 32 n The number of addresses = 2 32 26 = 2 6 = 64 NetID HostID 26 bits 6 bits 42
IPv4 ADDRESSES Three-Level Hierarchy: Example The organization has three offices and needs to divide the addresses into three subblocks of 32, 16, and 16 addresses. The first subnet has 32 addresses; then 32=2 32 n1 and n1=27 The first subnet has 16 addresses; then 16=2 32 n2 and n2=28 The first subnet has 16 addresses; then 16=2 32 n3 and n3=28 In subnet 1, the address 17.12.14.29 can give us the subnet address if we use the mask /27 Host: 00010001 00001100 00001110 00011101 (17.12.14.29) Mask: 11111111 11111111 11111111 11100000 (/27) Subnet: 00010001 00001100 00001110 00000000 (17.12.14.0) 43
IPv4 ADDRESSES Three-Level Hierarchy: Example (continued) The address of subnet 1 is (17.12.14.0/27) The first address and last address are: The binary representation of the given address 17.12.14.29: 00010001 00001100 00001110 00011101 If we set 32 27 rightmost bits to 0, we get the first address: 00010001 00001100 00001110 00000000 (17.12.14.0) The binary representation of the given address 17.12.14.29: 00010001 00001100 00001110 00011101 If we set 32 27 rightmost bits to 1, we get the last address: 00010001 00001100 00001110 00011111 (17.12.14.31) 44
IPv4 ADDRESSES Three-Level Hierarchy: Example (continued) Configuration and addresses in a 3-level subnetted network 45
IPv4 ADDRESSES Three-Level Hierarchy: Example (continued) In subnet 2, the address 17.12.14.45 can give us the subnet address if we use the mask /28 Host: 00010001 00001100 00001110 00101101 Mask: /28 Subnet: 00010001 00001100 00001110 00100000 (17.12.14.32) The last address is: The binary representation of the given address 17.12.14.45: 00010001 00001100 00001110 00101101 If we set 32 28 rightmost bits to 1, we get the last address: 00010001 00001100 00001110 00101111 (17.12.14.47) 46
IPv4 ADDRESSES Three-Level Hierarchy: Example (continued) In subnet 3, the address 17.12.14.50 can give us the subnet address if we use the mask /28 Host: 00010001 00001100 00001110 00110010 Mask: /28 Subnet: 00010001 00001100 00001110 00110000 (17.12.14.48) The last address is: The binary representation of the given address 17.12.14.50: 00010001 00001100 00001110 00110010 If we set 32 28 rightmost bits to 1, we get the last address: 00010001 00001100 00001110 00111111 (17.12.14.63) 47
IPv4 ADDRESSES Three-level hierarchy in an IPv4 address Network Address: 17.12.14.0/26 Subnet 1 Address: 17.12.14.0/27 Subnet 2 Address: 17.12.14.32 /28 Subnet 3 Address: 17.12.14.48 /28 48
IPv4 ADDRESSES Creating subnets IP address = <network number><main host number> The main host number is subdivided again into a network number and a host number: main host number = <subnet number><host number> IP address = <network number> <subnet number><host number> 49
Example 10 An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of customers as follows: a. The first group has 64 customers; each needs 256 addresses. b. The second group has 128 customers; each needs 128 addresses. c. The third group has 128 customers; each needs 64 addresses. Design the subblocks and find out how many addresses are still available after these allocations. 50
Solution Example 10 (continued) Group 1 (64 customers) For this group, each customer needs 256 addresses. This means that 8 (log2 256) bits are needed to define each host. The prefix length is then 32 8 = 24. The addresses are 51
Example 10 (continued) Group 2 (128 customers) For this group, each customer needs 128 addresses. This means that 7 (log2 128) bits are needed to define each host. The prefix length is then 32 7 = 25. The addresses are 52
Example 10 (continued) Group 3 (128 customers) For this group, each customer needs 64 addresses. This means that 6 (log 2 64) bits are needed to each host. The prefix length is then 32 6 = 26. The addresses are Number of granted addresses to the ISP: 65,536 Number of allocated addresses by the ISP: 40,960 Number of available addresses: 24,576 53
Example 10 (continued) An example of address allocation and distribution by an ISP 54
Network Address Translation (NAT) NAT enables a user to have a large set of addresses internally and one address, or a small set of addresses, externally. The traffic inside can use the large set; the traffic outside, the small set. To separate the addresses used inside the home or business and the ones used for the Internet, the Internet authorities have reserved three sets of addresses as private addresses. Addresses for private networks 55
Network Address Translation (NAT) NAT implementation The private network uses private addresses. The router that connects the network to the global address uses one private address and one global address. The private network is transparent to the rest of the Internet; the rest of the Internet sees only the NAT router with the address 200.24.5.8. 56
Network Address Translation (NAT) Addresses in a NAT All the outgoing packets go through the NAT router, which replaces the source address in the packet with the global NAT address. All incoming packets also pass through the NAT router, which replaces the destination address in the packet (the NAT router global address) with the appropriate private address. 57
Network Address Translation (NAT) NAT address translation 58
Network Address Translation (NAT) Two columns translation table includes: The private address and The external address (destination address of the packet) When the router translates the source address of the outgoing packet, it also makes note of the destination address (where the packet is going) in the table. When the response comes back from the destination, the router uses the source address of the packet (as the external address) to find the private address of the packet from the table. In this strategy, (using the two columns translation table) communication must always be initiated by the private network (using a client program such as HTTP, TELNET, or FTP to access the corresponding server program). 59
Network Address Translation (NAT) Five-column translation table: Use IP Addresses and Port Numbers to allow a many-to-many relationship between private-network hosts and external server programs. For example, two hosts with addresses 172.18.3.1 and 172.18.3.2 inside a private network can access the HTTP server on external host 25.8.3.2. 60
Network Address Translation (NAT) ISP and NAT 61
Network Address Translation (NAT) ISP and NAT An ISP that serves dial-up customers can use NAT technology to conserve addresses. For example, suppose an ISP is granted 1000 addresses, but has 100,000 customers. Each of the customers is assigned a private network address. The ISP translates each of the 100,000 source addresses in outgoing packets to one of the 1000 global addresses. It translates the global destination address in incoming packets to the corresponding private address. 62
IPv6 Structure of IPv6 IPv6 address consists of 16 bytes (16 octets); it is 128 bits long. IPv6 Address Space: 2 128 addresses are available. IPv6 Hexadecimal Notation: the address consists of 32 hexadecimal digits, with every four digits separated by colon: FDEC:0074:0000:0000:0000:BOFF:0000: FFFF IPv6 length: 128 bits = 16 bytes = 32 hex digits 63
Chapter 6 - Network Layer: Logical Addressing IPv4 ADDRESSES Address Space Address Notation Classful Addressing Classless Addressing Address Hierarchy Network Address Translation (NAT) NAT implementation NAT address translation ISP and NAT IPv6 ADDRESSES Address Space Address Notation 64