Chapter 5 Link Layer and LANs

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. Thanks and enjoy! JFK/KWR All material copyright 1996-2010 J.F Kurose and K.W. Ross, All Rights Reserved Data Link Layer 5-1

Computer Networking: A Top Down Approach

5th edition. Jim Kurose, Keith Ross Addison-Wesley, April 2009.

Chapter 5: The Data Link Layer
Our goals:

understand principles behind data link layer services:
 error detection and correction (… by the receiver)

 link access by sharing a broadcast channel: multiple access
• Instruct the hardware (PHY layer) when to transmit (… MAC protocols)

 link layer addressing  reliable data transfer, flow control

implementation of various link layer technologies
Data Link Layer 5-2

Link Layer
5.1 Introduction and 5.6 Link-layer switches services 5.7 PPP (Point-to-Point Protocol) 5.2 Error detection and 5.8 Link virtualization: MPLS correction (Multi-protocol Label Switching) 5.3Multiple access protocols New: WiFi 5.9 A day in the life of a web request (dropped: NOT 5.4 Link-layer Addressing meaningful in bottom/up 5.5 Ethernet approach to understanding networking) 3.4 New: Reliable data transfer + flow control
Data Link Layer 5-3

Link Layer: Introduction Terminology:   hosts and routers are nodes communication channels that connect adjacent nodes are links  wired links  wireless links  LANs  layer-2 packet is a frame. encapsulates datagram (from net layer) data-link layer has responsibility of transferring datagram from one node to physically adjacent node over a link Data Link Layer 5-4 .

g. may or may not provide reliable data transfer over link     tourist = datagram transport segment = communication link transportation mode = link layer protocol travel agent = routing algorithm Data Link Layer 5-5 .g.11 on last link transportation analogy  trip from Princeton to Lausanne  limo: Princeton to JFK  plane: JFK to Geneva  train: Geneva to Lausanne  each link protocol provides different services  e. 802. Ethernet on first link.Link layer: context  datagram transferred by different link protocols over different links:  e.. frame relay on intermediate links..

Link Layer Services

framing, link access:
 encapsulate datagram into frame, adding header, trailer  channel access if shared medium (a.k.a. broadcast medium)  “MAC” addresses used in frame headers to identify source, dest • different from IP address!

reliable delivery between adjacent nodes

 we learned how to do this already (ch. 3)! (Will do it in this ch.)  seldom used on low bit-error link (fiber, some twisted pair)  wireless links: high error rates
• Q.: Why both link-level and end-to-end reliability?

Data Link Layer


Link Layer Services (more)

flow control:
 pacing between (adjacent) sending and receiving nodes

error detection:
 errors caused by signal attenuation and noise  receiver detects presence of errors

error correction:
 receiver identifies and corrects bit error(s) without resorting to retransmission  receiver signals sender for retransmission
 with half duplex, nodes at both ends of link can transmit, but not at the same time
Data Link Layer 5-7

half-duplex and full-duplex

Where is the link layer implemented?

in each and every host link layer implemented in “adaptor” (aka network interface card NIC)
 Ethernet card, PCMCI card, 802.11 card  implements link, physical layer

host schematic application transport network link



attaches into host’s system buses combination of hardware, software, firmware

controller link physical physical transmission

host bus (e.g., PCI)

network adapter card

Data Link Layer


passes to upper layer at receiving side Data Link Layer 5-9 . rdt. rdt.Adaptors Communicating datagram controller datagram controller sending host datagram receiving host frame  sending side:  encapsulates datagram in frame  adds error checking bits. flow control.  receiving side  looks for errors. etc. flow control. etc  extracts datagram.

2 Error detection and correction 5.4 Reliable data transfer Data Link Layer 5-10 .6 Link-layer switches 5.8 Link virtualization: MPLS 5.Link Layer 5.4 Link-layer Addressing 5.5 Ethernet 5.1 Introduction and services 5.9 A day in the life of a web request 3.3Multiple access protocols 5.7 PPP 5.

may include header fields • Error detection not 100% reliable! • protocol may miss some errors.Error Detection EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking. but rarely • larger EDC field yields better detection and correction otherwise Data Link Layer 5-11 .

Parity Checking Single Bit Parity: Detect single bit errors Two Dimensional Bit Parity: Detect and correct single bit errors 0 0 Data Link Layer 5-12 .

