Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 356: Computer Network Architectures Lecture 10: IP forwarding

Similar presentations

Presentation on theme: "CS 356: Computer Network Architectures Lecture 10: IP forwarding"— Presentation transcript:

1 CS 356: Computer Network Architectures Lecture 10: IP forwarding
Xiaowei Yang

2 Overview IP addressing IP forwarding Address resolution protocol (ARP)
Forwarding algorithm Fragmentation Address resolution protocol (ARP) Internet Control Message protocol (ICMP) Error reporting

3 Global IP addresses

4 What is an IP Address? An IP address is a unique global identifier for a network interface An IP address uniquely identifies a network location Routers forwards a packet based on the destination address of the packet Uniqueness ensures global reachability

5 IP Addressing Addressing defines how addresses are allocated and the structure of addresses IPv4 (32-bit) Classful IP addresses (obsolete) Classless inter-domain routing (CIDR) (RFC 854, current standard) IP Version 6 addresses (128-bit)

6 An IPv4 address is often written in dotted decimal notation
Each byte is identified by a decimal number in the range [0…255]: 1st Byte = 128 2nd Byte = 143 3rd Byte = 137 4th Byte = 144

7 Structure of an IP address
31 network prefix host number An IP address encodes both a network number (network prefix) and an interface number (host number). network prefix identifies a network the host number identifies a specific host (actually, an interface on the network). The structure is designed to improve the scalability of routing Scales better than flat addresses

8 How long is a network prefix?
Before 1993: The network prefix is implicitly defined (class-based addressing) After 1993: The network prefix is indicated by a netmask

9 Before 1993: Class-based addressing
The Internet address space was divided up into classes: Class A: Network prefix is 8 bits long Class B: Network prefix is 16 bits long Class C: Network prefix is 24 bits long Class D is multicast address Class E is reserved

10 Classful IP Addresses (Until 1993)
Each IP address contained a key which identifies the class: Class A: IP address starts with “0” Class B: IP address starts with “10” Class C: IP address starts with “110” Class D: IP address starts with “1110” Class E: IP address starts wit “11110”

11 The old way: Internet Address Classes

12 The old way: Internet Address Classes

13 Problems with Classful IP Addresses
Fast growing routing table size Each router must have an entry for every network prefix ~ 221 = 2,097,152 class C networks In 1993, the size of routing tables started to outgrow the capacity of routers Local admins must request another network number before installing a new network at their site

14 Solution: Classless Inter-domain routing (CIDR)
Network prefix is of variable length No rigid class boundary Addresses are allocated hierarchically Routers aggregate multiple address prefixes into one routing entry to minimize routing table size

15 Hierarchical IP Address Allocation
Internet Assigned Numbers Authority Regional Internet Registries (Five of them) Internet Service Providers American Registry for Internet Numbers (ARIN) RIPE, APNIC, LACNIC, AfriNIC

16 CIDR network prefix has variable length
128 143 137 144 Addr 255 255 255 Mask A network mask specifies the number of bits used to identify a network in an IP address.

17 CIDR notation CIDR notation of an IP address:
/24 /24 is the prefix length. It states that the first 24 bits are the network prefix of the address (and the remaining 8 bits are available for specific host addresses) CIDR notation can nicely express blocks of addresses An address block [ , ] can be represented by an address prefix /16 How many IP addresses are there in a /x address block? 2 (32-x)

18 IP Forwarding

19 Forwarding of IP datagrams
There are two distinct processes to delivering IP datagrams: 1. Forwarding (data plane): How to pass a packet from an input interface to the output interface? 2. Routing (control plane): How to find and setup the forwarding tables?

20 Key points Each IP datagram contains the IP destination address
The “network part” of an IP address identifies a single physical network All hosts and routers that share the same network part of their address are connected to the same physical network Each physical network on the Internet has at least one router that connects this network to other physical networks

