0% found this document useful (0 votes)
42 views112 pages

Computer Networks: Link Layer and Lans: Rajesh Palit, Ph.D. North South University, Dhaka

The document discusses the link layer and local area networks (LANs). It covers topics such as link layer services including error detection, multiple access protocols like WiFi, link layer addressing, and Ethernet. Key aspects of the link layer are that it provides sharing of broadcast channels using MAC protocols, handles error detection and flow control, and implements link layer addressing between networked devices using MAC addresses.

Uploaded by

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

Computer Networks: Link Layer and Lans: Rajesh Palit, Ph.D. North South University, Dhaka

The document discusses the link layer and local area networks (LANs). It covers topics such as link layer services including error detection, multiple access protocols like WiFi, link layer addressing, and Ethernet. Key aspects of the link layer are that it provides sharing of broadcast channels using MAC protocols, handles error detection and flow control, and implements link layer addressing between networked devices using MAC addresses.

Uploaded by

WaleedWael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 112

Computer Networks:

Link Layer and LANs


Rajesh Palit, Ph.D.
North South University, Dhaka

Network Layer 4-1


Link Layer
5.1 Introduction and services 5.6 Link-layer switches
5.2 Error detection and
correction 3.4 Reliable data transfer +
5.3 Multiple access protocols flow control
WiFi
5.4 Link-layer Addressing
5.5 Ethernet

Data Link Layer 5-2


Link layer: context MAC: Medium Access Control

FC: Flow 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

PHY1 PHY 1 PHY 2 PHY 3 PHY 4


Data

ARP (Address Resolution Protocol): IP address  MAC address


(%ipconfig /all  for MAC addresses.) PHY: Physical layer  hardware
Data Link Layer 5-3
Link Layer: Introduction

Terminology:
wired
 hosts and routers are nodes
 communication channels that
connect adjacent nodes are links
 wired links
 wireless links

wired

wireless

Data Link Layer 5-4


Our goals:
 understand principles behind
data link layer services:

1  link access by sharing a broadcast


channel: multiple access
• Instruct the hardware (PHY layer) when
to transmit (… MAC protocols)

2  link layer addressing

Data Link Layer 5-5


Link Layer Services (more)

 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

Data Link Layer 5-6


Where is the link layer implemented?

 in each and every host


 link layer implemented in
“adaptor” (aka network host schematic
interface card NIC) application
transport
 Ethernet card, 802.11 card network
link cpu memory
 implements link, physical
layer
host
 attaches into host’s link
controller
bus
(e.g., PCI)
system buses physical
physical
 combination of hardware, transmission

software, firmware network adapter


card

Data Link Layer 5-7


Adaptors Communicating

datagram datagram

controller controller

datagram

sending host receiving host


datagram
frame

 sending side:  receiving side


 encapsulates datagram in  looks for errors
frame  extracts datagram, passes
 adds error checking bits, to upper layer at receiving
and sequence # for flow side
control
Data Link Layer 5-8
Link Layer
5.1 Introduction and 5.6 Link-layer switches
services 5.7 PPP
5.2 Error detection and
correction 3.4 Reliable data transfer
5.3Multiple access
protocols
5.4 Link-layer Addressing
5.5 Ethernet

Data Link Layer 5-9


Bit errors in frame (packet) transmissions

Transmitted: 1 0 1 1 1 0 0 1 Bit error is generally bursty


Received: 10011011
Tx: 10 1101 0011100111

Rx 10 0010 0011100111
Metric used to represent transmission media

BER: Bit Error Rate


Example: 4/16 = 0.25
BER = # of bit errors / Total # of bits transmitted

BER (copper): 10-8 BER (wireless): 10-5

BER (fibre optics): 10-12


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


Data Link Layer 5-12
Parity Checking

Single Bit Parity:


Detect single bit errors

Send this
………… But, this is received

(Example of odd parity)


Two kinds of parity:

* Odd parity: Set the parity bit to 1 or 0 to 1


make the total # of 1’s an odd number.
When you compute the parity bit, you
* Even parity: Set the parity bit to 1 or 0 to know that it should be a ‘1’.
make the total # of 1’s an even number

Data Link Layer 5-13


Parity Checking (Two dimensional)

Detect and correct single bit errors

… but this is
what you
Send this receive 0
0
Even parity

