Sunteți pe pagina 1din 182

Chapter 5 Link Layer and LANs

A note on the use of these ppt slides:


Were making these slides freely available to all (faculty, students, readers). Theyre 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, wed 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

Link layer: context

datagram transferred by different link protocols over different links:


e.g., Ethernet on first link, frame relay on intermediate links, 802.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.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

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

5-6

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

cpu

memory

attaches into hosts system buses combination of hardware, software, firmware

controller link physical physical transmission

host bus (e.g., PCI)

network adapter card

Data Link Layer

5-8

Adaptors Communicating
datagram controller datagram controller

sending host
datagram

receiving host

frame

sending side:
encapsulates datagram in frame adds error checking bits, rdt, flow control, etc.

receiving side
looks for errors, rdt, flow control, etc extracts datagram, passes to upper layer at receiving side
Data Link Layer 5-9

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

Data Link Layer 5-10

Error Detection
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

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

Data Link Layer 5-12

Internet checksum (review; details


in Transport Layer . Just wait.)
Goal: detect errors (e.g., flipped bits) in transmitted packet (note: used at transport layer only)
Sender:

treat segment contents as sequence of 16-bit integers checksum: addition (1s 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 - error detected YES - no error detected.

But maybe errors nonetheless?

Data Link Layer 5-13

Checksumming: Cyclic Redundancy Check


view data bits, D, as a binary number choose r+1 bit pattern (generator), G goal: choose r CRC bits, R, such that
<D,R> exactly divisible by G (modulo 2) zero remainder

receiver knows G:
Divides <D,R> by G. If non-zero remainder: error detected!

can detect all burst errors less than r+1 bits


widely used in practice (Ethernet, 802.11 WiFi, ATM)

Data Link Layer 5-14

CRC Example:
Want: D.2r XOR R = nG

D = 101110, r = 3, G = 1001

equivalently: equivalently:

D.2r = nG XOR R

if we divide D.2r by G, we get remainder R

R = remainder[

D.2r G

Data Link Layer 5-15

Process: Calculation of CRC

If the input bit above the leftmost divisor bit is 1, the divisor is XORed into the input. Else (the input bit above the leftmost divisor bit is 0) do nothing. 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.

Input: Divisor: G Align input and divisor on MSB

D.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

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

Data Link Layer 5-17

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.11 wireless LAN

shared wire (e.g., cabled Ethernet)

shared RF (e.g., 802.11 WiFi)

shared RF (satellite)

humans at a cocktail party (shared air, acoustical)


Data Link Layer 5-18

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.e., 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

Packet Collision
Link/MAC PHY Rx
+ data Tx

Link/MAC PHY

Link/MAC PHY

data Tx

20

Ideal Multiple Access Protocol


Broadcast channel of rate R bps 1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average rate R/M 3. fully decentralized:
no special node to coordinate transmissions no synchronization of clocks, slots

4. simple

Data Link Layer 5-21

MAC Protocols: a taxonomy


Three broad classes: Channel Partitioning (Commonly done in cellular networks)
divide channel into smaller pieces (time slots, frequency, code) allocate piece to node for exclusive use

Random

Access

channel not divided, allow collisions recover from collisions

Taking turns
nodes take turns

Data Link Layer 5-22

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, 1,3,4 have pkt, slots 2,5,6 idle
6-slot frame 1 3

Data Link Layer 5-23

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,3,4 have pkt, frequency bands 2,5,6 idle
frequency bands

FDM cable

Data Link Layer 5-24

Random Access Protocols

When node has packet to send


transmit at full channel data rate R. no a priori coordination among nodes (partial exception in WiFi)

two or more transmitting nodes collision, random access MAC protocol specifies:
how to detect collisions how to recover from collisions (e.g., via delayed retransmissions)

Examples of random access MAC protocols:


ALOHA and slotted ALOHA CSMA/CD, CSMA/CA
CD: Collision Detection CA: Collision Avoidance
Data Link Layer 5-25

CSMA: Carrier Sense Multiple Access

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

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,t0+1]

Data Link Layer 5-28

Pure Aloha efficiency


P(success by given node) = P(node transmits) .
P(no other node transmits in [t0, t0+1] = p . (1-p)N-1 . (1-p)N-1 = p . (1-p)2(N-1)
choosing optimum p and then letting n -> infty ...
= 1/(2e) = .18

P(no other node transmits in [t0-1,t0] .

even worse than slotted Aloha!

Data Link Layer 5-29

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, all nodes detect collision Operation: when node obtains fresh frame, 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

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, 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 efficiency


Efficiency : long-run fraction of successful slots (many nodes, all with many frames to send)

suppose: N nodes with many

frames to send, 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, take limit of Np*(1-p*)N-1 as N goes to infinity, gives:

Max efficiency = 1/e = .37

At best: channel

used for useful transmissions 37% of time!

Data Link Layer 5-32

CSMA (Carrier Sense Multiple Access)


CSMA: listen before you transmit: If channel sensed idle: transmit entire frame If channel sensed busy, defer transmission human analogy: dont interrupt others!

Data Link Layer 5-33

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 others 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, deferral as in CSMA
collisions detected within short time colliding transmissions aborted, reducing channel wastage easy in wired LANs: measure signal strengths difficult in wireless LANs

collision detection:

Data Link Layer 5-36

Exponential backoff

CSMA/CD

Start: i = 0 Sense medium

Wait TB = R*Tp

Busy
N

Wait

R = Random(0,2i-1)

No

Transmit frame WHILE detecting collision Collision i++ Send jamming signal + Abort Success
37

No collision

i > Kmax Yes

Error

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

38

CSMA/CD collision detection

Data Link Layer 5-39

Taking Turns MAC protocols


channel partitioning MAC protocols: share channel efficiently and fairly at high load inefficient at low load: delay in channel access, 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


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

Wireless LAN
IEEE 802.11/a/b/g

43

WLAN View
C: Computer, AP: Access Point

IEEE 802.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

IEEE 802.11/a/b/g/n Family


IEEE 802.11 802.11a 802.11b 802.11g 802.11n 802.11ac
(Draft/Nov. 2011)

Technique DSSS FHSS OFDM DSSS OFDM OFDM OFDM

Frequency Band 2.4 GHz 2.4 GHz 5 GHz 2.4 GHz 2.4 GHz 2.4/5 GHz 5 GHz

Rate (Mbps) 1 and 2 1 and 2 6--54 5.5 and 11 22 and 54

72 and 150

6.9 Gbps
45

Different Modes of Operation of MAC in IEEE 802.11


Modes of IEEE 802.11 MAC

Distributed Coordination Function

(DCF)

Point Coordination Function

mode

(PCF)

mode

With Hand-shake

Without Hand-shake

46

PCF Mode: Optional

The AP
Operates as the central controller for all nodes within its range. Decides who transmits and when. Can follow a round-robin policy to allocate slots. Note: There is no contention for medium access.

This mode
Can support real-time traffic due to periodic scheduling. Leads to waste of bandwidth if a scheduled node has no traffic. Is optional <= Spec.

47

DCF Mode: Mandatory

An AP
Need not be used.
Computers can directly communicate among themselves <= Ad hoc.

Is used to provide connectivity to the Internet.

In DCF
All nodes, including the AP, compete for medium access. The AP does not operate as a central controller. Delivery is best effort

48

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

DCF with hand-shake


A sender obtains permission from the receiver before transmitting a data frame. 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. ( dotRTSThreshold holds the value.) Incurs additional cost loss of some bandwidth due to hand-shake

50

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

DCF without hand-shake


A sender does not obtain permission from the receiver before transmitting a data frame. RTS/CTS mechanism is NOT used.

There is no prior coordination between sender and receiver

A sender transmits a frame


when some medium sensing conditions are satisfied.
To follow

When data frames are short


Use this to save bandwidth

52

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, the problems become worse.
53

Hidden Terminal Problem

A D

Problem - C is transmitting a frame to B. - A is unaware of Cs Tx. - Now, if A transmits, As Tx will collide with Cs at B The above problem is due to C being hidden from A. Hidden means being far away
54

Exposed Terminal Problem

A D

Tx

Problem - A is transmitting a frame to D. - B knows that someone is transmitting. - If B transmits a frame to C, no problem. However, B does not transmit because it is unaware of Ds location.
The above problem is due to B being exposed to As Tx.
55

No collision detection
Fact: Collision at receiver is more serious than collision at transmitter. In a wired LAN

Collision is indirectly detected after some delay by the sender. In a WLAN, collision detection by sender is not possible.
That is why we have the hidden terminal problem.

Collision is avoided (CA), rather than detected

56

WLAN MAC: CSMA/CA

(RTS: Request to Send; CTS: Clear to Send)

In CSMA/CA, collision is avoided using

PHY-level carrier sensing: Done in receiver hardware Virtual carrier sensing: Done by examining frame header
Frame headers of RTS, CTS, DATA A duration field in frame headers indicates for how long the sender of the frame may use the medium. 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. NAV = 0: Nobody had wanted to use the medium now.

Transmit condition: When medium is idle


(Carrier is absent) AND (NAV = 0)

57

NAV Update Mechanism

Each node has its own NAV. Procedure to update NAV

NAV is the length of time for which the medium is likely to remain busy. Initially: NAV = 0. With each passing s (micro second) NAV is updated using the duration field in a received frame
NAV = Max(NAV, duration) NAV = NAV 1 Stop decrementing if NAV = 0.

58

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

DATA Frame

Frame format
Frame Duration/ Control ID A1 A2 A3 Seq. Control A4

Frame Body

FCS

RA

TA

TA: Physically transmitting the frame.

TA

RA

60

Timing Intervals

The IEEE 802.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.t. a station is capable of determining if another


station initiated a Tx at the beginning of the previous slot.

61

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

DCF with Hand-shake: Tx


F: a new data frame to be transmitted i = 0, 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, CW saturates at CWmax.)


63

Backoff Mechanism

Initialize a counter: Backoff Time Counter (BTC)


BTC = Random(0,CW-1) The time unit of BTC is aSlotTime aSlotTime: propagation + transceiver switching time

As time passes, 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.
Subsequent decrementing is done for every aSlotTime of idleness of the medium.

64

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

DIFS

DIFS 3 3

Time
X

BTC = 5

B is executing backoff
X = aSlotTime

65

DCF with Hand-shake: Rx

Receive RTS
No

Receive DATA frame Send data to upper layer

NAV = 0? Yes

Medium idle for SIFS?


Yes

No

Medium idle for SIFS?

No

Yes

Send ACK

Send CTS

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

66

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.
67

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.
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 of Operation (Contd.)


After transmitting a beacon, 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

PCF Mode of Operation (Contd.)


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. The polled user sends data to the AP.

70

PCF Mode of Operation (Contd.)


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 retransmits data after PIFS. Note 2: If User 1 does not receive ACK, it does not retransmit data.
The polled user receives data from the AP and sends data to another user.
71

PCF Mode of Operation (Contd.)

DATA frame
Contains user data from AP to a specific station. 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.

72

PCF Mode of Operation (Contd.)

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

73

PCF Mode of Operation (Contd.)

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

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, frequency or code


random access (dynamic),
Time Division, Frequency Division, Code Division ALOHA, S-ALOHA, CSMA/CD carrier sensing: easy in some technologies (wire), hard in wireless CSMA/CD used in Ethernet CSMA/CA used in 802.11

taking turns

polling from central site, token passing

Bluetooth, FDDI (Fibre Dist. Data Interface), IBM Token Ring


Bluetooth piconet master Up to 7 slaves

Data Link Layer 5-76

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

Data Link Layer 5-77

MAC Addresses and ARP

(Address Resolution Protocol)

32-bit IP address: (for comparison only .)


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

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

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

ARP: Address Resolution Protocol


Question:
how to determine Bs MAC address knowing Bs IP address?

Each IP node (host, router) on LAN has ARP table ARP table: IP/MAC addr. mappings for some LAN nodes
< IP address; MAC address; TTL>

137.196.7.78 1A-2F-BB-76-09-AD 137.196.7.23 137.196.7.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.196.7.88

0C-C4-11-6F-E3-98

Data Link Layer 5-82

ARP protocol: Same LAN (network)

A wants to send datagram to B, and Bs MAC address not in As ARP table. 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 As 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

Addressing: routing to another LAN


walkthrough: send datagram from A to B via R.
focus on addressing - at both IP (datagram) and MAC layer (frame) assume A knows Bs IP address assume A knows Bs MAC address (how?) assume A knows IP address of first hop router, R (how?) assume A knows MAC address of first hop router interface (how?)

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-84

Addressing: routing to another LAN


A creates IP datagram with IP source A, destination B A creates link-layer frame with R's MAC address as dest, 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: 111.111.111.111 IP dest: 222.222.222.222

IP Eth Phy

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-85

Addressing: routing to another LAN


frame sent from A to R frame received at R, datagram removed, passed up to IP


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 Eth Phy

IP Eth Phy

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-86

Addressing: routing to another LAN


R forwards datagram with IP source A, destination B R creates link-layer frame with B's MAC address as dest, 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

IP Eth Phy

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-87

Addressing: routing to another LAN


R forwards datagram with IP source A, destination B R creates link-layer frame with B's MAC address as dest, 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

IP Eth Phy

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-88

Addressing: routing to another LAN


R forwards datagram with IP source A, destination B R creates link-layer frame with B's MAC address as dest, 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

A
111.111.111.111 74-29-9C-E8-FF-55

R
222.222.222.220 1A-23-F9-CD-06-9B 111.111.111.112 CC-49-DE-D0-AB-7D 111.111.111.110 E6-E9-00-17-BB-4B

B
222.222.222.222 49-BD-D2-C7-56-2A

222.222.222.221 88-B2-2F-54-1A-0F Data Link Layer 5-89

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

Data Link Layer 5-90

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

Metcalfes 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

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, sender clock rates

Data Link Layer 5-93

Ethernet Frame Structure (more)

Addresses: 6 bytes
if adapter receives frame with matching destination address, or with broadcast address (e.g. ARP packet), it passes data in frame to network layer protocol otherwise, adapter discards frame

Type: indicates higher layer protocol (mostly IP but others possible, e.g., Novell IPX, AppleTalk) CRC: checked at receiver, if error is detected, frame is dropped

Data Link Layer 5-94

Ethernet: Unreliable, connectionless


connectionless: No handshaking between sending and receiving NICs unreliable: receiving NIC doesnt 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

Ethernets MAC protocol: unslotted CSMA/CD

Data Link Layer 5-95

Ethernet CSMA/CD algorithm


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

Ethernets CSMA/CD (more)


Jam Signal: make sure all other transmitters are aware of collision; 48 bits Bit time: .1 microsec for 10 Mbps Ethernet ; for K=1023, 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,1}; delay is K 512 bit transmission times after second collision: choose K from {0,1,2,3} after ten collisions, choose K from {0,1,2,3,4,,1023}

See/interact with Java applet on AWL Web site: highly recommended !

Data Link Layer 5-97

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, cheap, decentralized!
Data Link Layer 5-98

as tprop goes to 0 as ttrans goes to infinity

802.3 Ethernet Standards: Link & Physical Layers

many different Ethernet standards

common MAC protocol and frame format different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 1Gbps, 10G bps different physical layer media: fiber, 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

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, global clock among nodes!

Hey, this is physical-layer stuff!


Data Link Layer5-100

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

Data Link Layer5-101

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

Switch

link-layer device: smarter than hubs, take active role


store, forward Ethernet frames examine incoming frames MAC address, selectively forward frame to one-or-more outgoing links when frame is to be forwarded on segment, 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, self-learning

Switch: allows multiple simultaneous transmissions


A

hosts have dedicated, direct connection to switch switches buffer packets Ethernet protocol used on each incoming link, but no collisions; full duplex

C 1 5 2 4

B 3

switching: A-to-A and Bto-B simultaneously, without collisions

each link is its own collision domain

C B

not possible with dumb hub

switch with six interfaces (1,2,3,4,5,6)

Data Link Layer5-104

Switch Table

Q: how does switch know that


A reachable via interface 4, B reachable via interface 5? A: each switch has a switch table, each entry: looks like a routing table! Q: how are entries created, maintained in switch table?
something like a routing protocol?

A C 1 5 2 4 C B B 3

(MAC address of host, interface to reach host, time stamp)


switch with six interfaces (1,2,3,4,5,6)

Data Link Layer5-105

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

MAC addr interface TTL

60

Switch table (initially empty)

Data Link Layer5-106

Switch: frame filtering/forwarding


When frame received: 1. 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

Self-learning, 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

MAC addr interface TTL

A A

1 4

60 60

Switch table (initially empty)

Data Link Layer5-108

Interconnecting switches

switches can be connected together


S4 S1 A B C S2 S3 F E G H I

Q: sending from A to G - 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

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

Q: show switch tables and packet forwarding in S1,


S2, S3, S4

Data Link Layer 5-110

Institutional network
to external network mail server

router

web server

IP subnet

Data Link Layer 5-111

Switches vs. Routers

both store-andforward devices

routers maintain routing tables, implement routing algorithms switches maintain switch tables, implement filtering, 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

VLANs: motivation
Whats wrong with this picture?

What happens if:

CS user moves office to EE, but wants connect to CS switch? single broadcast domain:
all layer-2 broadcast traffic (ARP, DHCP) crosses entire LAN (security/privacy, 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

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

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,3,5 belong to EE VLAN Ports 4,6,7,8 belong to CS VLAN

trunk port: carries frames between VLANS defined


over multiple physical switches
frames forwarded within VLAN between switches cant be vanilla 802.1 frames (must carry VLAN ID info) 802.1q protocol adds/removed additional header fields for frames forwarded between trunk ports
Data Link Layer 5-116

802.1Q VLAN frame format


Type

802.1 frame

802.1Q frame

2-byte Tag Protocol Identifier (value: 81-00)

Recomputed CRC

Tag Control Information (12 bit VLAN ID field, 3 bit priority field like IP TOS)

Data Link Layer 5-117

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

Data Link Layer 5-118

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.g., dialup link, 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

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, signal link failure to network layer network layer address negotiation: endpoint can learn/configure each others network address
Data Link Layer5-120

PPP non-requirements

no error correction/recovery no flow control out of order delivery OK no need to support multipoint links (e.g., polling)

Error recovery, flow control, data re-ordering all relegated to higher layers!

Data Link Layer5-121

PPP Data Frame


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

Data Link Layer5-122

PPP Data Frame


info: upper layer data being carried check: cyclic redundancy check for error detection

Data Link Layer5-123

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, continue data reception single 01111110: flag byte
Data Link Layer5-124

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 1960s/70s

layering of abstractions: dont sweat the details of the lower layer, only deal with lower layers abstractly

Data Link Layer5-128

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", V. Cerf, R. Kahn, IEEE Transactions on Communications, May, 1974, pp. 637-648.

satellite net
Data Link Layer5-129

The Internet: virtualizing networks


Internetwork layer (IP): addressing: internetwork appears as single, uniform entity, 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

Cerf & Kahns 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, MPLS invisible at internetwork layer. Looks like a link layer technology to IP!

Data Link Layer5-131

ATM and MPLS

ATM, MPLS separate networks in their own right


different service models, addressing, 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, MPLS: of technical interest in their own right


Data Link Layer5-132

Asynchronous Transfer Mode: ATM

1990s/00 standard for high-speed (155Mbps to 622 Mbps and higher) Broadband Integrated Service Digital Network architecture Goal: integrated, end-end transport of carry voice,

video, data

meeting timing/QoS requirements of voice, video (versus Internet best-effort model) next generation telephony: technical roots in telephone world packet-switching (fixed length packets, called cells) using virtual circuits

Data Link Layer5-133

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

5
Data Link Layer5-134

MPLS capable routers


a.k.a. label-switched router forwards packets to outgoing interface based only on label value (dont 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.g., 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

R4

R3
0 0

R5
A
out interface

R2
in label out label dest out interface

in label

outR1 label dest

0
Data Link Layer5-136

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

Data Link Layer5-137

Synthesis: a day in the life of a web request

journey down protocol stack complete!


application, transport, network, link

putting-it-all-together: synthesis!

goal: identify, review, understand protocols (at all layers) involved in seemingly simple scenario: requesting www page scenario: student attaches laptop to campus network, requests/receives www.google.com

Data Link Layer5-138

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 64.233.169.105

Googles network 64.233.160.0/19

Data Link Layer5-139

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 first-hop router, 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 IP, encapsulated in 802.1 Ethernet

Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN, received at router running DHCP server
Ethernet demuxed to IP demuxed, UDP demuxed to DHCP
Data Link Layer5-140

A day in the life connecting to the Internet


DHCP DHCP DHCP DHCP

DHCP UDP IP Eth Phy

DHCP server formulates DHCP ACK containing clients IP address, IP address of first-hop router for client, name & IP address of DNS server encapsulation at DHCP server, 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, knows name & addr of DNS server, IP address of its first-hop router
Data Link Layer5-141

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.google.com:

ARP ARP reply

Eth Phy

DNS query created, encapsulated in UDP, encapsulated in IP, encapsulated in Eth. In order to send frame to router, need MAC address of router interface: ARP

DNS

ARP query broadcast, received


by router, which replies with ARP reply giving MAC address of router interface

client now knows MAC address of first hop router, so can now send frame containing DNS query
Data Link Layer5-142

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 68.80.0.0/13

IP datagram containing DNS query forwarded via LAN switch from client to 1st hop router

IP datagram forwarded from campus network into comcast network, 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.google.com
Data Link Layer5-143

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.233.169.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

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.google.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.169.105

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, 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: lets take a breath


journey down protocol stack complete (except PHY) solid understanding of networking principles, practice .. could stop here . but lots of interesting topics!

wireless multimedia security network management


Data Link Layer5-147

3.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

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-149

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-150

Reliable data transfer: getting started


rdt_send(): called from above,

(e.g., 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,

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


Well: 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

Rdt1.0: reliable transfer over a reliable channel

underlying channel perfectly reliable


no bit errors no loss of packets

separate FSMs for sender, 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,data) deliver_data(data)

sender

receiver
Transport Layer3-153

Rdt2.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 (beyond rdt1.0):

Transport Layer3-154

Rdt2.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,NAK) rcvr->sender

new mechanisms in rdt2.0 (beyond rdt1.0):

Transport Layer3-155

rdt2.0: FSM specification


rdt_send(data) sndpkt = make_pkt(data, 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)

sender

Wait for call from below

rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data) , deliver_data(data) udt_send(ACK)


Transport Layer3-156

rdt2.0: operation with no errors


rdt_send(data) snkpkt = make_pkt(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,data), deliver_data(data) udt_send(ACK)
Transport Layer3-157

rdt2.0: error scenario


rdt_send(data) snkpkt = make_pkt(data, 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)

rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) extract(rcvpkt,data),deliver_data(data) udt_send(ACK)