21 Deliver the packet to the
Forwarding algorithm Is dst on the same physical network? Yes Deliver the packet to the Network directly How to determine whether a dst is on the same physical network? How to determine the next hop router? Routing No Forward to next-hop router

22 Detailed forwarding algorithm
If (networkNum == networkNum of one of my interfaces) then Deliver packet over the interface Else if (NetworkNum is in my forwarding table) then Deliver to the NextHop router Deliver packet to the default router

23 Forwarding table lookup
When a router or host needs to transmit an IP datagram, it performs a routing table lookup Forwarding table lookup: Use the IP destination address as a key to search the routing table Result of the lookup is the IP address of a next hop router, and/or the name of a network interface Destination address Next hop/ interface network prefix or host IP address loopback address default route IP address of next hop router Name of a network interface

24 Type of forwarding table entries
Network route Destination addresses is a network address (e.g., /24) Most entries are network routes Host route Destination address is an interface address (e.g., /32) Used to specify a separate route for certain hosts Default route Used when no network or host route matches Loopback address Routing table for the loopback address ( ) The next hop lists the loopback (lo0) interface as outgoing interface

25 Simplified forwarding algorithm
Observation: A directly physical network can be an entry in the forwarding table A default route can be an entry Simplified algorithm Look up destination algorithm in the forwarding table using longest prefix match Forward the packet to the next hop indicated by the matched entry

26 Longest prefix match = Longest Prefix Match: Search for the forwarding table entry that has the longest match with the prefix of the destination IP address Search for a match on all 32 bits Search for a match for 31 bits ….. 32. Search for a match on 0 bits Host route, loopback entry  32-bit prefix match Default route is represented as /0  0-bit prefix match Destination address Next hop /8 eth0 /16 R2 /20 R3 /20 R3 /24 R4 /32 R3 /0 (default) R5 The longest prefix match for is for 24 bits with entry /24 Datagram will be sent to R4

27 Q: How an IP packet is sent from H1 to H2 or H1 to R6?
eth0 Q: How an IP packet is sent from H1 to H2 or H1 to R6? Encapsulated into an Ethernet frame Ex: H1  H2 Nexthop: eth0 H1  H6 Nexthop: R1

28  Address Resolution Protocol
How to find out a host’s Ethernet address after knowing its IP address?  Address Resolution Protocol

29 ARP and RARP Note: The Internet is based on IP addresses Data link protocols (Ethernet, FDDI, ATM) may have different (MAC) addresses The ARP and RARP protocols perform the translation between IP addresses and MAC layer addresses We will discuss ARP for broadcast LANs, particularly Ethernet LANs RFC 826 RARP obsolete

30 Address Translation with ARP
ARP Request: Argon broadcasts an ARP request to all stations on the network: “What is the hardware address of ?”

31 Address Translation with ARP
ARP Reply: Router 137 responds with an ARP Reply which contains the hardware address

32 ARP Packet Format

33 Hardware type: ether (1) Prototype: taken from the set ether_type
IP: 0x0800 Opcode ARP request: 1 ARP reply: 2 Check RFC for implementation details

34 Example ARP Request from Argon is broadcasted:
Source addr in Ethernet header: 00:a0:24:71:e4:44 Destination addr in Ethernet header: FF:FF:FF:FF:FF:FF Source hardware address: 00:a0:24:71:e4:44 Source protocol address: Target hardware address: 00:00:00:00:00:00 Target protocol address: ARP Reply from Router137 is unicasted: Source addr: 00:e0:f9:23:a8:20 Dst addr: 00:a0:24:71:e4:44 Source hardware address: 00:e0:f9:23:a8:20 Source protocol address: Target hardware address: 00:a0:24:71:e4:44 Target protocol address:

35 ARP Cache Since sending an ARP request/reply for each IP datagram is inefficient, hosts maintain a cache (ARP Cache) of current entries. The entries expire after a time interval. Contents of the ARP Cache: ( ) at 00:10:4B:C5:D1:15 [ether] on eth0 ( ) at 00:B0:D0:E1:17:D5 [ether] on eth0 ( ) at 00:B0:D0:DE:70:E6 [ether] on eth0 ( ) at 00:05:3C:06:27:35 [ether] on eth1 ( ) at 00:B0:D0:E1:17:DB [ether] on eth0 ( ) at 00:B0:D0:E1:17:DF [ether] on eth0