Data Link Layer 5-14


Applications of Parity Checking

DES

RAID: Redundant Array of Inexpensive Drives

DES: Data Encryption Standard for


symmetric-key cryptography

Data Link Layer 5-15


For the following four bytes
of data, compute the
two dimensional odd parity bits.

11001101|
10111011|
011010 11 |
10000101 |

For the data and parity bits


generated above, introduce four bit
errors that the receiver will not be
able to detect…

Data Link Layer 5-16


Checksumming: Cyclic Redundancy Check
 view data bits, D, as a binary number
 choose r+1 bit pattern (generator), G
 goal: compute r CRC bits, R, such that
 <D,R> is 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 LAN, 802.11 WiFi, …)

Data Link Layer 5-17


CRC Example:
Want:
Properties of XOR:
D.2r XOR R = nG
equivalently: A XOR A = 0
D.2r = nG XOR R A XOR 0 = A
(A XOR B) XOR C = A XOR (B XOR C)
equivalently:
if we divide D.2r by G,
we get remainder R

D.2r
R = remainder[ ]
G

Data Link Layer 5-18


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: D.2r 1011 10 000
1001
Divisor: G ------------------
Align input and divisor on MSB 0 0 1 0 10 0 0 0
D = 101110
1 00 1
------------------ G = 1001
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
Transmit <D,R>: 101110011 ------------------
0 0 0 0 00 0 1 1
R
Data Link Layer 5-19
For the data bits D = 11001101 and
generator bits G = 1011,
compute the CRC bits.

What is the disadvantage of making


the CRC field as long as the data portion of a frame?

D.2r: 1 1 0 0 1 1 0 1 0 0 0 ?
G: 1 0 1 1
------------------

Data Link Layer 5-20


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.3 Multiple access request
protocols
5.4 Link-layer Addressing
5.5 Ethernet

Data Link Layer 5-21


Multiple Access Links and Protocols
Two types of “links”:
 point-to-point
 PPP for dial-up access
 broadcast (shared wire or medium)
 old-fashioned Ethernet
 802.11 wireless LAN

humans at a
shared wire (e.g., shared RF shared RF cocktail party
cabled Ethernet) (e.g., 802.11 WiFi) (satellite) (shared air, acoustical)

Data Link Layer 5-22


Multiple Access protocols
 single shared broadcast channel

 two or more simultaneous transmissions cause collision

 multiple access protocol


 distributed algorithm that determines when a node can
transmit

Data Link Layer 5-23


Packet Collision
Packet collision occurs at the receiver,
but transmitters must know that
collision has occurred.
Link/MAC Tx
data

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.

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 (plug-and-play, no complex hardware, …)

Data Link Layer 5-25


MAC Protocols: a taxonomy
Three broad classes:

 Channel Partitioning (Commonly done in cellular networks)


 divide channel into smaller “pieces” (time slots, frequency)
 allocate piece to node for exclusive use

 Random Access
 channel not divided, allow collisions
 “recover” from collisions OR do not let collision happen
 “Taking turns”
 nodes take turns

Data Link Layer 5-26


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

Data Link Layer 5-27


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


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 (or, even avoid collision)
 Examples of random access MAC protocols:
 ALOHA and slotted ALOHA
 CSMA/CD, CSMA/CA CSMA: Carrier Sense Multiple Access
• CD: Collision Detection  Reactive scheme
• CA: Collision Avoidance  Preventive scheme

Data Link Layer 5-29


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

30
Pure Aloha (Sender)

Binary Exponential Backoff Start:


i = 0

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 + Δ

i > Kmax i++ Timeout ACK received


Cancel timer

Yes
Success
Error

31
Pure Aloha

OK…
This is my
homework…

Data Link Layer 5-32


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


Pure Aloha efficiency

Throughput of Pure Aloha =

Total input rate (G) * Prob. of successful Packet Trans.

= G * e-2G
G: Number of packets in X sec.

Max throughput occurs at G = 0.5. where X is the packet Tx time.

Max Throughput = 1/(2e) = .18

Data Link Layer 5-34


Slotted ALOHA

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

Data Link Layer 5-35


Slotted Aloha efficiency

Throughput of Slotted Aloha =

Total input rate (G) * Prob. of successful Packet Trans.

