CS 455/555 Intro to Networks and Communications The Network Layer

Michele Weigle
Department of Computer Science Old Dominion University mweigle@cs.odu.edu

http://www.cs.odu.edu/~mweigle/courses/cs455-f06/ http://www.cs.odu.edu/~mweigle/courses/cs555-f06/
1

The Network Layer: Routing & Addressing
Outline
! ! ! !

Network layer functions Router architecture IP Internet Protocol
» Addressing

application transport network link physical

Routing algorithms
» Least cost path computation algorithms

! !

Hierarchical routing
» Connecting networks of networks

Routing on the Internet
» Intra-domain routing » Inter-domain routing
application transport network link physical

2

The Network Layer
Network Layer Functions
!

!

Application-layer protocols define when and how Logical end-to-end messages are sent transport Transport-layer protocols deliver data between processes on different end-systems
» Transport protocols execute only on end systems

application transport network link physical

Physical endto-end packet delivery
network link physical network link physical network link physical

network link physical

network link physical

network link physical

network link physical

!

Network-layer protocols deliver data from one end-system to another
» Network layer protocols execute on every end-system and router

network link physical

application transport network link physical
3

The Network Layer
Network Layer Functions
!

The network-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

The Network Layer: Routing & Addressing Outline ! ! ! ! Network layer functions Router architecture IP Internet Protocol » Addressing application transport network link physical Routing algorithms » Least cost path computation algorithms ! ! Hierarchical routing » Connecting networks of networks Routing on the Internet » Intra-domain routing » Inter-domain routing application transport network link physical 5 Router Architecture Overview 6 .

Routing Architecture Input Port Functions 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 Routing Architecture Three Types of Switching Fabrics 8 .

Output Ports ! ! Buffering required when datagrams arrive from fabric faster than the transmission rate Scheduling discipline chooses among queued datagrams for transmission 9 The Network Layer: Routing & Addressing Outline ! ! ! ! Network layer functions Router architecture IP Internet Protocol » Addressing application transport network link physical Routing algorithms » Least cost path computation algorithms ! ! Hierarchical routing » Connecting networks of networks Routing on the Internet » Intra-domain routing » Inter-domain routing application transport network link physical 10 .

typically a TCP segment or UDP datagram) 12 .The Internet Network layer Host and router network layer functions Transport layer: TCP. OSPF. UDP Routing protocols •path selection •RIP. type of ver len service 16-bit identifier flgs time to live upper layer length fragment offset Internet checksum ! IP datagrams » The protocol data units at the IP network layer) ! (Not to be confused with UDP datagrams) » The protocol data units at the UDP transport layer are also called datagrams 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length. BGP IP protocol •addressing conventions •IP datagram format •packet handling conventions Network layer routing table ICMP protocol •error reporting •router “signaling” Link layer Physical layer 11 The Internet Network layer IP datagram format 32 bits head.

1.2 223.1.3 223.1.3 223.27 ! What’s a network? » The set of devices that can communicate with each other without an intervening router " The devices attached to the same physical network » From an IP address perspective its: " 223.3.1.4 223.1.1 223.2 223.3.2.2 223.9 223.1. Network addresses ! IP address: » Network part (high order bits) » Host part (low order bits) 223.1.3.1.1 223.1.1.3.1.1.2 The set of device interfaces with IP addresses having a common network part Ethernet 14 .2.1.2.1.1.1.1.2.4 223.1.1.1.1.1.1 223.1.1.2 = 11011111 00000001 00000011 00000010 223 1 3 2 13 IP Addressing Host address v.1 223.1.1 223.2.1 223. not the host or router 223.2.2 223.1.IP Addressing Introduction ! ! IP address: 32-bit identifier for host or router interface Interface: connection between host or router and a physical link » Routers typically have multiple interfaces » Host may have multiple interfaces (typically not) » IP addresses are associated with an interface.9 223.1.1.1.2 223.3.3.27 223.3.