36 Putting it together

37 IP Forwarding Implementation Logistics
Next slide Lab2 input


39 IP Forwarding Logistics (Lab 2)
Sanity-check meets minimum length and has correct checksum Update header Decrement the TTL by 1, and compute the packet checksum over the modified header. Next hop IP lookup Find out which entry in the routing table has the longest prefix match with the destination IP address. Next hop MAC lookup Check the ARP cache for the next-hop MAC address corresponding to the next-hop IP. If it's there, send it. Otherwise, send an ARP request for the next-hop IP (if one hasn't been sent within the last second), and add the packet to the queue of packets waiting on this ARP request. Error reporting

40 Error reporting Internet Control Message Protocol (ICMP)
Ill-formatted packets TTL == 0 ARP receives no reply No protocol or application running at the destination No routing table match

41 Location in the protocol stack
The IP (Internet Protocol) relies on several other protocols to perform necessary control and routing functions: Control functions (ICMP) Multicast signaling (IGMP) Setting up forwarding tables (RIP, OSPF, BGP, PIM, …) 41

42 Overview The Internet Control Message Protocol (ICMP) is a helper protocol that supports IP with facility for Error reporting Simple queries ICMP messages are encapsulated as IP datagrams: 42

43 ICMP message format 4 byte header: Type (1 byte): type of ICMP message
Code (1 byte): subtype of ICMP message Checksum (2 bytes): similar to IP header checksum. Checksum is calculated over the entire ICMP message If there is no additional data, there are 4 bytes set to zero.  each ICMP message is at least 8 bytes long 43

44 ICMP Query message ICMP query:
Request sent by host to a router or host Reply sent back to querying host

45 Example of ICMP Queries
Type/Code: Description 8/0 Echo Request 0/0 Echo Reply 13/0 Timestamp Request 14/0 Timestamp Reply Extension (RFC 1256): 10/0 Router Solicitation 9/0 Router Advertisement The ping command uses Echo Request/ Echo Reply Before a host can send IP datagrams beyond its directly-attached subnet, it must discover the address of at least one operational router on that subnet. Typically, this is accomplished by reading a list of one or more router addresses from a (possibly remote) configuration file at startup time. On multicast links, some hosts also discover router addresses by listening to routing protocol traffic. Both of these methods have serious drawbacks: configuration files must be maintained manually -- a significant administrative burden -- and are unable to track dynamic changes in router availability; eavesdropping on routing traffic requires that hosts recognize the particular routing protocols in use, which vary from subnet to subnet and which are subject to change at any time. This document specifies an alternative router discovery method using a pair of ICMP [10] messages, for use on multicast links. It eliminates the need for manual configuration of router addresses and is independent of any specific routing protocol. The ICMP router discovery messages are called "Router Advertisements" and "Router Solicitations". Each router periodically multicasts a Router Advertisement from each of its multicast interfaces, announcing the IP address(es) of that interface. Hosts discover the addresses of their neighboring routers simply by listening for advertisements. When a host attached to a multicast link starts up, it may multicast a Router Solicitation to ask for immediate advertisements, rather than waiting for the next periodic ones to arrive; if (and only if) no advertisements are forthcoming, the host may retransmit the solicitation a small number of times, but then must desist from sending any more solicitations. Any routers that subsequently start up, or that were not discovered because of packet loss or temporary link partitioning, are eventually discovered by reception of their periodic (unsolicited) advertisements. (Links that suffer high packet loss rates or frequent partitioning are accommodated by increasing the rate of advertisements, rather than increasing the number of solicitations that hosts are permitted to send.) The router discovery messages do not constitute a routing protocol: they enable hosts to discover the existence of neighboring routers, but not which router is best to reach a particular destination. If a host chooses a poor first-hop router for a particular destination, it should receive an ICMP Redirect from that router, identifying a better one. A Router Advertisement includes a "preference level" for each advertised router address. When a host must choose a default router address (i.e., when, for a particular destination, the host has not been redirected or configured to use a specific router address), it is expected to choose from those router addresses that have the highest preference level (see Section in the Host Requirements -- Communication Layers RFC [1]). A network administrator can configure router address preference levels to encourage or discourage the use of particular routers as default routers. A Router Advertisement also includes a "lifetime" field, specifying the maximum length of time that the advertised addresses are to be considered as valid router addresses by hosts, in the absence of further advertisements. This is used to ensure that hosts eventually forget about routers that fail, become unreachable, or stop acting as routers. The default advertising rate is once every 7 to 10 minutes, and the default lifetime is 30 minutes. This means that, using the default values, the advertisements are not sufficient as a mechanism for "black hole" detection, i.e., detection of failure of the first hop of an active path -- ideally, black holes should be detected quickly enough to switch to another router before any transport connections or higher-layer sessions time out. It is assumed that hosts already have mechanisms for black hole detection, as required by [1]. Hosts cannot depend on Router Advertisements for this purpose, since they may be unavailable or administratively disabled on any particular link or from any particular router. Therefore, the default advertising rate and lifetime values were chosen simply to make the load imposed on links and hosts by the periodic multicast advertisements negligible, even when there are many routers present. However, a network administrator who wishes to employ advertisements as a supplemental black hole detection mechanism is free to configure smaller values. A router may choose to unicast the response directly to the soliciting host's address (if it is not zero), or multicast it to the interface's configured AdvertisementAddress; in the latter case, the interface's interval timer is reset to a new random value, as with unsolicited advertisements. 45 45