= G * e-G
G: Number of packets in X sec.

Max throughput occurs at G = 1. where X is the packet Tx time.

Max Throughput = 1/e = .37

Data Link Layer 5-36


CSMA (Carrier Sense Multiple Access)
CSMA: listen before you transmit:

 If channel is sensed idle: transmit entire frame

 If channel is sensed busy, defer transmission

Data Link Layer 5-37


CSMA/CD 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

38
CSMA/CD collision detection

Signal from all nodes


must reach all others

A B C D

Data Link Layer 5-39


CSMA/CD (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 …

Data Link Layer 5-40


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

Sense medium

Wait Y
TB = R*Tp Busy Wait

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


WHILE
detecting collision
No
Collision
No collision

i > Kmax i++ Send jamming signal +


(10) Abort

Yes
Success
Error

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

42
Past final
exam

A B C D

Data Link Layer 5-43


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?
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!

Random Access Channel Partitioning

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 Link Layer 5-46


“Taking Turns” MAC protocols
Token passing:
 control token passed from one
node to next sequentially. T
 token message
 concerns:
 token overhead
(nothing
 latency to send)
 single point of failure (token) T

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

Data Link Layer 5-49


Ethernet Frame Structure (example)

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


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 upper 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-51


Ethernet: unreliable, connectionless
 connectionless: no handshaking between
sending and receiving NICs
 unreliable: receiving NIC doesnt send acks or
nacks to sending NIC
 data in dropped frames recovered only if initial
sender uses higher layer rdt (e.g., TCP),
otherwise dropped data lost
 Ethernet’s MAC protocol: unslotted CSMA/CD
wth binary backoff

Link Layer 5-52


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

MAC protocol
application and frame format
transport
network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX
physical

copper (twister fiber physical layer


pair) physical layer
Link Layer 5-53
LAN Addresses and ARP

Each adapter on LAN has unique LAN address

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

FC: Flow 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

PHY1 PHY 1 PHY 2 PHY 3 PHY 4


Data

ARP (Address Resolution Protocol): IP address  MAC address


(%ipconfig /all  for MAC addresses.) PHY: Physical layer  hardware
Data Link Layer 5-55
ARP: Address Resolution Protocol

Question:  Each IP node (host, router)


How to determine B’s MAC address on LAN has ARP table
knowing B’s IP address?

 ARP table: IP/MAC addr.


137.196.7.78 mappings for LAN nodes
1A-2F-BB-76-09-AD

137.196.7.23 < IP address; MAC address; TTL>


137.196.7.14

LAN  TTL (Time To Live): time


71-65-F7-2B-08-53 58-23-D7-FA-20-B0 after which address mapping
will be forgotten (typically 20
min)
0C-C4-11-6F-E3-98
137.196.7.88

Data Link Layer 5-56


ARP protocol: Same LAN (network)

 A wants to send datagram to B,


and B’s MAC address not in A’s  A caches (saves) IP-to-MAC
ARP table. addr pair in its ARP table
 A broadcasts ARP query pkt until this becomes old
containing B's IP addr
 dest MAC address =
FF-FF-FF-FF-FF-FF  ARP is “plug-and-play”:
 all machines on LAN receive  nodes create their ARP
ARP query
tables without
 B receives ARP query, replies intervention from net
to A with its (B's) MAC addr administrator
 frame sent to A’s MAC
address (unicast)

Data Link Layer 5-57


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

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Data Link Layer 5-58


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

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Data Link Layer 5-59


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

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Data Link Layer 5-60


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

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Data Link Layer 5-61


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

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Data Link Layer 5-62


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

Data Link Layer 5-63


LAN with star topology
 bus topology popular  today: star topology prevails
through mid 90s  active switch in centre
 each “spoke” runs a
(separate) Ethernet
protocol (nodes do not
collide with each other)

switch

bus: coaxial cable star


Data Link Layer 5-64
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 Layer 5-65


Switch
 smarter than hubs, take active role

• Store and forward frames


• Examine incoming frame’s MAC
address, selectively forward frame
to one-or-more outgoing links when
frame is to be forwarded on segment,
using CSMA/CD to access segment switch

transparent
star
hosts are unaware of presence of switches

 plug-and-play, self-learning
switches do not need to be configured

Data Link Layer 5-66


Switch: allows multiple simultaneous transmissions
 hosts have dedicated, A
direct connection to switch
 switches buffer packets C’ B

 Ethernet protocol is used on 1 2


3
6
each link
5 4

 switching: A-to-A’ and B-to-B’ B’ A’


simultaneously, without
collisions switch with six interfaces
 not possible with dumb hub (1,2,3,4,5,6)

Data Link Layer 5-67


Switch Table
 Q: how does switch know that
A' reachable via interface 4, B'
A
reachable via interface 5?
C’ B
 A: each switch has a switch table 1 2
Time To Live 6 3
MAC addr Interface #
of host (TTL) 5 4

C
B’ A’
switch with six interfaces
(1,2,3,4,5,6)

 Q: How are entries created and


maintained in switch table?
Data Link Layer 5-68
Switch: self-learning Source: A
Dest: A’
 Switch learns which hosts can be
A A A’
reached through which interfaces
 When frame received C’ B

 Switch “learns” location of 1 2


6 3
sender: incoming LAN segment
5 4
 Records sender/location pair
in switch table C

B’ A’

MAC addr interface TTL


A 1 60 Switch table
(initially empty)

Data Link Layer 5-69


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 Layer 5-70


Self-learning, forwarding: example Source: A
Dest: 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’

MAC addr interface TTL


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

Data Link Layer 5-71


Interconnecting switches
 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!)

Data Link Layer 5-72


Self-learning multi-switch example
Suppose C sends frame to I, I responds to C

1 S4

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

 Q: show switch tables and packet forwarding in S1, S2, S3,S4

Data Link Layer 5-73


Switches vs. routers
application
both are store-and-forward: transport
datagram network
 routers: network-layer devices frame link
(examine network-layer physical link frame
headers)
physical
 switches: link-layer devices
(examine link-layer headers) switch
both have forwarding tables:
network datagram
 routers: compute tables using link
routing algorithms, IP frame
addresses physical
 switches: learn forwarding application
table using flooding, learning,
MAC addresses transport
network
link
physical

Link Layer 5-74


Wireless LAN

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

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)

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.
76
IEEE 802.11/a/b/g/n Family
IEEE Signal Frequency Rate
Transmission Band (Mbps)
802.11 DSSS 2.4 GHz 1 and 2
FHSS 2.4 GHz 1 and 2
802.11b DSSS 2.4 GHz 5.5 and 11
802.11a OFDM 5 GHz 6--54
802.11g OFDM 2.4 GHz 22 and 54
802.11n OFDM 2.4/5 GHz 72 and 150