Transport Layer3-158

rdt2.0 has a fatal flaw!


What happens if ACK/NAK corrupted?

Handling duplicates:

sender doesnt know what happened at receiver! cant just retransmit: possible duplicate

sender retransmits current pkt if ACK/NAK garbled sender adds sequence number to each pkt receiver discards (doesnt deliver up) duplicate pkt

stop and wait Sender sends one packet, then waits for receiver response

Transport Layer3-159

rdt2.1: sender, handles garbled ACK/NAKs


rdt_send(data)
sndpkt = make_pkt(0, 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

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

Transport Layer3-160

rdt2.1: receiver, handles garbled ACK/NAKs


rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq0(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt) sndpkt = make_pkt(NAK, 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) && (corrupt(rcvpkt) sndpkt = make_pkt(NAK, chksum) udt_send(sndpkt) rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq1(rcvpkt)

sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt)

rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK, chksum) udt_send(sndpkt)

Transport Layer3-161

rdt2.1: discussion
Sender: seq # added to pkt two seq. #s (0,1) will suffice. Why? must check if received ACK/NAK corrupted twice as many states
state must remember whether current pkt has 0 or 1 seq. #

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

rdt2.2: a NAK-free protocol


same functionality as rdt2.1, 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.2: sender, receiver fragments


