0% found this document useful (0 votes)
6 views98 pages

Link Layer Protocols

Uploaded by

dhruba.saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views98 pages

Link Layer Protocols

Uploaded by

dhruba.saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Network:

Link Layer Protocols


Modified version:- Rajesh Palit, Ph.D., North South University, Dhaka
Link layer and LANs: our goals
▪understand principles
behind link layer services:
• error detection, correction
• sharing a broadcast channel:
multiple access
• link layer addressing
• local area networks:
Ethernet, VLANs
▪Wireless networks

Link Layer: 6-2


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

Link Layer 4
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 nodes
cellular
• we already know how to do this!
• seldom used on low bit-error links Ethernet LANs
• wireless links: high error rates
• Q: why both link-level and end-end
WiFi
reliability?
Link Layer 5
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
Link Layer 6
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

Link Layer 7
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
Link Layer 8
Error Detection and Correction

Link Layer 9
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 rarely
? error
d data bits ▪ larger EDC field yields
D EDC D’ EDC’ better detection and
correction
bit-error prone link

Link Layer 10
Parity checking Can detect and correct errors
single bit parity: (without retransmission!)
▪ detect single bit errors ▪ two-dimensional parity: detect
and correct single bit errors
0111000110101011 1 row parity
d data bits d1,1 ... d1,j d1,j+1
d2,1 ... d2,j d2,j+1
parity bit
... ... ... ...
Even/odd parity: set parity bit so di,1 ... di,j di,j+1
there is an even/odd number of 1’s column
parity di+1,1 ... di+1,j di+1,j+1
At receiver:
▪ compute parity of d received detected 10101 1
no errors: 1 0 1 0 1 1
bits 11110 0 and 10110 0 parity
error
▪ compare with received parity bit 01110 1
correctable
single-bit 01110 1
– if different than error detected 10101 0 error: 10101 0
parity
error
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
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)
Link Layer 12
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
D.2r 1 0 0 1
R = remainder [ ] algorithm for 0 1 1
G computing R
R
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Link Layer 13
Multiple Access Protocols

Link Layer 14
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/4G. 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)
Link Layer 15
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

Link Layer 16
An ideal multiple access protocol
given: multiple access channel (MAC) of rate R bps
desiderata:
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

Link Layer 17
MAC protocols: taxonomy
Three broad classes:
▪ channel partitioning
• divide channel into smaller “pieces” (time
slots, frequency, code)
• allocate piece to node for exclusive use
• TDMA, FDMA, CDMA
▪ random access
• channel not divided, allow collisions
• “recover” from collisions or do not let collision
happen
• ALOHA, Slotted ALOHA, CSMA/CD, CSMA/CA
▪ “taking turns”
• nodes take turns, but nodes with more to
send can take longer turns
• Polling, Token passing

Link Layer 18
A.1 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

Link Layer 19
A.2 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

Link Layer 20
A.3 Code Division Multiple Access (CDMA)
• Code Division Multiple Access system is very different from time and frequency multiplexing. In this
system, a user has access to the whole bandwidth for the entire duration. The basic principle is that different
CDMA codes are used to distinguish among the different users.
• A signal is generated which extends over a wide bandwidth. A code called spreading code is used to perform
this action.
• Using a group of codes, which are orthogonal to each other, it is possible to select a signal with a given code
in the presence of many other signals with different orthogonal codes.

Link Layer: 6-21


