Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Chapter 4 Network Layer A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!) If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material. Modified by Melissa, Brigitte, and Amy Thanks and enjoy! JFK/KWR All material copyright 1996-2002 J.F Kurose and K.W. Ross, All Rights Reserved Computer Networking: A Top Down Approach Featuring the Internet, 2nd edition. Jim Kurose, Keith Ross Addison-Wesley, July 2002. Network Layer 4-1 Chapter 4 roadmap 4.1 Introduction and Network Service Models 4.2 Routing Principles 4.3 Hierarchical Routing 4.4 The Internet (IP) Protocol 4.4.1 IPv4 addressing 4.4.2 Moving a datagram from source to destination 4.4.3 Datagram format 4.4.4 IP fragmentation 4.4.5 ICMP: Internet Control Message Protocol 4.4.6 DHCP: Dynamic Host Configuration Protocol 4.4.7 NAT: Network Address Translation 4.5 Routing in the Internet 4.6 What’s Inside a Router 4.7 IPv6 4.8 Multicast Routing 4.9 Mobility Network Layer 4-2 4.4.1 IPv4 Addressing Roadmap • Definition of an IP Address • Definition of a Network from the IP perspective • Address Assignment ISPs Networks Hosts • Classful Addressing • Masking • Subnetting • Classful Addressing Alternative • Hierarchial Addressing • Quiz Network Layer 4-3 What is an IP Address? • IP address: 32-bit identifier for host, router interface • interface: connection between host/router and physical link 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.1.3 223.1.2.9 223.1.3.27 223.1.2.2 router’s typically have 223.1.3.2 223.1.3.1 multiple interfaces host may have multiple interfaces IP addresses associated with each interface 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 Network Layer 1 4-4 IP Addressing • IP address: network part (high order bits) host part (low order bits) • What’s a network ? (from IP address perspective) device interfaces with same network part of IP address can physically reach each other without intervening router 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.1.3 223.1.2.9 223.1.3.27 223.1.2.2 LAN 223.1.3.1 223.1.3.2 network consisting of 3 IP networks (for IP addresses starting with 223, first 24 bits are network address) Network Layer 4-5 IP Addressing 223.1.1.2 How to find the networks? • Detach each interface from router, host • create “islands of isolated networks 223.1.1.1 223.1.1.4 223.1.1.3 223.1.9.2 223.1.7.0 223.1.9.1 223.1.7.1 223.1.8.1 223.1.8.0 223.1.2.6 Interconnected system consisting of six networks 223.1.2.1 223.1.3.27 223.1.2.2 223.1.3.1 223.1.3.2 Network Layer 4-6 IP Addresses given notion of “network”, let’s re-examine IP addresses: “class-full” addressing: 32 bits class A 0 network 10 16,777,214 network 16,384 (214) C 110 1110 128.0.0.0 to 191.255.255.255 host 65,534 network 2,097,151 (221-1) D 1.0.0.0 to 127.255.255.255 host 126 (27-2) B 2^32 addresses = 4 billion addresses multicast address host 254 192.0.0.0 to 223.255.255.255 224.0.0.0 to 239.255.255.255 Network Layer 4-7 Address Assignment: To ISPs Q: How does an ISP get block of addresses? A: ICANN: Internet Corporation for Assigned Names and Numbers allocates addresses manages DNS assigns domain names, resolves disputes Network Layer 4-8 Address Assignment: To Networks Q: How does network get network part of IP addr? A: gets allocated portion of its provider ISP’s address space ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20 Organization 0 Organization 1 Organization 2 ... 11001000 00010111 00010000 00000000 11001000 00010111 00010010 00000000 11001000 00010111 00010100 00000000 ….. …. 200.23.16.0/23 200.23.18.0/23 200.23.20.0/23 …. Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23 Network Layer 4-9 Address Assignment: To Hosts Q: How does host get IP address? • hard-coded by system admin in a file Wintel: control-panel->network->configuration>tcp/ip->properties • DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server “plug-and-play” Network Layer 4-10 Masking the Network Portion A 255.0.0.0 11111111 00000000 00000000 00000000 B 255.255.0.0 11111111 11111111 000 00000 00000000 C 255.255.255.0 11111111 11111111 11111111 00000000 131.229.157.11 = Class B 10000011 11100101 01100111 00001011 11111111 11111111 00000000 00000000 10000011 11100111 00000000 00000000 Smith College = 131.229.0.0 Network Layer 4-11 Class B Sub-Netting: 2 bits Original Mask 255.255. 128 64 32 16 8 4 2 1 1 1 0 0 0000 New Mask 255.255.192 192 2 Bits 0 0 0 1 1 0 1 1 Address 0-Invalid 64 128 192-Invalid Range 0-63 64-127 128-191 192-255 Valid None 65-126 129-190 None TOTAL = New Nets 0 1 1 0 2 nets # Hosts per Net 0 62 62 0 124 hosts Source: NetCom Systems <www.netliban.com/download/tcpip%20address.doc> Network Layer 4-12 Class B Sub-Netting: 3 bits Original Mask 255.255. 128 64 32 16 8 4 2 1 1 1 1 0 0000 New Mask 255.255.224 224 2 Bits 000 001 010 111 100 101 110 111 Address Range 0-Invalid 0-31 32 32-63 64 64-95 96 96-127 128 128-159 160 160-191 192 192-223 224-Invalid 224-255 Valid None 33-62 65-94 97-126 129-158 161-190 193-222 None TOTAL = New Nets 0 1 1 1 1 1 1 0 6 nets Source: NetCom Systems <www.netliban.com/download/tcpip%20address.doc> # Hosts per Net 0 30 30 30 30 30 30 0 180 hosts Network Layer 4-13 Class “B” Sub-Netting Subnet Bits 2 3 4 5 6 Subnets 2-2 2 6 14 30 62 Hosts Per Net 62 30 14 6 2 Total Hosts Subnet Mask 124 180 196 180 124 255.255.192 255.255.224 255.255.240 255.255.248 255.255.252 A Network or Host Address cannot contain all 0’s or all 1’s. Source: NetCom Systems <www.netliban.com/download/tcpip%20address.doc> Network Layer 4-14 The “Classful” Alternative: CIDR • Classful addressing: inefficient use of address space, address space exhaustion e.g., class B net allocated enough addresses for 65K hosts, even if only 2K hosts in that network • CIDR: Classless InterDomain Routing network portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in network portion of address network part host part 11001000 00010111 00010000 00000000 200.23.16.0/23 Network Layer 4-15 Hierarchical addressing: route aggregation Hierarchical addressing allows efficient advertisement of routing information: Organization 0 200.23.16.0/23 “Send me anything with addresses beginning 200.23.16.0/20” Organization 1 200.23.18.0/23 Organization 2 200.23.20.0/23 Organization 7 . . . . . . Fly-By-Night-ISP Internet 200.23.30.0/23 ISPs-R-Us “Send me anything with addresses beginning 199.31.0.0/16” Network Layer 4-16 Hierarchical addressing: more specific routes ISPs-R-Us has a more specific route to Organization 1 Organization 0 200.23.16.0/23 Organization 2 200.23.20.0/23 Organization 7 . . . “Send me anything with addresses beginning 200.23.16.0/20” . . . Fly-By-Night-ISP Internet 200.23.30.0/23 ISPs-R-Us Organization 1 200.23.18.0/23 “Send me anything with addresses beginning 199.31.0.0/16 or 200.23.18.0/23” Network Layer 4-17 IP Address Quiz What IP address is contained in 11/8? • 15.31.184.254 14.50.97.103 • 8.85.29.189 11.150.208.105 What IP address matches 7.74.34.159/32? • 7.74.39/24 7.74.34.52/32 • 7.74.34/24 Network Layer 4-18 IP Address Quiz What IP address is contained in 86.32/12? • 86.33.224.123 86.79.65.216 86.58.119.74 86.68.206.154 What IP address contains 152.7.77.159 and 152.31.47.252? • 152.0/11 152.40/13 • 153.0/9 152.64.12 Network Layer 4-19 Web Resources • “whois” demo • www.iana.org/ipaddress/ip-addresses.htm • General info + Quizzes • www.freesoft.org/CIE/Course/Subnet/index.htm Network Layer 4-20 Chapter 4 roadmap 4.1 Introduction and Network Service Models 4.2 Routing Principles 4.3 Hierarchical Routing 4.4 The Internet (IP) Protocol 4.4.1 IPv4 addressing 4.4.2 Moving a datagram from source to destination 4.4.3 Datagram format 4.4.4 IP fragmentation 4.4.5 ICMP: Internet Control Message Protocol 4.4.6 DHCP: Dynamic Host Configuration Protocol 4.4.7 NAT: Network Address Translation 4.5 Routing in the Internet 4.6 What’s Inside a Router 4.7 IPv6 4.8 Multicast Routing 4.9 Mobility Network Layer 4-21 Getting a datagram from source to dest. forwarding table in A Dest. Net. next router Nhops 223.1.1 223.1.2 223.1.3 IP datagram: misc source dest fields IP addr IP addr data * datagram remains unchanged A 223.1.1.4 223.1.1.4 1 2 2 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.1 223.1.3.27 E 223.1.3.2 Network Layer 4-22 Getting a datagram from source to dest. misc data fields 223.1.1.1 223.1.1.3 Starting at Amelia, send IP datagram addressed to Marga: Amelia’s Forwarding Table Dest. Net. next router Nhops 223.1.1 223.1.2 223.1.3 223.1.1.4 223.1.1.4 Amelia 223.1.1.1 look up net. address of Marga in forwarding table Marga is on same net. as Amelia link layer will send datagram directly to Marga inside link-layer frame 1 2 2 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 Marga 223.1.1.3 223.1.3.1 223.1.2.2 223.1.3.27 223.1.3.2 Network Layer 4-23 Getting a datagram from source to dest. Amelia’s Forwarding Table misc data fields 223.1.1.1 223.1.2.2 Starting at Amelia, dest. to Sonya : look up network address of Sonya in forwarding table Sonya on different network i.e. not directly attached routing table: next hop router to Sonya is 223.1.1.4 link layer sends datagram to router 223.1.1.4 inside link-layer frame Dest. Net. next router Nhops 223.1.1 223.1.2 223.1.3 223.1.1.4 223.1.1.4 1 2 2 Amelia 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 Sonya 223.1.2.2 223.1.1.3 223.1.3.1 223.1.3.27 223.1.3.2 datagram arrives at 223.1.1.4 continued….. Network Layer 4-24 Getting a datagram from source to dest. forwarding table in router misc data fields 223.1.1.1 223.1.2.2 Arriving at 223.1.4, destined for 223.1.2.2 look up network address of Dest. Net router Nhops interface 223.1.1 223.1.2 223.1.3 - 1 1 1 router’s interface 223.1.2.9 router, Sonya directly attached link layer sends datagram to 223.1.2.2 inside link-layer frame via interface 223.1.2.9 Sonya receives datagram 223.1.3.27 Amelia 223.1.1.1 Sonya in forwarding table Sonya on same network as 223.1.1.4 223.1.2.9 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 Sonya 223.1.2.2 223.1.1.3 223.1.3.1 223.1.3.27 223.1.3.2 Network Layer 4-25 Smith Routers Quad Science Center Neilson Cutter Stoddard Seelye UMass MHC Network Layer 4-26 IP datagram format IP protocol version number header length “type” of data max number remaining hops (decremented at each router) upper layer protocol 32 bits head. type of length ver len service fragment flgs 16-bit identifier offset upper time to Internet layer live checksum total datagram length fragmentation 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP or UDP segment) E.g. record route taken, specify list of routers to visit. Network Layer 4-27 Recall IP datagram format head. type of length ver len service fragment flgs 16-bit identifier offset upper time to Internet layer live checksum misc source dest fields IP addr IP addr source IP address data destination IP address Options (if any) data (variable length, typically a TCP or UDP segment) Network Layer 4-28 How Much Overhead with TCP? Consider All overhead up till now: • Application Layer application transport • Transport Layer • Network Layer network link *Consider application layer at end, start with transport layer physical Network Layer 4-29 Transport Layer 32 bits 20 bytes of TCP, no options included source port # dest port # sequence number acknowledgement number head not UAP R S F len used checksum Receive window Urg data pnter Options (none) data (variable length) Network Layer 4-30 Network Layer 20 bytes minimum for IP Datagram Also, no Options Note: our TCP segment header information follows our IP datagram header information ver head. type of len service 16-bit identifier upper time to layer live length flgs fragment offset Internet checksum source IP address destination IP address Options (none) data (our TCP segment) Network Layer 4-31 Total TCP Overhead 20 bytes of TCP header application 20 bytes IP Datagram header transport = 40 bytes + application layer network overhead link physical Network Layer 4-32 IP Fragmentation & Reassembly network links have MTU (max.transfer size) different link types, different MTUs fragmentation: in: one large datagram out: 3 smaller datagrams large IP datagram data header divided (“fragmented”) one datagram becomes several datagrams “reassembled” only at final destination IP header bits used to identify, the order of fragments reassembly Network Layer 4-33 IP Fragmentation and Reassembly Recall the IP Datagram included: ID, Flag, and offset information for fragmentation. Example 4000 byte datagram MTU = 1500 bytes length ID fragflag =4000 =7 =0 offset =0 One large datagram becomes several smaller datagrams length ID fragflag =1500 =7 =1 offset =0 length ID fragflag offset =1500 =7 =1 =1480 length ID fragflag offset =1040 =7 =0 =2960 Applet:http://wps.aw.com/wps/media/objects/221/227091/applets/ip/ipfra gmentation.html Network Layer 4-34 Quiz: Four Questions Q: Suppose an application generates chunks of 60 bytes of data every second, and each chunk gets encapsulated in a TCP segment and then an IP datagram. What percentage of each datagram will contain application data? A. 40% B. 20% C. 80% D. 60% Ans: D or 60%, this because we will gain 40bytes more from TCP and IP datagram segments, thus our whole chunk of information is 100bytes, therefore the application we started with or 60bytes is 60/100 or 60%. Network Layer 4-35 Are you Challenged Yet? Q: Consider sending a 1300 byte datagram into a link that has an MTU of 500 bytes. A. Three fragments are created with offsets 0, 500 1000 B. Three fragments are created, with offsets 0, 460 and 920. C. Three fragments are created with offsets 0, 480 and 960. D. None of the above ANS: C Network Layer 4-36 You have a 50% Chance! Q: With a datagram network layer, each packet carries the address of the destination host. (Note: If your answer is incorrect we will have to redo the entire lecture) True False Ans: True Network Layer 4-37 Don’t Forget Brigitte’s Lecture Q:The network portion of an IP address is the same for all the hosts on the same IP network. True False Ans: True Network Layer 4-38 Chapter 4 roadmap 4.1 Introduction and Network Service Models 4.2 Routing Principles 4.3 Hierarchical Routing 4.4 The Internet (IP) Protocol 4.4.1 IPv4 addressing 4.4.2 Moving a datagram from source to destination 4.4.3 Datagram format 4.4.4 IP fragmentation 4.4.5 ICMP: Internet Control Message Protocol 4.4.6 DHCP: Dynamic Host Configuration Protocol 4.4.7 NAT: Network Address Translation 4.5 Routing in the Internet 4.6 What’s Inside a Router 4.7 IPv6 4.8 Multicast Routing 4.9 Mobility Network Layer 4-39 The Internet Network layer (recap) Host, router network layer functions: Transport layer: TCP, UDP Network layer IP protocol •addressing conventions •datagram format •packet handling conventions Routing protocols •path selection •RIP, OSPF, BGP forwarding table ICMP protocol •error reporting •router “signaling” Link layer physical layer 4-30 Network Layer 4-40 ICMP: Internet Control Message Protocol ICMP is used by the following for communication in the network-layer: o Hosts o Routers o Gateways RFC 792 Typically used for error reporting o Unreachable host, network, port protocol o Echo request/reply (in ping) telnet server IP router TCP software telnet client Network Layer 4-41 IP datagram format 32 bits head. type of length ver len service fragment flgs 16-bit identifier offset upper time to Internet layer live checksum 32 bit source IP address 32 bit destination IP address Options (if any) how much overhead with TCP? 20 bytes of TCP 20 bytes of IP = 40 bytes + app layer overhead data (variable length, typically a TCP or UDP segment) Network Layer 4-42 ICMP: Internet Control Message Protocol ICMP messages are carried in IP datagrams, so they are architecturally below IP. ICMP message contain: o Type and code field o First eight bytes of IP datagram that caused the ICMP message generation Not only for error messaging o ping o traceroute Type 0 3 3 3 3 3 3 4 Code 0 0 1 2 3 6 7 0 8 9 10 11 12 0 0 0 0 0 description echo reply (ping) dest. network unreachable dest host unreachable dest protocol unreachable dest port unreachable dest network unknown dest host unknown source quench (congestion control - not used) echo request (ping) route advertisement router discovery TTL expired bad IP header Network Layer 4-43 DHCP: Dynamic Host Configuration Protocol DHCP assigns IP addresses to hosts dynamically. client-server protocol o client = newly arriving host wanting to obtain network config info (including IP address) o If DHCP server exists, all is good o If DHCP server does not exist, DHCP relay agent (typically router) is needed. o DHCP relay agent knows address of a DHCP server for that network Client-server protocol (cont) o Renew its lease time o Allows reuse of addresses o Support for mobile users who want to join networks (continued later) Network Layer 4-44 DHCP client-server scenario A B 223.1.2.1 DHCP server 223.1.1.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.1 223.1.3.27 223.1.3.2 E arriving DHCP client needs address in this network Network Layer 4-45 DHCP: Dynamic Host Configuration Protocol Overview of DHCP protocol steps DHCP server discovery o First task = find DHCP server o Send DHCP discover message DHCP server offer(s) o DHCP offer message sent back to client o address lease time – valid time of IP address (may be renewed) Overview of DHCP protocol steps DHCP request o New client will choose among offers and respond with a request message o New client echoes config parameters to server it chooses DHCP ACK o Server responds with an acknowledgement, confirming configuration parameters Network Layer 4-46 DHCP: Dynamic Host Configuration Protocol Network Layer 4-47 DHCP client-server scenario DHCP server: 131.229.64.27 DHCP discover arriving client src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0 transaction ID: 654 DHCP offer src: 131.229.64.27, 67 dest: 255.255.255.255, 68 yiaddrr: 131.229.183.50 transaction ID: 654 Lifetime: 3600 secs DHCP request time src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 131.229.183.50 transaction ID: 655 Lifetime: 3600 secs DHCP ACK src: 131.229.64.27, 67 dest: 255.255.255.255, 68 yiaddrr: 131.229.183.50 transaction ID: 655 Lifetime: 3600 secs Network Layer 4-48 DHCP: Dynamic Host Configuration Protocol Network Layer 4-49 NAT: Network Address Translation rest of Internet local network (e.g., home network) 192.168.0/24 192.168.0.1 192.168.0.108 192.168.0.109 12.222.208.63 192.168.0.110 All datagrams leaving local network have same single source NAT IP address: 12.222.208.63, different source port numbers Datagrams with source or destination in this network have 192.168.0/24 address for source, destination (as usual) Network Layer 4-50 NAT: Network Address Translation Motivation: local network uses just one IP address as far as outside word is concerned: no need to be allocated range of addresses from ISP: just one IP address is used for all devices can change addresses of devices in local network without notifying outside world can change ISP without changing addresses of devices in local network devices inside local net not explicitly addressable, visible by outside world (a security plus). Network Layer 4-51 NAT: Network Address Translation Implementation: NAT router must: outgoing datagrams: replace (source IP address, port #) of every outgoing datagram to (NAT IP address, new port #) . . . remote clients/servers will respond using (NAT IP address, new port #) as destination addr. remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair incoming datagrams: replace (NAT IP address, new port #) in dest fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table Network Layer 4-52 NAT: Network Address Translation NAT translation table WAN side addr LAN side addr 2: NAT router changes datagram 12.222.208.63, 5001 source addr from …… 192.168.0.108, 3345 to 12.222.208.63, 5001, updates table 2 1: host 192.168.0.108 sends datagram to www.yahoo.com, 80 192.168.0.108, 3345 …… S: 192.168.0.108, 3345 D: www.yahoo.com, 80 192.168.0.108 1 S: 12.222.208.63, 5001 D: www.yahoo.com, 80 138.76.29.7 S: www.yahoo.com, 80 D: 12.222.208.63, 5001 3 3: Reply arrives dest. address: 12.222.208.63, 5001 192.168.0.109 10.0.0.4 S: www.yahoo.com, 80 D: 192.168.0.108, 3345 4 4: NAT router 192.168.0.110 changes datagram dest addr from 12.222.208.63, 5001 to 192.168.0.108, 3345 Network Layer 4-53 NAT: Network Address Translation 16-bit port-number field: 60,000 simultaneous connections with a single LAN-side address! NAT is controversial: routers should only process up to layer 3 violates end-to-end argument • NAT possibility must be taken into account by app designers, eg, P2P applications address shortage should instead be solved by IPv6 Network Layer 4-54 NAT Manipulation in the IP datagram NAT translation original head. type of length ver len service fragment flgs 16-bit identifier offset upper time to Internet layer live checksum head. type of length len service fragment 16-bit identifier flgs offset upper time to Internet layer live checksum ver 192.168.0.108:3345 12.222.208.63:5001 www.yahoo.com:80 www.yahoo.com:80 Options (if any) Options (if any) data (variable length, typically a TCP or UDP segment) data (variable length, typically a TCP or UDP segment) Network Layer 4-55