Just wait.Internet checksum (review. details in Transport Layer ….error detected  YES . flipped bits) in transmitted packet (note: used at transport layer only) Sender:    treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into UDP checksum field Receiver:  compute checksum of received segment  check if computed checksum equals checksum field value:  NO . But maybe errors nonetheless? Data Link Layer 5-13 .) Goal: detect “errors” ( error detected.g..

such that  <D. D.Checksumming: Cyclic Redundancy Check    view data bits.11 WiFi. as a binary number choose r+1 bit pattern (generator). ATM) Data Link Layer 5-14 .R> by G. If non-zero remainder: error detected! can detect all burst errors less than r+1 bits widely used in practice (Ethernet.R> exactly divisible by G (modulo 2)  zero remainder    receiver knows G:  Divides <D. G goal: choose r CRC bits. R. 802.

CRC Example: Want: D.2r G ] Data Link Layer 5-15 . G = 1001 equivalently: equivalently: D.2r by G. r = 3.2r = nG XOR R if we divide D.2r XOR R = nG D = 101110. we get remainder R R = remainder[ D.

Process: Calculation of CRC If the input bit above the leftmost divisor bit is 1. The divisor is then shifted one bit to the right () The process is repeated until the divisor reaches the right-hand end of the input row.2r 1011 10 000 1001 -----------------0 0 1 0 10 0 0 0 1 00 1 -----------------0 0 1 0 10 0 0 0 1 0 01 -----------------0 0 0 0 11 0 0 0 1 00 1 -----------------0 0 0 0 11 0 0 0 10 0 1 -----------------0 0 0 0 01 0 1 0 1 001 -----------------0 0 0 0 00 0 1 1 R Data Link Layer 5-16 . Input: Divisor: G Align input and divisor on MSB D. the divisor is XORed into the input. Else (the input bit above the leftmost divisor bit is 0) do nothing.

Link Layer 5.3Multiple access protocols 5.4 Link-layer Addressing 5.6 Link-layer switches 5.2 Error detection and correction 5.7 PPP 5.5 Ethernet 5.8 Link virtualization: MPLS 5.1 Introduction and services 5.9 A day in the life of a web request Data Link Layer 5-17 .

acoustical) Data Link Layer 5-18 .. cabled Ethernet) shared RF (e.g..Multiple Access Links and Protocols Two types of “links”:  point-to-point  PPP for dial-up access  point-to-point link between Ethernet switch and host  broadcast (shared wire or medium)  old-fashioned Ethernet  upstream HFC  802. 802.11 WiFi) shared RF (satellite) humans at a cocktail party (shared air.11 wireless LAN shared wire (e.g.

determine when a node can transmit communication about channel sharing must use channel itself!  no separate control channel for coordination Data Link Layer 5-19 .e..Multiple Access protocols   single shared broadcast channel two or more simultaneous transmissions by nodes: interference  collision if node receives two or more signals at the same time multiple access protocol   distributed algorithm that determines how nodes share channel. i.

Packet Collision Link/MAC PHY Rx + data Tx Link/MAC PHY Link/MAC PHY data Tx 20 .

simple Data Link Layer 5-21 .Ideal Multiple Access Protocol Broadcast channel of rate R bps 1. 2. when one node wants to transmit. slots 4. each can send at average rate R/M 3. it can send at rate R. when M nodes want to transmit. fully decentralized:  no special node to coordinate transmissions  no synchronization of clocks.

allow collisions  “recover” from collisions  “Taking turns”  nodes take turns Data Link Layer 5-22 . code)  allocate piece to node for exclusive use  Random Access  channel not divided. frequency.MAC Protocols: a taxonomy Three broad classes:  Channel Partitioning (Commonly done in cellular networks)  divide channel into smaller “pieces” (time slots.

3.6 idle 6-slot frame 1 3 4 1 3 4 Data Link Layer 5-23 . slots 2.4 have pkt.5. 1.Channel Partitioning MAC protocols: TDMA TDMA: time division multiple access     access to channel in "rounds" each station gets fixed length slot (length = pkt trans time) in each round unused slots go idle example: 6-station LAN.

Channel Partitioning MAC protocols: FDMA FDMA: frequency division multiple access     channel spectrum divided into frequency bands each station assigned fixed frequency band unused transmission time in frequency bands go idle example: 6-station LAN. 1.4 have pkt.6 idle frequency bands FDM cable Data Link Layer 5-24 . frequency bands 2.3.5.

 no a priori coordination among nodes (…partial exception in WiFi)   two or more transmitting nodes ➜ “collision”. CSMA/CA • CD: Collision Detection • CA: Collision Avoidance Data Link Layer 5-25 CSMA: Carrier Sense Multiple Access . via delayed retransmissions)  Examples of random access MAC protocols:  ALOHA and slotted ALOHA  CSMA/CD.g.Random Access Protocols  When node has packet to send  transmit at full channel data rate R. random access MAC protocol specifies:  how to detect collisions  how to recover from collisions (e..

Aloha Protocol Developed in the 1970s at U of Hawaii  To interconnect terminals with mainframes  LAN/ WLAN: Possible. but not used  GSM: Cell phones use this protocol to request a channel from the base stations  Two types   Pure Aloha (Continuous time)  Slotted Aloha 26 .

Pure Aloha Exponential backoff Start: i = 0 Wait TB = R*Tp Transmit Frame Start a timer T = 2*Tp + Δ R = Random(0.2i-1) No i > Kmax Yes i++ Timeout ACK received Cancel timer Success 27 Error .

t0+1] Data Link Layer 5-28 .Pure (unslotted) ALOHA    unslotted Aloha: simpler. no synchronization when frame first arrives  transmit immediately collision probability increases:  frame sent at t0 collides with other frames sent in [t0-1.

18 P(no other node transmits in [t0-1.. (1-p)N-1 = p . P(no other node transmits in [t0. (1-p)N-1 .t0] . even worse than slotted Aloha! Data Link Layer 5-29 .. = 1/(2e) = . t0+1] = p .Pure Aloha efficiency P(success by given node) = P(node transmits) . (1-p)2(N-1) … choosing optimum p and then letting n -> infty .

all nodes detect collision Operation:  when node obtains fresh frame.Slotted ALOHA Assumptions:  all frames same size  time divided into equal size slots (time to transmit 1 frame)  nodes start to transmit only at slot beginning  nodes are synchronized  if 2 or more nodes transmit in a slot. transmits in next slot  if no collision: node can send new frame in next slot  if collision: node retransmits frame in each subsequent slot with prob. p until success Data Link Layer 5-30 .

wasting slots  idle slots  nodes may be able to detect collision in less than time to transmit packet  clock synchronization Data Link Layer 5-31 .Slotted ALOHA Pros  single active node can continuously transmit at full rate of channel  highly decentralized: only slots in nodes need to be in sync  simple Cons  collisions.

take limit of Np*(1-p*)N-1 as N goes to infinity. each transmits in slot with probability p prob that given node has success in a slot = p(1-p)N-1 prob that any node has a success = Np(1-p)N-1 max efficiency: find p* that maximizes Np(1-p)N-1 for many nodes.Slotted Aloha efficiency Efficiency : long-run fraction of successful slots (many nodes. all with many frames to send)    suppose: N nodes with many   frames to send. gives: Max efficiency = 1/e = .37 At best: channel used for useful transmissions 37% of time! ! Data Link Layer 5-32 .

defer transmission human analogy: don’t interrupt others!  Data Link Layer 5-33 .CSMA (Carrier Sense Multiple Access) CSMA: listen before you transmit: If channel sensed idle: transmit entire frame  If channel sensed busy.

CSMA/CD Concepts of Carrier Sense and Collision Detection Sense voltage (V) on medium: V > Vth1  carrier is present V V > Vth2  collision Vth2 Vth1 Time MAC/ PHY Data Tx Rx Collision? Carrier? Medium 34 .

CSMA collisions collisions can still occur: propagation delay means two nodes may not hear each other’s transmission collision: note: entire packet transmission time wasted role of distance & propagation delay in determining collision probability Data Link Layer 5-35 .

CSMA/CD (Collision Detection) CSMA/CD: carrier sensing. reducing channel wastage  easy in wired LANs: measure signal strengths  difficult in wireless LANs  collision detection: Data Link Layer 5-36 . deferral as in CSMA  collisions detected within short time  colliding transmissions aborted.

2i-1) No Transmit frame WHILE detecting collision Collision i++ Send jamming signal + Abort Success 37 No collision i > Kmax Yes Error .Exponential backoff CSMA/CD Start: i = 0 Sense medium Wait TB = R*Tp Busy N Y Wait R = Random(0.

38 .CSMA/CD  Medium sensing is done for 96 bit-times.  Tp is equated with 512 bit-times.  Jamming signal length is 48 bits. Jamming signal creates enough energy on the medium for collision detection.  “i” saturates at 10.

CSMA/CD collision detection Data Link Layer 5-39 .

1/N bandwidth allocated even if only 1 active node! random access MAC protocols  efficient at low load: single node can fully utilize channel  high load: collision overhead “taking turns” protocols look for best of both worlds! Data Link Layer 5-40 .“Taking Turns” MAC protocols channel partitioning MAC protocols:  share channel efficiently and fairly at high load  inefficient at low load: delay in channel access.

“Taking Turns” MAC protocols Polling:  master node “invites” slave nodes to transmit in turn  typically used with “dumb” slave devices  concerns:  polling overhead  latency  single point of failure (master) data poll master data slaves Data Link Layer 5-41 .

“Taking Turns” MAC protocols Token passing:  control token passed from one node to next sequentially.  token message  concerns:  token overhead  latency  single point of failure (token) T (nothing to send) T data Data Link Layer 5-42 .

11/a/b/g 43 .Wireless LAN IEEE 802.

WLAN View C: Computer.11 protocol C Access Point C Radio range of the AP Basic Service Set (BSS): BSSID = MAC address of AP Independent BSS (IBSS)= BSS .AP Extended Service Set (ESS): A collection of BSS connected by a Distribution System 44 . AP: Access Point IEEE 802.

11g 802.4 GHz 2.11/a/b/g/n Family IEEE 802.4 GHz 2.11 802.11b 802.11n 802.5 and 11 22 and 54 72 and 150 6.9 Gbps 45 .IEEE 802.11ac (Draft/Nov.4 GHz 2.4/5 GHz 5 GHz Rate (Mbps) 1 and 2 1 and 2 6--54 5. 2011) Technique DSSS FHSS OFDM DSSS OFDM OFDM OFDM Frequency Band 2.4 GHz 5 GHz 2.11a 802.

11 MAC Distributed Coordination Function (DCF) Point Coordination Function mode (PCF) mode With Hand-shake Without Hand-shake 46 .11 Modes of IEEE 802.Different Modes of Operation of MAC in IEEE 802.

• Can follow a round-robin policy to allocate slots. 47 . Note: There is no contention for medium access. • Decides who transmits and when. • Is optional <= Spec.  This mode • Can support real-time traffic due to periodic scheduling.PCF Mode: Optional  The AP • Operates as the central controller for all nodes within its range. • Leads to waste of bandwidth if a scheduled node has no traffic.

 In DCF  All nodes. compete for medium access. including the AP.  Delivery is best effort 48 . • Computers can directly communicate among themselves <= Ad hoc.DCF Mode: Mandatory  An AP  Need not be used.  Is used to provide connectivity to the Internet.  The AP does not operate as a central controller.

Alternating use of PCF and DCF  The WLAN operates • In the PCF mode for T1 seconds – Bandwidth guarantee for some nodes • In the DCF mode for T2 seconds – Nodes with additional traffic can contend for a share of the bandwidth PCF T1 DCF T2 PCF T3 DCF T4 PCF DCF Time 49 .

 called hand-shake  Hand-shake mechanism  • Sender transmits a Request To Send (RTS) frame • Receiver gives permission by sending back a Clear To Send (CTS) frame • Used to increase the probability of successful Tx when – Packet length is long.) • Incurs additional cost – loss of some bandwidth due to hand-shake 50 .DCF with hand-shake A sender obtains permission from the receiver before transmitting a data frame. ( dotRTSThreshold holds the value.

DCF with and without hand-shake  The two modes are not mutually exclusive. • A node decides what mode to use on a frame/frame basis. • The MAC management database contains a variable – dotRTSThreshold: integer in bytes – Length of a data frame >= dotRTSThreshold » Use hand-shake – Length of a data frame < dotRTSThreshold » Do not use hand-shake DCF PCF PCF DCF PCF No hand-shake Mode of operation of the same node Hand-shake 51 } .

• To follow …  When data frames are short  Use this to save bandwidth 52 .  • There is no prior coordination between sender and receiver  A sender transmits a frame  when some medium sensing conditions are satisfied.  RTS/CTS mechanism is NOT used.DCF without hand-shake A sender does not obtain permission from the receiver before transmitting a data frame.

Problems in WLAN Hidden Terminal Problem  Exposed Terminal Problem  Inability to detect collision (at the receiver)   Assumption  All nodes have identical radio ranges • how far away their signals can be received  Note  The assumption is not the cause of the problems.  Without this assumption. 53 . the problems become worse.

. .C is transmitting a frame to B.Hidden Terminal Problem A D B C • Problem . if A transmits. A’s Tx will collide with C’s at B The above problem is due to C being hidden from A.A is unaware of C’s Tx. • Hidden means being “far away” … 54 • .Now.

Exposed Terminal Problem A D B C Tx • Problem . .A is transmitting a frame to D.B knows that someone is transmitting. However. B does not transmit because it is unaware of D’s location. 55 • .If B transmits a frame to C. . no problem. The above problem is due to B being exposed to A’s Tx.

• That is why we have the hidden terminal problem. collision detection by sender is not possible.  Collision is avoided (CA). rather than detected … 56 .  In a wired LAN   Collision is indirectly detected after some delay by the sender.  In a WLAN.No collision detection Fact: Collision at receiver is more serious than collision at transmitter.

DATA • A duration field in frame headers indicates – for how long the sender of the frame may use the medium. CTS. CTS: Clear to Send)  In CSMA/CA. • A Network Allocation Vector is managed using duration fields – Each node has its own NAV (essentially an integer) – NAV > 0: A node had announced its intention to use the medium now.WLAN MAC: CSMA/CA  (RTS: Request to Send. – NAV = 0: Nobody had wanted to use the medium now.  Transmit condition: When medium is idle (Carrier is absent) AND (NAV = 0) 57 . collision is avoided using  PHY-level carrier sensing: Done in receiver hardware  Virtual carrier sensing: Done by examining frame header • Frame headers of RTS.

duration) • NAV = NAV – 1 • Stop decrementing if NAV = 0.  58 .NAV Update Mechanism  Each node has its own NAV.  Initially: NAV = 0.  With each passing μs (micro second)  NAV is updated using the duration field in a received frame • NAV = Max(NAV. Procedure to update NAV  NAV is the length of time for which the medium is likely to remain busy.

RTS and CTS Frames  Frame format RTS Frame Duration Control 2 2 RA 6 TA 6 FCS 4 bytes CTS/ ACK Frame Duration Control 2 2 RA 6 4 FCS bytes FCS: RA: TA: Frame Check Sequence Receiver Address Transmitter Address  CRC 59 .

TA RA 60 .DATA Frame  Frame format Frame Duration/ Control ID A1 A2 A3 Seq. Control A4 Frame Body FCS RA TA TA: Physically transmitting the frame.

11 MAC defines 4 timing intervals  2 at the PHY level • SIFS: Short Inter-Frame Space • aSlot (10 micro-sec) (20 micro-sec) (SIFS + aSlot) (PIFS + aSlot)  2 at the MAC level • PIFS: Priority (in PCF) IFS • DIFS: Distributed IFS Note: aSlot is chosen s. 61 . a station is capable of determining if another station initiated a Tx at the beginning of the previous slot.t.Timing Intervals  The IEEE 802.

Hand-shake using RTS/CTS Value of “duration” in RTS A data DIFS RTS SIFS DATA Value of “duration” in CTS B C (neighbor of A) D (neighbor of B) SIFS CTS SIFS ACK Value of NAV of C Value of NAV of D Time 62 .

CW = CWmin No NAV =0? Yes Medium idle for DIFS? No End of backoff Random Backoff Yes Send RTS Start a timer CTS is received Cancel timer Timeout Send DATA (F) Start a timer ACK is received Timeout i = i+1 CW = CWmin*2i (At some point.DCF with Hand-shake: Tx F: a new data frame to be transmitted i = 0.) 63 . CW saturates at CWmax.

• Subsequent decrementing is done for every aSlotTime of idleness of the medium. BTC is decremented as follows  BTC = BTC -1 if medium is idle for aSlotTime  Pause decrementing BTC if medium is busy  Resume decrementing BTC if medium is idle for DIFS.CW-1) • The time unit of BTC is aSlotTime • aSlotTime: propagation + transceiver switching time  As time passes.Backoff Mechanism  Initialize a counter: Backoff Time Counter (BTC)  BTC = Random(0. 64 .

Backoff Mechanism
Ch. busy due to node A Ch. Busy due to node C






DIFS 3 3


BTC = 5







B is executing backoff
X = aSlotTime


DCF with Hand-shake: Rx

Receive RTS

Receive DATA frame Send data to upper layer

NAV = 0? Yes

Medium idle for SIFS?


Medium idle for SIFS?



Send ACK

Send CTS

Note: The above two fragments of flow-charts can be easily merged.


DCF Mode without Hand-shake

A special case of DCF with hand-shake
 RTS/CTS frames are not exchanged.

The idea of NAV is still used in this mode
 All nodes process the received RTS/CTS of others
Without handshake RTS/CTS

This must process received RTS/CTS

NOTE: A node may broadcast a DATA frame to all  Done in DCF without hand-shake  Receivers do not send back an ACK.

• SIFS < PIFS < DIFS • You know that – PIFS = SIFS + aSlotTime – DIFS = SIFS + 2*aSlotTime  If the medium is idle for PIFS. transmit a beacon frame – Beacon contains a CFPMaxDuration field – Nodes receiving a beacon update their NAV to CFPMaxDuration » These nodes perceive the medium to be busy for CFPMaxDuration 68 .PCF Mode: AP becomes the controller AP alternates between PCF and DCF modes  AP operates as the controller as follows   AP senses the medium at the start of a CF (ContentionFree) period for a PIFS (Priority IFS) interval.

)  After transmitting a beacon.PCF Mode of Operation (Contd. AP waits for SIFS before transmitting one of the following • • • • • DATA frame CF Poll frame DATA+CF Poll frame ACK frame CF End frame 69 .

) CF Poll frame AP User 1 CF Poll SIFS User 2 AP User 1 CF Poll SIFS DATA SIFS SIFS DATA ACK ACK Time The polled user sends data to another user.PCF Mode of Operation (Contd. 70 . The polled user sends data to the AP.

71 .PCF Mode of Operation (Contd. Note 2: If User 1 does not receive ACK.) DATA + CF Poll frame AP User 1 User 2 DATA+CF Poll SIFS ACK DATA ACK SIFS Note 1: If AP does not receive an ACK. it does not retransmit data. it retransmits data after PIFS. The polled user receives data from the AP and sends data to another user.

72 .  The receiver sends back an ACK after SIFS interval.  AP does not receive an ACK • Retransmit the DATA after a PIFS interval  AP can broadcast a DATA frame • These are not ACKed.)  DATA frame  Contains user data from AP to a specific station.PCF Mode of Operation (Contd.

 Receiver of DATA frame sends an ACK to the sender.)  CF Poll frame  AP grants permission to another node to transmit DATA to the AP or to a third node. 73 . it can not retransmit its data frame until it is polled again. it sends a null DATA frame.  If the polled station does not receive an ACK.PCF Mode of Operation (Contd.  If the polled node has no data to send.

)  CF End frame  Identifies the end of CF period  Sent by an AP under two conditions • AP has no data to send and no node to poll – Can happen before the pre-announced CFPMaxDuration – Receiving nodes set NAV = 0. • Normal end of CF period – (Initially: CFPDurRemaining = CFPMaxDuration) – CFPDurRemaining time expires 74 .PCF Mode of Operation (Contd.

A node joining a WLAN with an AP (No need for such a procedure in a wired LAN)  Two ways for a node to join a WLAN   Passive scanning • Scan a channel for a Beacon frame • If a Beacon frame is received – Negotiate Authentication and Association processes  Active Scanning • Transmit a Probe frame • If a Probe Response is received – Negotiate Authentication and Authorization processes 75 .

Summary of MAC protocols   channel partitioning by time. Code Division ALOHA. Data Interface). Frequency Division.      Time Division. IBM Token Ring Bluetooth piconet master Up to 7 slaves Data Link Layer 5-76 . CSMA/CD carrier sensing: easy in some technologies (wire). hard in wireless CSMA/CD used in Ethernet CSMA/CA used in 802. FDDI (Fibre Dist. S-ALOHA. token passing  Bluetooth. frequency or code random access (dynamic).11  taking turns  polling from central site.

4 Reliable data transfer Data Link Layer 5-77 .5 Ethernet 5.7 PPP 5.4 Link-Layer Addressing 5.3Multiple access protocols 5.8 Link virtualization: MPLS 5.Link Layer 5.2 Error detection and correction 5.1 Introduction and services 5.9 A day in the life of a web request 3.6 Link-layer switches 5.

)  network-layer address  used to get datagram to destination IP subnet  MAC (or LAN or physical or Ethernet) address:  function: get frame from one interface to another physically-connected interface (same network)  48 bit MAC address (for most LANs) • burned in NIC ROM. also sometimes software settable Data Link Layer 5-78 .MAC Addresses and ARP  (Address Resolution Protocol) 32-bit IP address: (for comparison only ….

Need for knowing MAC address RIP BGP OSPF UDP TCP ICMP Network layer Routing Table IP Link1 Link2 Link3 Link4 PHY1 PHY2 PHY3 PHY4 2 1 3 4 OSPF: Open Shortest Path First BGP: Border Gateway Protocol RIP: Routing Information Protocol TCP: Transmission Control Protocol UDP: User Datagram Protocol ICMP: Internet Control Message Protocol 79 .

LAN Addresses and ARP Each adapter on LAN has unique LAN address 1A-2F-BB-76-09-AD Broadcast address = FF-FF-FF-FF-FF-FF 71-65-F7-2B-08-53 LAN (wired or wireless) 58-23-D7-FA-20-B0 = adapter 0C-C4-11-6F-E3-98 Data Link Layer 5-80 .

LAN   Address (more) MAC address allocation administered by IEEE manufacturer buys portion of MAC address space (to assure uniqueness) MAC flat address ➜ portability  can move LAN card from one LAN to another   (IP hierarchical address NOT portable)  address depends on IP subnet to which node is attached Data Link Layer 5-81 .

14 LAN 71-65-F7-2B-08-53 58-23-D7-FA-20-B0 TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) 137. router) on LAN has ARP table ARP table: IP/MAC addr.7.196.23 137.7.78 1A-2F-BB-76-09-AD 137.7. TTL>   137.196. mappings for some LAN nodes < IP address.88 0C-C4-11-6F-E3-98 Data Link Layer 5-82 .7.196. MAC address.ARP: Address Resolution Protocol Question: how to determine B’s MAC address knowing B’s IP address?  Each IP node (host.196.

and B’s MAC address not in A’s ARP table.ARP protocol: Same LAN (network)    A wants to send datagram to B. A broadcasts ARP query packet. containing B's IP address  dest MAC address = FF-FF-FF-FF-FF-FF  all machines on LAN receive ARP query B receives ARP query. replies to A with its (B's) MAC address  frame sent to A’s MAC address (unicast)  A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)  soft state: information that times out (goes away) unless refreshed  ARP is “plug-and-play”:  nodes create their ARP tables without intervention from net administrator Data Link Layer 5-83 .