B. 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
• Carrier Sense Multiple Access (CSMA)
• CSMA/CD – collision detection
• CSMA/CA – collision avoidance Link Layer 22
Pure ALOHA efficiency
P(success by given node) = P(node transmits) *
P(no other node transmits in [t0-1,t0] * *
P(no other node transmits in [t0-1,t0]
= p . (1-p)N-1 . (1-p)N-1
= p . (1-p)2(N-1)
… choosing optimum p and then letting n
= 1/(2e) = 0.18

even worse than slotted Aloha!

Link Layer: 6-24


B.2 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

Link Layer 25
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 = 0.37
▪ at best: channel used for useful transmissions 37% of time!
Link Layer 26
B.3 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

Link Layer 27
B.3 Concepts of Carrier Sense and Collision Detection

Sense voltage (V) on medium:

V > Vth1 🡺 carrier is present


V > Vth2 🡺 collision

V
Vth2
MAC/
PHY Data Vth1
Time
Collision?
Tx Rx Carrier?

Medium
B.3 CSMA with Collision Detection

Signal from all nodes


must reach all others

A B C D

5-29
B.3 CSMA with Collision Detection

CSMA/CD: Carrier Sense Multiple Access with CD


▪ Tx attempts multiple times (multiple access)
▪ Collisions are detected within short time
▪ A colliding transmission is aborted - don’t keep wasting
channel resource
 Collision detection:
▪ Easy in wired LANs: explained before …

▪ Not possible in wireless LANs: will be explained …

5-30
New frame
Exponential backoff
CSMA/CD Start:
i=0

Sense medium

Wait Bus Y
TB = R*Tp Wait
y
N

R = Random(0,2i-1) Transmit frame


WHILE
detecting collision
No
Collision
No collision
i>
i++ Send jamming signal +
Kmax
(10) Abort

Yes
Success
Error

5-31
B.3 CSMA with Collision Detection

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

32
Computers A, B, and C and one router are connected
to an Ethernet bus 100 metres apart
to make a LAN using the CSMA/CD protocol.
Assume that signal propagates on the Ethernet bus at a
speed of 2 x 108 m/sec, and all nodes can transmit data
at the rate of 100 Mbps .

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?

5-33
CSMA/CA is discussed later on

5-34
C. 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!

Link Layer 35
C.1 Taking turns MAC protocols: Polling
Polling:
▪ centralized controller “invites”
other nodes to transmit in turn data
poll
▪ typically used with “dumb”
devices centralized
data controller
▪ concerns:
• polling overhead
• latency
client devices
• single point of failure (master)
• Bluetooth uses polling

Link Layer 36
C.2 Taking turns MAC protocols: Token Passing
T
token passing:
▪ control token message
explicitly passed from one node
(nothing
to next, sequentially to send)
▪ transmit while holding token T
▪ concerns:
• token overhead
• latency
• single point of failure
(token) data

Link Layer 37
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 (later)
▪ taking turns
• polling from central site, token passing
• Bluetooth, FDDI, token ring

Link Layer: 6-38


Medium Access Control (MAC) Address

5-39
MAC addresses
▪ 32-bit IP address:
• network-layer address for interface
• used for layer 3 (network layer) forwarding
• e.g.: 128.119.40.136
▪ MAC (or LAN or physical or Ethernet) address:
• function: used “locally” to get frame from one interface to another
physically-connected interface (same subnet, in IP-addressing sense)
• 48-bit MAC address (for most LANs) burned in NIC ROM, also
sometimes software settable
• e.g.: 1A-2F-BB-76-09-AD
hexadecimal (base 16) notation
(each “numeral” represents 4 bits)
Link Layer: 6-40
MAC addresses
each interface on LAN
▪ has unique 48-bit MAC address
▪ has a locally unique 32-bit IP address (as we’ve seen)

137.196.7.78
1A-2F-BB-76-09-AD

LAN
(wired or wireless)
137.196.7/24
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14

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

Link Layer: 6-41


MAC addresses
▪ MAC address allocation administered by IEEE
▪ manufacturer buys portion of MAC address space (to
assure uniqueness)
▪ analogy:
• MAC address: like Social Security Number
• IP address: like postal address
▪ MAC flat address: portability
• can move interface from one LAN to another
• recall IP address not portable: depends on IP subnet to which
node is attached
Link Layer: 6-42
ARP: address resolution protocol
Question: how to determine interface’s MAC address, knowing its IP
address?
ARP table: each IP node (host,
ARP
router) on LAN has table
137.196.7.78
ARP
1A-2F-BB-76-09-AD • IP/MAC address mappings for
ARP some LAN nodes:
LAN < IP address; MAC address; TTL>
71-65-F7-2B-08-53
137.196.7.23
58-23-D7-FA-20-B0
137.196.7.14 • TTL (Time To Live): time after
ARP 0C-C4-11-6F-E3-98 which address mapping will be
137.196.7.88
forgotten (typically 20 min)

Link Layer: 6-43


ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address

A broadcasts ARP query, containing B's IP addr


Ethernet frame (sent to FF-FF-FF-FF-FF-FF)
1 • destination MAC address = FF-FF-FF-FF-FF-FF
• all nodes on LAN receive ARP query C Source MAC: 71-65-F7-2B-08-53
Source IP: 137.196.7.23
ARP table in A Target IP address: 137.196.7.14

IP addr MAC addr TTL
TTL
A B
1
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14

D
Link Layer: 6-44
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address

ARP message into Ethernet frame


(sent to 71-65-F7-2B-08-53)
C Target IP address: 137.196.7.14
Target MAC address:
ARP table in A 58-23-D7-FA-20-B0

IP addr MAC addr TTL
TTL
A B
2
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14

2 B replies to A with ARP response,


giving its MAC address
D
Link Layer: 6-45
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address

C
ARP table in A
IP addr MAC addr TTL
TTL
137.196. 58-23-D7-FA-20-B0 500
A B
7.14

71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14

3 A receives B’s reply, adds B entry


into its local ARP table
D
Link Layer: 6-46
Ethernet Switch

Link Layer: 6-47


Ethernet: physical topology
▪ bus: popular through mid 90s
• all nodes in same collision domain (can collide with each other)
▪ switched: prevails today
• active link-layer 2 switch in center
• each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with
each other)

bus: coaxial cable switched

Link Layer: 6-48


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

5-49
Ethernet switch
▪ Switch is a link-layer device: takes an active role
• store, forward Ethernet (or other type of) frames
• examine incoming frame’s 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
▪ transparent: hosts unaware of presence of switches
▪ plug-and-play, self-learning
• switches do not need to be configured

Link Layer: 6-50


Switch: multiple simultaneous transmissions
▪ hosts have dedicated, direct
connection to switch A
▪ switches buffer packets C’ B
▪ Ethernet protocol used on each 1 2
incoming link, so: 6
3
• no collisions; full duplex 5 4
• each link is its own collision
domain B’ C
A’
▪ switching: A-to-A’ and B-to-B’ can transmit
simultaneously, without collisions switch with six
interfaces (1,2,3,4,5,6)

Link Layer: 6-51


Switch: multiple simultaneous transmissions
▪ hosts have dedicated, direct
connection to switch A
▪ switches buffer packets C’ B
▪ Ethernet protocol used on each 1 2
incoming link, so: 6
3
• no collisions; full duplex 5 4
• each link is its own collision
domain B’ C
A’
▪ switching: A-to-A’ and B-to-B’ can transmit
simultaneously, without collisions switch with six
interfaces (1,2,3,4,5,6)
• but A-to-A’ and C to A’ can not happen
simultaneously
Link Layer: 6-52
Switch forwarding table
Q: how does switch know A’ reachable via
interface 4, B’ reachable via interface 5? A
C’ B
A: each switch has a switch table, each
entry: 1 2
6
▪ (MAC address of host, interface to reach 3
5 4
host, time stamp)
▪ looks like a routing table! B’ C
A’
Q: how are entries created, maintained
in switch table?
▪ something like a routing protocol?
Link Layer: 6-53
Switch: self-learning
Source: A
Dest: A’
▪ switch learns which hosts
A A’
can be reached through A
which interfaces C’ B
• when frame received, switch 1 2
6
“learns” location of sender: 3
5
incoming LAN segment 4

• records sender/location pair B’ C


A’
in switch table
Switch table
MAC addr interface TTL (initially empty)
A 1 60

Link Layer: 6-54


Switch: frame filtering/forwarding
when frame received at switch:
1. record incoming link, MAC address of sending host
2. index switch table using MAC destination address
3. if entry found for destination
then {
if destination on segment from which frame arrived
then drop frame
else forward frame on interface indicated by entry
}
else flood /* forward on all interfaces except arriving interface */

Link Layer: 6-55


Self-learning, forwarding: example Source: A
Dest: A’

▪ frame destination, A’, A A’


location unknown: flood A
C’ B
▪ destination A location
1
known: selectively send 6A A’
2

on just one link 3


5 4

B’ C
A’ A A’

MAC addr interface TTL


A 1 60 switch table
A’ 4 60 (initially empty)

Link Layer: 6-56


Interconnecting switches
self-learning switches can be connected together:

S4

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

Q: sending from A to G - how does S1 know to forward frame destined


to G via S4 and S3?
A: self learning! (works exactly the same as in single-switch case!)

Link Layer: 6-57


Switches vs. routers application
transport
both are store-and-forward: datagram
frame
network
link
▪ routers: network-layer devices (examine physical link frame
network-layer headers) physical

▪ switches: link-layer devices (examine switch


link-layer headers) network datagram
link frame
both have forwarding tables: physical
▪ routers: compute tables using routing application
algorithms, IP addresses transport
▪ switches: learn forwarding table using network
link
flooding, learning, MAC addresses
physical

6-586-58
Link Layer:
Virtual LAN

Link Layer: 6-59


Port-based VLANs port-based VLAN: switch ports grouped (by
switch management software) so that
single physical switch ……
Virtual Local Area
Network (VLAN) 7 9 15
1
2 8 10 16
switch(es) supporting
… …
VLAN capabilities can
EE (VLAN ports 1-8) CS (VLAN ports 9-15)
be configured to define
multiple virtual LANS … operates as multiple virtual switches
over single physical LAN
infrastructure.
1 7 9 15

2 8 10 16

… …
EE (VLAN ports 1-8) CS (VLAN ports 9-15)

Link Layer: 6-60


Port-based VLANs
▪ 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
▪ dynamic membership: ports can be
dynamically assigned among VLANs 1 7 9 15

2 8 10 16

▪ forwarding between VLANS: done via … …


routing (just as with separate switches) EE (VLAN ports 1-8) CS (VLAN ports 9-15)

• in practice vendors sell combined switches


plus routers

Link Layer: 6-61


VLANS spanning multiple switches

1 7 9 15 1 3 5 7
2 8 10 16 2 4 6 8

… … …
EE (VLAN ports 1-8) CS (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 can’t be vanilla 802.1
frames (must carry VLAN ID info)
▪ 802.1q protocol adds/removed additional header fields for frames
forwarded between trunk ports
Link Layer: 6-62
EVPN: Ethernet VPNs (aka VXLANs)

5
1 7 9 15 1 3 7
2 8 10 16 IP Ethernet 2 4 6 8
datagram frame
… … …
Sunnyvale Bangalore
data center Ethernet data center

Layer-2 Ethernet switches logically connected to each other (e.g., using IP as an


underlay)
▪ Ethernet frames carried within IP datagrams between sites
▪ “tunneling scheme to overlay Layer 2 networks on top of Layer 3 networks ... runs over
the existing networking infrastructure and provides a means to "stretch" a Layer 2
network.” [RFC 7348]
Link Layer: 6-63
CSMA/CA
CSMA with Collision Avoidance

Link Layer: 6-64


B.4 CSMA/CA → Wireless LAN

WAN Standards: IEEE 802.11/a/b/g/n/ac


LAN
WWAN
WLAN
MAN

CSMA/CD
IEEE 802.3 Protocol Number LAN
Ethernet

CSMA/CA
IEEE 802.11 CSMA/CD
WiFi

5-65
WLAN: Basic idea

C: Computer, AP: Access Point

C Access
Point Basic Service Set
(identified by the MAC address of the AP:
C
BSSID)

Radio range of the AP

Independent BSS (IBSS)= BSS – AP

Extended Service Set (ESS): A collection of BSS


connected by a Distribution System
Example: The NSU WiFi network is one ESS.
5-66
IEEE 802.11 Wireless LAN
IEEE 802.11 standard Year Data Rate Range Frequency Signal Transmission
802.11b 1999 11 Mbps 30 m 2.4 Ghz DHSS
802.11g 2003 54 Mbps 30m 2.4 Ghz OFDM
802.11n (WiFi 4) 2009 600 Mbps 70m 2.4, 5 Ghz OFDM

802.11ac (WiFi 5) 2013 3.47 Gbps 70m 5 Ghz OFDM

802.11ax (WiFi 6) 2020 14 Gbps 70m 2.4, 5 Ghz OFDM


35 – 560 unused TV bands
802.11af 2014 1 Km OFDM
Mbps (54-790 MHz)
802.11ah 2017 347Mbps 1 Km 900 Mhz OFDM

▪ all use CSMA/CA for multiple access, and have base-station and ad-hoc
network versions

Wireless and Mobile Networks: 7- 67


802.11: Channels

▪ spectrum divided into channels at different frequencies


• AP admin chooses frequency for AP
• interference possible: channel can be same as that chosen by
neighboring AP!

Example: 2.4 GHz

Class 22: 68
Different Modes of Operation of MAC in IEEE 802.11

Modes of IEEE
802.11 MAC

Distributed Coordination Point Coordination Function


Function (DCF) mode (PCF) mode

Handshake Without Handshake mode


mode

5-69
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

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

71
AP

PCF DCF PCF DCF PCF


T1 T2 T3 T4 Time

Handshake
Without
handshake
5-72
Handshake mode

Frame length >= dotRTSThreshold

5-73
DCF with handshake
Control Frames:
RTS: Request To Send
CTS: Clear To Send

Sender handshake Receiver

Repeat this…
74
DCF without handshake

Sender Receiver

Repeat
this…

75
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

5-76
As a result, if your frame
encountered collision at the
receiver, you are NOT aware Hidden Terminal Problem
of that. Exposed Terminal Problem
5-77
Hidden Terminal Problem
C is transmitting a frame to B.
A is unaware of C’s Tx.

A B C

Now, if A transmits, A’s frame will collide with C’s at B

• This problem is due to C being hidden from A.


• Hidden means being “far away” … Solution exists:
CSMA/CA
(Collision
Avoidance)

5-78
Exposed Terminal Problem

A B C
No solution has
been provided so
D far…..

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.

Problem: Loss of opportunity to transmit 🡺 Loss of bandwidth ….

The above problem is due to B being exposed to A’s Tx.

5-79
WLAN MAC: CSMA/CA (basic idea)
 Collision is avoided by using two techniques
▪ PHY-level carrier sensing: Done in receiver hardware

▪ Virtual carrier sensing:


• An integer variable in each node – called NAV (Network
Allocation Vector) -- indicates whether or not a nearby node
is likely to be transmitting now.
• NAV > 0 🡺 Most likely another node is transmitting.
• NAV = 0 🡺 No one nearby is transmitting.
• NAV < 0: This condition does not occur.

❖ Transmit condition: Medium is idle at the receiver.

(Carrier is absent) AND (NAV = 0)

Time 80
CSMA/CA: NAV in detail
• Recall the handshake mechanism with RTS and CTS
• A duration field in frame header indicates the length
of time the sender of the frame may use the medium.
• All nodes which receive RTS and CTS (and DATA )
update their NAV as follows
Events that update NAV: Initially NAV = 0

With each passing μs (micro second)


If (NAV > 0 ) NAV = NAV – 1
Else stop decrementing NAV

If a frame (e.g. RTS, CTS) with duration field is received


NAV = Max(NAV, duration)

81
RTS and CTS Frames

RTS Frame
Duration RA TA FCS
Control
2 2 6 6 4 bytes

CTS/ Frame Duratio


RA FCS
ACK Control n
2 2 6 4 bytes

FCS: Frame Check Sequence 🡸 CRC


RA: Receiver Address
TA: Transmitter Address

82
DATA Frame

Frame Seq.
Contr Duration A1 A2 A3 contr A4 Frame Body FCS
ol ol
RA TA

TA: Physically transmitting the frame.

TA RA

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

• 2 at the MAC level


• PIFS: Priority (in PCF) IFS (SIFS + aSlot)
• DIFS: Distributed IFS (PIFS + aSlot)

aSlot is chosen s.t. a node can


determine if another node
initiated a Tx aSlot time before
(= propagation time + some hardware delay)

Time
84
Timing intervals are used to control priority

SIFS
PIFS
DIFS

By keeping SIFS shortest, it is ensured that an


ongoing cycle of Tx (with handshake or without handshake)
is not disturbed ….
No one else can Tx between RTS, CTS, DATA, ACK.

PIFS < DIFS enables an AP to become


the controller of a BSS …

5-85
Handshake using RTS/CTS (A wants to send data to B)
(Note: “duration” info in DATA will not be shown.)

A B
Medium is idle
&& NAV == 0 D
C
Value of “duration” in RTS

DIFS RTS SIFS


DATA
A

SIFS Value of “duration” in CTS


SIFS
CTS ACK
B
Min value of NAV of C

C
(neighbors of A)
Min value of NAV of D
D
(neighbors of B) Time

5-86
F: a new data frame to be transmitted
DCF with Hand-shake: Tx
i = 0, CW = CWmin

No NAV =0?
End of
Yes backoff

Medium idle No Random


for DIFS? 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)

5-87
Backoff Mechanism
 Initialize a counter: Backoff Time Counter (BTC)
▪ BTC = Random(0,CW-1) ……time unit of BTC is aSlot

❖ As time passes, BTC is decremented as follows


At the start, let ch. remain idle for DIFS.
Next, if ch. is idle for aSlot: BTC = BTC -1 🡺 Repeat this

Anytime the medium is busy: Freeze BTC

❖BTC == 0 🡺 End of backoff

88
Backoff Mechanism

Ch. busy due Ch. Busy due to


to node A node C

Time
DIFS DIFS
X X X X

B 5 4 3 3 3 2 1 0
BTC = 5

B is executing backoff
X = aSlotTime

5-89
DCF with Handshake: Rx

Receive RTS
Receive DATA frame

No
NAV = 0?

Yes

No Medium idle for No


Medium idle for SIFS?
SIFS?
Yes

Yes

Send CTS Send ACK

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

5-90
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

RTS/CTS This must process


received RTS/CTS

91
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

5-92
PCF Mode: AP becomes the controller: How?
 AP alternates between PCF and DCF modes
SIFS
PIFS
DIFS

❖ AP operates as the controller as follows

If AP finds medium to be idle (no carrier && NAV == 0) for PIFS, it transmits a
beacon frame.
Beacon contains a CFPMaxDuration field (CFP: Contention Free Period)

Nodes receiving a beacon update their NAV to CFPMaxDuration

These nodes perceive the medium to be busy for CFPMaxDuration


They do not transmit unless asked to do so by the AP.

93
Optional
PCF Mode of Operation (Contd.)

▪ After transmitting a beacon, AP waits for PIFS before transmitting


one of the following

• DATA frame
• CF Poll frame (CF: Contention Free)
• DATA+CF Poll frame
• ACK frame
• CF End frame

94
PCF Mode of Operation (Contd.) Optional

CF Poll frame If a user does not have


data, it sends a null DATA
frame (A DATA frame with no
actual data)

AP User 1 User 2 AP User 1


PIFS PIFS
CF Poll CF Poll

SIFS SIFS
DATA DATA

SIFS SIFS
ACK ACK

PIFS PIFS

Time

5-95
PCF Mode of Operation (Contd.) Optional

DATA + CF Poll frame


AP User 1 User 2
PIFS DATA+CF
Poll

SIFS

SIFS
ACK
DATA

SIFS

ACK

PIFS

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.
5-96
Optional
PCF Mode of Operation (Contd.)
DATA from AP (unicast): 1 🡪 1 DATA from AP (broadcast): 1 🡪 all
User 2
AP User 1 User 1 AP

DATA DATA
DATA

PIFS
SIFS
DATA
DATA

ACK PIFS
PIFS
DATA DATA
DATA
(lost)
PIFS
SIFS DATA
DATA
(lost)
ACK

No ACK….

5-97
Optional
PCF Mode of Operation (Contd.)

 CF End frame
▪ Identifies the end of CF period

– Receiving nodes set NAV = 0.

98
Summary: Link Layer Protocols
▪ principles behind data link layer services:
• error detection, correction
• sharing a broadcast channel: multiple access
• link layer addressing
▪ instantiation, implementation of various link layer technologies
• Ethernet
• switched LANS, VLANs
▪ Wireless Networks

Link Layer: 6-99

You might also like