Lec04 Link
Lec04 Link
Note: The slides are adapted from the materials from Prof. Richard Han at CU Boulder and Profs. Jennifer Rexford and Mike Freedman at Princeton University,
and the networking book (Computer Networking: A Top Down Approach) from Kurose and Ross.
Broadcast Links: Shared Media
2
3
5
Outline
• Link-layer protocols
– Encoding, framing, error detection
6
Digital -> Analog Encoding
• Signals sent over physical links
– Source node: bits -> signal
– Receiving node: signal -> bits
• Encoding in telegraph
– Morse code: “long”
and “short” signals
7
Digital -> Analog Encoding
• Signals sent over physical links
– Source node: bits -> signal
– Receiving node: signal -> bits
• Simplify some electrical engineering details
– Assume two discrete signals, high and low
– E.g., could correspond to two different voltages
• Simple approach: Non-return to zero
– High for a 1, low for a 0
8
Problem With NRZ
• Long strings of 0s or 1s introduce problems
– No transitions from low-to-high, or high-to-low
• Clock-based
– Make each frame a fixed size
– No ambiguity about start and end of frame
– But, may be wasteful 13
Character/Byte Stuffing Example
• Sentinel X, at both start and end of packet
• Stuff X in data, replace X with escape character
“E” (DLE in textbook) and X, i.e., X -> (E,X)
• PPP uses byte stuffing for PPP data payload
Data: AKLWXIKKEZLXKDKLEXYBE
Send: XAKLWEXIKKEEZLEXKDKLEEEXYBEEX
Receiver: AKLWXIKKEZLXKDKLEXYBE
14
Bit Stuffing Example
• Similar to byte stuffing, except bit stuffing is not confined to byte
boundaries
• HDLC denotes beginning and end of a packet/frame with
“01111110” flag
• Since “01111110” may occur anywhere (across byte boundaries)
in data, then “stuff” it:
– At sender, after 5 consecutives one, insert a “0”
– At receiver, “0111110” -> stuffing, so destuff, “01111110” -> end of frame,
“01111111” -> error
Data: 0110111111100111110111111111100000
Send: 0111110011011111011001111100111110111110000000111110
Receiver: 0110111111100111110111111111100000
15
Error Detection
• Errors are unavoidable
– Electrical interference, thermal noise, etc.
• Error detection
– Transmit extra (redundant) information
– Use redundant information to detect errors
– Extreme case: send two copies of the data
– Trade-off: accuracy vs. overhead
16
Probability of Packet Error
• Send N bits. Probability of bit error = Pb
• Assume independent bit errors. What is the
probability of packet error?
– Prob[packet error] = Prob[at least 1 bit is corrupt]
= 1- Prob[every bit is clean] = 1-(1-Pb)N
– If Pb= 10-6, and N=10000 bits, then
Prob[packet error] = 9.95 * 10-3 ~= 1%
• Optical links have much lower probabilities of bit
error: 10-12
• Wireless links have much higher probabilities of bit
error: 10-3
– Bit errors correlated, not independent
17
Error detection
EDC: error detection and correction bits (e.g., redundancy)
D: data protected by error checking, may include header fields
23
Error Correction (Continued)
• Forward Error Correction (FEC)
– Many types, e.g., Reed-Solomon coding
– Add K bits of redundancy to N bits, to form a (N+K)-bit
long packet, or vector
25
Collisions
71-65-F7-2B-08-53 1A-2F-BB-76-09-AD
0C-C4-11-6F-E3-98
28
Channel Partitioning: FDMA
FDMA: frequency division multiple access
• Channel spectrum divided into frequency bands
– Each station has fixed frequency band (Wifi channels 1-11)
• Unused transmission time in bands go idle
• Example: 6-station LAN with bands 1, 3, and 4
frequency bands
29
Channel Partitioning: FDMA
FDMA: frequency division multiple access
• Channel spectrum divided into frequency bands
– Each station has fixed frequency band (Wifi channels 1-11)
• Unused transmission time in bands go idle
• Example: 6-station LAN with bands 1, 3, and 4
30
“Taking Turns” MAC protocols
Polling Token passing
• Primary node “invites” • Control token passed from
secondary nodes to one node to next sequentially
transmit in turn • Token message
• Concerns: • Concerns:
– Polling overhead – Token overhead
– Latency – Latency
– Single point of failure – Single point of failure (token)
(primary)
31
Random Access Protocols
• When node has packet to send
– Transmit at full channel data rate R.
– No a priori coordination among nodes
assumptions: operation:
▪ all frames same size ▪ when node obtains fresh
▪ time divided into equal size frame, transmits in next slot
slots (time to transmit 1 • if no collision: node can send
frame)
new frame in next slot
▪ nodes start to transmit only
slot beginning • if collision: node retransmits
▪ nodes are synchronized frame in each subsequent
slot with probability p until
▪ if 2 or more nodes transmit in success
slot, all nodes detect collision
randomization – why?
Slotted ALOHA
node 1 1 1 1 1
2 2 2
C: collision
node 2
S: success
3
node 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
▪ highly decentralized: only slots in in less than time to transmit packet
nodes need to be in sync
▪ simple ▪ clock synchronization
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:
t0 - 1 t0 t0 + 1
0.37
0.18
38
CSMA (Carrier Sense Multiple Access)
• Collisions hurt the efficiency of ALOHA protocol
– At best, channel is useful 37% of the time
• ALOHA: transmit before listen
• CSMA: listen before transmit
– If channel sensed idle: transmit entire frame
– If channel sensed busy, defer transmission
• 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
39
CSMA (Carrier Sense Multiple Access)
CSMA: Listen before transmit spatial layout of nodes
40
CSMA/CD Collision Detection
• Detect collision
– Abort transmission
– Jam the link
• Hard in wireless
– Must receive data
while transmitting
41
Ethernet CSMA/CD algorithm
cable headend
CMTS
…
splitter cable
cable modem
… modem
ISP termination system
Downstream channel i
CMTS
Upstream channel j
cable headend
t1 t2 Residences with cable modems
• “Taking turns”
(a) Inefficient at high load
(b) Efficient at all loads
(c) Robust to failures
• Random access
(a) Inefficient at low load
(b) Efficient at all load
(c) Robust to failures
46