222.222. R (how?)  assume A knows MAC address of first hop router interface (how?) A 49-BD-D2-C7-56-2A 222.220 1A-23-F9-CD-06-9B 111.  focus on addressing .222.Addressing: routing to another LAN walkthrough: send datagram from A to B via both IP (datagram) and MAC layer (frame)  assume A knows B’s IP address  assume A knows B’s MAC address (how?)  assume A knows IP address of first hop router.221 88-B2-2F-54-1A-0F Data Link Layer 5-84 .222.111.110 E6-E9-00-17-BB-4B B 222.112 CC-49-DE-D0-AB-7D 111.111.111 74-29-9C-E8-FF-55 R 222.111.111.

221 88-B2-2F-54-1A-0F Data Link Layer 5-85 .222 IP Eth Phy A 111.111 74-29-9C-E8-FF-55 R 1A-23-F9-CD-06-9B 111.111 IP dest: 222.111.110 E6-E9-00-17-BB-4B B CC-49-DE-D0-AB-7D 111. destination B A creates link-layer frame with R's MAC address as dest.111.111. frame contains A-to-B IP datagram MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B IP src: routing to another LAN   A creates IP datagram with IP source A.222 49-BD-D2-C7-56-2A 222.222.

111.222 IP Eth Phy IP Eth Phy A 111.111.222.Addressing: routing to another LAN   frame sent from A to R frame received at R.112 CC-49-DE-D0-AB-7D 111. passed up to IP MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B IP src: 111.222 49-BD-D2-C7-56-2A 88-B2-2F-54-1A-0F Data Link Layer 5-86 .111 74-29-9C-E8-FF-55 R datagram removed.111.111 IP dest: E6-E9-00-17-BB-4B B 1A-23-F9-CD-06-9B 111.

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.222 49-BD-D2-C7-56-2A E6-E9-00-17-BB-4B B 222.221 88-B2-2F-54-1A-0F Data Link Layer 5-87 . IP Eth Phy IP Eth Phy A 111.Addressing: routing to another LAN   R forwards datagram with IP source A.112 CC-49-DE-D0-AB-7D 1A-23-F9-CD-06-9B 111. destination B R creates link-layer frame with B's MAC address as dest.222.111 IP dest: 222.111 74-29-9C-E8-FF-55 R 222.222.222.

