Ch 11. Data Link Control

Report
Ch 11. Data Link Control
Data Link Layer
• Functionalities of data link layer
– Data link control (chapter 11):
about node-to-node
communication
– Media access control (chapter 12):
about link sharing
• Data link control
– Framing (the bits organization)
– Flow and error control
Application
Presentation
Session
Transport
Network
Data Link
Physical
11.1 Framing
• Transmission unit in data link layer
– Pack (stream) bits into frames (packets)
• Fixed-size framing (size itself is a delimiter)
• Variable-size framing
– How to distinguish a frame from the other frames?
» A character-oriented approach
» A bit-oriented approach
Variable-size Framing
• Character-oriented framing (old times, designed to transfer text)
– A frame starts with a special character of 1 byte (flag)
Source and destination
address
Error correction,
detection bits
– If data includes “the same bit pattern” as flag (or ESC),
do stuffing and unstuffing,
using ESC
Variable-size Framing
• Bit-oriented framing (graphic, audio, video, text)
– Flag is a bit-pattern, e.g., 01111110
– Stuffing and unstuffing are done by adding/removing a
single bit, e.g., adding/removing 0 after every “11111”
11.2 Flow and Error Control
• Data link control
– Flow control – the sender restricts the amount of data that
can be sent, due to speed and buffer limitation at the
receiver side
• Any receiving device has a limited amount of memory in which to
store incoming data. The receiving device must be able to inform
the sending device before those limits are reached and to request
either slow down and temporarily stop.
– Error control – referred to both error detection and error
correction. In case of errors, they are often recovered by
error correction code, or by retransmission. This process is
called automatic repeat request (ARQ).
11.3 Data Link Control Protocols
• Different protocols for
– Noiseless channels: Simplest and Stop-and-Wait
– Noisy channels: Stop-and-Wait ARQ, Go-Back-N ARQ,
and Selective Repeat ARQ
• Uni-directional vs. bidirectional
– For simplicity, we consider two protocols for each
direction (i.e., uni-directional)
– In reality, the protocols are bidirectional
• Small control frames (e.g., acknowledgement) are
piggybacked over frames of the flow in the opposite
direction
11.4 Noiseless Channels
• Ideal error-free channels
– No frames are lost
• Simplest protocol
– No flow or error control
– Assume that the receiver can handle any frame
immediately
Procedure of Simplest Protocol
SENDER
while(true) {
WaitForEvent();
if(Event(RequestToSend)) {
GetData();
MakeFrame();
SendFrame();
}
}
RECEIVER
while(true) {
WaitForEvent();
if(Event(ArrivalNotification)) {
ReceiveFrame();
ExtractData()
DeliverData();
}
}
Flow Diagram of Simplest Protocol
Transmission time
Stop-and-Wait Protocol
• Receiver-side limitation
– Receiver processes frames at a lower rate than
transmitter’s sending rate
– Frames can be stored at the receiver, but the storage
space is limited
• Procedure of Stop-and-Wait (buffer size of 1 at
receiver)
Confirmation frame
Pseudo Code of Stop-and-Wait
SENDER
canSend = true;
while(true) {
WaitForEvent();
if(Event(RequestToSend)
AND canSend) {
GetData();
MakeFrame();
SendFrame();
canSend = false;
}
if(Event(ArrivalNotification)) {
ReceiveFrame();
canSend = true;
}
}
RECEIVER
while(true) {
WaitForEvent();
if(Event(ArrivalNotification)) {
ReceiveFrame();
ExtractData()
DeliverData();
SendFrame();
}
}
ACK sent
ACK received
Flow Diagram of Stop-and-Wait
11.5 Noisy Channels
• Noiseless channels are non-existent
• Stop-and-Wait Automatic Repeat Request (ARQ)
– Add a simple error control to Stop-and-Wait protocol
– For corrupted frame, add redundancy bits to detect
errors at the receiver
– To identify the lost frame, number the frames
• Recovery (of Stop-and-Wait ARQ)
– Sender starts a timer after transmits a frame
– If a frame is corrupted or lost, the receiver will not send
an ACK, and the sender can retransmit the frame “when
the timer expires”
– Sender should keep a copy of a frame for retransmission
Procedure of Stop-and-Wait ARQ
• To minimize the frame size, we look for the smallest range of
sequence numbers that provides unambiguous communication.
• If the field is m bits long, the sequence numbers start form 0, go
to 2m – 1 and then are repeated.
Pseudo Code of Stop-and-Wait ARQ
SENDER
canSend = true;
Sn = 0
ACK received
while(true) {
WaitForEvent();
if(Event(RequestToSend)
AND canSend) {
GetData();
MakeFrame(Sn);
SendFrame(Sn);
StartTimer();
Sn = Sn + 1;
canSend = false;
}
if(Event(ArrivalNotification)) {
ReceiveFrame(ackNo);
if(not corrupted AND ackNo == Sn)
{
StopTimer();
PurgeFrame(Sn-1);
canSend = true;
}
}
if(Event(TimeOut) {
ResendFrame(Sn-1);
StartTimer();
}
}
(continue to the next)
Timer expiration and
retransmission
Pseudo Code of Stop-and-Wait ARQ
RECEIVER
Rn = 0
while(true) {
WaitForEvent();
Discard frame
if(Event(ArrivalNotification)) {
if corrupted
if(corrupted)
continue; /* do nothing */
if(seqNo == Rn) {
ExtractData();
Check Seq. No.
DeliverData();
Rn = Rn + 1;
}
SendFrame(Rn);
}
}
Flow Diagram of Stop-and-Wait ARQ
Efficiency of Stop-and-Wait
• Reminder: bandwidth-delay product
– Channel can be considered as a pipe
– The pipe size (volume) is the number of bits that the sender can
transmit into the system while waiting for an ACK from the
receiver
– = bandwidth x delay (round-trip time)
• Example 11.4
– The system has a link with bandwidth 1Mbps and 10ms
transmission delay (20ms in a round trip). If a frame is 1000 bits in
length, what is the utilization under Stop-and-Wait?
– 1000 / (bandwidth-delay product) = 1k / (1M x 20m) = 1k/20k = 5%
• Stop-and-Wait ARQ protocol is very inefficient!
Go-Back-N ARQ
• Improve efficiency of Stop-and-Wait
– Sender transmits up to N frames while waiting an ACK
• Sliding window: range of sequences at sender
that are sent (or can be sent) by the sender, but
not acknowledged yet
Go-Back-N ARQ
• The receive window makes sure that the correct data frames are
received and the correct acknowledgments are sent.
• The size of the receive window is always 1.
• The receive is always looking for the arrival of a specific frame and
other are discarded and needs to be resent.
Procedure of Go-Back-N ARQ
multiple frames are in transmission
• Retransmission
– When the timer expires, the sender resends all the
outstanding frames (i.e., goes back by N sequence)
Algorithm 11.7 Go-Back-N sender algorithm
Algorithm 11.7 Go-Back-N sender algorithm
(continued)
Algorithm 11.8 Go-Back-N receiver algorithm
11.25
Flow Diagram of Go-Back-N ARQ (1)
ACK is cumulative: ACK 3 also
acknowledge Frame 1
Flow Diagram of Go-Back-N ARQ (2)
Discussion
• Stop-and-Wait ARQ can be considered as a
special case of Go-Back-N ARQ with sliding
window of size 1
• Go-Back-N is also inefficient for noisy channels
– It resends all outstanding frames including those
that already arrived at the receiver
Selective Repeat ARQ
• Receiver stores the out-of-order frames
– Receiver informs the sender of which frame is
missing by Negative Acknowledgement (NAK or
NACK)
– Sender needs multiple timers for each frame
Two Sliding Windows
• Sender’s sliding window
• Receiver’s sliding window
The sizes of sender’s and
receiver’s windows are the same
Design of Selective Repeat ARQ
Algorithm 11.9 Sender-site Selective Repeat algorithm
(continued)
11.32
Algorithm 11.9 Sender-site Selective Repeat algorithm
11.33
(continued)
(continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm
11.34
(continued)
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.35
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.36
Flow Diagram of Selective Repeat ARQ
NAK (or NACK) for
an out-of-order
frame
Timer per
each frame
Piggybacking
• In bidirectional connection, control
information (i.e., ACK and NAK) can be
embedded in the data frame of the reverse
direction
Size of Sliding Windows
• A problem may occur if the
sequence number space is limited
• Go-Back-N ARQ
– The size of sender’s sliding window
should be less than N
• Selective Repeat ARQ
– The size of both sender’s and
receiver’s sliding windows should be
no greater than N/2
– Refer to Fig. 11.21 for an example
High-level Data Link Control
High-level Data Link Control (HDLC) is a bit-oriented
protocol for communication over point-to-point and
multipoint links. It implements the ARQ mechanisms in
two possible configurations:
• Normal response mode (NRM)
• Asynchronous balanced mode (ABM)
Figure 11.26 Asynchronous balanced mode
Normal response mode
Asynchronous balanced mode
11.41
HDLC frames
HDLC defines three types of frames:
• Information frames (I-frames)
• Transmits user data & control information relating to user data
(piggybacking).
• Supervisory frames (S-frames)
• Transmits control information
• Unnumbered frames (U-frames)
• Reserved for system management.
Frame check sequence
11.42
Homework
• Exercise in Chap. 11
– 18, 24, 25, 29
– Additional problem) A system uses the Stop-and-Wait ARQ
protocol. If each packet carries 1000 bits of data and
transmitted over a link with rate 100 Kbps, how long does
it take to send 1 million bits of data if the distance
between the sender and receiver is 5000 Km and the
propagation speed is 2x108 m?
• Ignore the overhead due to headers and trailers
• Assume that each ACK is of 10 bits length
• Ignore queuing and processing delay, but do NOT ignore
transmission and propagation delay
• Assume that no data or ACK frame is lost or damaged

similar documents