data link layer5-1 chapter 5 link layer and lans a note on the use of these ppt slides: we’re...
TRANSCRIPT
Data Link Layer 5-1
Chapter 5Link Layer and LANs
A note on the use of these ppt slides:We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!) If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2010J.F Kurose and K.W. Ross, All Rights Reserved
Computer Networking: A Top Down Approach 5th edition. Jim Kurose, Keith RossAddison-Wesley, April 2009.
Data Link Layer 5-2
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3 Multiple access protocols
New: WiFi
5.4 Link-layer Addressing
5.5 Ethernet
5.6 Link-layer switches
3.4 New: Reliable data transfer + flow control
Link layer: context
Data Link Layer 5-3
PHY1 PHY 1
Link Layer
Network Layer Network Layer TCP
App
PHY 2 PHY 3 PHY 4
1 2
43
MAC
FCARP
MAC
FCARP
MAC: Medium Access Control
Error detection
Correction (optional)
:
Data
PHY: Physical layer hardwareARP (Address Resolution Protocol): IP address MAC address(%ipconfig /all for MAC addresses.)
FC: Flow Control
DestMACaddr
Data Link Layer 5-4
Link Layer: Introduction
Terminology: hosts and routers are nodes communication channels that
connect adjacent nodes are links wired links wireless links
We will focus on
broadcast links.
Point-to-point
link
wired
wireless
wired
Chapter 5: The Data Link LayerOur goals: understand principles behind data link
layer services:
link access by sharing a broadcast channel: multiple access
• Instruct the hardware (PHY layer) when to transmit (… MAC protocols)
link layer addressing
Data Link Layer 5-5
1
2
Data Link Layer 5-6
Link Layer Services (more)
error detection: errors caused by signal attenuation and noise 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
3
4
Data Link Layer 5-7
Where is the link layer implemented?
in each and every host link layer implemented in
“adaptor” (aka network interface card NIC) Ethernet card, 802.11 card implements link, physical
layer
attaches into host’s system buses
combination of hardware, software, firmware
controller
physicaltransmission
cpu memory
host bus (e.g., PCI)
network adaptercard
host schematic
applicationtransportnetwork
link
linkphysical
Data Link Layer 5-8
Adaptors Communicating
sending side: encapsulates datagram in
frame adds error checking bits,
and sequence # for flow control
receiving side looks for errors extracts datagram, passes
to upper layer at receiving side
controller controller
sending host receiving host
datagram datagram
datagramframe
datagram
Wait…
details
will follow
Data Link Layer 5-9
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3Multiple access protocols
5.4 Link-layer Addressing
5.5 Ethernet
5.6 Link-layer switches
5.7 PPP
3.4 Reliable data transfer
Data Link Layer 5-10
Bit errors in frame (packet) transmissions
Transmitted: 1 0 1 1 1 0 0 1
Received: 1 0 0 1 1 0 1 1
Bit error is generally bursty
Tx: 1 0 1 1 0 1 0 0 1 1 1 0 0 1 1 1
Rx 1 0 0 0 1 0 0 0 1 1 1 0 0 1 1 1Metric used to represent transmission media
BER: Bit Error Rate
BER = # of bit errors / Total # of bits transmitted
Example: 4/16 = 0.25
BER (copper): 10-8BER (wireless): 10-5
BER (fibre optics): 10-12
New
Data Link Layer 5-11
Error DetectionEDC= 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-12
What are all the error detection
mechanisms that I will learn
You will learn …
Parity bits (today …)
C
RC:
Cyclic Redundancy Check (Link layer)
In
ternet Checksum
(Network Layer, Transport Layer)
Data Link Layer 5-13
Parity Checking
Single Bit Parity:Detect single bit errors
Use two-dimensional bit parity to
detect and correct single bit errors
Two kinds of parity: * Odd parity: Set the parity bit to 1 or 0 to make the total # of 1’s an odd number. * Even parity: Set the parity bit to 1 or 0 to make the total # of 1’s an even number
(Example of odd parity)
Send this ………… But, this is received
1
You find the frame to
be erroneous, but you
cannot locate the bit error.
When you compute the parity bit, youknow that it should be a ‘1’.
Data Link Layer 5-14
Parity Checking (Two dimensional)
Detect and correct single bit errors
Send this
Inconsistent
Row….
Inconsistent
column….
0
0
… but this iswhat you receive
Fix this error
0 1.Even parity
Data Link Layer 5-15
Where is parity checking used?
Not generally in network protocols
these days...
But, it is used
here and here
and here ….
Applications of Parity Checking
DES
RAID: Redundant Array of Inexpensive Drives
Media access is a noisy process…..
because of imperfect fabrication
and hardware aging.
DES: Data Encryption Standard for symmetric-key cryptography
Data Link Layer 5-16
What kinds of questions
can be asked on the exams?
ECE358
Mid-term S’12
1 1 0 0 1 1 0 1 |1 0 1 1 1 0 1 1 |0 1 1 0 1 0 1 1 |1 0 0 0 0 1 0 1 |
For the following four bytesof data, compute the two dimensional odd parity bits.
For the data and parity bits generated above, introduce four bit errors that the receiver will not be able to detect…
ECE358
Mid-term F’12
Data Link Layer 5-17
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-18
CRC Example:
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by G, we get remainder R
R = remainder[ ]D.2r
G
Properties of XOR:
A XOR A = 0A XOR 0 = A(A XOR B) XOR C = A XOR (B XOR C)
Data Link Layer 5-19
1 0 1 1 1 0 0 0 01 0 0 1------------------0 0 1 0 10 0 0 0 1 00 1 ------------------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 0 0 1------------------0 0 0 0 00 0 1 1
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.
Detailed
Calculation of CRC
Input: D.2r
Divisor: GAlign input and divisor on MSB
R
D = 101110G = 1001
Transmit <D,R>: 101110011
Data Link Layer 5-20
What questions
can be asked on the exams?For the data bits D = 11001101 and generator bits G = 1011, compute the CRC bits.
ECE358
Mid-term S’12
What is the length
of the CRC field?D.2r: 1 1 0 0 1 1 0 1 0 0 0 ?G: 1 0 1 1------------------
What is the disadvantage of making the CRC field as long as the data portion of a frame?
Data Link Layer 5-21
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3Multiple access protocols
5.4 Link-layer Addressing
5.5 Ethernet
5.6 Link-layer switches
5.7 PPP
5.8 Link virtualization: MPLS
5.9 A day in the life of a web request
Data Link Layer 5-22
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
shared wire (e.g., cabled Ethernet)
shared RF (e.g., 802.11 WiFi)
shared RF(satellite)
humans at acocktail party
(shared air, acoustical)shared wire (e.g., cabled Ethernet)
Data Link Layer 5-23
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
24
Packet Collision
PHY
Link/MACdata
PHY
Link/MACdata
PHY
Link/MAC
+
Rx
Tx
Tx
Packet collision occurs at the receiver,but transmitters must know that collision has occurred.
Note
Data Link Layer 5-25
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-26
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-27
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
1 3 4 1 3 4
6-slotframe
Data Link Layer 5-28
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
frequ
ency
bands time
FDM cable
Data Link Layer 5-29
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
30
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
31
Pure Aloha (Sender)
Start:
i = 0
Start a timerT = 2*Tp + Δ
ACK receivedCancel timer
Success
Timeouti++
Transmit<Frame, EDC>
i > Kmax
R = Random(0,2i-1)
Wait for TB
TB = R*Tp
Error
Yes
No
Binary Exponential Backoff
Remember this
Wait here
Tp is the signal propagation time
between sender and receiver
Kmax: a constant
(say, 10)
i: local var;
retransmit count
EDC: Error Detection
Code
Frame
from upper layer
(0, 63)(0, 31)(0, 15)(0, 7)(0, 3)(0, 1)
Data Link Layer 5-32
Pure Aloha
What does
the receiver
do?
OK…This is my homework…
Data Link Layer 5-33
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-34
Pure Aloha efficiency
Throughput of Pure Aloha =
Total input rate (G) * Prob. of successful Packet Trans.
= G * e-2G
Max Throughput = 1/(2e) = .18
e = 2.71828
G: Number of packets in X sec.
where X is the packet Tx time.Max throughput occurs at G = 0.5.
Data Link Layer 5-35
Slotted ALOHA
Assumptions: all frames are same size time divided into equal
size slots (time to transmit 1 frame)
nodes start to transmit only at slot beginning
nodes are synchronized
Operation: when node obtains fresh frame,
transmit in next slot if Tx is not successful,
retransmit in following slots after some wait..
Data Link Layer 5-36
Slotted Aloha efficiency
Throughput of Slotted Aloha =
Total input rate (G) * Prob. of successful Packet Trans.
= G * e-G
Max Throughput = 1/e = .37
e = 2.71828
G: Number of packets in X sec.
where X is the packet Tx time.Max throughput occurs at G = 1.
Data Link Layer 5-37
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
Don’t interrupt others…
38
CSMA/CD Concepts of Carrier Sense and Collision Detection
Tx Rx
Data
Collision?Carrier?
Medium
MAC/PHY
Sense voltage (V) on medium:
V > Vth1 carrier is present V > Vth2 collision
Time
Vth2
Vth1
V
Vth2: Threshold 2
Vth1: Threshold 1
Done in hardware
Data Link Layer 5-39
CSMA/CD collision detection
Signal from all nodesmust reach all others
Remember this
Therefore,
collision occurring at
a receiving node is
detected by the frame’s
sender…. after some delay..
A B C D
Data Link Layer 5-40
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 …
41
CSMA/CD Start:i = 0
Success
Send jamming signal +Abort
i++
Sense medium
i > Kmax
R = Random(0,2i-1)
WaitTB = R*Tp
Error
Yes
No
Busy WaitY
N
No collisionCollision
Transmit frameWHILE detecting collision
Exponential backoff
96 bit-time
48 bit-time
(10)
Tp = 512 bit-time
New frame
42
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.
Data Link Layer 5-43
I started transmitting
after sensing no-carrier….
Why did it collide with another frame…..?
Are they not listening…
A B C D
Past finalexam
Data Link Layer 5-44
I have learned CSMA/CD…
What kinds of questions should I
expect on the exams
Computers A, B, and C and one router are connected to an Ethernet bus 100 metres apartto 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 .
F’12 Mid-term
A B C Router100 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-45
Another question …. Mid-term F’12
Justify the use of
binary exponential backoff
in MAC protocols.
Compare the slotted Aloha protocol
with the CSMA/CD protocol by
identifying five comparison criteria.
Criteria
Slotted Aloha
CSMA/CD
Data Link Layer 5-46
“Taking Turns” MAC protocolschannel 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
Random Access Channel Partitioning
Taking turns
Data Link Layer 5-47
“Taking Turns” MAC protocols
Polling: master node “invites”
slave nodes to transmit in turn
typically used with “dumb” slave devices
concerns: polling overhead latency single point of failure
(master)
master
slaves
poll
data
data
Data Link Layer 5-48
“Taking Turns” MAC protocols
Token passing: control token passed from one
node to next sequentially. token message concerns:
token overhead latency single point of failure (token)
T
data
(nothingto send)
T
IBM Token Ring
was developed at
IBM Zurich to compete
against CSMA/CD.
Data Link Layer 5-49
Where are all those
different kinds of MAC
protocols used
Ch. Partitioning MAC
-Cellphone networks
-Bluetooth
Random access MAC
-LAN (Local Area Network)
-WLAN (Wireless LAN)
Taking turns
- Bluetooth
Data Link Layer 5-50
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3Multiple access protocols
5.4 Link-Layer Addressing
5.5 Ethernet
5.6 Link-layer switches
5.7 PPP
5.8 Link virtualization: MPLS
5.9 A day in the life of a web request
3.4 Reliable data transfer
Data Link Layer 5-51
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-52
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-53
LAN Addresses and ARP
Each adapter on LAN has unique LAN address
Broadcast addr. =FF-FF-FF-FF-FF-FF
= adapter
1A-2F-BB-76-09-AD
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
71-65-F7-2B-08-53
LAN(wired orwireless)
ARP context
Data Link Layer 5-54
PHY1 PHY 1
Link Layer
Network Layer Network Layer TCP
App
PHY 2 PHY 3 PHY 4
1 2
43
MAC
FCARP
MAC
FCARP
MAC: Medium Access Control
Error detection
Correction (optional)
:
Data
PHY: Physical layer hardwareARP (Address Resolution Protocol): IP address MAC address(%ipconfig /all for MAC addresses.)
FC: Flow Control
DestMACaddr
Data Link Layer 5-55
ARP: Address Resolution Protocol
Each IP node (host, router) on LAN has ARP table
Question: How to determine B’s MAC address knowing B’s IP address?
58-23-D7-FA-20-B071-65-F7-2B-08-53
1A-2F-BB-76-09-AD
0C-C4-11-6F-E3-98
LAN
137.196.7.23
137.196.7.78
137.196.7.14
137.196.7.88
ARP table: IP/MAC addr. mappings for LAN nodes
< IP address; MAC address; TTL>
TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min)
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 ARP table.
B receives ARP query, replies to A with its (B's) MAC addr frame sent to A’s MAC
address (unicast)
A broadcasts ARP query pkt containing B's IP addr dest MAC address = FF-FF-FF-FF-FF-FF all machines on LAN
receive ARP query
A caches (saves) IP-to-MAC addr pair in its ARP table until this becomes old
ARP is “plug-and-play”:nodes create their ARP tables without intervention from net administrator
Data Link Layer 5-57
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B222.222.222.220
111.111.111.110E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.11174-29-9C-E8-FF-55
A
IPEthPhy
IP src: 111.111.111.111 IP dest: 222.222.222.222
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
222.222.222.22249-BD-D2-C7-56-2A
222.222.222.22188-B2-2F-54-1A-0F
B
Data Link Layer 5-58
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B222.222.222.220
111.111.111.110E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.11174-29-9C-E8-FF-55
A
IPEthPhy
frame sent from A to R
IP src: 111.111.111.111 IP dest: 222.222.222.222
MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B
IPEthPhy
frame received at R, datagram removed, passed up to IP
222.222.222.22249-BD-D2-C7-56-2A
222.222.222.22188-B2-2F-54-1A-0F
B
Data Link Layer 5-59
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B222.222.222.220
111.111.111.110E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.11174-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.22188-B2-2F-54-1A-0F
BA
IP src: 111.111.111.111 IP dest: 222.222.222.222
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
IPEthPhy
IPEthPhy
Data Link Layer 5-60
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B222.222.222.220
111.111.111.110E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.11174-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.22188-B2-2F-54-1A-0F
BA
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
IP src: 111.111.111.111 IP dest: 222.222.222.222
MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A
IPEthPhy
IPEthPhy
Data Link Layer 5-61
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B222.222.222.220
111.111.111.110E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.11174-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.22188-B2-2F-54-1A-0F
BA
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
IP src: 111.111.111.111 IP dest: 222.222.222.222
MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A
IPEthPhy
Data Link Layer 5-62
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3 Multiple access protocols
5.4 Link-layer Addressing
5.5 Ethernet
5.6 Link-layer switches, LANs, VLANs
5.7 PPP
5.8 Link virtualization: MPLS
5.9 A day in the life of a web request
Data Link Layer 5-63
LAN with star topology
bus topology popular through mid 90s
bus: coaxial cable
switch
star
today: star topology prevails active switch in centre each “spoke” runs a
(separate) Ethernet protocol (nodes do not collide with each other)
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
Switch smarter than hubs, take active role
Data Link Layer 5-65
switch
star
• 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 transparent
hosts are unaware of presence of switches
plug-and-play, self-learningswitches do not need to be configured
Data Link Layer 5-66
Switch: allows multiple simultaneous transmissions
switching: A-to-A’ and B-to-B’ simultaneously, without collisions not possible with dumb hub
A
A’
B
B’
C
C’
switch with six interfaces(1,2,3,4,5,6)
1 23
45
6
hosts have dedicated, direct connection to switch
switches buffer packets
Ethernet protocol is used on each link
Data Link Layer 5-67
Switch Table
Q: how does switch know that A’ reachable via interface 4, B’ reachable via interface 5? A
A’
B
B’
C
C’
switch with six interfaces(1,2,3,4,5,6)
1 23
456
Q: How are entries created and maintained in switch table?
A: each switch has a switch tableMAC addrof host
Interface # Time To Live(TTL)
Data Link Layer 5-68
Switch: self-learning
A
A’
B
B’
C
C’
1 23
45
6
A A’
Source: ADest: A’
MAC addr interface TTL
Switch table (initially empty)
A 1 60
Switch learns which hosts can be reached through which interfaces
Records sender/location pair in switch table
When frame received
Switch “learns” location of sender: incoming LAN segment
Data Link Layer 5-69
Switch: frame filtering/forwardingWhen 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 floodforward on all but the interface on which the frame arrived
Data Link Layer 5-70
Self-learning, forwarding: example
A
A’
B
B’
C
C’
1 23
45
6
A A’
Source: ADest: A’
MAC addr interface TTL
Switch table (initially empty)
A 1 60
A A’A A’A A’A A’A A’
frame destination unknown: flood
A’ A
destination A location known:
A’ 4 60
selective send
Data Link Layer 5-71
Interconnecting switches
switches can be connected together
A
B
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!)
S1
C D
E
FS2
S4
S3
H
I
G
Data Link Layer 5-72
Self-learning multi-switch example
Suppose C sends frame to I, I responds to C
Q: show switch tables and packet forwarding in S1, S2, S3,S4
A
B
S1
C D
E
FS2
S4
S3
H
I
G
1
2
Data Link Layer 5-73
Institutional network
to externalnetwork
router
IP subnet
mail server
web server
Data Link Layer 5-74
Fall 2012 Final Exam Question[3] Consider the institutional local area network shown in Figure 1.
Complete the following switching table at Ethernet switch S1. An arbitrary number of rows have been given. Add more rows, if you need them. Make assumptions if there is a need.
All the computing entities, except H1 and H4, are fully functional and sending and receiving data packets. H1 is switched off, whereas H4’s Ethernet interface is broken.
1
2 34
5
75
Wireless LAN
Standards: IEEE 802.11/a/b/g/n
LAN
CSMA/CD
76
WLAN: Basic idea
AccessPoint
C
C
C: Computer, AP: Access Point
Radio range of the AP
Independent BSS (IBSS)= BSS – AP
Extended Service Set (ESS): A collection of BSS connected by a Distribution System
Basic Service Set(identified by the MAC address of the AP:BSSID)
Example: The UW WiFi network is one ESS.
CSMA/CA (Collision Avoidance)
protocolAlso known
as WiFi access
77
IEEE 802.11/a/b/g/n Family
IEEE Signal Transmission
Frequency Band
Rate
(Mbps)
802.11 DSSS
FHSS
2.4 GHz
2.4 GHz
1 and 2
1 and 2
802.11b DSSS 2.4 GHz 5.5 and 11
802.11a OFDM 5 GHz 6--54
802.11g
802.11n
802.11ac
OFDM
OFDM
OFDM
2.4 GHz
2.4/5 GHz
5 GHz
22 and 54
72 and 150
6.9 Gbps
DSSS: Direct Sequence Spread SpectrumFHSS: Frequency Hopping Spread SpectrumOFDM: Orthogonal Frequency Division Multiplexing
Data Link Layer 5-78
Are there
different MAC protocols in
IEEE 802.11/a/b/g/n standards
They have all different
PHY layers ……
But, all of them have the
same MAC protocol …..
The AP is the controller
AP decides who transmits
and when.
- There is no need for an AP.
- If AP is there, it behaves
like an ordinary node.
- Nodes make their own decisions toTx.
79
First …. Different Modes of Operation of MAC in IEEE 802.11
Modes of IEEE 802.11 MAC
Point Coordination
Function (PCF) mode
Distributed Coordination
Function (DCF) mode
Handshakemode
Without Handshake mode No prior permission
is needed.
Seek permission from
receiver before sending data
80
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
This mode
is optional …
81
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.
All APs must
implement this…
The AP tells all when to
enter the PCF mode and the
DCF mode
Data Link Layer 5-82
How are all those
modes related?
PCF DCF PCF DCF
TimeT1 T2 T3 T4
Handshake
Without handshake
AP
PCF
Data Link Layer 5-83
How do I know when to use
handshake and when to use
without-handshake
Handshake mode
The MAC management database
holds a variable: dotRTSThreshold
(integer in bytes)
Frame length >= dotRTSThreshold
Without-Handshake mode
Frame length <
dotRTSThreshold
For “long” frames, you want
to reduce the prob. of collision…
with some overhead
84
DCF with handshake
How is handshake implemented
RTS
CTS
Control Frames:RTS: Request To SendCTS: Clear To Send
DATA
ACK
How is handshake implemented
Under a certain condition ….
(to be explained soon ….)
handshakeSender Receiver
Receiver is
under no
obligation
to send CTS.
Note: There is
strict timing
relationship
between successive
frames
Repeat this…
85
DCF without handshake
ACK
Under a certain condition ….
to be explained soon ….
Sender Receiver
DATA
Repeat this…
Data Link Layer 5-86
What is the big deal in a WLAN?
What happens to my RTS, CTS, DATA, ACK,…..
Do they collide with Tx from other nodes
Note the diff. between
a wired medium & a wireless medium
Wired
Signal from all nodesmust reach all others
A B C
DWireless
Signal from some nodesmay not reach all others
This diff. leadsto some problemsRemember this diff…
Data Link Layer 5-87
What problems can arise
in a wireless net
You do not receive
the signal received by
the intended receiver of
your frame.
As a result, if your frameencountered collision at thereceiver, you are NOT awareof that.
Collision detection is not always
possible in a wireless LAN.
88
Two Problems in WLAN
Hidden Terminal Problem
collision in some
more details…
Exposed Terminal Problem
89
Hidden Terminal Problem
A B C
•This problem is due to C being hidden from A.• Hidden means being “far away” …
D
C is transmitting a frame to B.A is unaware of C’s Tx.
Now, if A transmits, A’s frame will collide with C’s at B
Collision occurs at B,
but A cannot detect it…
Solution exists:CSMA/CA(Collision Avoidance)
90
Exposed Terminal Problem
A B C
B knows that someone is transmitting.
The above problem is due to B being exposed to A’s Tx.
D
A is transmitting a frame to D.
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 ….
No solution has beenprovided so far…..
91
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.
Transmit condition: Medium is idle at the receiver.
(Carrier is absent) AND (NAV = 0)
Time
92
CSMA/CA: NAV in detail
• A duration field in frame header indicates the length of time the sender of the frame may use the medium.
• Recall the handshake mechanism with RTS and CTS
• All nodes which receive RTS and CTS (and DATA ) update their NAV as follows
Events that update NAV: Initially NAV = 0
If a frame (e.g. RTS, CTS) with duration field is received
NAV = Max(NAV, duration)
With each passing μs (micro second) If (NAV > 0 ) NAV = NAV – 1Else stop decrementing NAV
93
RTS and CTS Frames
FrameControl
Duration RA TA FCSRTS
2 2 6 6 4 bytes
FrameControl
Duration RA FCSCTS/ACK
2 2 6 4 bytes
FCS: Frame Check Sequence CRCRA: Receiver AddressTA: Transmitter Address
94
DATA Frame
FrameControl
Duration A1 A2 A3 A4Seq.
controlFCSFrame Body
RA TA
TA: Physically transmitting the frame.
TA RA
Datagram from the upper layer
95
Timing Intervals The IEEE 802.11 MAC defines 4 timing intervals
Time
• 2 at the PHY level
• 2 at the MAC level
• SIFS: Short Inter-Frame Space (10 micro-sec) between successive frames (RTS, CTS, DATA, ACK, …)
• aSlot (20 micro-sec)
• 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)
Data Link Layer 5-96
DIFS
PIFS
SIFS
Timing intervals are used to control priority
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 …
97
Handshake using RTS/CTS (A wants to send data to B)
SIFS
SIFS
SIFS
Value of “duration” in RTS
Value of “duration” in CTS
A
B
C(neighbors of A)
D(neighbors of B)
Min value of NAV of C
Min value of NAV of D
Time
DIFS
A B
CD
RTS
CTS
DATA
ACK
Medium is idle&& NAV == 0
That is how
collision is avoided
(Note: “duration” info in DATA will not be shown.)
98
DCF with Hand-shake: TxF: a new data frame to be transmittedi = 0, CW = CWmin
NAV =0?
Send RTSStart a timer
Cancel timerSend DATA (F)Start a timer
i = i+1
CW = CWmin*2i
( CW saturates at CWmax)
Timeout
Timeout
RandomBackoff
No
Yes
CTS is received
ACK is received
End of backoff
i: Retry count, CW: Contention Window
CWmin: Min. value of CW (typical: 32)
CWmax: Max. value of CW (typical :
256)
DIFS: Distributed Interframe Space
Yes
No
Medium idle for DIFS?
99
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
100
Backoff Mechanism
Ch. busy due to node A
Ch. Busy due to node C
DIFS DIFSX X X X
BTC = 5
5 4 3 3 2 3
X = aSlotTime
B 1 0
Time
B is executing backoff
101
DCF with Handshake: Rx
Receive RTS
NAV = 0?
Send CTS
No
Yes
No
Yes
Receive DATA frame
Send ACK
Note: The above two fragments of flow-charts can be easily merged.
No
Yes
Medium idle forSIFS?
Medium idle forSIFS?
102
DCF Mode without Handshake A special case of DCF with 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 processreceived RTS/CTS
103
Data transmission without handshake(A wants to send data to B)
SIFS
A
B
C(neighbor of A)
D(neighbor of B) Time
DIFS
A B
CD
DATA
ACK
Medium is idle&& NAV == 0
No guarantee!
Value of “duration” in DATA
Value of NAV of C
104
PCF Mode: AP becomes the controller: How?
AP alternates between PCF and DCF modes
AP operates as the controller as follows
DIFS
PIFS
SIFS Recall
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 CFPMaxDurationThey do not transmit unless asked to do so by the AP.
105
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
106
PCF Mode of Operation (Contd.)
CF Poll frame
AP APUser 1 User 2 User 1
CF Poll CF Poll
DATA DATA
ACK ACK
SIFS
SIFS
SIFS
SIFS
Time
PIFS PIFS
If a user does not havedata, it sends a null DATA frame(A DATA frame with no actual data)
PIFS PIFS
If ACK is not received, user 1
waits until it is polled again.
107
PCF Mode of Operation (Contd.)DATA + CF Poll frame
The polled user receives data from the AP and sends data to another user.
Note 1: If AP does not receive an ACK, it retransmits data after PIFS.
AP User 1 User 2
DATA+CF Poll
DATA
ACK
SIFS
SIFS
ACKSIFS
Note 2: If User 1 does not receive ACK, it does not retransmit data.
PIFS
PIFS
108
PCF Mode of Operation (Contd.)DATA from AP (unicast): 1 1
AP User 1
DATA
SIFS
ACK
APUser 1 User 2
DATA
DATA from AP (broadcast): 1 all
DATA
DATADATA
PIFS
DATA(lost)DATA
PIFSPIFS
SIFS
DATA
ACK
No ACK….
DATADATA(lost)
PIFS
109
PCF Mode of Operation (Contd.)
CF End frame Identifies the end of CF period
– Receiving nodes set NAV = 0.
Data Link Layer5-110
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
Bluetoothpiconet
master
Up to 7 slaves
Data Link Layer5-111
Could I see some past exam questions …
F’12 Mid-term
Identify five differences between the CSMA/CD and the CSMA/CA protocols by identifying five comparison criteria. Use the following table to answer the question.
Criteria CSMA/CD CSMA/CA
Data Link Layer5-112
F’12 Mid-term
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.
More past exam questions …
Clearly explain the hidden terminal problem. S’12 Mid-term
Data Link Layer5-113
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3Multiple access protocols
5.4 Link-Layer Addressing
5.5 Ethernet
5.6 Link-layer switches
5.7 PPP (Skipping this)
3.4 Reliable Data Transfer
Data Link Layer5-114
I learned about accessing broadcast links …
Ethernet ……. and …. WiFi …..
Are there other
kinds of links??
There are
point-to-point links
Point-to-point linkBroadcast link
Data Link Layer5-115
Point to Point Data Link Control
one sender, one receiver, one link: easier than broadcast link: no Media Access Control no need for explicit MAC addressing
popular point-to-point DLC protocols: PPP (point-to-point protocol) HDLC: High level data link control (Data link used
to be considered “high layer” in protocol stack!
Data Link Layer5-116
PPP Design Requirements [RFC 1557]
packet framing: encapsulation of network-layer datagram in data link frame carry network layer data of any network layer
protocol (not just IP) at same time ability to demultiplex upwards
bit transparency: must carry any bit pattern in the data field
error detection (no correction) connection liveness: detect, signal link failure to
network layer network layer address negotiation: endpoint can
learn/configure each other’s network address
Data Link Layer5-117
PPP non-requirements
no error correction/recovery no flow control out of order delivery OK no need to support multipoint links (e.g., polling)
Error recovery, flow control, data re-ordering all relegated to higher layers!
Data Link Layer5-118
PPP Data Frame
Flag: delimiter (framing) Address: does nothing (only one option) Control: does nothing; in the future possible multiple
control fields Protocol: upper layer protocol to which frame delivered
Data Link Layer5-119
PPP Data Frame
info: upper layer data being carried check: cyclic redundancy check for error detection
Data Link Layer5-120
Byte Stuffing “data transparency” requirement: data field must be
allowed to include flag pattern <01111110> Q: is received <01111110> data or flag?
Sender: adds (“stuffs”) extra < 01111110> byte after each < 01111110> data byte
Receiver: two 01111110 bytes in a row: discard first byte,
continue data reception single 01111110: flag byte
Data Link Layer5-121
Byte Stuffing
flag bytepatternin datato send
flag byte pattern plusstuffed byte in transmitted data
1 0
Data Link Layer5-122
Link Layer
5.1 Introduction and services
5.2 Error detection and correction
5.3Multiple access protocols
5.4 Link-Layer Addressing
5.5 Ethernet
5.6 Link-layer switches 5.7 PPP
3.4 Reliable data transfer
3-123
3.4 Principles of Reliable Data Transfer
important in app., transport, link layers
3-124
Principles of Reliable data transfer important in app., transport, link layers
3-125
Principles of Reliable data transfer important in app., transport, link layers
characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
3-126
Reliable data transfer: getting started
sendside
receiveside
rdt_send(): called from above
udt_send(): called by rdt,to transfer frame over unreliable channel to receiver
rdt_rcv(): called when packet arrives on rcv-side of channel
deliver_data(): called by rdt to deliver data to upper
3-127
Reliable data transfer: getting started
We will: incrementally develop sender and receiver sides of rdt.
state1 state2
event causing state transition
actions taken on state transition
eventactions
use finite state machines (FSM) to specify sender, receiver
consider only unidirectional data transfer but control info will flow in both directions!
3-128
Rdt1.0: reliable transfer over a reliable channel
underlying channel perfectly reliable no bit errors no loss of packets
packet = make_pkt(data)udt_send(packet)
Wait for call from above
rdt_send(data)extract (packet,data)deliver_data(data)
Wait for call from below
rdt_rcv(packet)
sender receiver
Worse can happen
Packet duplication
Packet reordering
separate FSMs for sender, receiver: sender sends data into underlying channel receiver reads data from underlying channel
3-129
Rdt2.0: channel with bit errors underlying channel may flip bits in frame
checksum to detect bit errors
new mechanisms in rdt2.0 (beyond rdt1.0): error detection receiver feedback: control msgs (ACK,NAK)
the question: how to recover from errors?
acknowledgements (ACKs): receiver explicitly tells sender that pkt received is OK
negative acknowledgements (NAKs): receiver explicitly tells sender that pkt had errors
sender retransmits pkt on receipt of NAK sender transmits next pkt on receipt of ACK
(Note: Correction by receiver is very expensive ….)
3-130
rdt2.0: FSM specification
Wait for call from above
sndpkt = make_pkt(data, checksum)udt_send(sndpkt)
extract(rcvpkt,data) ,deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && isNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) && corrupt(rcvpkt)Wait for ACK or NAK
Wait for call from below
sender
receiverrdt_send(data)
3-131
rdt2.0: operation with no errors
Wait for call from above
snkpkt = make_pkt(data, checksum)udt_send(sndpkt)
extract(rcvpkt,data), deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && isNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) && corrupt(rcvpkt)Wait for ACK or NAK
Wait for call from below
rdt_send(data)
3-132
rdt2.0: error scenario
Wait for call from above
snkpkt = make_pkt(data, checksum)udt_send(sndpkt)
extract(rcvpkt,data),deliver_data(data)udt_send(ACK)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && isNAK(rcvpkt)
udt_send(NAK)
rdt_rcv(rcvpkt) && corrupt(rcvpkt)Wait for ACK or NAK
Wait for call from below
rdt_send(data)
3-133
rdt2.1: sender, handles garbled ACK/NAKs
Wait for call 0 from above
sndpkt = make_pkt(0, data, checksum)udt_send(sndpkt)
rdt_send(data)
Wait for ACK or NAK 0
udt_send(sndpkt)
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) ||isNAK(rcvpkt) )
sndpkt = make_pkt(1, data, checksum)udt_send(sndpkt)
rdt_send(data)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) )
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt)
Wait for call 1 from above
Wait for ACK or NAK 1
3-134
rdt2.0 has a fatal flaw!
What if ACK/NAK corrupted?
sender doesn’t know what happened at receiver!
can’t just retransmit: possible duplicate
Handling duplicates: sender retransmits current
pkt if ACK/NAK garbled sender adds sequence
number to each pkt receiver discards duplicate
pkt
Sender sends one packet, then waits for receiver response
stop and wait
Note: Because of stop-and-wait, you need justtwo sequence numbers …… {0, 1} …..
3-135
rdt2.1: receiver, handles (garbled ACK/NAKs)
Wait for 0 from below
sndpkt = make_pkt(NAK, chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq0(rcvpkt)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)
extract(rcvpkt,data)deliver_data(data)sndpkt = make_pkt(ACK, chksum)udt_send(sndpkt)
Wait for 1 from below
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq0(rcvpkt)
extract(rcvpkt,data)deliver_data(data)sndpkt = make_pkt(ACK, chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt)
/* Do not deliver data to upper layer */sndpkt = make_pkt(ACK, chksum)udt_send(sndpkt)
rdt_rcv(rcvpkt) && not corrupt(rcvpkt) && has_seq1(rcvpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt)
/* Do not deliver data to upper layer */sndpkt = make_pkt(ACK, chksum)udt_send(sndpkt)
sndpkt = make_pkt(NAK, chksum)udt_send(sndpkt)
Duplicate
data
Corrupted
data
Good data
Good data
Duplicate
data
Corrupted
data
3-136
rdt2.1: discussion
Sender: seq # added to pkt two seq. #’s (0,1) will
suffice. must check if received
ACK/NAK corrupted twice as many states
state must “remember” whether “current” pkt has 0 or 1 seq. #
Receiver: must check if received packet
is duplicate state indicates whether 0 or 1 is
expected pkt seq #
note: receiver can not know if its last ACK/NAK was received OK at sender
3-137
rdt2.2: a NAK-free protocol
same functionality as rdt2.1, using ACKs only
instead of NAK, receiver sends ACK for last pkt received OK receiver must explicitly include seq # of pkt being ACKed
duplicate ACK at sender results in same action as NAK: retransmit current pkt
3-138
rdt2.2: sender fragment
Wait for call 0 from above
sndpkt = make_pkt(0, data, checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || isACK(rcvpkt,1))
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0)
Wait for ACK 0
A duplicate ACK
for the previous
packet #1
Wait for ACK 1 Wait for
call 1 from above
sndpkt = make_pkt(1, data, checksum)udt_send(sndpkt)
rdt_send(data)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || isACK(rcvpkt,0))
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,1)
3-139
rdt2.2: receiver fragment
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data)deliver_data(data)sndpkt = make_pkt(ACK1, chksum)udt_send(sndpkt)
Wait for 0 from below
Wait for 1 from below
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq1(rcvpkt))
udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq0(rcvpkt))
udt_send(sndpkt)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq0(rcvpkt)
extract(rcvpkt,data)deliver_data(data)sndpkt = make_pkt(ACK0, chksum)udt_send(sndpkt)
3-140
rdt3.0: channels with errors and loss
New assumption:
Underlying channel can also lose packets (data or ACKs)
Approach: sender waits “reasonable” amount of time for ACK
Not enough
possible deadlock, because
packet loss
retransmits if no ACK is received in this time
if pkt (or ACK) just delayed (not lost): retransmission will be duplicate,
but use of seq. #’s already handles this
checksum, seq. #, ACKs, retransmissions will be of help, but not enough
3-141
rdt3.0 sender (rdt2.2 + Timer + minor changes)
sndpkt = make_pkt(0, data, checksum)udt_send(sndpkt)start_timer
rdt_send(data)
Wait for ACK0
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) ||isACK(rcvpkt,1) )
Wait for call 1 from above
sndpkt = make_pkt(1, data, checksum)udt_send(sndpkt)start_timer
rdt_send(data)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,0)
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) ||isACK(rcvpkt,0) )
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) && isACK(rcvpkt,1)
stop_timer
stop_timer
udt_send(sndpkt)start_timer
timeout
udt_send(sndpkt)start_timer
timeout
rdt_rcv(rcvpkt)
Wait for call 0 from above
Wait for ACK1
rdt_rcv(rcvpkt)
3-142
rdt3.0 in action
3-143
rdt3.0 in action
3-144
rdt3.0: stop-and-wait operation
first packet bit transmitted, t = 0
sender receiver
RTT
last packet bit transmitted, t = L / R
first packet bit arriveslast packet bit arrives, send ACK
ACK arrives, send next packet, t = RTT + L / R
RTT: Round-Trip Time = 2 x propagation delay.
L = Packet lengthR = Data rate
3-145
Performance of rdt3.0
ex: 1 Gbps link, 15 ms prop. delay, 8000 bit packet:
Usender: utilization (= fraction of time sender is busy sending)
U sender
= .008
30.008 = 0.00027
microseconds
L / R
RTT + L / R =
if RTT=30 msec, 1KB pkt every 30 msec 33KB/sec throughput over 1 Gbps link
dsmicrosecon8bps10
bits80009
R
Ld trans
network protocol limits use of physical resources!
3-146
Pipelined protocols
pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged pkts
range of sequence numbers must be increased (sequence # {0, 1} are not enough.)
two generic forms of pipelined protocols:
go-Back-N and selective repeat
3-147
Pipelining: increases utilization
first packet bit transmitted, t = 0
sender receiver
RTT
last bit transmitted, t = L / R
first packet bit arriveslast packet bit arrives, send ACK
ACK arrives, send next packet, t = RTT + L / R
last bit of 2nd pkt arrives, send ACKlast bit of 3rd pkt arrives, send ACK
U sender
= .024
30.008 = 0.0008
microseconds
3 * L / R
RTT + L / R =
Increase utilizationby a factor of 3
3-148
Pipelined Protocols (Sliding Window Protocols)
Go-back-N: big picture: Selective Repeat: big pic sender can have up to N unACKed pkts in pipeline
sender can have up to N unACKed pkts in pipeline
sender has a timer for oldest unACKed packet
sender has one timer for each unACKed packet
if timer expires, retransmit all unACKed pkts
when a timer expires, retransmit only one pkt corresponding to the timeout
rcvr sends individual ack for each packet rcvr sends individual ack for
each packet Sender interprets acks as
cumulative acks
(Cumulative ACK: If ACK for pkt #5 is received, all pkts including and up to #5 have been correctly received)
3-149
Pipelined Protocols
Remember:
The idea of cumulative ACK
is protocol specific…..
In TCP,if the sender has received ACKfor data byte #125, it meansall bytes up to and including byte #124have been received correctly andthe receiver is expecting byte #125.
3-150
Go-Back-N: Sender
k-bit seq # in pkt header: for k = 5, seq.# are: 0, 1, 2, 3, ……. 31.
“window” of up to N, consecutive unACKed pkts allowed
Already ACKed Sent, but ACK not received
Usable, not sent yet
Not usable
Window
send_base next_seq_num
timeout(n): retransmit pkt n and all higher seq # pkts in window
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Window
snapshot
3-151
Go-Back-N: Sender Already ACKedSent, but ACK not received
Usable, not sent yet
Not usable
The sender receives ACKs for 3 pkts
The sender receives2 data pktsfrom upper layer
Window
send_base next_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Window
send_basenext_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Window
send_basenext_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Window
snapshot
3-152
Go-Back-N: Sender Already ACKedSent, but ACK not received
Usable, not sent yet
Not usable
Window
send_basenext_seq_num
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Timeout occursRetransmit
Window
snapshot
3-153
GBN: sender extended FSM
Wait start_timerudt_send(sndpkt[base])udt_send(sndpkt[base+1])…udt_send(sndpkt[nextseqnum-1])
timeout
rdt_send(data)
if (nextseqnum < base+N) { sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum]) if (base == nextseqnum) start_timer nextseqnum++ }else refuse_data(data)
base = getacknum(rcvpkt)+1If (base == nextseqnum) stop_timer // All packets have been ACKed…else start_timer
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
base=0nextseqnum=0
rdt_rcv(rcvpkt) && corrupt(rcvpkt)
3-154
GBN: receiver extended FSM
out-of-order pkt: discard (don’t buffer) -> no receiver buffering! Re-ACK pkt with highest in-order seq #
Wait
udt_send(sndpkt)
default
rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) && hasseqnum(rcvpkt,expectedseqnum)
extract(rcvpkt,data)deliver_data(data)sndpkt = make_pkt(expectedseqnum,ACK,chksum)udt_send(sndpkt)expectedseqnum++
expectedseqnum=0sndpkt = make_pkt(expectedseqnum,ACK,chksum)
ACK-only: always send ACK for correctly-received pkt with highest in-order seq # need only remember expectedseqnum
3-155
GBN in action
3-156
Selective Repeat
receiver individually ACKs all correctly received pkts
buffers pkts, as needed,
for eventual in-order delivery to upper layer
Important
sender only resends pkts for which ACK is not received and timeout occurs
3-157
Selective repeat: sender window
Window
send_base next_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
ACK received for 7 and 8.
Window
send_basenext_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
3-158
Selective repeat: sender window
Window
send_base next_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Timeout occurs for #7Retransmit
2 new packets arrive from upper layer
Window
send_base next_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(Don’t blink now…..)
3-159
Selective repeat: receiver window
Window
receive_basenext_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Pkt #7 is received
Window
receive_basenext_seq_num
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
3-160
Selective repeat
data from above : if next available seq # in
window, send pkt
timeout(n): resend pkt n, restart timer
ACK(n) in [sendbase,sendbase+N]:
mark pkt n as received if n smallest unACKed pkt,
advance window base to next unACKed seq #
senderpkt n in [rcvbase, rcvbase+N-1]
receiver
otherwise: ignore
send ACK(n) out-of-order: buffer
in-order: deliver (also deliver buffered, in-order pkts),
advance window to next not-yet-received pkt
pkt n in [rcvbase-N,rcvbase-1]
ACK(n)
3-161
Selective repeat in action
3-162
Selective repeat: dilemma
Example: seq #’s: 0, 1, 2, 3 window size = 3
receiver sees no difference in two scenarios!
incorrectly passes duplicate data as new in (a)
Data Link Layer5-163
End of Link Layer