ESE 4070-5070 Fall 2025
Class 2 part 1
Andy Smith
andsmi@[Link]
The Link Layer
The four layer Internet model
Source End-Host Dest End-Host
Application Application
Transport Router Router Transport
Network Network Network Network
Link Link Link Link
Link layer: introduction
terminology: mobile network
▪ hosts, routers: nodes national or global ISP
▪ communication channels that
connect adjacent nodes along
communication path: links
• wired , wireless
• LANs
▪ layer-2 packet: frame,
encapsulates datagram datacenter
network
link layer has responsibility of
transferring datagram from one node enterprise
to physically adjacent node over a link network
Link layer: context
▪ datagram transferred by
different link protocols over
different links:
• e.g., WiFi on first link,
Ethernet on next link
▪ each link protocol provides
different services
• e.g., may or may not provide
reliable data transfer over link
Transportation analogy
transportation analogy:
▪ trip from Penn to London
Penn • limo: Penn to PHL
PHL • plane: PHL to LHR
• train: LHR to Central London
▪ tourist = datagram
▪ transport segment =
communication link
▪ transportation mode = link-
layer protocol
▪ travel agent = routing
algorithm
LHR London
Link layer: services
…
▪ Framing, link access:
…
• encapsulate datagram into frame, adding
header, trailer Cable access
• channel access if shared medium
• “MAC” addresses in frame headers identify
source, destination (different from IP
address!)
▪ Reliable delivery between adjacent cellular
nodes
• seldom used on low bit-error links Ethernet LANs
• wireless links: high error rates
WiFi
Link layer: services (more)
▪ Flow control: …
• pacing between adjacent sending and …
receiving nodes Cable access
▪ Error detection:
• errors caused by signal attenuation, noise.
• receiver detects errors, signals
retransmission, or drops frame
▪ Error correction: cellular
• receiver identifies and corrects bit error(s)
without retransmission Ethernet LANs
▪ Half-duplex and full-duplex:
• with half duplex, nodes at both ends of link WiFi
can transmit, but not at same time
Host link-layer implementation
▪ in each-and-every host
▪ link layer implemented on-chip or
in network interface card (NIC) application
transport
• implements link, physical layer network
link
cpu memory
▪ attaches into host’s system buses host bus
(e.g., PCI)
controller
▪ combination of hardware, link
physical
physical
software, firmware
network interface
Interfaces communicating
application application
transport transport
cpu memory memory CPU
datagram network network
link link
linkh datagram controller controller datagram
link link
physical physical
physical physical
sending side: receiving side:
▪ encapsulates datagram in frame ▪ looks for errors, reliable data
▪ adds error checking bits, reliable data transfer, flow control, etc.
transfer, flow control, etc. ▪ extracts datagram, passes to
upper layer at receiving side
Error detection
EDC: “Error Detection and Correction” bits (e.g., redundancy)
D: data protected by error checking, may include header fields
datagram datagram Error detection not 100%
otherwise reliable!
all
bits in D’ N ▪ protocol may miss
OK detected some errors, but
? error
d data bits rarely
D EDC D’ EDC’ ▪ larger EDC field yields
better detection and
bit-error prone link correction
Parity checking row parity
Two-D parity: d1,1 ... d1,j d1,j+1
d2,1 ... d2,j d2,j+
single bit even parity: ... ... ... 1. ..
▪ detect single bit di,1 ... di,j di,j+1
column
errors 1
parity
di+1,1 ... di+1,j di+1,j+
0111000110101011
1
d data bits
9 1’s (odd) parity bit = 1 ▪ detect two-bit errors
Even parity: set parity bit so there is an even ▪ detect and correct single bit errors
number of 1’s
without retransmission!
At receiver:
▪ compute parity of d+1 received detected 10101 1
no errors: 1 0 1 0 1 1
bits, if not even, then error 11110 0
and 10110 0 parity
error
detected correctable
01110 1 single-bit 01110 1
▪ can detect odd number of bit 00101 0 error: 00101 0
flips parity
error
Cyclic Redundancy Check (CRC)
▪ more powerful error-detection coding
▪ D: data bits (given, think of these as a binary number)
▪ G: bit pattern (generator), of r+1 bits (given, specified in CRC standard)
r CRC bits
d data bits
D R bits to send
<D,R> = D *2r XOR R formula for these bits
sender: compute r CRC bits, R, such that <D,R> exactly divisible by G (mod 2)
• 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)
Cyclic Redundancy Check (CRC): example
Sender wants to compute R G 1 0 1 0 1 1
such that: 1 0 0 1 1 0 1 1 1 0 0 0 0
D . 2r XOR R = nG 1 0 0 1
1 0 1 D* 2r (here, r=3)
0 0 0
... or equivalently (XOR R both sides): 1 0 1 0
D . 2r = nG XOR R 1 0 0 1
1 1 0
... which says: 0 0 0
if we divide D . 2r by G, we 1 1 0 0
1 0 0 1
want remainder R to satisfy: 1 0 1 0
1 0 0 1
R = remainder [ D 2 ]
. r
algorithm for 0 1 1
G computing R
R
Multiple access links, protocols
two types of “links”:
▪ point-to-point
• point-to-point link between Ethernet switch, host
• PPP for dial-up access
▪ broadcast (shared wire or medium)
• old-school Ethernet
• upstream HFC in cable-based access network
• 802.11 wireless LAN, 4G/5G. satellite
shared wire (e.g., shared radio: 4G/5G shared radio: WiFi shared radio: satellite humans at a cocktail party
cabled Ethernet) (shared air, acoustical)
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 node can transmit
▪ communication about channel sharing must use channel itself!
• no out-of-band channel for coordination
An ideal multiple access protocol
given: multiple access channel (MAC) of rate R bps
Desired attributes:
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
MAC protocols: taxonomy
three broad classes:
▪ channel partitioning
• 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, but nodes with
more to send can take longer turns
Channel partitioning MAC protocols: TDMA
TDMA: time division multiple access
▪ access to channel in “rounds”
▪ each station gets fixed length slot (length = packet transmission
time) in each round
▪ unused slots go idle
▪ example: 6-station LAN, 1,3,4 have packets to send, slots 2,5,6 idle
6-slot 6-slot
frame frame
1 3 4 1 3 4
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 packet to send, frequency bands 2,5,6 idle
frequency bands
FDM cable
Random access protocols
▪ when node has packet to send
• transmit at full channel data rate R
• no a priori coordination among nodes
▪ two or more transmitting nodes: “collision”
▪ random access protocol specifies:
• how to detect collisions
• how to recover from collisions (e.g., via delayed retransmissions)
▪ examples of random access MAC protocols:
• ALOHA, slotted ALOHA
• CSMA, CSMA/CD, CSMA/CA
Slotted ALOHA
operation:
t0 t0+1
▪ when node obtains fresh
assumptions: frame, transmits in next slot
▪ all frames same size • if no collision: node can send
▪ time divided into equal size new frame in next slot
slots (time to transmit 1 frame) • if collision: node retransmits
▪ nodes start to transmit only frame in each subsequent
slot beginning slot with probability p until
▪ nodes are synchronized success
▪ if 2 or more nodes transmit in randomization – why?
slot, all nodes detect collision
Slotted ALOHA
node 1 1 1 1 1
node 2 2 2 2
C: collision
S: success
node 3 3 3 3
E: empty
C E C S E C E S S
Pros: Cons:
▪ single active node can ▪ collisions, wasting slots
continuously transmit at full rate ▪ idle slots
of channel
▪ nodes may be able to detect collision in
▪ highly decentralized: only slots in less than time to transmit packet
nodes need to be in sync
▪ simple ▪ clock synchronization
Slotted ALOHA: efficiency
efficiency: long-runfraction 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!
CSMA (carrier sense multiple access)
simple CSMA: listen before transmit:
• if channel sensed idle: transmit entire frame
• if channel sensed busy: defer transmission
▪ human analogy: don’t interrupt others!
CSMA/CD: CSMA with collision detection
• collisions detected within short time
• colliding transmissions aborted, reducing channel wastage
• collision detection easy in wired, difficult with wireless
▪ human analogy: the polite conversationalist
CSMA: collisions spatial layout of nodes
▪ collisions can still occur with
carrier sensing:
• propagation delay means two nodes
may not hear each other’s just-
started transmission
▪ collision: entire packet
transmission time wasted
• distance & propagation delay play
role in in determining collision
probability
CSMA/CD: spatial layout of nodes
▪ CSMA/CD reduces the amount of
time wasted in collisions
• transmission aborted on collision
detection
Ethernet CSMA/CD algorithm
1. Ethernet receives datagram from network layer, creates frame
2. If Ethernet senses channel:
if idle: start frame transmission.
if busy: wait until channel idle, then transmit
3. If entire frame transmitted without collision - done!
4. If another transmission detected while sending: abort, send jam signal
5. After aborting, enter binary (exponential) backoff:
• after mth collision, chooses K at random from {0,1,2, …, 2m-1}.
Ethernet waits K·512 bit times, returns to Step 2
• more collisions: longer backoff interval
CSMA/CD efficiency
▪ Tprop = max prop delay between 2 nodes in LAN
▪ ttrans = time to transmit max-size frame
1
efficiency =
1 + 5t prop /ttrans
▪ efficiency goes to 1
• as tprop goes to 0
• as ttrans goes to infinity
▪ better performance than ALOHA: and simple, cheap, decentralized !
“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!
“Taking turns” MAC protocols
polling:
▪ centralized controller “invites” other
nodes to transmit in turn data
poll
▪ typically used with “dumb” devices
▪ concerns: centralized
data controller
• polling overhead
• latency
• single point of failure (master) client devices
• Bluetooth uses polling
• Virtual Output Queue router
architectures
“Taking turns” MAC protocols
T
token passing:
▪ control token message
explicitly passed from one
(nothing
node to next, sequentially to send)
▪ transmit while holding T
token
▪ concerns:
• token overhead
• latency
• single point of failure data
(token)
Cable access network: FDM, TDM and random access!
Internet frames, TV channels, control transmitted
downstream at different frequencies
cable headend
CMTS
…
splitter cable
cable modem
… modem
ISP termination system
▪ multiple downstream (broadcast) FDM channels: up to 1.6 Gbps/channel
▪ single CMTS transmits into channels
▪ multiple upstream channels (up to 1 Gbps/channel)
▪ multiple access: all users contend (random access) for certain upstream
channel time slots; others assigned TDM
Cable access network:
MAP frame for
Interval [t1, t2]
Downstream channel i
CMTS
Upstream channel j
cable headend
t1 t2 Residences with cable modems
Minislots containing Assigned minislots containing cable modem
minislots request frames upstream data frames
DOCSIS: data over cable service interface specification
▪ FDM over upstream, downstream frequency channels
▪ TDM upstream: some slots assigned, some have contention
• downstream MAP frame: assigns upstream slots
• request for upstream slots (and data) transmitted random access (binary
backoff) in selected slots
Summary of MAC protocols
▪ channel partitioning, by time, frequency or code
• Time Division, Frequency Division
▪ random access (dynamic),
• ALOHA, S-ALOHA, CSMA, CSMA/CD
• carrier sensing: easy in some technologies (wire), hard in
others (wireless)
• CSMA/CD used in Ethernet
• CSMA/CA used in 802.11
▪ taking turns
• polling from central site, token passing
• Bluetooth, FDDI, token ring, VoQ router architecture
15 Minute Break!