Lecture 11: Link Layer Slides derived from those available on the site of the book “Computer Networking”, by Kurose and Ross, PEARSON
A Layered Architecture application: network application protocol (messages) transport: process to process data transfer (segments) network: host to host data transfer (datagrams) link: across individual links data transfer (frames) physical: over the “wire” data transfer (bits) application transport network link physical
Terminology nodes: hosts, switches, routers global ISP nodes: hosts, switches, routers link: communication channel that connects adjacent nodes wired links wireless links frame: link-layer “packet”
Link-layer Overview global ISP Data transfer from one node to a physically adjacent node Different protocols over different links e.g., Ethernet, WiFi, frame relay Different services for each protocol e.g., over-the-link reliable data delivery
Transportation Analogy Trip from Princeton to Lausanne taxi: Princeton to JFK plane: JFK to Geneva train: Geneva to Lausanne Tourist = datagram Transport segment = link Transportation mode = link layer protocol Travel agent = routing algorithm
Hardware & Software Implementation Hardware: network adaptor (NIC) encapsulation, decapsulation link access, error detection Software: CPU addressing NIC interaction application transport network link physical cpu memory host bus (e.g., PCI) controller physical transmission network adapter
Outline Link-layer services Link-layer forwarding++ A to Z: retrieving a web page
Outline Link-layer services Link-layer forwarding++ A to Z: retrieving a web page
Link Layer Services Error detection Reliable data delivery Link access detect bit errors caused by signal attenuation, noise drop frames with bit errors Reliable data delivery error detection + correction/retransmission used for links with high-error rate (wireless) Link access how to share the same link with other nodes Flow control pacing between adjacent sending and receiving nodes
Error Detection & Correction otherwise EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking, may include header fields Error detection not 100% reliable! protocol may miss some errors, but rarely larger EDC field yields better detection and correction
Error Detection & Correction (2) Single bit parity detect single bit errors Two-dimensional bit parity detect and correct single bit errors Cyclic Redundancy Check (CRC) more powerful error-detection than parity checking widely used in practice: Ethernet, WiFi
(shared air, acoustical) Media Access Control (MAC) Point-to-point links state-of-the-art Ethernet Broadcast links (shared medium) old-fashioned Ethernet, WiFi shared wire (e.g., cabled Ethernet) shared RF (e.g., 802.11 WiFi) shared RF (satellite) humans at a cocktail party (shared air, acoustical)
MAC Protocols Given The problem An ideal multiple access protocol single shared broadcast link of rate R The problem interference = two or more simultaneous transmissions collision = node receives two or more signals at the same time An ideal multiple access protocol when only one node wants to transmit, it can send at rate R when N nodes want to transmit, each can send at average rate R/N simple, fully decentralized
MAC Protocols Classification Channel partitioning channel divided into smaller “pieces” (time slots, frequency bands) allocate one piece to each node for exclusive use Random access channel not divided, allow collisions detect and recover from collisions Taking turns nodes take turns
Efficient at high load. Inefficient at low load. Channel Partitioning TDMA: time divided in equal frames and slots 1 3 4 6-slot frame FDMA: frequency spectrum divided into frequency bands frequency bands time FDM cable Efficient at high load. Inefficient at low load.
Efficient at low load. Inefficient at high load. Random Access 1 2 3 node 1 node 2 node 3 C S E if single node - transmit at full rate R bps if N nodes - transmit at well bellow ideal R/N bps each (collisions, empty slots) Efficient at low load. Inefficient at high load.
CSMA - Carrier Sense Multiple Access Sense the channel before transmitting if channel sensed idle, transmit if channel sensed busy, defer transmission
spatial layout of nodes CSMA Collisions spatial layout of nodes Collisions can still occur due to propagation delay Collision probability depends on propagation delay
CSMA/CD - Collision Detection Sense the channel before transmitting if channel sensed idle, transmit if channel sensed busy, defer transmission If a collision is detected abort transmission defer transmission
spatial layout of nodes CSMA/CD - Collision Detection spatial layout of nodes
CSMA/CD Algorithm 1. NIC receives datagram from network layer, creates frame 2. If NIC senses channel idle, starts frame transmission. If NIC senses channel busy, waits until channel idle, then transmits. 3. If NIC transmits entire frame without detecting another transmission, NIC is done with frame! 4. If NIC detects another transmission while transmitting, aborts and sends jam signal 5. After aborting, NIC enters exponential backoff: more collisions -> longer wait interval
Taking Turns (1) Polling: master “invites” slave to transmit Main concerns polling overhead single point of failure (master) data poll master data slaves
Taking Turns (2) Token passing: control token passed from one node to the next sequentially Main concerns token overhead single point of failure (token) T (nothing to send) T data
MAC Protocols Channel partitioning Random access Taking turns efficient at high load inefficient at low load Random access efficient at low load inefficient at high load (due to collisions) Taking turns look for best of both worlds single point of failure
Outline Link-layer services Link-layer forwarding++ A to Z: retrieving a web page
MAC Addresses Used to move frames between link-layer nodes one address per NIC Format: 48 bit address, flat usually shown in hexadecimal format 1A-2F-BB-76-09-AD 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 71-65-F7-2B-08-53 LAN
Address Resolution Protocol (ARP) Question: - How to determine interface’s MAC address, knowing its IP address? 1A-2F-BB-76-09-AD 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 71-65-F7-2B-08-53 LAN 137.196.7.23 137.196.7.78 137.196.7.14 137.196.7.88 Answer: - Source broadcasts request for destination’s MAC address - Stores response in local ARP table < IP address; MAC address; TTL>
Ethernet The dominant wired LAN technology First widely used LAN technology Simpler, cheaper than token LANs and ATM Kept up with speed race: 10 Mbps – 100 Gbps
Ethernet Services Connectionless Unreliable MAC protocol no handshaking between sending and receiving NICs Unreliable receiving NIC does not send ACKs or NACKs to sending NIC recover dropped frames only if sender uses higher layer “rdt” (TCP) MAC protocol CSMA/CD with exponential backoff
Ethernet Frame Structure Sending adapter encapsulates datagram in Ethernet frame preamble: 7 x 10101010 followed by 1 x 10101011 synchronize sender, receiver clock rates addresses: 48 bit source, source/destination MAC address receive frame only if destination matches or broadcast type: indicates higher layer protocol mostly IP, others possible CRC: cyclic redundancy check at receiver dest. address source data (payload) CRC preamble type
Ethernet Physical Topology bus: popular in the mid 90s all nodes in same collision domain (frames can collide) star: prevails today active switch in the middle - each “spoke” in a separate collision domain (no collisions) switch bus star
Link-layer Switch Forwards frames within LAN Self-learning determines output port based on destination MAC address similar to router forwarding process Self-learning forwarding table populated automatically no need for manual configuration or routing protocol
switch forwarding table Self-learning Source: A Dest: A’ A A’ B B’ C C’ 1 2 3 4 5 6 A A’ - frame destination A’, location unknown: flood - frame destination A, location known: selectively send on just one link A A’ A A’ A A’ A A’ A A’ A’ A MAC addr interface TTL A 1 60 switch forwarding table (initially empty) A’ 4 60
Self-learning (2) When a frame is received at the switch: 1. Record pair (source MAC address; incoming link) 2. Index forwarding table using destination MAC address 3. If entry found: - if destination on link from which frame arrived drop frame - else forward frame on link indicated by entry (else) If entry not found: - flood: forward on all links except the arriving interface
Self-learning: Interconnected Switches B S1 C Scenario: A wants to send frame to H - Question: how does S1 know to forward via S4 and S3? - Answer: self learning, exactly the same way
Switches vs. Routers Both are store-and-forward application transport network link physical Both are store-and-forward routers: network-layer devices (examine network-layer headers) switches: link-layer devices (examine link-layer headers) Both have forwarding tables routers: using routing switches: using self-learning datagram frame link physical frame switch network link physical datagram frame application transport network link physical
Forwarding to Another LAN Scenario: - A sends a datagram to B via router R - A knows IP address of B (how?) - A knows IP address of R (how?) - A knows MAC address of R (how?) R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 74-29-9C-E8-FF-55 A 222.222.222.222 49-BD-D2-C7-56-2A 222.222.222.221 88-B2-2F-54-1A-0F B
Forwarding to Another LAN - create IP datagram with source IP-A, destination IP-B - create link-layer frame with source MAC-A, destination MAC-R, frame contains A-to-B IP datagram MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B IP Eth Phy IP src: 111.111.111.111 IP dest: 222.222.222.222 R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 74-29-9C-E8-FF-55 A 222.222.222.222 49-BD-D2-C7-56-2A 222.222.222.221 88-B2-2F-54-1A-0F B
Forwarding to Another LAN - send frame from A to R - receive frame at R, extract datagram, pass it up to IP layer MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B IP src: 111.111.111.111 IP dest: 222.222.222.222 IP src: 111.111.111.111 IP dest: 222.222.222.222 IP Eth Phy IP Eth Phy R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 74-29-9C-E8-FF-55 A 222.222.222.222 49-BD-D2-C7-56-2A 222.222.222.221 88-B2-2F-54-1A-0F B
Forwarding to Another LAN - forward datagram with source IP-A, destination IP-B - create link-layer frame with source MAC-R, destination MAC-B, frame contains A-to-B IP datagram MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A IP src: 111.111.111.111 IP dest: 222.222.222.222 IP Eth Phy R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 74-29-9C-E8-FF-55 A 222.222.222.222 49-BD-D2-C7-56-2A 222.222.222.221 88-B2-2F-54-1A-0F B
Forwarding to Another LAN - send frame from R to B IP src: 111.111.111.111 IP dest: 222.222.222.222 MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A IP Eth Phy IP Eth Phy R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 74-29-9C-E8-FF-55 A 222.222.222.222 49-BD-D2-C7-56-2A 222.222.222.221 88-B2-2F-54-1A-0F B
Forwarding to Another LAN - send frame from R to B - receive frame at B, extract datagram, pass it up to IP layer MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A IP src: 111.111.111.111 IP dest: 222.222.222.222 IP Eth Phy B A R 111.111.111.111 222.222.222.222 49-BD-D2-C7-56-2A 74-29-9C-E8-FF-55 222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.110 E6-E9-00-17-BB-4B 111.111.111.112 222.222.222.221 CC-49-DE-D0-AB-7D 88-B2-2F-54-1A-0F
Outline Link-layer services Link-layer forwarding++ A to Z: retrieving a web page
Synthesis - A day in the life of a web request application transport network link physical scenario: - attach laptop to campus network - request/receive www.google.com page goal: - review the protocols involved at all layers
A day in the life… scenario browser DNS server Comcast network 68.80.0.0/13 school network 68.80.2.0/24 web page web server Google’s network 64.233.160.0/19 64.233.169.105
… connecting to the Internet (1) DHCP UDP IP Eth Phy DHCP DHCP Laptop uses DHCP to get: - IP address, subnet mask - IP address of first-hop router - IP address of DNS server router (runs DHCP) DHCP DHCP discovery message - encapsulated in UDP - encapsulated in IP - encapsulated in Ethernet DHCP DHCP UDP IP Eth Phy DHCP Ethernet frame broadcast on LAN - destination MAC: 0xffffffffffff - received by DHCP server (running on the router)
… connecting to the Internet (2) DHCP DHCP UDP IP Eth Phy router (runs DHCP) - DHCP server and laptop exchange -offer -request -acknowledgement DHCP UDP IP Eth Phy DHCP DHCP DHCP Laptop has IP address, knows IP address of the first-hop router and a DNS server
Laptop knows MAC address of the first-hop router … L2 learning DNS UDP IP Eth Phy DNS - Laptop uses DNS to get the IP address for www.google.com router (runs DHCP) ARP ARP query - DNS query -encapsulated in UDP -encapsulated in IP -encapsulated in.. ooops! - Laptop needs to get the MAC address of the first-hop router Eth Phy ARP ARP reply - ARP request broadcasted on LAN, received at first-hop router - Router sends ARP response back Laptop knows MAC address of the first-hop router
Laptop knows IP address of www.google.com … L3 learning DNS UDP IP Eth Phy DNS DNS server DNS UDP IP Eth Phy DNS router (runs DHCP) DNS DNS DNS DNS Comcast network 68.80.0.0/13 - DNS query (IP datagram) forwarded to first-hop router via switch - DNS query (IP datagram) forwarded to Comcast network, DNS server - DNS server sends DNS response back to laptop Laptop knows IP address of www.google.com
TCP connection established … TCP connection setup HTTP HTTP TCP IP Eth Phy router (runs DHCP) SYN SYNACK SYN - Web browser process opens TCP socket TCP IP Eth Phy - Sends SYN segment SYN SYNACK - Web server responds with SYNACK segment SYNACK web server 64.233.169.105 TCP connection established
Web page is finally displayed! … HTTP request/reply HTTP HTTP HTTP TCP IP Eth Phy router (runs DHCP) HTTP HTTP - Web browser sends HTTP request to web server HTTP TCP IP Eth Phy HTTP - Web server sends HTTP reply to web client (the web page) HTTP web server 64.233.169.105 Web page is finally displayed!