Computer Networks: Link Layer and Lans: Rajesh Palit, Ph.D. North South University, Dhaka
Computer Networks: Link Layer and Lans: Rajesh Palit, Ph.D. North South University, Dhaka
4
: 3 Error detection
1 2 Correction
(optional)
App
TCP
Network Layer Network Layer
ARP FC ARP FC
Dest Link
MAC Layer
addr MAC MAC
Terminology:
wired
hosts and routers are nodes
communication channels that
connect adjacent nodes are links
wired links
wireless links
wired
wireless
error detection:
errors caused by signal attenuation and noise
3
receiver detects presence of errors
error correction:
receiver identifies and corrects bit error(s) without resorting
to retransmission
receiver signals sender for retransmission
flow control:
pacing between (adjacent) sending and receiving nodes
datagram datagram
controller controller
datagram
Rx 10 0010 0011100111
Metric used to represent transmission media
otherwise
Send this
………… But, this is received
… but this is
what you
Send this receive 0
0
Even parity
DES
11001101|
10111011|
011010 11 |
10000101 |
receiver knows G:
Divides <D,R> by G. If non-zero remainder: error detected!
D.2r
R = remainder[ ]
G
D.2r: 1 1 0 0 1 1 0 1 0 0 0 ?
G: 1 0 1 1
------------------
humans at a
shared wire (e.g., shared RF shared RF cocktail party
cabled Ethernet) (e.g., 802.11 WiFi) (satellite) (shared air, acoustical)
PHY
Rx Link/MAC
+ PHY
Link/MAC
data
Tx
PHY
24
Ideal Multiple Access Protocol
Broadcast channel of rate R bps
1. when one node wants to transmit, it can send at rate R.
3. fully decentralized:
no special node to coordinate transmissions
no synchronization of clocks, slots
Random Access
channel not divided, allow collisions
“recover” from collisions OR do not let collision happen
“Taking turns”
nodes take turns
6-slot
frame
1 3 4 1 3 4
frequency bands
FDM cable
Two types
Pure Aloha (Continuous time)
Slotted Aloha
30
Pure Aloha (Sender)
Wait for TB
TB = R*Tp
Transmit
<Frame, EDC>
(0, 63)
(0, 31)
(0, 15)
R = Random(0,2i-1) (0, 7)
(0, 3) Start a timer
(0, 1)
No T = 2*Tp + Δ
Yes
Success
Error
31
Pure Aloha
OK…
This is my
homework…
= G * e-2G
G: Number of packets in X sec.
Assumptions:
all frames are same size Operation:
time divided into equal when node obtains fresh frame,
size slots (time to transmit transmit in next slot
1 frame) if Tx is not successful,
nodes start to transmit
retransmit in following slots
only at slot beginning
after some wait..
nodes are synchronized
= G * e-G
G: Number of packets in X sec.
V
Vth2
MAC/
PHY Data Vth1
Time
Collision?
Tx Rx Carrier?
Medium
38
CSMA/CD collision detection
A B C D
Sense medium
Wait Y
TB = R*Tp Busy Wait
Yes
Success
Error
41
CSMA/CD
42
Past final
exam
A B C D
A B C Router
100 m 100 m 100 m
• After finding the bus to be idle for a little while, A and the router
start transmitting their frames exactly at the same time. How many
bits of data can node A transmit before detecting collision?
• What is the maximum time gap between the start of transmission and
detection of collision by A?
• What is the length of the smallest frame that A can transmit while
knowing whether or not it collided with a transmission from the
router?
Data Link Layer 5-44
“Taking Turns” MAC protocols
channel partitioning MAC protocols:
share channel efficiently and fairly at high load
inefficient at low load: 1/N bandwidth allocated even if only 1
active node!
random access MAC protocols:
efficient at low load: single node can fully utilize
channel
Much collision overhead at high load
“taking turns” protocols
look for best of both worlds!
Load
Taking turns
Data Link Layer 5-45
“Taking Turns” MAC protocols
Polling:
master node “invites”
slave nodes to data
poll
transmit in turn
typically used with master
“dumb” slave devices data
concerns:
polling overhead
latency slaves
single point of failure
(master)
data
Data Link Layer 5-47
Data Link Layer 5-48
Link Layer
5.1 Introduction and 5.6 Link-layer switches
services 5.7 PPP
5.2 Error detection and 5.8 Link virtualization: MPLS
correction 5.9 A day in the life of a web
5.3Multiple access request
protocols
5.4 Link-Layer Addressing 3.4 Reliable data transfer
5.5 Ethernet
Preamble:
7 bytes with pattern 10101010 followed by one byte with
pattern 10101011
used to synchronize receiver, sender clock rates
MAC protocol
application and frame format
transport
network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX
physical
1A-2F-BB-76-09-AD
LAN
(wired or = adapter
wireless)
71-65-F7-2B-08-53
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
Broadcast addr. =
FF-FF-FF-FF-FF-FF
Data Link Layer 5-54
ARP context MAC: Medium Access Control
4
: 3 Error detection
1 2 Correction
(optional)
App
TCP
Network Layer Network Layer
ARP FC ARP FC
Dest Link
MAC Layer
addr MAC MAC
IP
Eth
Phy
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
IP IP
Eth Eth
Phy Phy
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
IP
Eth
Phy
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
switch
twisted pair
hub
transparent
star
hosts are unaware of presence of switches
plug-and-play, self-learning
switches do not need to be configured
C
B’ A’
switch with six interfaces
(1,2,3,4,5,6)
B’ A’
A A A’
frame destination C’ B
unknown: flood
1 2
A6A’ 3
destination A 4
5
location known:
selective send A’ A
C
B’ A’
S1
S3
A S2
F
D I
B C
G H
E
1 S4
S1 2 S3
A S2
F
D I
B C
G H
E
LAN
CSMA/CD
75
WLAN: Basic idea
C: Computer, AP: Access Point
C Access
Point Basic Service Set
(identified by the MAC address of the AP:
C
BSSID)
Modes of IEEE
802.11 MAC
79
PCF Mode
The AP
• Operates as the central controller in the BSS.
• Decides who transmits and when.
• There is no contention for medium access
• Can follow a round-robin policy to allocate slots.
This mode
• Leads to waste of bandwidth if a scheduled node has no traffic.
• Is based on the idea of polling Recall “taking-turns” MAC
80
DCF Mode
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.
81
AP
Handshake
Without
handshake
Data Link Layer 5-82
Handshake mode
Repeat this…
84
DCF without handshake
Sender Receiver
Repeat
this…
85
Signal from all nodes
must reach all others
Wired
This diff. leads
to some problems
Signal from some nodes
A B C
may not reach all others
Wireless
D
88
Hidden Terminal Problem
C is transmitting a frame to B.
A is unaware of C’s Tx.
A B C
Solution exists:
CSMA/CA
(Collision Avoidance)
89
Exposed Terminal Problem
A B C
No solution has been
provided so far…..
D
A is transmitting a frame to D.
B knows that someone is transmitting.
If B transmits a frame to C, it does not collide with A’s at D.
However, B does not transmit because B is unaware of D’s location.
90
WLAN MAC: CSMA/CA (basic idea)
Time 91
CSMA/CA: NAV in detail
• Recall the handshake mechanism with RTS and CTS
92
RTS and CTS Frames
RTS Frame
Duration RA TA FCS
Control
2 2 6 6 4 bytes
CTS/ Frame
Duration RA FCS
ACK Control
2 2 6 4 bytes
93
DATA Frame
Frame Seq.
Duration A1 A2 A3 A4 Frame Body FCS
Control control
RA TA
TA RA
94
Timing Intervals
The IEEE 802.11 MAC defines 4 timing intervals
• 2 at the PHY level
• SIFS: Short Inter-Frame Space (10 micro-sec) between
successive frames (RTS, CTS, DATA, ACK, …)
• aSlot (20 micro-sec)
Time
95
Timing intervals are used to control priority
SIFS
PIFS
DIFS
A B
Medium is idle
&& NAV == 0 D
C
Value of “duration” in RTS
C
(neighbors of A)
Min value of NAV of D
D
(neighbors of B) Time
97
DCF with Hand-shake: Tx
F: a new data frame to be transmitted
i = 0, CW = CWmin
No NAV =0?
End of
Yes backoff
Yes
Send RTS
Start a timer
Timeout
CTS is received
Cancel timer
Send DATA (F)
Start a timer
Timeout
ACK is received
i = i+1
CW = CWmin*2i
( CW saturates at CWmax)
98
Backoff Mechanism
Initialize a counter: Backoff Time Counter (BTC)
BTC = Random(0,CW-1) ……time unit of BTC is aSlot
99
Backoff Mechanism
Time
DIFS DIFS
X X X X
B 5 4 3 3 3 2 1 0
BTC = 5
B is executing backoff
X = aSlotTime
100
DCF with Handshake: Rx
Receive RTS
Receive DATA frame
No
NAV = 0?
Yes
Yes
101
DCF Mode without Handshake
A special case of DCF without handshake
RTS/CTS frames are not exchanged.
The idea of NAV is still used in this mode
Recall: All nodes process the received RTS/CTS of others
Without
handshake
102
Data transmission without handshake
(A wants to send data to B)
A B
Medium is idle D
&& NAV == 0
C
Value of “duration”
in DATA
DIFS DATA
A
SIFS
ACK
B
Value of NAV of C
C
(neighbor of A)
D
(neighbor of B) Time
103
PCF Mode: AP becomes the controller: How?
AP alternates between PCF and DCF modes
SIFS
PIFS
DIFS
• DATA frame
• CF Poll frame (CF: Contention Free)
• DATA+CF Poll frame
• ACK frame
• CF End frame
105
PCF Mode of Operation (Contd.)
If a user does not have
CF Poll frame data, it sends a null DATA frame
(A DATA frame with no actual data)
SIFS SIFS
DATA DATA
SIFS SIFS
ACK ACK
PIFS PIFS
Time
106
PCF Mode of Operation (Contd.)
DATA + CF Poll frame
AP User 1 User 2
PIFS DATA+CF
Poll
SIFS
SIFS
ACK
DATA
SIFS
ACK
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.
107
PCF Mode of Operation (Contd.)
DATA from AP (unicast): 1 1 DATA from AP (broadcast): 1 all
AP User 1 User 1 AP User 2
DATA DATA
DATA
PIFS
SIFS
DATA
DATA
ACK PIFS
PIFS
DATA DATA
DATA
(lost)
PIFS
SIFS DATA
DATA
(lost)
ACK
No ACK….
108
PCF Mode of Operation (Contd.)
CF End frame
Identifies the end of CF period
– Receiving nodes set NAV = 0.
109
Summary of MAC protocols
channel partitioning by time, frequency or code
Time Division, Frequency Division, Code Division
random access (dynamic),
ALOHA, S-ALOHA, CSMA/CD, CSMA/CA
carrier sensing: easy in some technologies (wire), hard in wireless
CSMA/CD used in Ethernet based LAN
CSMA/CA used in WiFi (802.11) based WLAN
taking turns
polling from central site, token passing
Examples: Bluetooth, IBM Token Ring
master
Bluetooth
piconet
Up to 7 slaves
Clearly explain why the timing intervals SIFS, PIFS, and DIFS have
been ordered as SIFS < PIFS < DIFS in the CSMA/CA protocol.
Link Layer5-112