46 ICMP Error message ICMP error messages report error conditions
Typically sent when a datagram is discarded Error message is often passed from ICMP to the application program 46

47 ICMP Error message ICMP error messages include the complete IP header and the first 8 bytes of the payload (typically: UDP, TCP)

48 Example: ICMP Port Unreachable
RFC 792: If, in the destination host, the IP module cannot deliver the datagram because the indicated protocol module or process port is not active, the destination host may send a destination unreachable message to the source host. Scenario: Request a service at a port 80 Client Server No process is waiting at port 80 Port Unreachable 48

49 Common ICMP Error messages
Type Code Description 3 0–5 Destination unreachable Notification that an IP datagram could not be forwarded and was dropped. The code field contains an explanation. (traceroute) 5 0–3 Redirect Informs about an alternative route for the datagram and should result in a routing table update. The code field explains the reason for the route change. 11 0, 1 Time exceeded Sent when the TTL field has reached zero (Code 0) or when there is a timeout for the reassembly of segments (Code 1) (traceroute) 12 Parameter problem Sent when the IP header is invalid (Code 0) or when an IP header option is missing (Code 1) 49

50 Some subtypes of the “Destination Unreachable”
Code Description Reason for Sending Network Unreachable No routing table entry is available for the destination network. 1 Host Unreachable Destination host should be directly reachable, but does not respond to ARP Requests. 2 Protocol Unreachable The protocol in the protocol field of the IP header is not supported at the destination. 3 Port Unreachable The transport protocol at the destination host cannot pass the datagram to an application. 4 Fragmentation Needed and DF Bit Set IP datagram must be fragmented, but the DF bit in the IP header is set. (MTU discovery) 5 Source route failed The source routing option has failed. 50

51 ICMP applications Ping Traceroute MTU discovery

52 Ping: Echo Request and Reply
Host or Router Host or router ICMP ECHO REQUEST ICMP ECHO REPLY Type (= 8 or 0) Code (=0) Checksum 32-bit sender timestamp identifier sequence number Optional data Ping’s are handled directly by the kernel Each Ping is translated into an ICMP Echo Request The Ping’ed host responds with an ICMP Echo Reply 52