rdt_send(data) sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt) rdt_rcv(rcvpkt) &&
Wait for call 0 from above
Wait for ACK 0

(corrupt(rcvpkt) || isACK(rcvpkt,1))

udt_send(sndpkt) rdt_rcv(rcvpkt) && notcorrupt(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) deliver_data(data) sndpkt = make_pkt(ACK1, chksum) udt_send(sndpkt)

Transport Layer3-164

rdt3.0: channels with errors and loss


New assumption: underlying channel can also lose packets (data or ACKs)
checksum, seq. #, ACKs, retransmissions will be of help, 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. #s already handles this receiver must specify seq # of pkt being ACKed requires countdown timer
Transport Layer3-165

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

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) )

rdt_rcv(rcvpkt)

rdt_send(data)
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

Performance of rdt3.0

rdt3.0 works, but performance stinks ex: 1 Gbps link, 15 ms prop. delay, 8000 bit packet:

L 8000bits dtrans 8 microsecon ds 9 R 10 bps


U sender: utilization fraction of time sender busy sending

sender

L/R RTT + L / R

.008
30.008

= 0.00027

if RTT=30 msec, 1KB pkt every 30 msec -> 33kB/sec thruput

microsec onds

over 1 Gbps link network protocol limits use of physical resources!

Transport Layer3-169