802.11ac OFDM 5 GHz 6.9 Gbps

DSSS: Direct Sequence Spread Spectrum


FHSS: Frequency Hopping Spread Spectrum
OFDM: Orthogonal Frequency Division Multiplexing
77
Data Link Layer 5-78
First ….
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

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

PCF DCF PCF DCF PCF


T1 T2 T3 T4 Time

Handshake
Without
handshake
Data Link Layer 5-82
Handshake mode

Frame length >= dotRTSThreshold

Data Link Layer 5-83


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

Sender handshake Receiver

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

Data Link Layer 5-86


As a result, if your frame
encountered collision at the
receiver, you are NOT aware
of that.
Data Link Layer 5-87
Two Problems in WLAN

 Hidden Terminal Problem

 Exposed Terminal Problem

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

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.

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

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

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

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

FCS: Frame Check Sequence  CRC


RA: Receiver Address
TA: Transmitter Address

93
DATA Frame

Frame Seq.
Duration A1 A2 A3 A4 Frame Body FCS
Control control
RA TA

TA: Physically transmitting the frame.

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)

• 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
95
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 …

Data Link Layer 5-96


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

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

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

99
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

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

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

RTS/CTS This must process


received RTS/CTS

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

 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.
104
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

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)

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

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

Data Link Layer5-110


Clearly explain why collision detection is not
possible in wireless local area networks.

Clearly explain why the timing intervals SIFS, PIFS, and DIFS have
been ordered as SIFS < PIFS < DIFS in the CSMA/CA protocol.

Clearly explain the hidden terminal problem.

Data Link Layer 5-111


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, WLANs
 could stop here …. but lots of interesting
topics!

Link Layer5-112

You might also like