Chap4.4 Network Layer

Chap4.4 Network Layer - 3/16/10 IP datagram format IP...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3/16/10 IP datagram format IP protocol version number header length (bytes) “type” of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to Many slides in this document adapted from materials for Kurose and Ross, Computer Networking, 5th edition. copyright 1996-2009 J.F Kurose and K.W. Ross, All Rights Reserved 32 bits ver head. type of len service length fragment 16 ­bit idenJfier flgs offset Jme to upper header layer live checksum 32 bit source IP address 32 bit desJnaJon IP address OpJons (if any) E.g. Jmestamp, record route taken, specify list of routers to visit. total datagram length (bytes) for fragmentaJon/ reassembly Network Layer Part 2 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 ­2 IP FragmentaJon & Reassembly •  network links have MTU (max.transfer size)  ­ largest possible link ­level frame. –  different link types, different MTUs large IP datagram divided (“fragmented”) within net –  one datagram becomes several datagrams –  “reassembled” only at final desJnaJon –  IP header bits used to idenJfy, order related fragments fragmentaJon: in: one large datagram out: 3 smaller datagrams IP FragmentaJon and Reassembly Example ❒  4000 byte datagram ❒  MTU = 1500 bytes length ID fragflag offset =4000 =x =0 =0 One large datagram becomes several smaller datagrams length ID fragflag offset =1500 =x =1 =0 length ID fragflag offset =1500 =x =1 =185 length ID fragflag offset =1040 =x =0 =370 •  reassembly 1480 bytes in data field offset = 1480/8 Network Layer 4 ­3 Network Layer 4 ­4 IP Addressing: introducJon •  IP address: 32 ­bit idenJfier for host, router interface •  interface: connecJon between host/router and physical link –  router’s typically have mulJple interfaces –  host typically has one interface –  IP addresses associated with each interface 223.1.1.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.1.3 223.1.3.27 223.1.2.1 Subnets •  IP address: –  subnet part (high order bits) –  host part (low order bits) 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.1.3 223.1.3.27 223.1.2.2 223.1.2.2 •  What’s a subnet ? –  device interfaces with same subnet part of IP address –  can physically reach each other without intervening router subnet 223.1.3.1 223.1.3.2 223.1.3.1 223.1.3.2 223.1.1.1 = 11011111 00000001 00000001 00000001 223 Network Layer network consisJng of 3 subnets 1 1 1 4 ­5 Network Layer 4 ­6 3/16/10 Subnets Recipe •  To determine the subnets, detach each interface from its host or router, creaJng islands of isolated networks. Each isolated network is called a subnet. 223.1.1.0/24 223.1.2.0/24 Subnets How many? 223.1.1.1 223.1.1.2 223.1.1.4 223.1.1.3 223.1.9.2 223.1.7.0 223.1.9.1 223.1.8.1 223.1.3.0/24 223.1.2.6 223.1.2.1 223.1.2.2 223.1.3.1 223.1.8.0 223.1.7.1 223.1.3.27 223.1.3.2 Subnet mask: /24 Network Layer 4 ­7 Network Layer 4 ­8 IP addressing: CIDR CIDR: Classless InterDomain RouJng –  subnet porJon of address of arbitrary length –  address format: a.b.c.d/x, where x is # bits in subnet porJon of address IP addresses: how to get one? Q: How does a host get IP address? •  hard ­coded by system admin in a file •  DHCP: Dynamic Host ConfiguraJon Protocol: dynamically get address from as server –  Windows: control ­panel ­>network ­>configuraJon ­ >tcp/ip ­>properJes –  UNIX: /etc/rc.config –  “plug ­and ­play” 11001000 00010111 00010000 00000000 200.23.16.0/23 Network Layer 4 ­9 Network Layer 4 ­10 subnet part host part DHCP: Dynamic Host ConfiguraJon Protocol Goal: allow host to dynamically obtain its IP address from network server when it joins network Can renew its lease on address in use Allows reuse of addresses (only hold address while connected an “on”) Support for mobile users who want to join network (more shortly) DHCP client ­server scenario A 223.1.1.1 DHCP server 223.1.2.1 DHCP overview: –  host broadcasts “DHCP discover ” msg [opJonal] –  DHCP server responds with “DHCP offer ” msg [opJonal] –  host requests IP address: “DHCP request ” msg –  DHCP server sends address: “DHCP ack” msg Network Layer 4 ­11 B 223.1.1.2 223.1.1.4 223.1.2.9 223.1.1.3 223.1.3.1 223.1.3.27 223.1.2.2 223.1.3.2 E arriving DHCP client needs address in this network Network Layer 4 ­12 3/16/10 DHCP client ­server scenario DHCP server: 223.1.2.5 DHCP discover src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0 transaction ID: 654 DHCP offer src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 654 Lifetime: 3600 secs DHCP: example DHCP DHCP DHCP DHCP arriving client DHCP UDP IP Eth Phy DHCP •  connecJng laptop needs its IP address, addr of first ­hop router, addr of DNS server: use DHCP ❒  DHCP request encapsulated in DHCP UDP IP Eth Phy DHCP DHCP DHCP DHCP UDP, encapsulated in IP, encapsulated in 802.1 Ethernet 168.1.1.1 DHCP request Jme src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs DHCP ACK src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs Network Layer 4 ­13 router (runs DHCP) ❒  Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN, received at router running DHCP server ❒  Ethernet demux’ed to IP demux’ed, UDP demux’ed to DHCP 4 ­14 Network Layer DHCP: example DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy •  DCP server formulates DHCP ACK containing client’s IP address, IP address of first ­hop router for client, name & IP address of DNS server DHCP: wireshark output (home LAN) Message type: Boot Request (1) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 (0.0.0.0) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 0.0.0.0 (0.0.0.0) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP Request Option: (61) Client identifier Length: 7; Value: 010016D323688A; Hardware type: Ethernet Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Option: (t=50,l=4) Requested IP Address = 192.168.1.101 Option: (t=12,l=5) Host Name = "nomad" Option: (55) Parameter Request List Length: 11; Value: 010F03062C2E2F1F21F92B 1 = Subnet Mask; 15 = Domain Name 3 = Router; 6 = Domain Name Server 44 = NetBIOS over TCP/IP Name Server …… request ❒  encapsulaJon of DHCP server, DHCP DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy router (runs DHCP) frame forwarded to client, demux’ing up to DHCP at client ❒  client now knows its IP address, name and IP address of DSN server, IP address of its first ­hop router Message type: Boot Reply (2) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 192.168.1.101 (192.168.1.101) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 192.168.1.1 (192.168.1.1) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP ACK Option: (t=54,l=4) Server Identifier = 192.168.1.1 Option: (t=1,l=4) Subnet Mask = 255.255.255.0 Option: (t=3,l=4) Router = 192.168.1.1 Option: (6) Domain Name Server Length: 12; Value: 445747E2445749F244574092; IP Address: 68.87.71.226; IP Address: 68.87.73.242; IP Address: 68.87.64.146 Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net." reply Network Layer 4 ­15 Network Layer 4 ­16 IP addresses: how to get one? Q: How does network get subnet part of IP addr? A: gets allocated porJon of its provider ISP’s address space ISP's block Organization 0 Organization 1 Organization 2 ... Organization 7 11001000 00010111 00010000 00000000 11001000 00010111 00010000 00000000 11001000 00010111 00010010 00000000 11001000 00010111 00010100 00000000 ….. …. 11001000 00010111 00011110 00000000 200.23.16.0/20 200.23.16.0/23 200.23.18.0/23 200.23.20.0/23 …. 200.23.30.0/23 Hierarchical addressing: route aggregaJon Hierarchical addressing allows efficient adverJsement of rouJng informaJon: OrganizaJon 0 200.23.16.0/23 OrganizaJon 1 200.23.18.0/23 OrganizaJon 2 200.23.20.0/23 OrganizaJon 7 . . . . . . Fly ­By ­Night ­ISP “Send me anything with addresses beginning 200.23.16.0/20” Internet 200.23.30.0/23 ISPs ­R ­Us “Send me anything with addresses beginning 199.31.0.0/16” 4 ­18 Network Layer 4 ­17 Network Layer 3/16/10 Hierarchical addressing: more specific routes ISPs ­R ­Us has a more specific route to OrganizaJon 1 OrganizaJon 0 IP addressing: the last word... Q: How does an ISP get block of addresses? A: ICANN: Internet CorporaJon for Assigned Names and Numbers 200.23.16.0/23 “Send me anything with addresses beginning 200.23.16.0/20” Internet OrganizaJon 2 200.23.20.0/23 OrganizaJon 7 . . . . . . Fly ­By ­Night ­ISP –  allocates addresses –  manages DNS –  assigns domain names, resolves disputes 200.23.30.0/23 ISPs ­R ­Us OrganizaJon 1 “Send me anything with addresses beginning 199.31.0.0/16 or 200.23.18.0/23” 200.23.18.0/23 Network Layer 4 ­19 Network Layer 4 ­20 NAT: Network Address TranslaJon rest of Internet local network (e.g., home network) 10.0.0/24 10.0.0.4 138.76.29.7 10.0.0.3 10.0.0.1 NAT: Network Address TranslaJon ImplementaJon: 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 desJnaJon addr. 10.0.0.2 –  remember (in NAT translaEon table) every (source IP address, port #) to (NAT IP address, new port #) translaJon 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 All datagrams leaving local network have same single source NAT IP address: 138.76.29.7, different source port numbers Datagrams with source or desJnaJon in this network have 10.0.0/24 address for source, desJnaJon (as usual) Network Layer 4 ­21 Network Layer 4 ­22 NAT: Network Address TranslaJon 2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table 2 NAT translaJon table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 …… …… 1: host 10.0.0.1 sends datagram to 128.119.40.186, 80 NAT traversal problem •  client wants to connect to server with address 10.0.0.1 –  server address 10.0.0.1 local to Client LAN (client can’t use it as desJnaJon addr) –  only one externally visible NATted address: 138.76.29.7 10.0.0.1 ? 10.0.0.4 S: 10.0.0.1, 3345 D: 128.119.40.186, 80 S: 138.76.29.7, 5001 D: 128.119.40.186, 80 1 10.0.0.4 S: 128.119.40.186, 80 D: 10.0.0.1, 3345 10.0.0.1 10.0.0.2 138.76.29.7 S: 128.119.40.186, 80 D: 138.76.29.7, 5001 4 3 3: Reply arrives dest. address: 138.76.29.7, 5001 10.0.0.3 4: NAT router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345 Network Layer 4 ­23 •  soluJon 1: staJcally configure NAT to forward incoming connecJon requests at given port to server –  e.g., (123.76.29.7, port 2500) always forwarded to 10.0.0.1 port 25000 138.76.29.7 NAT router Network Layer 4 ­24 3/16/10 NAT traversal problem •  soluJon 2: Universal Plug and Play (UPnP) Internet Gateway Device (IGD) Protocol. Allows NATted host to: 10.0.0.1 NAT traversal problem •  soluJon 3: relaying (used in Skype) IGD 10.0.0.4  learn public IP address (138.76.29.7) 138.76.29.7  add/remove port mappings (with lease Jmes) i.e., automate staJc NAT port map configuraJon –  NATed client establishes connecJon to relay –  External client connects to relay –  relay bridges packets between to connecJons 2. connecJon to relay iniJated by client Client 3. relaying established 1. connecJon to relay iniJated by NATted host 138.76.29.7 NAT router 10.0.0.1 NAT router Network Layer 4 ­25 Network Layer 4 ­26 ICMP: Internet Control Message Protocol •  used by hosts & routers to communicate network ­level informaJon –  error reporJng: unreachable host, network, port, protocol –  echo request/reply (used by ping) network ­layer “above” IP: –  ICMP msgs carried in IP datagrams ICMP message: type, code plus first 8 bytes of IP datagram causing error 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) 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 4 ­27 Traceroute and ICMP •  Source sends series of UDP segments to dest –  First has TTL =1 –  Second has TTL=2, etc. –  Unlikely port number •  •  When nth datagram arrives to nth router: –  Router discards datagram –  And sends to source an ICMP message (type 11, code 0) –  Message includes name of router& IP address •  •  When ICMP message arrives, source calculates RTT •  Traceroute does this 3 Jmes Stopping criterion •  UDP segment eventually arrives at desJnaJon host •  DesJnaJon returns ICMP “host unreachable” packet (type 3, code 3) •  When source gets this ICMP, stops. Network Layer Network Layer 4 ­28 IPv6 •  IniJal moJvaJon: 32 ­bit address space soon to be completely allocated. •  AddiJonal moJvaJon: –  header format helps speed processing/forwarding –  header changes to facilitate QoS IPv6 datagram format: –  fixed ­length 40 byte header –  no fragmentaJon allowed Network Layer 4 ­29 IPv6 Header (Cont) Priority: idenJfy priority among datagrams in flow Flow Label: idenJfy datagrams in same “flow.” (concept of“flow” not well defined). Next header: idenJfy upper layer protocol for data Network Layer 4 ­30 3/16/10 Tunneling Logical view: A IPv6 Tunneling E IPv6 B IPv6 tunnel F IPv6 Logical view: A IPv6 B IPv6 tunnel E IPv6 F IPv6 Physical view: A IPv6 B IPv6 IPv4 IPv4 E IPv6 F IPv6 Physical view: A IPv6 Flow: X Src: A Dest: F data B IPv6 C IPv4 D IPv4 E IPv6 F IPv6 Flow: X Src: A Dest: F data Src:B Dest: E Flow: X Src: A Dest: F data Src:B Dest: E Flow: X Src: A Dest: F data A ­to ­B: IPv6 Network Layer 4 ­31 B ­to ­C: IPv6 inside IPv4 Network Layer B ­to ­C: IPv6 inside IPv4 E ­to ­F: IPv6 4 ­32 Chapter 4: Network Layer •  4. 1 IntroducJon •  4.2 Virtual circuit and datagram networks •  4.3 What’s inside a router •  4.4 IP: Internet Protocol –  –  –  –  Datagram format IPv4 addressing ICMP IPv6 Interplay between rouJng, forwarding routing algorithm •  4.5 RouJng algorithms –  Link state –  Distance Vector –  Hierarchical rouJng local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 •  4.6 RouJng in the Internet –  RIP –  OSPF –  BGP value in arriving packet’s header •  4.7 Broadcast and mulJcast rouJng 0111 1 32 Network Layer 4 ­33 Network Layer 4 ­34 Graph abstracJon 5 2 Graph abstracJon: costs 5 •  c(x,x’) = cost of link (x,x’) 3 2 1 3 1 2 v 2 3 3 1 w 1 5 v w 1 u 1 Graph: G = (N,E) z 2 5  ­ e.g., c(w,z) = 5 u z 2 x y x y N = set of routers = { u, v, w, x, y, z } E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) } Remark: Graph abstracJon is useful in other network contexts Example: P2P, where N is set of peers and E is set of TCP connecJons Network Layer 4 ­35 •  cost could always be 1, or inversely related to bandwidth, or inversely related to congesJon Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp ­1,xp) QuesJon: What’s the least ­cost path between u and z ? RouJng algorithm: algorithm that finds least ­cost path Network Layer 4 ­36 3/16/10 RouJng Algorithm classificaJon Global or decentralized informaJon? Global: •  all routers have complete topology, link cost info •  “link state” algorithms Decentralized: •  router knows physically ­ connected neighbors, link costs to neighbors •  iteraJve process of computaJon, exchange of info with neighbors •  “distance vector” algorithms A Link ­State RouJng Algorithm Dijkstra’s algorithm •  net topology, link costs known to all nodes –  accomplished via “link state broadcast” –  all nodes have same info •  computes least cost paths from one node (‘source”) to all other nodes –  gives forwarding table for that node •  iteraJve: awer k iteraJons, know least cost path to k dest.’s StaJc or dynamic? StaJc: •  routes change slowly over Jme Dynamic: •  routes change more quickly –  periodic update –  in response to link cost changes NotaJon: •  c(x,y): link cost from node x to y; = ∞ if not direct neighbors path from source to dest. v •  D(v): current value of cost of •  p(v): predecessor node along path from source to v •  N': set of nodes whose least cost path definiJvely known Network Layer 4 ­37 Network Layer 4 ­38 Dijsktra’s Algorithm 1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞ 7 8 Loop 9 find w not in N' such that D(w) is a minimum 10 add w to N' 11 update D(v) for all v adjacent to w and not in N' : 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N' Network Layer 4 ­39 Dijkstra’s algorithm: example Step 0 1 2 3 4 5 N' u ux uxy uxyv uxyvw uxyvwz D(v),p(v) D(w),p(w) 2,u 5,u 2,u 4,x 2,u 3,y 3,y D(x),p(x) 1,u D(y),p(y) D(z),p(z) ∞ ∞ ∞ 2,x 4,y 4,y 4,y 5 2 v 2 3 3 1 w 1 5 u 1 z 2 4 ­40 x y Network Layer Dijkstra’s algorithm: example (2) ResulJng shortest ­path tree from u: Dijkstra’s algorithm, discussion Algorithm complexity: n nodes •  each iteraJon: need to check all nodes, w, not in N •  n(n+1)/2 comparisons: O(n2) •  more efficient implementaJons possible: O(nlogn) OscillaJons possible: •  e.g., link cost = amount of carried traffic 1 v u w z x y ResulJng forwarding table in u: desJnaJon v x y w z link (u,v) (u,x) (u,x) (u,x) (u,x) Network Layer 4 ­41 A 00 D 1 0 1+e e B 1 2+e A 1+e 1 D 0 0 B D 0 1 A 00 2+e 1+e B 2+e A 1+e 1 C e 0 D 0 e B C C 0 C iniJally … recompute rouJng … recompute … recompute 4 ­42 Network Layer ...
View Full Document

This note was uploaded on 03/21/2010 for the course CS 4457 taught by Professor Cetti during the Spring '10 term at UVA.

Ask a homework question - tutors are online