rdt3.0: stop-and-wait operation


sender first packet bit transmitted, t = last packet bit transmitted, t = 0 L /R RTT receive r

first packet bit arrives last packet bit arrives, send ACK

ACK arrives, send next packet, t = RTT + L / R

= sender

L/R RTT + L / R

.008
30.008

= 0.00027

microsec onds
Transport Layer3-170

Pipelined protocols
pipelining: sender allows multiple, in-flight, 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,

selective repeat

Transport Layer3-171

Pipelining: increased utilization


sender
first packet bit transmitted, t last bit transmitted, t == 0 L/ R RTT

receiver

first packet bit arrives last packet bit arrives, send ACK last bit of 2nd pkt arrives, send ACK last bit of 3rd pkt arrives, send ACK

ACK arrives, send next packet, t = RTT + L / R

Increase utilization by a factor of 3!


3*L/R .024
30.008

sender

RTT + L / R

= 0.0008

microsecon ds
Transport Layer3-172

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 unacked 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 all unacked packets

doesnt ack packet if theres a gap

sender maintains timer for each unacked packet


when a timer expires, retransmit only unacked packet

Transport Layer3-173

Go-Back-N
Sender:

k-bit seq # in pkt header window of up to N, consecutive unacked pkts allowed

ACK(n): ACKs all pkts up to, 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