2.1 223.N N N N N N N N .1.1.255 1 0 N N N N N N.27 223.1.H H H H H H H H 7 bits 24 bits (128 networks) (16.1 223.0 .3.255.H H H H H H H H 14 bits 16 bits (16.1.7.1.2.255 0 N N N N N N N.1.0.0.1.1 223.9.1.0.4 223.127. H H H H H H H H.3 223. Network addresses ! A network (subnet) is the set of hosts reachable without having to traverse a router » Detach each interface from router or host » Create “islands” of isolated networks 223.6 223.1.777.152 networks) (256 hosts) 16 .0.216 hosts) Class B 128.0 .0.223.3.255.255.1 223.255 1 1 0 N N N N N.1 223.1.097.255.H H H H H H H H.2 223.3.1.H H H H H H H H.N N N N N N N N.2.2 15 IP Addressing Class-Based (or classful) Addressing Class A 1.255.0 .1 223.536 hosts) Class C 192.N N N N N N N N .2 223.0 point-to-point Note: single link is an (IP) network 223.8.1.191.1.1.IP Addressing Host address v.384 networks) (65.1.0.1.1.8.7.1.1.0 223.255.2 223.9.1. H H H H H H H H 21 bits 8 bits (2.

0.223 224 .255 » 172.0 .Addressing Class-Based Addressing Class A B C D Range 0 .172.191 192 .127 128 .255.192.225.255.239 17 Addressing Private Addresses ! Network addresses assigned by IANA (Internet Assigned Number Authority) Private addresses available » 10.0 .31.0.0.0 .0.255 (see RFC 1597) ! 18 .10.255 » 192.255.168.16.168.

0.Addressing Special IP Addresses ! 127.0.1 is the most popular address for loopback 19 Addressing Class-Based Addressing 20 .

we get A. or classless addressing (CIDR) Netmask » 32-bit number to identify which bits are network prefix in the IP address ! ! 21 Addressing Classless Addressing (CIDR) ! Router compares destination IP with known network IP » D is dest IP addr.10. ! 22 .0) » D = 10000000 00001010 00000010 00000011 (128.10. M is mask.3) » A = 10000000 00001010 00000000 00000000 (128. A is network IP addr » A == (D & M) Example: » M = 11111111 11111111 00000000 00000000 (255.Addressing Classless Addressing (CIDR) ! Why don’t we use class-based addressing anymore? Today. we use subnet addressing.0.2.0) » Using binary AND between M and D.0.255.

called the network mask (netmask) » Used only in routing tables. 128.0.0 Class B address becomes 128.23.IP Addressing Classless InterDomain Routing (CIDR) Network part Host part 11001000 00010111 00010000 00000000 200.c. not IP datagram source/destination 23 Addressing Classless Addressing (CIDR) ! With CIDR. where x is the number of bits in network portion of address.0 / 23 24 .b.10.0.16.16.0/16 » first 16 bits are network prefix » second 16 bits are host suffix 10000000 00001010 00000000 00000000 Network part Host part 128 10 0 0 11001000 00010111 00010000 00000000 200.0 / 23 ! ! Network portion of address has an arbitrary length Address format: a.d/x.23.10.

211. 4 bits for host suffix 10000000 128 11010011 211 00000000 0 00010000 16 ! ! How do customers assign addresses to hosts? 128.Addressing Classless Addressing (CIDR) ! Example w/class-based addressing » ISP has one class B address (128.211.32/28 » ISP keeps rest of the addresses for other customers 25 Addressing Classless Addressing (CIDR) ! One customer gets 128.0.128.16/28 » one customer gets 128.211.0.0.211.16/28 » » » » » 28 bits for network prefix.17 .0.211.0) » Two customers have 12 computers » ISP can’t assign them (can’t break up the class B address space) ! Example w/classless addressing » one customer gets 128.0.30 » host part all 0s and host part all 1s are reserved 26 .211.0.

255.64.224 255.248 » What is the CIDR address? 28 .0 255.0 255.2.192 255.248.255.240.0.0.255.0/26 » How many assignable IP addresses? » What is the range of assignable IP addresses? » What is the proper netmask? ! 130.255.0 255.255.255.255.255.255.192.255.255.0/20 » How many assignable IP addresses? » What is the range of assignable IP addresses? » What is the proper netmask? ! range: 130.0.0 255.255.0 255.254.0.248 255.0 255.255.0 255.0 255.255.224.0 255.255.224.0.255.128.0 255.0.64.127.128.255.127.128.192.255.255.240.136.255.0 255./8 /9 /10 /11 /12 /13 /14 /15 /16 /17 /18 /19 /20 /21 /22 /23 /24 /25 /26 /27 /28 /29 /30 255.0 255.252.255.0 255.254.0 255.255.0.0.255.252 16777216 8388608 4194304 2097152 1048576 524288 262144 131072 65536 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 Class A Class B ISP / large business ISP / large business ISP / large business Small ISP / large business Small ISP / large business Class C Large LAN Small LAN Small LAN Small LAN 27 Problems ! 152.127.240 255.255.134 and netmask: 255.248.0.0 255.0 255.128 255.0 255.252.129 .130.0.

all hosts share the same network portion 223.1.1.IP addresses How are IP addresses assigned? ! 223.1.4 The network address is assigned by the ISP » Hosts portion only.1.1 223.2 ! Host address » Static assignment: " DCHP Server 223.1.1.1.3 Configuration parameter (manually) set during system installation 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 29 » Dynamic assignment at boot/wake-up time " Datagram Routing and Transmission IP datagram encapsulation (Ethernet) 8 bytes 6 bytes 2 6 bytes bytes 46 to 1500 bytes 4 bytes CRC CRC Preamble Destination Source Address Address Type IP header Data data IP Datagram user data Link layer addresses (not same as IP addresses) TCP header TCP Segment ! Sending interface adapter encapsulates IP datagram (or other network layer protocol packet) in an Ethernet frame 30 .1.

type of ver len service 16-bit identifier flgs time to protocol type live IP protocol version Header length (bytes) Network layer service requested Maximum number of remaining hops (decremented at each router) Transport layer protocol to receive payload (UDP. different MTUs . TCP) length fragment offset Internet checksum Total IP datagram length (bytes) 32 bit source IP address 32 bit destination IP address Options (if any) For fragmentation/ reassembly Data (variable length..g.. specify routing path. record route taken. 31 IP Datagrams Fragmentation & Reassembly ! Network links have a maximum frame size » Called the maximum transmission unit (MTU) » Different link types. typically a TCP segment or UDP datagram) E. ! Large IP datagrams must be “fragmented” to link MTU sizes » One IP datagram becomes several IP datagrams as it transits networks » “Fragments” reassembled only at the final destination Fragmentation ! All fragments carry the same IP identification number » All fragments (except the last) have the fragment bit set Reassembly 32 .: Timestamp.Datagram Routing and Transmission IP datagram format 32 bits head. etc.

980 byte message sent in an FDDI frame (MTU 4000B) The message generates 3 fragments when it transits an Ethernet (MTU 1500 B) » How much application data is in each fragment? 33 Problem ! ! ! ! Original MTU of 4000 B Sending IP datagram of 2000 B (including IP header) Transits over network with MTU of 576 B How is datagram fragmented? 34 .980 byte TCP segment) encapsulated in one FDDI frame One large IP datagram becomes several smaller IP datagrams length ID fragment offset =1500 =x =1 =0 length ID fragment offset =1500 =x =1 =1480 length ID fragment offset =1040 =x =0 =2960 ! ! Each IP datagram encapsulated in one Ethernet frame Consider a 3.IP Fragmentation and Reassembly Ethernet MTU example length ID fragment offset = 4000 = x =0 =0 IP datagram (20 byte IP header + 3.

1. Net.4 1 2 ! An application on A generates an IP datagram addressed to B » The IP layer on A looks up the network address of B.1.3.1 223.1.3.1) A 223.1.1.1.1.2.1.1.1/24 *(default) 223.3 223.2 223.1.27 223..3 fields Routing table in A data Dest.1/24 *(default) 223.1.1.1.1.1 223.27 223.Routing IP Datagrams Example Routing table in A misc source dest fields IP addr IP addr IP Datagram data Dest.2.2 E 223.1.1. next router Nhops 223.2 E 223.1 223.1. Net.1.1 223.9 ! A’s link layer sends the IP datagram directly to B inside link-layer frame » B and A are assumed to be connected to the same physical network B 223.1 223.4 223.2.3.1.1.1.2 36 .3.1.1.1.1.1.1.1.1 223.1. » And determines that B is on same network as A (223.1.4 223.1.1.2.1.2 35 Routing IP Datagrams Routing to a local destination misc 223.2 223.3.1.3.1.9 ! B 223.1.2.1.1..3 223.2.4 1 2 ! 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 link-layer addresses A 223.1 223. next router Nhops 223.1.

9 » Datagram arrives at 223.27 223.2.9 ! A’s datagram addressed to E arrives at the router » The router looks up network address of E (223.1.1.2.1 223.1/24 223.2 ! Router’s link layer sends the datagram to 223.1.1.2.1.1.2) as E - 1 1 1 223.3/24 A 223.2.1.3.2.3.1.4 as the default for all networks A 223.2 fields Routing table in router data Dest.2 fields data Routing table in A Dest.1.27 223. next network router Nhops interface 223.1.1.4 1 2 ! Host A generates an IP datagram addressed to E » The IP layer on A looks up up network address of E (223.1.1.1.3 223.1.1 223.1.27 B 223.1.1.2.1.2/24 223.1.1.1.1.1.2 38 .4 223.4 223.2.1.1.1.1.3.1.1.9 223.2 E 223.4 223. next router Nhops 223.1.3.1 223.2 E ! A’s link layer sends IP datagram to router inside link-layer frame 223. Net.2.1 223.1.1.2 223.1.3.1.1.2 223.Routing IP Datagrams Routing to a remote destination misc 223.1.1.1 223.3 223.1.2) » E has the same network address as router’s interface 223.1.9 B 223.1.1.1.2 37 Routing IP Datagrams Routing to a remote destination misc 223.9 » Router is directly attached to the same network (223.1 223.2 inside a link-layer frame via interface 223.1.1 223.2.1.3.2.1 223.3.1.2.1.1.2.1.1.1.2.1.1/24 *(default) 223.2) » A determines that E is NOT on same network as A » A’s routing table shows router 223.1.

76. destination (as usual) 40 .not used) echo request (ping) route advertisement router discovery TTL expired 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 39 The Internet Network Layer NAT: Network Address Translation rest of Internet local network (e. home network) 10.7.3 10.0/24 10.g.29.0/24 address for source.0. network. routers. unreachable {host.0.. protocol} » Echo request/reply (used by ping) ! Provides network-layer functions logically “above” IP » ICMP is encapsulated in IP datagrams Type 0 3 3 3 3 3 3 4 8 9 10 11 12 Code 0 0 1 2 3 6 7 0 0 0 0 0 0 description echo reply (ping) network unreachable host unreachable protocol unreachable port unreachable network unknown host unknown source quench (congestion control .29.0.2 138. gateways to communicate network-level information » Error reporting: e.The Internet Network Layer The Internet control message protocol ICMP ! Used by hosts. port.4 10.0.g.7 10. different source port numbers Datagrams with source or destination in this network have 10.0.0.0..76.1 All datagrams leaving local network have same single source NAT IP address: 138.0.0.0.

186.186.3.76.1 192.76. 3345 D: 128.76. a) b) What should you put in the NAT table at your router? What address and port should you tell your friend to contact in order to reach your web server? 42 .168.1 sends datagram to 128.29.119.0.76.0.4 S: 128.The Internet Network Layer NAT: Network Address Translation 2: NAT router changes datagram source addr from 10.2 “The Internet” 152.186.76.0.0.13. 5001 D: 128.254 192.29. a) b) What data is filled into the NAT table during connection setup? What information is changed in the SYN and SYN/ACK packets leaving and entering your network? 2) You’ve setup a web server on 192.0.186. address: 138.119.29.7.76.0.7 S: 128. 80 D: 138.0.0.168.40.119. 5001 4: NAT router changes datagram dest addr from 138.40.3 and want to access a web server running on 152.7.7. 80 1 10.119.3 to be able to access it. 80 S: 10.0. 5001 10.1.2 138.2.0.76.0. 5001.0.168.0.1.2.76.40.0.2. 3345 …… …… 1: host 10.13.1.168.7.29.3 3: Reply arrives dest.1 10.7 192.29.0.7.0.0.29.1.29. 80 D: 10.119.40.0.168.1. 3345 to 138. 3345 41 Problems 192. 3345 10.76. 80 S: 138.40.0.2.76.0.2.29.2 and want your friend at 152. 5001 to 10.168.76.13.7.3 138.3 1) You are using 192. 5001 3 4 10.2. updates table 2 NAT translation table WAN side addr LAN side addr 138.