222.222.112 CC-49-DE-D0-AB-7D 111.110 E6-E9-00-17-BB-4B B 222.111.Addressing: routing to another LAN   R forwards datagram with IP source A.111 74-29-9C-E8-FF-55 R 222.220 1A-23-F9-CD-06-9B destination B R creates link-layer frame with B's MAC address as dest. 49-BD-D2-C7-56-2A 222.111 IP dest: 222.222. 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.221 88-B2-2F-54-1A-0F Data Link Layer 5-88 .222.222 IP Eth Phy IP Eth Phy A 111.111.

111.112 CC-49-DE-D0-AB-7D 111.111.220 1A-23-F9-CD-06-9B IP dest: E6-E9-00-17-BB-4B B 88-B2-2F-54-1A-0F Data Link Layer 5-89 .111 74-29-9C-E8-FF-55 R 222. destination B R creates link-layer frame with B's MAC address as dest.Addressing: routing to another LAN   R forwards datagram with IP source A.111. 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.222 IP Eth Phy A 49-BD-D2-C7-56-2A 222.

5 Ethernet 5.Link Layer 5.9 A day in the life of a web request Data Link Layer 5-90 .8 Link virtualization: MPLS 5.1 Introduction and services 5.3Multiple access protocols 5.2 Error detection and correction 5.7 PPP 5.6 Link-layer switches 5.4 Link-Layer Addressing 5.

