Professional Documents
Culture Documents
Chapter 4: IP Layer
ECE 610 Winter 2013
Outline
4.1 Introduction
4.3
Routing algorithms
- Network layer protocols are implemented in every host and router. - Router examines header fields in all datagrams passing through it
4-1
Encapsulation
Decapsulation
message
- Data packet at layer 3 is called datagram - At sender: encapsulate segments in datagram - At receiver: decapsulate datagram to segments
4-2
Responsible for: - Making routing decisions to determine the routes that datagrams take from source host to the destination one - The delivery of segments received from the source nodes transport layer to the destination nodes transport layer
4-3
- Data link layer is responsible for delivery data from a node to a physically adjacent node in the same network. - Network layer is responsible for delivering data between end hosts probably in different networks
4-4
- Internetworking: interconnecting different networks (various LAN technologies, telephone network, satellite link, ATM networks etc.) and making them look the same to the upper layer - Logical gluing of heterogeneous physical networks together to look like a single network to the upper layers. - The transport layer should not be worried about the underlying physical network assumes it has a logical connection between source and destination nodes.
4-5
- Allow transparent interconnection across different network technologies on a global scale - Internetworking building a single, seamless virtual network out of multiple physical networks - Hides underlying technologies details of physical networks from end user and application programs - To Hide Heterogeneity Create virtual network
- Facilitate communications between autonomous domains - Able to move datagrams between any hosts on the internetwork
4-6
- Internetworks: A collection of interconnected networks is called an internetwork or an internet. Internet is one example of a really big internetwork.
Net51 Net
G H
Net53 Net
G G
Net55 Net
G
Net52 Net
Net54 Net
G H
4-7
Why Internetworking?
1- To build a network of networks or internet - Operating over multiple, coexisting, different network technologies 2- To provide universal communication services independent of underlying network technologies - Providing everywhere connectivity through IP packet transfer 3- To support distributed applications - Any application designed to operate based on Internet communication services immediately operates across the entire Internet Rapid deployment of new applications, e.g., Email, WWW, Peer-to-peer
4-8
How can data be exchanged between networks? - Devices used to connect heterogeneous networks: - Special-purpose computer system - Dedicated - Works with LAN or WAN technologies - Known as: Routers or gateways - A router can interconnect networks that use different technologies, including different media and media access techniques, physical addressing schemes or frame formats.
4-9
- We cannot use the data link layer addresses because these addresses depend on the technology used in the data link layer.
4-10
- Each packet reaches its destination via several routes. - Which route is suitable or optimum?
To deliver a datagram from A to D, How S1 knows that it has to send the datagram to f3 instead of f2
4-11
Packetizing: - Network layer encapsulates segments received from upper layer protocols into datagram. - At receiver: decapsulate datagrams and deliver segments to transport layer. Fragmenting/reassembly: - A datagram can travel through different networks with different maximum frame size. - The network layer must be able to fragment datagrams into smaller units so that they can be transferred over various data-link layer technologies.
4-12
best effort none CBR VBR ABR UBR constant rate guaranteed rate guaranteed minimum none
- Network layer protocols: IP (Internet protocol), AppleTalk, IPX (Novell Netware), DECNet - The internet provides best effort service on bandwidth, delay, .. not guarantees
4-13
company network
4-14
TCP, UDP IP, ICMP Network access PPP, Ethernet, IEEE 802.11, WAN technologies
4-15
- OSI and TCP/IP Layers have roughly same functionality - TCP/IP used in the internet - TCP/IP is a set of protocols developed to allow cooperating computers to share resources across a network - The transport layer moves data between applications - Transport layer and below provide network-independent transport services - Layers above transport are application-oriented - Connectionless vs. connection-oriented - OSI: Network layer supports both - Transport layers supports only connection-oriented - TCP/IP: Network layer supports only connectionless Transport layers supports both
4-16
Outline
4.1 Introduction
4.3
Routing algorithms
4.2.1 IP Addresses
- The address in the network layer of the TCP/IP model is called Internet Address or IP address - IPv4 address: 32-bit (4 byte) identifier that uniquely and universally defines a connection between a host or a router and the network. - Routers typically have multiple interfaces (multiple IPs)
223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.3.2
223.1.1.3
223.1.3.27
- A host may have multiple interfaces (e.g., wired Ethernet, wireless 802.11)
223.1.3.1
4-17
- The IP addresses are unique (each connection has a different address) and universal (must be accepted by any host wants to connect to the internet). - IP format: X.Y.W.Z - Four decimal values, each number represents eight bits each number between 0 and 255)
4-18
Class A
Network (7 bits)
128 to 191
Class B
10
Class C
110
224 to 239
Network (21bits)
Host (8 bits)
Class D
1110
240 to 255
Multicast address
Class E
1111
- This hierarchy means that routers only need to know the network portion not the address of each individual host. - IP addresses are divided into five classes: A, B, C, D, and E. - Classes A, B, and C are available to organizations - Class D and E are reserved for special purposes and are not assigned to organizations. - Initial bits determine class E.g., Waterloo network address: 129.97 (class B network). - Class A: Only 27 (128) networks can belong to this class each network has 224 addresses (> 16 million) - Very few class A networks in the world, e.g. Arpanet the earliest packet switched WAN (started 40 years ago)
4-20
- Class B: for medium size network - 214 (16384) networks Each network can have up to 216 (65536) addresses. - Class C: for small network - 221 networks can belong to this class - Each network can have up to 28 (256) addresses - Class D & E: Reserved for special purposes and not available to organizations. - Class D: for multicast network - Packets are addressed to a multicast group - Not often supported on Internet - In classfull addressing, the network address is the one that is assigned to the organization. Ratio of addresses space:
1/2 1/4 1/8 1/16 1/16
4-21
Class A
Class B
Class C
Class D Class E
- Class A networks: too big, too few. - Class C networks: too small, too many. - Class B networks: not enough (run out already). - In classful addressing, the network address is the one that is assigned to the organization. - The number of addresses in class A and B may be larger than the needs of organizations. - Millions of class A addresses are wasted. - Many of class B addresses are wasted. - The number of addresses in class C is smaller than the needs of most organizations.
4-22
3 bytes = 224 Last IP reserved for special purpose; not allowed to use
4-23
4-24
Class C for small organisation. Limited IP address in each blocks, which is smaller than the needs of 28 most organisations
4-25
- Routing: the outside world recognises the network via network address, not the individual host-IPs The routing tables do not contain individual IPs but network addresses - Improve scalability easier routing
29
4-26
The first bit is 0; this is a class A address. 2) 11110011 10011011 11111011 00001111
The first 4 bits are 1s; this is a class E address. 3) 227.12.14.87 The first byte is 227 (between 224 and 239); the class is D. 4) 252.5.15.111 The first byte is 252 (between 240 and 255); the class is E. 5) 134.11.78.56 The first byte is 134 (between 128 and 191); the class is B.
4-27
- Given the address 23.56.7.91, find the network address. The class is A. Only the first byte defines the netid. We can find the network address by replacing the hostid bytes (56.7.91) with 0s. Therefore, the network address is 23.0.0.0. - Given the address 132.6.17.85, find the network address. The class is B. The first 2 bytes defines the netid. We can find the network address by replacing the hostid bytes (17.85) with 0s. Therefore, the network address is 132.6.0.0. - Given the network address 17.0.0.0, find the class. The class is A because the netid is only 1 byte. - A network address is different from a netid. A network address has both netid and hostid, with 0s for the hostid. - Later we will use mask to calculate the network address 31 easily.
4-28
- Given the network address 220.34.76.0, find the class, the block, and the range of the addresses. 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. - Given the network address 17.0.0.0, find the class, the block, and the range of the addresses. 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 132.21.0.0, find the class, the block, and the range of the addresses. The class is B because the first byte is between 128 and 191. The block has a netid of 132.21.
32
4-29
4-30
- Stress on router processing power and memory allocation Short-term solution: How to have an addressing scheme that meets exactly the needs of the users ? - Subnetting - Supernetting - Classless InterDomain Routing (CIDR) - Variable Length Subnet Mask (VLSM)
Long-term solution: IPv6 with much bigger address space. The IPv4 address shortage was one of the reasons behind the IPv6.
4-31
4.2.3 Subnetting
- IP address are designed with 2 levels of hierarchy: networkID & host-ID. - In Subnetting: A network is divided into several smaller groups (subnets) with each group having its own subnet IP address but still appear as a single network to the rest of the Internet. - In this case, IP address will have 3 levels (main network, subnet, host) - Host portion of address partitioned into subnet number (most significant part) and host number (least significant part)
Original address Subnetted address
10 10
Net ID Net ID
- Subnet addressing introduces another hierarchical level - Subnet: Assign IP addresses to specific computers so that all computers on the same local area network have a similar subnet address. - Each LAN that is logically grouped together by IP number is called a TCP/IP subnet. - Subnet devices:- Have same subnet part of IP address - Can physically reach each other without intervening a router
223.1.1.1 223.1.1.2 223.1.1.4 223.1.1.3 223.1.2.1 223.1.2.9 223.1.2.2
223.1.3.27
subnet
223.1.3.1 223.1.3.2
4-33
- Assume each subnet needs 100 addresses we need only 7 bits for the host, remaining 9 bits of the host part will be assigned to subnets 4-34
Subnet mask
- Subnet mask is a 32-bit consists of zeros and ones
- Subnet masks specify where the split between network, subnet and host portions is
- Default/subnet mask when ANDed with the IP address it gives the network/subnet addresses
Class B
4-35
1- In original IP: IP has two portions network address and host address To get network address Host part set to 0 use the class default mask 2-In subnetted IP: IP has three portions network address, subnet address, and host address To get subnet address host part set to 0 use the subnet mask Network/subnet addresses: identify the network/subnet to which the host is connected
4-36
Calculate subnet address using bitwise AND operations: X and 0 = 0, X and 1 = X, where X is a bit
IP
172.24.57.18
10101100 00011000 00111001 00000000 10101100 00011000 00111001 00010010 11111111 11111111 11111111 11110000 10101100 00011000 00111001 00010000 4-37
An easier way to calculate subnet address:- If the byte in the mask is 255, copy the byte in the address because 255 = 11111111 and 1 AND X = X - If the byte in the mask is 0, replace the byte in the address with 0 because it is 00000000 and 0 AND X = 0 - If the byte in the mask is neither 255 nor 0, do bitwise and operations
Slash Notation
172.24.57.18/28
4-38
Netmask Usage
1- Subnet mask enables a computer to determine which computers are on the same subnet. This is very important for message routing. E.g., IP address: 129.118.49.189
Subnet mask: 255.255.255.0 IP address: 129.118.49.x the same subnet is for the computers in
2- How does the router know which subnet a packet should go? - External router has routing table based on network addresses. - Internal router has routing table based on subnetwork addresses.
4-39
- A router receives a datagram with a destination IP address W.X.Y.Z How to forward it? - Each forwarding table in a router (or in a host) is composed of 3 columns:
- For each entry in the routing table, the router uses the mask of the entry to calculate the network address of W.X.Y.Z. - Then, it compares the network address which it obtains with the one in the 2nd column in the entry. - If they match, it will forward the datagram via the corresponding next hop
4-40
Q: A router outside an organization receives a packet with destination address 190.240.7.91. Show how it finds the network address to route the packet. A: The router follows three steps: 1. The router looks at the first byte of the address to find the class. It is class B. 2. The default mask for class B is 255.255.0.0. The router ANDs this mask with the address to get 190.240.0.0. 3. The router looks in its routing table to find out how to route the packet to this destination. Q: Given the address 132.6.17.85 and the default class B mask 255.255.0.0, find network address. A: The default mask is 255.255.0.0, which means that the first 2 bytes are preserved and the other 2 bytes are set to 0s. The network address is 132.6.0.0. 4-41
Q: Given the address 201.180.56.5 and the class C default mask 255.255.255.0, find the network address. A: 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. Q: Given the address 23.56.7.91 and the default class A mask, find the beginning address (network address). A: The default mask is 255.0.0.0, which means that only the first byte is preserved and the other 3 bytes are set to 0s. The network address is 23.0.0.0. - A host IP address 141.14.2.21, its subnet mask is 255.255.252.0000 The subnet address is obtained using a bit-wise AND: 141.14.0.0 - If the host wants to send a datagram to IP address 141.14.4.254 check if the destination resides in the same subset apply subnet mask: the result 141.14.4
4-42
Different subnets The destination resides at different network, so route the packet to the router Q: A router inside an organization receives a packet with destination address 190.240.33.91/19. Show how it finds the subnetwork address to route the packet. 1. The subnet mask is 255.255.224.0 or /19 2. Applying the mask to the address, 190.240.33.91. The subnet address is 190.240.32.0. 3. The router looks in its routing table to find how to route the packet to this destination.
1. The router looks at the first byte of the address to find the class. It is class B. 2. The default mask for class B is 255.255.0.0. or /16 The router ANDs this mask with the address to get 190.240.0.0. 3. The router looks in its routing table to find out how to route the packet to this destination.
Start address = subnet address Last address: 10010110 1100100 X 1111111 X takes values from 00000000 to 111111111 Note 10010110 = 150, 1100100 =100 What is the Subnet mask? 11111111 11111111 11111111 10000000 Q: A company is granted the site address 201.70.64.0 (class C). The company needs six subnets. Design the subnets. A: The number of 1s in the default mask is 24 (class C). The company needs six subnets. Since 6 is not a power of 2, the next number that is a power of 2 is 8 (23). That means up to 8 subnets. Hence, we need 3 more 1s in the subnet mask = 11111111.11111111.11111111.11100000 or 255.255.255.224 4-45
The total number of 1s in the subnet mask is 27 (24 + 3). Since the total number of 0s is 5 (32 - 27). The number of addresses in each subnet is 25 (5 is the number of 0s) or 32.
4-46
A company is granted the site address 181.56.0.0 (class B). The company needs 1000 subnets. Design the subnets. The number of 1s in the default mask is 16 (class B). The company needs 1000 subnets. Since it is not a power of 2, the next number is 1024 (210). We need 10 more 1s in the subnet mask. The total number of 1s in the subnet mask is 26 (16 + 10). The total number of 0s is 6 (32 - 26). The submask is 11111111 11111111 255.255.255.192 11111111 11000000 or
The number of subnets is 1024. The number of addresses in each subnet is 26 (6 is the number of 0s) or 64.
4-47
4-48
R1 Accept all traffic to 141.14.0.0 - R3 Accept all traffic to 4-50 141.14.64.0 or 141.14.128.0 Outside world is not aware of subnetting but only router R1 is.