GBN: sender extended FSM


rdt_send(data)

L
base=1 nextseqnum=1

if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(nextseqnum,data,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: receiver extended FSM


default
udt_send(sndpkt) rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt,expectedseqnum) extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(expectedseqnum,ACK,chksum) udt_send(sndpkt) expectedseqnum++

Wait expectedseqnum=1 sndpkt = make_pkt(expectedseqnum,ACK,chksum)

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 (dont buffer) -> no receiver buffering! Re-ACK pkt with highest in-order seq #
Transport Layer3-176

GBN in action

Transport Layer3-177

Selective Repeat

receiver individually acknowledges all correctly received pkts


buffers pkts, 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, unACKed pkts

Transport Layer3-178

Selective repeat: sender, receiver windows

Transport Layer3-179

Selective repeat
data from above :

sender

receiver pkt n in [rcvbase, rcvbase+N-1]


if next available seq # in window, send pkt

timeout(n):

resend pkt n, restart timer


mark pkt n as received if n smallest unACKed pkt, advance window base to next unACKed seq #

ACK(n) in [sendbase,sendbase+N]:

pkt n in [rcvbase-N,rcvbase-1]

send ACK(n) out-of-order: buffer in-order: deliver (also deliver buffered, in-order pkts), advance window to next not-yet-received pkt ACK(n) ignore

otherwise:

Transport Layer3-180

Selective repeat in action

Transport Layer3-181

Selective repeat: dilemma


Example:

seq #s: 0, 1, 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

S-ar putea să vă placă și