Ethernet “dominant” wired LAN technology:  cheap $20 for NIC  first widely used LAN technology  simpler. cheaper than token LANs and ATM  kept up with speed race: 10 Mbps – 10 Gbps Metcalfe’s Ethernet sketch Data Link Layer 5-91 .

Star topology  bus topology popular through mid 90s  today: star topology prevails  all nodes in same collision domain (can collide with each other)  active switch in center  each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with each other) switch bus: coaxial cable star Data Link Layer 5-92 .

sender clock rates Data Link Layer 5-93 .Ethernet Frame Structure Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble:  7 bytes with pattern 10101010 followed by one byte with pattern 10101011  used to synchronize receiver.

it passes data in frame to network layer protocol  otherwise.g. frame is dropped Data Link Layer 5-94 . ARP packet). e.g. if error is detected.. Novell IPX.Ethernet Frame Structure (more)  Addresses: 6 bytes  if adapter receives frame with matching destination address. adapter discards frame   Type: indicates higher layer protocol (mostly IP but others possible. or with broadcast address (e. AppleTalk) CRC: checked at receiver.

connectionless   connectionless: No handshaking between sending and receiving NICs unreliable: receiving NIC doesn’t send acks or nacks to sending NIC  stream of datagrams passed to network layer can have gaps (missing datagrams)  gaps will be filled if app is using TCP  otherwise. app will see gaps  Ethernet’s MAC protocol: unslotted CSMA/CD Data Link Layer 5-95 .Ethernet: Unreliable.

If NIC transmits entire {0.1. After aborting. If NIC detects another from network layer. NIC If NIC senses channel enters exponential busy. then transmits collision.Ethernet CSMA/CD algorithm 1. 5. NIC Step 2 is done with frame ! Data Link Layer 5-96 . starts frame transmission. returns to another transmission. NIC waits frame without detecting K·512 bit times. transmission while creates frame transmitting. If NIC senses channel idle. waits until channel backoff: after mth idle. NIC receives datagram 4. aborts and sends jam signal 2. NIC chooses K at random from 3.2.2m-1}.….

Ethernet’s CSMA/CD (more) Jam Signal: make sure all other transmitters are aware of collision. for K=1023. delay is K· 512 bit transmission times  after second collision: choose K from {…. 48 bits Bit time: .3.1023} See/interact with Java applet on AWL Web site: highly recommended ! Data Link Layer 5-97 .3}…  after ten collisions.1 microsec for 10 Mbps Ethernet .1.1}. choose K from {0.4. wait time is about 50 msec Exponential Backoff:  Goal: adapt retransmission attempts to estimated current load  heavy load: random wait will be longer  first collision: choose K from {0.

CSMA/CD efficiency   Tprop = max prop delay between 2 nodes in LAN ttrans = time to transmit max-size frame efficiency   1 1  5t prop/ttrans efficiency goes to 1 better performance than ALOHA: and simple. decentralized! Data Link Layer 5-98  as tprop goes to 0  as ttrans goes to infinity  . cheap.

100 Mbps.802. 1Gbps. 10 Mbps. 10G bps  different physical layer media: fiber.3 Ethernet Standards: Link & Physical Layers  many different Ethernet standards  common MAC protocol and frame format  different speeds: 2 Mbps. cable application transport network link physical MAC protocol and frame format 100BASE-TX 100BASE-T4 100BASE-T2 100BASE-SX 100BASE-FX 100BASE-BX copper (twister pair) physical layer fiber physical layer Data Link Layer 5-99 .

global clock among nodes!  Hey.Manchester encoding    used in 10BaseT each bit has a transition allows clocks in sending and receiving nodes to synchronize to each other  no need for a centralized. this is physical-layer stuff! Data Link Layer5-100 .

9 A day in the life of a web request Data Link Layer5-101 .7 PPP 5.1 Introduction and services 5. LANs.2 Error detection and correction 5.3 Multiple access protocols 5. VLANs 5.8 Link virtualization: MPLS 5.4 Link-layer Addressing 5.6 Link-layer switches.Link Layer 5.5 Ethernet 5.

Hubs … physical-layer (“dumb”) repeaters:  bits coming in on one link go out all other links at same rate  all nodes connected to hub can collide with one another  no frame buffering  no CSMA/CD at hub: host NICs detect collisions twisted pair hub Data Link Layer5-102 .

selectively forward frame to one-or-more outgoing links when frame is to be forwarded on segment. take active role  store. forward Ethernet frames  examine incoming frame’s MAC address. self-learning . uses CSMA/CD to access segment  hosts are unaware of presence of switches  switches do not need to be configured Data Link Layer5-103  transparent  plug-and-play.Switch  link-layer device: smarter than hubs.

without collisions  each link is its own collision domain C B’ A’  not possible with dumb hub switch with six interfaces (1. full duplex C’ 1 5 2 4 B 3 6  switching: A-to-A’ and Bto-B’ simultaneously.6) Data Link Layer5-104 . direct connection to switch switches buffer packets Ethernet protocol used on each incoming link.3.5.4. but no collisions.2.Switch: allows multiple simultaneous transmissions A    hosts have dedicated.

maintained in switch table?  something like a routing protocol? A C’ 1 5 2 4 C B’ B 3  6  (MAC address of host.6) Data Link Layer5-105 . B’ reachable via interface 5? A: each switch has a switch table.4. interface to reach host.3.Switch Table  Q: how does switch know that A’ reachable via interface 4. each entry: looks like a routing table! Q: how are entries created.2. time stamp)   A’ switch with six interfaces (1.5.

Switch: self-learning  Source: A Dest: A’ switch learns which hosts can be reached through which interfaces  when frame received. switch “learns” location of sender: incoming LAN segment  records sender/location pair in switch table A A A’ C’ 1 5 2 4 C B’ B 3 6 A’ MAC addr interface TTL A 1 60 Switch table (initially empty) Data Link Layer5-106 .

record link associated with sending host 2. index switch table using MAC dest address 3. if entry found for destination then { if dest on segment from which frame arrived then drop the frame else forward the frame on interface indicated } else flood forward on all but the interface on which the frame arrived Data Link Layer5-107 .Switch: frame filtering/forwarding When frame received: 1.

forwarding: example   Source: A Dest: A’ A A A’ C’ 1 2 4 C B 3 frame destination unknown: flood 6 A A’ selective send destination A location known: B’ 5 A’ A A’ MAC addr interface TTL A A’ 1 4 60 60 Switch table (initially empty) Data Link Layer5-108 .Self-learning.

how does S1 know to  forward frame destined to F via S4 and S3? A: self learning! (works exactly the same as in single-switch case!) Data Link Layer5-109 .Interconnecting switches  switches can be connected together S4 S1 A B C S2 S3 F E G H I D  Q: sending from A to G .

Self-learning multi-switch example Suppose C sends frame to I. I responds to C 1 S1 A B C S2 2 F E G H S4 S3 I D  Q: show switch tables and packet forwarding in S1. S3. S4 Data Link Layer 5-110 . S2.

Institutional network to external network mail server router web server IP subnet Data Link Layer 5-111 .

Routers  both store-andforward devices   routers maintain routing tables. learning algorithms  routers: network-layer devices (examine network-layer headers)  switches are link-layer devices (examine linklayer headers) application transport datagram network frame link physical frame link physical switch network datagram link frame physical application transport network link physical Data Link Layer 5-112 .Switches vs. implement filtering. implement routing algorithms switches maintain switch tables.

but wants connect to CS switch? single broadcast domain:  all layer-2 broadcast traffic (ARP. DHCP) crosses entire LAN (security/privacy.VLANs: motivation What’s wrong with this picture? What happens if:   CS user moves office to EE. efficiency issues) Computer Science Electrical Engineering Computer Engineering  each lowest level switch has only few ports in use Data Link Layer 5-113 .

VLANs Virtual Local Area Network Switch(es) supporting VLAN capabilities can be configured to define multiple virtual LANS over single physical LAN infrastructure. Port-based VLAN: switch ports grouped (by switch management software) so that single physical switch …… 1 2 7 8 9 10 15 16 … Electrical Engineering (VLAN ports 1-8) … Computer Science (VLAN ports 9-15) … operates as multiple virtual switches 1 2 7 9 10 15 16 8 … Electrical Engineering (VLAN ports 1-8) … Computer Science (VLAN ports 9-16) Data Link Layer 5-114 .

Port-based VLAN  traffic isolation: frames to/from ports 1-8 can only reach ports 1-8  can also define VLAN based on MAC addresses of endpoints. rather than switch port router 1 2 7 8 9 10 15 16  dynamic membership: ports can be dynamically assigned among VLANs … Electrical Engineering (VLAN ports 1-8) … Computer Science (VLAN ports 9-15)  forwarding between VLANS: done via routing (just as with separate switches)  in practice vendors sell combined switches plus routers Data Link Layer 5-115 .

1q protocol adds/removed additional header fields for frames forwarded between trunk ports Data Link Layer 5-116 .8 belong to CS VLAN  trunk port: carries frames between VLANS defined over multiple physical switches  frames forwarded within VLAN between switches can’t be vanilla 802.3.1 frames (must carry VLAN ID info)  802.7.VLANS spanning multiple switches 1 2 7 8 9 10 15 16 1 2 3 4 5 6 7 8 … Electrical Engineering (VLAN ports 1-8) … Computer Science (VLAN ports 9-15) Ports 2.6.5 belong to EE VLAN Ports 4.

1Q VLAN frame format Type 802.1Q frame 2-byte Tag Protocol Identifier (value: 81-00) Recomputed CRC Tag Control Information (12 bit VLAN ID field.1 frame 802.802. 3 bit priority field like IP TOS) Data Link Layer 5-117 .

7 PPP 5.1 Introduction and services 5.5 Ethernet 5.4 Link-Layer Addressing 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request Data Link Layer 5-118 .Link Layer 5.2 Error detection and correction 5.6 Link-layer switches 5.3Multiple access protocols 5.

dialup link..g. ISDN line popular point-to-point DLC protocols:  PPP (point-to-point protocol)  HDLC: High level data link control (Data link used to be considered “high layer” in protocol stack! Data Link Layer 5-119 .Point to Point Data Link Control   one sender. one receiver. one link: easier than broadcast link:  no Media Access Control  no need for explicit MAC addressing  e.

signal link failure to network layer network layer address negotiation: endpoint can learn/configure each other’s network address Data Link Layer5-120 .PPP Design Requirements [RFC 1557]      packet framing: encapsulation of network-layer datagram in data link frame  carry network layer data of any network layer protocol (not just IP) at same time  ability to demultiplex upwards bit transparency: must carry any bit pattern in the data field error detection (no correction) connection liveness: detect.

data re-ordering all relegated to higher layers! Data Link Layer5-121 . polling) Error recovery.PPP non-requirements     no error correction/recovery no flow control out of order delivery OK no need to support multipoint links (e. flow control.g..

PPP Data Frame     Flag: delimiter (framing) Address: does nothing (only one option) Control: does nothing. IPCP. PPP-LCP. IP. etc) Data Link Layer5-122 .g.. in the future possible multiple control fields Protocol: upper layer protocol to which frame delivered (e.

PPP Data Frame   info: upper layer data being carried check: cyclic redundancy check for error detection Data Link Layer5-123 .

continue data reception  single 01111110: flag byte Data Link Layer5-124 .Byte Stuffing  “data transparency” requirement: data field must be allowed to include flag pattern <01111110>  Q: is received <01111110> data or flag?   Sender: adds (“stuffs”) extra < 01111110> byte after each < 01111110> data byte Receiver:  two 01111110 bytes in a row: discard first byte.

Byte Stuffing flag byte pattern in data to send flag byte pattern plus stuffed byte in transmitted data Data Link Layer5-125 .

PPP Data Control Protocol
Before exchanging network-layer data, data link peers must  configure PPP link (max. frame length, authentication)

learn/configure network layer information  for IP: carry IP Control Protocol (IPCP) msgs (protocol field: 8021) to configure/learn IP address

Data Link Layer5-126

Link Layer
    

5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet

 

5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
3.4 Reliable data transfer

Skip 5.8 and 5.9

Data Link Layer5-127

Virtualization of networks
Virtualization of resources: a powerful abstraction in systems engineering:  computing examples: virtual memory, virtual devices  Virtual machines: e.g., java  IBM VM OS from 1960’s/70’s

layering of abstractions: don’t sweat the details of the lower layer, only deal with lower layers abstractly

Data Link Layer5-128

Kahn.The Internet: virtualizing networks 1974: multiple unconnected nets     ARPAnet data-over-cable networks packet satellite network (Aloha) packet radio network … differing in:     addressing conventions packet formats error recovery routing ARPAnet "A Protocol for Packet Network Intercommunication". Cerf. 1974. 637-648. V. IEEE Transactions on Communications. May. satellite net Data Link Layer5-129 . pp. R.

despite underlying local network heterogeneity  network of networks Gateway:  “embed internetwork packets in local packet format or extract them”  route (at internetwork level) to next gateway gateway ARPAnet satellite net Data Link Layer5-130 .The Internet: virtualizing networks Internetwork layer (IP):  addressing: internetwork appears as single. uniform entity.

Cerf & Kahn’s Internetwork Architecture What is virtualized? two layers of addressing: internetwork and local network  new layer (IP) makes everything homogeneous at internetwork layer  underlying local network technology  cable  satellite  56K telephone modem  today: ATM. Looks like a link layer technology to IP!  Data Link Layer5-131 . MPLS … “invisible” at internetwork layer.

routing from Internet  viewed by Internet as logical link connecting IP routers  just like dialup link is really part of separate network (telephone network)  ATM. addressing. MPLS separate networks in their own right  different service models. MPLS: of technical interest in their own right Data Link Layer5-132 .ATM and MPLS  ATM.

data  meeting timing/QoS requirements of voice. called “cells”) using virtual circuits Data Link Layer5-133 .Asynchronous Transfer Mode: ATM   1990’s/00 standard for high-speed (155Mbps to 622 Mbps and higher) Broadband Integrated Service Digital Network architecture Goal: integrated. video (versus Internet best-effort model)  “next generation” telephony: technical roots in telephone world  packet-switching (fixed length packets. end-end transport of carry voice. video.

Multiprotocol label switching (MPLS)  initial goal: speed up IP forwarding by using fixed length label (instead of IP address) to do forwarding  borrowing ideas from Virtual Circuit (VC) approach  but IP datagram still keeps IP address! PPP or Ethernet header MPLS header IP header remainder of link-layer frame label 20 Exp S TTL 3 1 5 Data Link Layer5-134 .

.MPLS capable routers a.g.a. label-switched router  forwards packets to outgoing interface based only on label value (don’t inspect IP address)   signaling protocol needed to set up forwarding  MPLS forwarding table distinct from IP forwarding tables  RSVP-TE  forwarding possible along paths that IP alone would not allow (e.k. source-specific routing) !!  use MPLS for traffic engineering  must co-exist with IP-only routers Data Link Layer5-135 .

MPLS forwarding tables in label out label dest out interface 10 12 8 A D A 0 0 1 in label out label dest out interface 10 12 6 9 A D 1 0 R6 0 0 1 D 1 R4 R3 0 0 R5 A out interface R2 in label out label dest out interface in label outR1 label dest 6 - A 0 Data Link Layer5-136 8 6 A 0 .

1 Introduction and services 5.9 A day in the life of a web request Data Link Layer5-137 .4 Link-Layer Addressing 5.7 PPP 5.5 Ethernet 5.Link Layer 5.8 Link virtualization: MPLS 5.6 Link-layer switches 5.3Multiple access protocols 5.2 Error detection and correction 5.

google. link  putting-it-all-together: synthesis!  goal: identify. review. requests/receives www. Data Link Layer5-138 . understand protocols (at all layers) involved in seemingly simple scenario: requesting www page  scenario: student attaches laptop to campus network. transport.Synthesis: a day in the life of a web request  journey down protocol stack complete!  application. school network 68.A day in the life: scenario browser DNS server Comcast network 68.0/24 web page web server 64.80.105 Google’s network Data Link Layer5-139 .160.

1 Ethernet  Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN. addr of first-hop router. received at router running DHCP server Ethernet demuxed to IP demuxed. UDP demuxed to DHCP Data Link Layer5-140  . encapsulated in IP.A day in the life… connecting to the Internet DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy DHCP  connecting laptop needs to get its own IP address. addr of DNS server: use DHCP  DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy router (runs DHCP) DHCP request encapsulated in UDP. encapsulated in 802.

name & IP address of DNS server encapsulation at DHCP server. knows name & addr of DNS server. IP address of first-hop router for client.A day in the life… connecting to the Internet DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy  DHCP server formulates DHCP ACK containing client’s IP address. frame forwarded (switch learning) through LAN. demultiplexing at client DHCP client receives DHCP ACK reply  DHCP DHCP DHCP DHCP DHCP DHCP UDP IP Eth Phy router (runs DHCP)  Client now has IP address. IP address of its first-hop router Data Link Layer5-141 .

google. which replies with ARP reply giving MAC address of router interface  client now knows MAC address of first hop router. encapsulated in UDP. In order to send frame to router. need MAC address of router interface: ARP DNS ARP query broadcast. so can now send frame containing DNS query Data Link Layer5-142 . encapsulated in IP. encapsulated in  ARP ARP reply Eth Phy  DNS query created. received by router.A day in the life… ARP (before DNS. before HTTP) DNS DNS DNS ARP query DNS UDP IP ARP Eth Phy  before sending HTTP request. need IP address of www.

routed (tables created by RIP. OSPF. IS-IS and/or BGP routing protocols) to DNS server demuxed to DNS server DNS server replies to client with IP address of www.A day in the life… using DNS DNS DNS DNS DNS DNS DNS DNS UDP IP Eth Phy DNS DNS DNS DNS UDP IP Eth Phy DNS server Comcast network   IP datagram containing DNS query forwarded via LAN switch from client to 1st hop router   IP datagram forwarded from campus network into comcast Data Link Layer5-143 .

105 to send HTTP request. client first opens TCP socket to web server TCP SYN segment (step 1 in 3-way handshake) interdomain routed to web server web server responds with TCP SYNACK (step 2 in 3way handshake) TCP connection established! Data Link Layer5-144  .233.A day in the life… TCP connection carrying HTTP HTTP SYNACK SYN SYNACK SYN SYNACK SYN HTTP TCP IP Eth Phy   SYNACK SYN SYNACK SYN SYNACK SYN TCP IP Eth Phy  web server 64.169.

google.169.105  .com web server responds with HTTP reply (containing web page) IP datagram containing HTTP reply routed back to client Data Link Layer5-145  web server 64.233.A day in the life… HTTP request/reply HTTP HTTP HTTP HTTP HTTP HTTP HTTP HTTP  HTTP TCP IP Eth Phy web page finally (!!!) displayed  HTTP request sent into TCP socket HTTP HTTP HTTP HTTP HTTP TCP IP Eth Phy  IP datagram containing HTTP request routed to www.

VLANs  PPP  virtualized networks as a link layer: MPLS synthesis: a day in the life of a web request Data Link Layer5-146 .Chapter 5: Summary  principles behind data link layer services:  error detection. correction  sharing a broadcast channel: multiple access  link layer addressing   instantiation and implementation of various link layer technologies  Ethernet  switched LANS.

practice  …. but lots of interesting topics!      wireless multimedia security network management Data Link Layer5-147 .. could stop here ….Chapter 5: let’s take a breath journey down protocol stack complete (except PHY)  solid understanding of networking principles.

4 Principles of Reliable data transfer   important in app.. transport. link layers top-10 list of important networking topics! Link layer  Network characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer3-148 .3.

. transport.Principles of Reliable data transfer   important in app. link layers top-10 list of important networking topics! Link layer  Network characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer3-149 .

transport..Principles of Reliable data transfer   important in app. link layers top-10 list of important networking topics! Link layer  Network characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt) Transport Layer3-150 .

by app. Passed data to deliver to receiver upper layer deliver_data(): called by rdt to deliver data to upper send side receive side udt_send(): called by rdt.. (e.). to transfer packet over unreliable channel to receiver rdt_rcv(): called when packet arrives on rcv-side of channel Transport Layer3-151 .Reliable data transfer: getting started rdt_send(): called from above.g.

Reliable data transfer: getting started We’ll:  incrementally develop sender. receiver sides of reliable data transfer protocol (rdt)  consider only unidirectional data transfer  but control info will flow on both directions!  use finite state machines (FSM) to specify sender. receiver state 1 state: when in this “state” next state uniquely determined by next event event causing state transition actions taken on state transition event actions state 2 Transport Layer3-152 . deliver_data(data) sender receiver Transport Layer3-153 . receiver:  sender sends data into underlying channel  receiver read data from underlying channel Wait for call from above rdt_send(data) packet = make_pkt(data) udt_send(packet) Wait for call from below rdt_rcv(packet) extract (packet.0: reliable transfer over a reliable channel  underlying channel perfectly reliable  no bit errors  no loss of packets  separate FSMs for sender.

0: channel with bit errors   underlying channel may flip bits in packet the question: how to recover from errors:  checksum to detect bit errors  acknowledgements (ACKs): receiver explicitly tells sender that pkt received OK How doacknowledgements (NAKs): receiver explicitly humans recover from “errors”  negative during conversation? tells sender that pkt had errors  sender retransmits pkt on receipt of NAK  error detection  receiver feedback: control msgs (ACK.NAK) rcvr->sender  new mechanisms in rdt2.0): Transport Layer3-154 .Rdt2.0 (beyond rdt1.

NAK) rcvr->sender  new mechanisms in rdt2.Rdt2.0): Transport Layer3-155 .0 (beyond rdt1.0: channel with bit errors   underlying channel may flip bits in packet the question: how to recover from errors:  checksum to detect bit errors  acknowledgements (ACKs): receiver explicitly tells sender that pkt received OK  negative acknowledgements (NAKs): receiver explicitly tells sender that pkt had errors  sender retransmits pkt on receipt of NAK  error detection  receiver feedback: control msgs (ACK. . checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for call from above Wait for ACK or NAK receiver rdt_rcv(rcvpkt) && corrupt(rcvpkt) udt_send(sndpkt) udt_send(NAK) rdt_rcv(rcvpkt) && isACK(rcvpkt) L sender Wait for call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt.0: FSM specification rdt_send(data) sndpkt = make_pkt(data. deliver_data(data) udt_send(ACK) Transport Layer3-156 .

deliver_data(data) udt_send(ACK) Transport Layer3-157 L .data). checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for rdt_rcv(rcvpkt) && corrupt(rcvpkt) Wait for ACK or call from udt_send(sndp NAK above udt_send(NAK) kt) rdt_rcv(rcvpkt) && isACK(rcvpkt) Wait for call from below rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt.0: operation with no errors rdt_send(data) snkpkt = make_pkt(data.rdt2.

rdt2.deliver_data(data) udt_send(ACK) Transport Layer3-158 . checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt) Wait for call from above Wait for ACK or NAK udt_send(sndpkt) rdt_rcv(rcvpkt) && corrupt(rcvpkt) udt_send(NAK) Wait for call from below rdt_rcv(rcvpkt) && isACK(rcvpkt) L rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract( error scenario rdt_send(data) snkpkt = make_pkt(data.

0 has a fatal flaw! What happens if ACK/NAK corrupted?  Handling duplicates:     sender doesn’t know what happened at receiver! can’t just retransmit: possible duplicate sender retransmits current pkt if ACK/NAK garbled sender adds sequence number to each pkt receiver discards (doesn’t deliver up) duplicate pkt stop and wait Sender sends one packet.rdt2. then waits for receiver response Transport Layer3-159 .

data. data. checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) ) Wait for Wait for rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt) call 0 from above ACK or NAK 0 udt_send(sndpkt) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt) L rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) ) udt_send(sndpkt) Wait for ACK or NAK 1 Wait for call 1 from above L rdt_send(data) sndpkt = make_pkt(1.rdt2. checksum) udt_send(sndpkt) Transport Layer3-160 . handles garbled ACK/NAKs rdt_send(data) sndpkt = make_pkt(0.1: sender.

1: receiver. chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt) sndpkt = make_pkt(NAK. chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt) sndpkt = make_pkt(NAK.rdt2. chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt. chksum) udt_send(sndpkt) Wait for 0 from below Wait for 1 from below rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq0(rcvpkt) sndpkt = make_pkt(ACK. chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq1(rcvpkt) sndpkt = make_pkt( deliver_data(data) sndpkt = make_pkt(ACK. chksum) udt_send(sndpkt) Transport Layer3-161 .data) deliver_data(data) sndpkt = make_pkt(ACK. handles garbled ACK/NAKs rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq0(rcvpkt) extract(rcvpkt.

rdt2. # Receiver:  must check if received packet is duplicate  state indicates whether 0 or 1 is expected pkt seq #  note: receiver can not know if its last ACK/NAK received OK at sender Transport Layer3-162 . Why?  must check if received ACK/NAK corrupted  twice as many states  state must “remember” whether “current” pkt has 0 or 1 seq.1: discussion Sender:  seq # added to pkt  two seq. #’s (0.1) will suffice.

1.2: a NAK-free protocol   same functionality as rdt2. using ACKs only instead of NAK. receiver sends ACK for last pkt received OK  receiver must explicitly include seq # of pkt being ACKed  duplicate ACK at sender results in same action as NAK: retransmit current pkt Transport Layer3-163 .rdt2. deliver_data(data) sndpkt = make_pkt(ACK1.1)) udt_send(sndpkt) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt. receiver fragments rdt_send(data) sndpkt = make_pkt(0. chksum) udt_send(sndpkt) Transport Layer3-164 . checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && Wait for call 0 from above Wait for ACK 0 (corrupt(rcvpkt) || isACK(rcvpkt.0) sender FSM fragment rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq1(rcvpkt)) udt_send(sndpkt) L Wait for 0 from below receiver FSM fragment rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt. data.2: sender.

but not enough Approach: sender waits “reasonable” amount of time for ACK    retransmits if no ACK received in this time if pkt (or ACK) just delayed (not lost):  retransmission will be duplicate. but use of seq.rdt3.0: channels with errors and loss New assumption: underlying channel can also lose packets (data or ACKs)  checksum. seq. #. #’s already handles this  receiver must specify seq # of pkt being ACKed requires countdown timer Transport Layer3-165 . ACKs. retransmissions will be of help.

rdt3.0 sender
rdt_send(data) sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) start_timer Wait for call 0from above Wait for ACK0 rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,1) ) rdt_rcv(rcvpkt)



rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,1)

timeout udt_send(sndpkt) start_timer rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0) stop_timer

Wait for ACK1 Wait for call 1 from above

timeout udt_send(sndpkt) start_timer rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,0) )


sndpkt = make_pkt(1, data, checksum) udt_send(sndpkt) start_timer



Transport Layer3-166

rdt3.0 in action

Transport Layer3-167

rdt3.0 in action

Transport Layer3-168

0   rdt3.008 = 0.0 works. but performance stinks ex: 1 Gbps link.Performance of rdt3.00027  if RTT=30 msec. 15 ms prop. 8000 bit packet: L 8000bits dtrans    8 microsecon ds 9 R 10 bps  U sender: utilization – fraction of time sender busy sending U sender = L/R RTT + L / R = . 1KB pkt every 30 msec -> 33kB/sec thruput microsec onds over 1 Gbps link  network protocol limits use of physical resources! Transport Layer3-169 . delay.008 30.

t = RTT + L / R U = sender L/R RTT + L / R = . send next packet. t = last packet bit transmitted.0: stop-and-wait operation sender first packet bit transmitted. t = 0 L /R RTT receive r first packet bit arrives last packet bit arrives.008 30.rdt3. send ACK ACK arrives.008 = 0.00027 microsec onds Transport Layer3-170 .