53 Traceroute xwy@linux20$ traceroute -n
traceroute to ( ), 30 hops max, 60 byte packets ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms * *

54 Traceroute algorithm Sends out three UDP packets with TTL=1,2,…,n, destined to a high port Routers on the path send ICMP Time exceeded message with their IP addresses until n reaches the destination distance Destination replies with port unreachable ICMP messages

55 Fragmentation and Reassembly
(not required for Lab 2)

56 Different networks have different Maximum Transmission Units (MTUs)

57 IP Fragmentation and Reassembly
What if the size of an IP datagram exceeds the MTU? IP datagram is fragmented into smaller units. What if the route contains networks with different MTUs? MTUs: FDDI: Ethernet: 1500 Fragmentation: IP router splits the datagram into several datagrams

58 Design question: Where is Fragmentation/reassembly done?
Fragmentation can be done at the sender or at intermediate routers The same datagram can be fragmented several times. Reassembly of original datagram is only done at destination hosts !! (why?)

59 What’s involved in Fragmentation?
The following fields in the IP header are involved: Identification When a datagram is fragmented, the identification is the same in all fragments Used to reassemble the original packet Flags DF bit is set: datagram cannot be fragmented and must be discarded if MTU is too small ICMP sent MF bit: 1: this is not the last fragment 0: last fragment 59

60 What’s involved in Fragmentation?
The following fields in the IP header are involved: header version DS ECN total length (in bytes) length D M Identification Fragment offset (13-bit) F F time-to-live (TTL) protocol header checksum Fragment offset Offset of the payload of the current fragment in the original datagram in units of 8 bytes Why? Because the field is only 13 bits long, while the total length is 16 bits. Total length Total length of the current fragment

61 Example of Fragmentation
A datagram with size 2400 bytes must be fragmented according to an MTU limit of 1000 bytes 61

62 Determining the length of fragments
Maximum payload length = 1000 – 20 = 980 bytes Offset specifies the bytes in multiple of 8 bytes. So the payload must be a multiple of 8 bytes. % 8 = 976 (the largest number that is less than 980 and divisible by 8) The payload for the first fragment is 976 and has bytes 0 ~ 975 of the original IP datagram. The offset is 0. The payload for the second fragment is 976 and has bytes 976 ~ of the original IP datagram. The offset is 976 / 8 = 122. The pay load of the last fragment is 2400 – 976 * 2 = 428 bytes and has bytes 1952 ~ 2400 of the original IP datagram. The offset is 244. Total length of three fragments: = 2440 > 2400 Why? Two additional IP headers. To determine the size of the fragments we recall that, since there are only 13 bits available for the fragment offset, the offset is given as a multiple of eight bytes. As a result, the first and second fragment have a size of 996 bytes (and not 1000 bytes). This number is chosen since 976 is the largest number smaller than 1000–20= 980 that is divisible by eight. The payload for the first and second fragments is 976 bytes long, with bytes 0 through 975 of the original IP payload in the first fragment, and bytes 976 through 1951 in the second fragment. The payload of the third fragment has the remaining 428 bytes, from byte 1952 through With these considerations, we can determine the values of the fragment offset, which are 0, 976 / 8 = 122, and 1952 / 8 = 244, respectively, for the first, second and third fragment. 62 62

63 Path MTU discovery Fragmentation slows down the router
 should be done by end hosts How does a sender know the MTU of a path? A host only knows the MTU of its links Solution send large packets with DF set If receive ICMP Fragmentation needed messages, reduce maximum segment size

64 Summary IP addressing IP forwarding Address resolution protocol (ARP)
Forwarding algorithm Fragmentation Address resolution protocol (ARP) Internet Control Message protocol (ICMP) Error reporting Next: DHCP, NAT, IPv6, VPN and Tunneling

Download ppt "CS 356: Computer Network Architectures Lecture 10: IP forwarding"

Similar presentations

Ads by Google