Ch 11. Data Link Control

Preview:

DESCRIPTION

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. 11.1 Framing. - PowerPoint PPT Presentation

Citation preview

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

ApplicationPresentation

SessionTransportNetworkData LinkPhysical

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)

– If data includes “the same bit pattern” as flag (or ESC), do stuffing and unstuffing, using ESC

Source and destination address

Error correction, detection bits

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

SENDERwhile(true) { WaitForEvent(); if(Event(RequestToSend)) { GetData(); MakeFrame(); SendFrame(); }}

RECEIVERwhile(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-WaitSENDERcanSend = true;while(true) { WaitForEvent(); if(Event(RequestToSend) AND canSend) { GetData(); MakeFrame(); SendFrame(); canSend = false; } if(Event(ArrivalNotification)) { ReceiveFrame(); canSend = true; }}

RECEIVERwhile(true) { WaitForEvent(); if(Event(ArrivalNotification)) { ReceiveFrame(); ExtractData() DeliverData(); SendFrame(); }}

ACK received

ACK sent

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 ARQSENDERcanSend = true;Sn = 0while(true) { WaitForEvent(); if(Event(RequestToSend) AND canSend) { GetData(); MakeFrame(Sn); SendFrame(Sn); StartTimer(); Sn = Sn + 1; canSend = false; }

(continue to the next)

if(Event(ArrivalNotification)) { ReceiveFrame(ackNo); if(not corrupted AND ackNo == Sn) { StopTimer(); PurgeFrame(Sn-1); canSend = true; } }

if(Event(TimeOut) { ResendFrame(Sn-1); StartTimer(); }}

ACK received

Timer expiration and retransmission

Pseudo Code of Stop-and-Wait ARQRECEIVERRn = 0while(true) { WaitForEvent(); if(Event(ArrivalNotification)) { if(corrupted) continue; /* do nothing */ if(seqNo == Rn) { ExtractData(); DeliverData(); Rn = Rn + 1; } SendFrame(Rn); }}

Check Seq. No.

Discard frame if corrupted

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

• Retransmission– When the timer expires, the sender resends all the

outstanding frames (i.e., goes back by N sequence)

multiple frames are in transmission

Algorithm 11.7 Go-Back-N sender algorithm

Algorithm 11.7 Go-Back-N sender algorithm (continued)

11.25

Algorithm 11.8 Go-Back-N receiver algorithm

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

11.32

Algorithm 11.9 Sender-site Selective Repeat algorithm

(continued)

11.33

Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)

(continued)

11.34

Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)

11.35

Algorithm 11.10 Receiver-site Selective Repeat algorithm

11.36

Algorithm 11.10 Receiver-site Selective Repeat algorithm

Flow Diagram of Selective Repeat ARQ

Timer per each frame

NAK (or NACK) for an out-of-order

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

High-level Data Link Control

11.41

Figure 11.26 Asynchronous balanced mode

Asynchronous balanced mode

Normal response mode

11.42

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

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