1 CPSC 826 Intering The Network Layer: Routing & Addressing Outline The Network Layer Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu November 10, 2004 Network layer functions Router architecture IP Internet Protocol» Addressing Routing algorithms» Least cost path computation algorithms Hierarchical routing» Connecting s of s Routing on the Internet» Intra-domain routing» Inter-domain routing http://www.cs.clemson.edu/~mweigle/courses/cpsc826 2 The Network Layer Network Layer Functions Application-layer protocols define when and how messages are sent Logical end-toend Transport-layer protocols deliver data between processes on different endsystems» Transport protocols execute only on end systems Network-layer protocols deliver data from one end-system to another» Network layer protocols execute on every end-system and router Physical endto-end packet delivery 3 The Network Layer Network Layer Functions The -layer provides two important functions:» Routing: the route taken by packets from source to destination (involves all routers)» Forwarding (aka Switching): the movement of packets from an input interface to an appropriate output interface (involves a single router) 4
5 The Network Layer: Routing & Addressing Outline Router Architecture Overview Network layer functions Router architecture IP Internet Protocol» Addressing Routing algorithms» Least cost path computation algorithms Hierarchical routing» Connecting s of s Routing on the Internet» Intra-domain routing» Inter-domain routing 6 Routing Architecture Input Port Functions Routing Architecture Three Types of Switching Fabrics Decentralized switching: Given datagram destination, lookup output port using forwarding table in input port memory (forwarding table copied to input port) Goal: complete input port processing at line speed» Lookup should take less time than time to receive next packet at input port Queuing: if datagrams arrive faster than forwarding rate into switch fabric 7 8
9 Output Ports The Network Layer: Routing & Addressing Outline Buffering required when datagrams arrive from fabric faster than the transmission rate Scheduling discipline chooses among queued datagrams for transmission Network layer functions Router architecture IP Internet Protocol» Addressing Routing algorithms» Least cost path computation algorithms Hierarchical routing» Connecting s of s Routing on the Internet» Intra-domain routing» Inter-domain routing 10 The Internet Network layer Host and router layer functions The Internet Network layer IP datagram format Network layer Routing protocols path selection RIP, OSPF, BGP Transport layer: TCP, UDP routing table Link layer Physical layer IP protocol addressing conventions IP datagram format packet handling conventions ICMP protocol error reporting router signaling IP datagrams» The protocol data units at the IP layer) (Not to be confused with UDP datagrams)» The protocol data units at the UDP layer are also called datagrams ver head. len 32 bits 16-bit identifier flgs time to live type of service upper layer fragment offset Internet checksum 32 bit source IP address 32 bit destination IP address Options (if any) data (variable, typically a TCP segment or UDP datagram) 11 12
13 Introduction IP address: 32-bit identifier for host or router interface Interface: connection between host or router and a» Routers typically have multiple interfaces» Host may have multiple interfaces (typically not)» IP addresses are associated with an interface, not the host or router 7 = 11011111 00000001 00000011 00000010 Host address v. Network addresses IP address:» Network part (high order bits)» Host part (low order bits) What s a?» The set of devices that can communicate with each other without an intervening router The devices attached to the same» From an IP address perspective its: The set of device interfaces with IP addresses having a common part 7 Ethernet 223 1 2 3 14 Host address v. Network addresses A (subnet) is the set of hosts reachable without having to traverse a router» Detach each interface from router or host» Create islands of isolated s 223.1.1.4 223.1.9.2 223.1.9.1 223.1.8.1 223.1.7.0 223.1.8.0 Note: single point-to-point is an (IP) 223.1.7.1 223.1.2.6 7 Class-based addressing Class A addresses» 128 s» 65,536 to 2 24 hosts Class B addresses» 16,384 s» 256 to 65,536 hosts 0 1 2 3 4 8 16 24 31 0 net id host id (IP addresses 1.0.0.0 through 127.255.255.255) 0 1 2 3 4 8 16 24 31 1 0 net id host id Class C addresses (IP addresses 128.0.0.0 through 191.255.255.255)» 2 21 s» less than 256 hosts 0 1 2 3 4 1 1 0 8 net id 16 24 host id 31 Class D addresses» 28-bit multicast (IP addresses 192.0.0.0 through 223.255.255.255) addresses» No origin or 0 1 2 3 4 8 16 24 31 information is encoded 1 1 1 0 multicast address (IP addresses 224.0.0.0 through 239.255.255.255) 15 16
17 Classless InterDomain Routing (CIDR) IP addresses How are IP addresses assigned? Network Host part part 11001000 00010111 00010000 00000000 200.23.16.0 / 23 Class-based addressing» Inefficient use of address space, address space exhaustion» E.g., class B allocated enough addresses for 64K hosts, even if only 300 hosts in that Classless addressing» Network portion of address has an arbitrary» Address format: a.b.c.d/x, where x is the number of bits in portion of address; called the mask (netmask) Used only in routing tables, not IP datagram source/destination The address is assigned by the ISP» Hosts portion only; all hosts share the same portion Host address» Static assignment: 223.1.1.4 DCHP Server Configuration parameter (manually) set during system installation» Dynamic assignment at boot/wake-up time DHCP: Dynamic Host Configuration Protocol Host broadcasts a DHCP discover message DHCP server responds with a DHCP offer message Host requests IP address: DHCP request message DHCP server sends address: DHCP ack message 18 IP addresses How are addresses assigned? Datagram Routing and Transmission IP datagram encapsulation (Ethernet) ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20 Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 0001011 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23....... Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23 ISPs obtain a block of addresses from ICANN (Internet Corporation for Assigned Names and Numbers)» ICANN allocates IP address blocks, manages DNS, (used to assign domain names) resolves disputes ISPs subdivide their block among their customers 2 8 bytes 6 bytes 6 bytes bytes 46 to 1500 bytes 4 bytes Preamble Destination Address Link layer addresses (not same as IP addresses) Source Address Type IP header Data data TCP header user data CRC CRC IP Datagram TCP Segment Sending interface adapter encapsulates IP datagram (or other layer protocol packet) in an Ethernet frame 19 20
21 Datagram Routing and Transmission IP datagram format IP protocol version Header (bytes) Network layer service requested Maximum number of remaining hops (decremented at each router) Transport layer protocol to receive payload (UDP, TCP) ver head. len time to live 32 bits type of service 16-bit identifier flgs protocol type fragment offset Internet checksum 32 bit source IP address 32 bit destination IP address Options (if any) Data (variable, typically a TCP segment or UDP datagram) Total IP datagram (bytes) For fragmentation/ reassembly E.g.: Timestamp, record route taken, specify routing path, etc. Routing IP Datagrams Example misc fields source IP addr dest IP addr IP Datagram data All routing is based on the IP destination address field in the IP header IP destination address (and data fields) never change!» Delivery to intermediate hops involves -layer addresses A B Dest. Net. next router Nhops 223.1.1/24-1 *(default) 223.1.1.4 2 Routing table in A 7 E 22 Routing IP Datagrams Routing to a local destination misc fields data An on A generates an IP datagram addressed to B» The IP layer on A looks up the address of B...» And determines that B is on same as A (223.1.1) A s layer sends the IP datagram directly to B inside -layer frame» B and A are assumed to be connected to the same A B Dest. Net. next router Nhops 223.1.1/24-1 *(default) 223.1.1.4 2 Routing table in A 7 E 23 Routing IP Datagrams Routing to a remote destination misc Routing table in A fields data Dest. Net. next router Nhops Host A generates an IP datagram addressed to E» The IP layer on A looks up up address of E (223.1.2)» A determines that E is NOT on same as A» A s routing table shows router 223.1.1.4 as the default for all s A s layer sends IP datagram to router inside -layer frame A B 223.1.1/24-1 *(default) 223.1.1.4 2 7 E 24
25 Routing IP Datagrams Routing to a remote destination misc fields data A s datagram addressed to E arrives at the router» The router looks up address of E (223.1.2)» E has the same address as router s interface 223.1.2.9» Router is directly attached to the same (223.1.2) as E Router s layer sends the datagram to inside a -layer frame via interface 223.1.2.9» Datagram arrives at Routing table in router Dest. next router Nhops interface 223.1.1/24-1 223.1.1.4 223.1.2/24-1 223.1.2.9 223.1.3/24-1 7 A B 7 E IP Datagrams Fragmentation & Reassembly Network s have a maximum frame size» Called the maximum transmission unit (MTU)» Different types, different MTUs Large IP datagrams must be fragmented to MTU sizes» One IP datagram becomes several IP datagrams as it transits s» Fragments reassembled only at the final destination All fragments carry the same IP identification number» All fragments (except the last) have the fragment bit set... Fragmentation Reassembly 26 IP Fragmentation and Reassembly Ethernet MTU example = 4000 ID = x fragment offset = 0 = 0 One large IP datagram becomes several smaller IP datagrams =1500 =1500 =1040 ID =x ID =x ID =x fragment =1 offset =0 fragment offset =1 =1480 fragment offset =0 =2960 IP datagram (20 byte IP header + 3,980 byte TCP segment) encapsulated in one FDDI frame Each IP datagram encapsulated in one Ethernet frame Consider a 3,980 byte message sent in an FDDI frame The message generates 3 fragments when it transits an Ethernet» How much data is in each fragment? 27 The Internet Network Layer The Internet control message protocol ICMP Type Code description Used by hosts, routers, gateways 0 0 echo reply (ping) to communicate -level 3 0 unreachable information 3 1 host unreachable» Error reporting: e.g., unreachable 3 2 protocol unreachable {host,, port, protocol} 3 3 port unreachable» Echo request/reply (used by ping) 3 6 unknown Provides -layer functions 3 7 host unknown logically above IP 4 0 source quench (congestion control - not used)» ICMP is encapsulated in IP datagrams 8 0 echo request (ping) 9 0 route advertisement 10 0 router discovery 11 0 TTL expired 12 0 bad IP header» ICMP is assigned a protocol number in the IP header just like TCP and UDP ICMP message: type + code + first 8 bytes of IP datagram triggering the ICMP message 28
29 The Internet Network Layer NAT: Network Address Translation The Internet Network Layer NAT: Network Address Translation rest of Internet 138.76.29.7 All datagrams leaving local have same single source NAT IP address: 138.76.29.7, different source port numbers local (e.g., home ) 10.0.0/24 10.0.0.4 Datagrams with source or destination in this have 10.0.0/24 address for source, destination (as usual) 10.0.0.1 10.0.0.2 10.0.0.3 2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table 2 NAT translation table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 S: 138.76.29.7, 5001 D: 128.119.40.186, 80 138.76.29.7 S: 128.119.40.186, 80 D: 138.76.29.7, 5001 3 3: Reply arrives dest. address: 138.76.29.7, 5001 10.0.0.4 S: 10.0.0.1, 3345 D: 128.119.40.186, 80 S: 128.119.40.186, 80 D: 10.0.0.1, 3345 1 1: host 10.0.0.1 sends datagram to 128.119.40, 80 4: NAT router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345 4 10.0.0.1 10.0.0.2 10.0.0.3 30