“in-flight”.Pipelined protocols pipelining: sender allows multiple. selective repeat Transport Layer3-171 . yet-tobe-acknowledged pkts  range of sequence numbers must be increased  buffering at sender and/or receiver  two generic forms of pipelined protocols: go-Back-N.

024 30.Pipelining: increased utilization sender first packet bit transmitted. send ACK ACK arrives. t = RTT + L / R Increase utilization by a factor of 3! 3*L/R . send ACK last bit of 2nd pkt arrives. t last bit transmitted. send next packet.0008 microsecon ds Transport Layer3-172 .008 U sender = RTT + L / R = = 0. t == 0 L/ R RTT receiver first packet bit arrives last packet bit arrives. send ACK last bit of 3rd pkt arrives.

Pipelined Protocols Go-back-N: big picture: Selective Repeat: big pic  sender can have up to N  sender can have up to N unacked packets in unack’ed packets in pipeline pipeline  rcvr only sends  rcvr sends individual ack cumulative acks for each packet  sender has timer for oldest unacked packet  if timer expires. retransmit only unack’ed packet Transport Layer3-173 . retransmit all unack’ed packets  doesn’t ack packet if there’s a gap  sender maintains timer for each unacked packet  when a timer expires.

consecutive unack’ed pkts allowed    ACK(n): ACKs all pkts up to.Go-Back-N Sender:   k-bit seq # in pkt header “window” of up to N. including seq # n .“cumulative ACK”  may receive duplicate ACKs (see receiver) timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window Transport Layer3-174 .

chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) start_timer nextseqnum++ } else refuse_data(data) Wait rdt_rcv(rcvpkt) && corrupt(rcvpkt) timeout start_timer udt_send(sndpkt[base]) udt_send(sndpkt[base+1]) … udt_send(sndpkt[nextseqnum-1]) rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) base = getacknum(rcvpkt)+1 If (base == nextseqnum) stop_timer else start_timer Transport Layer3-175 .GBN: sender extended FSM rdt_send(data) L base=1 nextseqnum=1 if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(

ACK.expectedseqnum) extract(rcvpkt.chksum) udt_send(sndpkt) expectedseqnum++ Wait expectedseqnum=1 sndpkt = make_pkt( deliver_data(data) sndpkt = make_pkt(expectedseqnum.ACK.chksum) L ACK-only: always send ACK for correctly-received pkt with highest in-order seq #  may generate duplicate ACKs  need only remember expectedseqnum  out-of-order pkt:  discard (don’t buffer) -> no receiver buffering!  Re-ACK pkt with highest in-order seq # Transport Layer3-176 .GBN: receiver extended FSM default udt_send(sndpkt) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt.

GBN in action Transport Layer3-177 .

as needed. for eventual in-order delivery to upper layer  sender only resends pkts for which ACK not received  sender timer for each unACKed pkt  sender window  N consecutive seq #’s  again limits seq #s of sent. unACK’ed pkts Transport Layer3-178 .Selective Repeat  receiver individually acknowledges all correctly received pkts  buffers pkts.

Selective repeat: sender. receiver windows Transport Layer3-179 .

advance window to next not-yet-received pkt ACK(n) ignore otherwise:  Transport Layer3-180 .sendbase+N]:   pkt n in [rcvbase-N. restart timer mark pkt n as received if n smallest unACKed pkt. advance window base to next unACKed seq # ACK(n) in [sendbase. send pkt timeout(n):  resend pkt n. in-order pkts). rcvbase+N-1]    if next available seq # in window.rcvbase-1]  send ACK(n) out-of-order: buffer in-order: deliver (also deliver buffered.Selective repeat data from above :  sender receiver pkt n in [rcvbase.

Selective repeat in action Transport Layer3-181 .

1.Selective repeat: dilemma Example:   seq #’s: 0. 2. 3 window size=3   receiver sees no difference in two scenarios! incorrectly passes duplicate data as new in (a) Q: what relationship between seq # size and window size? Transport Layer3-182 .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.