1 / 64

CS 356: Computer Network Architectures Lecture 10: IP forwarding

CS 356: Computer Network Architectures Lecture 10: IP forwarding. Xiaowei Yang xwy@cs.duke.edu. Overview. IP addressing IP forwarding Forwarding algorithm Fragmentation Address resolution protocol (ARP) Internet Control Message protocol (ICMP) Error reporting. Global IP addresses.

cole-moody
Download Presentation

CS 356: Computer Network Architectures Lecture 10: IP forwarding

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 356: Computer Network ArchitecturesLecture 10: IP forwarding Xiaowei Yang xwy@cs.duke.edu

  2. Overview • IP addressing • IP forwarding • 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]: 10000000 10001111 10001001 10010000 1st Byte = 128 2nd Byte = 143 3rd Byte = 137 4th Byte = 144 128.143.137.144

  7. Structure of an IP address 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 31 0 network prefix host number

  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 • American Registry for Internet Numbers (ARIN) • RIPE, APNIC, LACNIC, AfriNIC Regional Internet Registries (Five of them) Internet Service Providers

  16. CIDR network prefix has variable length A network mask specifies the number of bits used to identify a network in an IP address. 144 137 128 143 Addr 10000000 10001111 10001001 10010000 255 255 0 255 Mask 11111111 11111111 1111111 00000000

  17. CIDR notation CIDR notation of an IP address: 128.143.137.144/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 [128.195.0.0, 128.195.255.255] can be represented by an address prefix 128.195.0.0/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. How to determine whether a dst is on the same physical network? How to determine the next hop router? Routing Forwarding algorithm Is dst on the same physical network? Yes Deliver the packet to the Network directly 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 • Else • 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

  24. Type of forwarding table entries Network route Destination addresses is a network address (e.g., 10.0.2.0/24) Most entries are network routes Host route Destination address is an interface address (e.g., 10.0.1.2/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 (127.0.0.1) 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.0.0/0  0-bit prefix match = 128.143.71.21 Destination address Next hop 10.0.0.0/8 eth0 128.143.0.0/16 R2 128.143.64.0/20 R3 128.143.192.0/20 R3 128.143.71.0/24 R4 128.143.71.55/32 R3 0.0.0.0/0 (default) R5 The longest prefix match for 128.143.71.21 is for 24 bits with entry 128.143.71.0/24 Datagram will be sent to R4

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

  28. 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 128.143.137.1?”

  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. 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:44Source protocol address: 128.143.137.144Target hardware address: 00:00:00:00:00:00Target protocol address: 128.143.137.1 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: 128.143.137.1 Target hardware address: 00:a0:24:71:e4:44Target protocol address: 128.143.137.144 Example

  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: (128.143.71.37) at 00:10:4B:C5:D1:15 [ether] on eth0 (128.143.71.36) at 00:B0:D0:E1:17:D5 [ether] on eth0 (128.143.71.35) at 00:B0:D0:DE:70:E6 [ether] on eth0 (128.143.136.90) at 00:05:3C:06:27:35 [ether] on eth1 (128.143.71.34) at 00:B0:D0:E1:17:DB [ether] on eth0 (128.143.71.33) at 00:B0:D0:E1:17:DF [ether] on eth0

  36. Putting it together

  37. IP Forwarding Implementation Logistics Next slide Lab2 input

  38. ICMP

  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. 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, …) Location in the protocol stack 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 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 serviceat a port 80 Client Server No process is waiting at port 80 Port Unreachable 48

  49. Common ICMP Error messages 49

  50. Some subtypes of the “Destination Unreachable” 50

More Related