Lecture 8 Reminder: Homework 3, Programming Project 2 due on Thursday. Questions? Tuesday, September 20 CS 475 Networks - Lecture 8 1 Outline Chapter 3 - Internetworking 3.1 Switching and Bridging 3.2 Basic Internetworking (IP) 3.3 Routing 3.4 Implementation and Performance 3.5 Summary Tuesday, September 20 CS 475 Networks - Lecture 8 2 Basic Internetworking (IP) Bridges and LAN switches from last section have limited ability to scale and to handle heterogeneity. An internetwork (or just internet - with lowercase i) is a logical network built out of a collection of physical networks. Each physical network uses one technology (e.g., Ethernet or Wi-Fi). Tuesday, September 20 CS 475 Networks - Lecture 8 3 Basic Internetworking (IP) An example internet is shown at right. Routers or gateways are used to connect different physical networks. Tuesday, September 20 CS 475 Networks - Lecture 8 4 Basic Internetworking (IP) The figure above illustrates how host H1 and H8 are logically connected in an internet. While switches operate only at the physical layer, routers operate at the higher networking layer of the protocol stack. Tuesday, September 20 CS 475 Networks - Lecture 8 5 Service Model The Internet protocol (IP) service model is unreliable (best-effort) and connectionless. This simple model allows IP to run over almost any physical link. It also keeps router design simple. Reliable, connection-oriented services can use IP. These services just need to be implemented at a higher layer in the protocol stack. Tuesday, September 20 CS 475 Networks - Lecture 8 6 Service Model - Packet Format The IP Version 4 packet format is shown at right. The HLen field is the size of the header (number of 32 bit words). The Type Of Service (TOS) field allows for differentiated service. Tuesday, September 20 The IP packet is treated as a collection of 32 byte words. CS 475 Networks - Lecture 8 7 Service Model - Packet Format The Length fields contains the entire packet size in bytes (up to 65,535 bytes). The Ident, Flags and Offset support fragmentation and reassembly and will be discussed shortly. The Time To Live (TTL) field is decremented at each router. When it reaches 0 the packet can be dropped. It is intended to prevent an endlessly circulating packet. An initial value of 64 is the default. Tuesday, September 20 CS 475 Networks - Lecture 8 8 Service Model - Packet Format The Protocol field is a demux key (TCP is 6, UDP is 17). The Checksum is a 16 bit checksum over the header. Packets with checksum errors are dropped. The SourceAddr and DestinationAddr are 32 bit IP addresses (not MAC addresses!) There may be any number of Options. These are rarely used. Tuesday, September 20 CS 475 Networks - Lecture 8 9 Service Model - Fragmentation and Reassembly To allow sending IP packets over links with different Maximum Transmission Units (MTUs) IP allows packets to be fragmented while in route to the destination. Fig 3.17 IP packet fragmentation Tuesday, September 20 CS 475 Networks - Lecture 8 10 Service Model - Fragmentation and Reassembly The Ident field is the same in each fragment (it is the same as in the original packet). The M bit in the Flags field is 1 except in the last fragment. The Offset is the byte offset divided by 8.(Fragmentation is on an 8 byte boundary only.) Notice that the fragments are not reassembled until they reach the destination. Tuesday, September 20 CS 475 Networks - Lecture 8 11 Global Addresses IP addresses are globally unique. Each host has a unique IP (actually each interface has a unique IP, hosts with multiple NICs and routers will have multiple IP addresses). IP addresses are hierarchical. They consist of a network part and a host part. Fig 3.19 IP Addresses (a) class A address (b) class B address (c) class C address The network and host parts of the IP address are not fixed-size. Tuesday, September 20 CS 475 Networks - Lecture 8 12 Datagram Forwarding in IP Hosts or routers that have the same network part are on the same physical network. Every physical network connected to the Internet contains at least one router. The network part uniquely identifies a single physical network on the Internet. Every IP datagram contains the IP address of the destination. Tuesday, September 20 CS 475 Networks - Lecture 8 13 Datagram Forwarding in IP Every node in the path (including the source) looks at the network part of the destination address to determine if it is on the same physical network as the destination. If the node is on the same physical network it sends it directly to the destination If not, it sends the packet to the next hop router by consulting its forwarding table. Tuesday, September 20 CS 475 Networks - Lecture 8 14 Datagram Forwarding in IP Conceptually the forwarding table for router R2 could appear as shown at right. Tuesday, September 20 R2 forwarding table Network NextHop CS 475 Networks - Lecture 8 1 R1 2 Int 1 3 Int 0 4 R3 15 Datagram Forwarding in IP A network may have multiple routers. If the forwarding table does not contain an entry for a desired network, the packet can be sent to the default router (or gateway). The forwarding table for many end nodes (hosts) may contain only an entry for a single default router. Note that forwarding tables used in routers contain entries for network addresses, not individual hosts. Tuesday, September 20 CS 475 Networks - Lecture 8 16 Subnetting The original IP classes (A, B, C) resulted in a lot of wasted IP address. Every network, no matter how small, required at least a class C network address with up to 255 hosts. A fairly large network of 1000 hosts would require a class B network address leaving 64000 IP addresses unusable. Subnetting allows for much more efficient use of the IP address space by allowing a network number to be split and the pieces assigned to different subnets. Tuesday, September 20 CS 475 Networks - Lecture 8 17 Subnetting Subnetting works by using a portion of the host number as a subnet ID. The subnet ID and network number together form a subnet number (address). A subnet mask is used to define which bits of an address are part of the subnet address and which bits are used to identify a host on the subnet. Tuesday, September 20 CS 475 Networks - Lecture 8 18 Subnetting In the example at right a subnet mask with 24 leading 1s allows a Class B address to be subnetted into 256 subnets with 255 hosts on each subnet. All hosts on the same subnet have the same subnet address and subnet mask. Externally the subnetted network still appears as a single Class B network. Tuesday, September 20 CS 475 Networks - Lecture 8 19 Subnetting An example subnetted network is shown at right. The top two networks can have up to 127 hosts. The bottom network can have up to 255 hosts. Tuesday, September 20 CS 475 Networks - Lecture 8 20 Subnetting A host now ANDs a destination IP with its own subnet mask to see if the destination subnet is the same as the source's subnet. If it is, the packet is sent directly to the destination. If it is not, the packet is sent to the default router. Note that it is not necessary that the 1s in the subnet mask be contiguous, but this is highly recommended. Tuesday, September 20 CS 475 Networks - Lecture 8 21 Subnetting Forwarding tables for the internal routers must also include a subnet mask. Forwarding table for Router R1 Subnet # 128.96.34.0 128.96.34.128 128.96.33.0 Tuesday, September 20 CS 475 Networks - Lecture 8 SubnetMask 255.255.255.128 255.255.255.128 255.255.255.0 Next intf0 intf1 R2 22 Classless Addressing Classless Interdomain Routing (CIDR) drops the classful addresses discussed previously and allows the network part of an IP address to be any length. In CIDR, network addresses are represented using a /X after the network prefix. 192.4.16/24 would include all IP addresses in the range 192.4.16.0 – 192.4.16.255 (256 IP numbers), while 192.4.16/20 would include all IP addresses in the range 192.4.16.0 – 192.4.31.255 (4096 IP numbers). Tuesday, September 20 CS 475 Networks - Lecture 8 23 Classless Addressing Fig. 3.22 Route Aggregation The ISP advertises a 21 bit CIDR address that is used externally for routing. Routers within the ISP route traffic to 8 different networks. Tuesday, September 20 CS 475 Networks - Lecture 8 24 Classless Addressing With CIDR the network portion of an IP address may match multiple entries in a router's forwarding table. Forwarding is then based on the “longest match”. Entries for both 171.69/16 and 171.69.10/24 match an IP destination of 171.69.10.100. The second entry is the longest, so the packet would be routed to 171.69.10/24. A packet addressed to 171.69.12.5 would be routed to 171.69/16 (assuming that there are no other matching entries). Tuesday, September 20 CS 475 Networks - Lecture 8 25 Address Translation (ARP) The Address Resolution Protocol (ARP) enables a host to dynamically construct a table (known as the ARP table or cache) of IP addresses to physical address mappings. Since the mappings may change over time (NIC card replacement) the entries time-out and are removed periodically (15 minutes is typical). ARP relies on the fact that most link-level technologies support broadcast. Tuesday, September 20 CS 475 Networks - Lecture 8 26 Address Translation (ARP) If a host wants to send an IP datagram to a node on the same network it first checks its ARP cache for a mapping. If there is no entry, the host broadcasts an ARP query. The query contains the target IP, the source IP and source link-layer address. The target adds or refreshes its ARP cache with a source entry and then sends an ARP reply to the source. Tuesday, September 20 CS 475 Networks - Lecture 8 27 Address Translation (ARP) The ARP packet format used on Ethernet is shown above. HLen and PLen are the lengths of the hardware and protocol addresses in bits. Operation is 1 for a query and 0 for a reply. Tuesday, September 20 CS 475 Networks - Lecture 8 28 Address Translation (ARP) Wireshark capture of an ARP request by 10.10.0.200 for 10.10.0.21 Tuesday, September 20 CS 475 Networks - Lecture 8 29 Host Configuration (DHCP) Ethernet addresses are hardwired into the adaptor. IP addresses can not be hardwired since all hosts on the same physical network must have a common network address. Most operating systems allow the IP address and the IP address of the default router/ gateway to be manually configured. Manual configuration is time consuming and error prone. The primary method of automatic configuration is known as Dynamic Host Configuration Protocol (DHCP). Tuesday, September 20 CS 475 Networks - Lecture 8 30 Host Configuration (DHCP) A DHCP server sends out IP addresses to hosts when they boot. The server can be configured to always give the same IP address to the same interface (based on its MAC address) or the server can hand out IP addresses from a pool of IP addresses. The DHCP server might be a standard computer server or a router. The DHCP server might also be setup to provide other network services (DNS, email, etc). Tuesday, September 20 CS 475 Networks - Lecture 8 31 Host Configuration (DHCP) When a host on the network boots, it sends a DHCPDISCOVER message to the IP broadcast address (255.255.255.255). Routers will pass IP broadcasts to other subnetworks (subnets) but not to other networks. The DCHP server replies with an IP address that can be used by the hosts. It is possible to use DHCP relay agents so that one DHCP server can provide IP addresses to multiple networks. Tuesday, September 20 CS 475 Networks - Lecture 8 32 Host Configuration (DHCP) A DHCP relay agent receives a broadcast DHCPDISCOVER message and sends a unicast to a DHCP server on another network. Tuesday, September 20 DHCP packet format (See the text for details.) CS 475 Networks - Lecture 8 33 Error Reporting (ICMP) IP networks support a companion protocol – Internet Control Message Protocol (ICMP) - that is used for reporting errors back to the source host whenever a router (or host) is unable to process a datagram successfully (destination host unreachable, failed reassembly, TTL decremented to 0, checksum error, etc.) An ICMP-Redirect control message can be used to send a better route back to a host so that it can update its forwarding table. Tuesday, September 20 CS 475 Networks - Lecture 8 34 Virtual Networks and Tunnels Virtual circuit networks can be used to create virtual private networks (VPNs) that act very much like separate private networks. VPNs use a shared network to create private networks. Tuesday, September 20 CS 475 Networks - Lecture 8 35 Virtual Networks and Tunnels The Internet can be used to create VPNs via the use of an IP tunnel. An IP tunnel is a virtual pointto-point link between two endpoint routers. Tuesday, September 20 CS 475 Networks - Lecture 8 36 Virtual Networks and Tunnels If router R1 receives a packet containing an address in network 2, it encapsulates the packet in an IP packet destined for router R2. R2 strips the added header and forwards the packet to network 2. VPNs can be used for security or to carry non-IP packets across an IP network. Tunnels can also be used to connect two routers that may have special capabilities. Tuesday, September 20 CS 475 Networks - Lecture 8 37 In-class Exercises Explore the following Unix commands: 1) arp 2) route 3) ping and traceroute (Unix)/tracert(Windows) Tuesday, September 20 CS 475 Networks - Lecture 8 38