43
Ch 11. Data Link Control

Ch 11. Data Link Control

  • Upload
    nerice

  • View
    134

  • Download
    0

Embed Size (px)

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

Page 1: Ch 11. Data Link Control

Ch 11. Data Link Control

Page 2: 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

Page 3: Ch 11. Data Link Control

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

Page 4: Ch 11. Data Link Control

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

Page 5: Ch 11. Data Link Control

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”

Page 6: Ch 11. Data Link Control

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

Page 7: Ch 11. Data Link Control

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

Page 8: Ch 11. Data Link Control

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

Page 9: Ch 11. Data Link Control

Procedure of Simplest Protocol

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

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

Page 10: Ch 11. Data Link Control

Flow Diagram of Simplest Protocol

Transmission time

Page 11: Ch 11. Data Link Control

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

Page 12: Ch 11. Data Link Control

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

Page 13: Ch 11. Data Link Control

Flow Diagram of Stop-and-Wait

Page 14: Ch 11. Data Link Control

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

Page 15: Ch 11. Data Link Control

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.

Page 16: Ch 11. Data Link Control

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

Page 17: Ch 11. Data Link Control

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

Page 18: Ch 11. Data Link Control

Flow Diagram of Stop-and-Wait ARQ

Page 19: Ch 11. Data Link Control

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!

Page 20: Ch 11. Data Link Control

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

Page 21: Ch 11. Data Link Control

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.

Page 22: Ch 11. Data Link Control

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

Page 23: Ch 11. Data Link Control

Algorithm 11.7 Go-Back-N sender algorithm

Page 24: Ch 11. Data Link Control

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

Page 25: Ch 11. Data Link Control

11.25

Algorithm 11.8 Go-Back-N receiver algorithm

Page 26: Ch 11. Data Link Control

Flow Diagram of Go-Back-N ARQ (1)

ACK is cumulative: ACK 3 also acknowledge Frame 1

Page 27: Ch 11. Data Link Control

Flow Diagram of Go-Back-N ARQ (2)

Page 28: Ch 11. Data Link Control

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

Page 29: Ch 11. Data Link Control

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

Page 30: Ch 11. Data Link Control

Two Sliding Windows

• Sender’s sliding window

• Receiver’s sliding window

The sizes of sender’s and receiver’s windows are the same

Page 31: Ch 11. Data Link Control

Design of Selective Repeat ARQ

Page 32: Ch 11. Data Link Control

11.32

Algorithm 11.9 Sender-site Selective Repeat algorithm

(continued)

Page 33: Ch 11. Data Link Control

11.33

Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)

(continued)

Page 34: Ch 11. Data Link Control

11.34

Algorithm 11.9 Sender-site Selective Repeat algorithm (continued)

Page 35: Ch 11. Data Link Control

11.35

Algorithm 11.10 Receiver-site Selective Repeat algorithm

Page 36: Ch 11. Data Link Control

11.36

Algorithm 11.10 Receiver-site Selective Repeat algorithm

Page 37: Ch 11. Data Link Control

Flow Diagram of Selective Repeat ARQ

Timer per each frame

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

frame

Page 38: Ch 11. Data Link Control

Piggybacking

• In bidirectional connection, control information (i.e., ACK and NAK) can be embedded in the data frame of the reverse direction

Page 39: Ch 11. Data Link Control

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

Page 40: Ch 11. 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)

High-level Data Link Control

Page 41: Ch 11. Data Link Control

11.41

Figure 11.26 Asynchronous balanced mode

Asynchronous balanced mode

Normal response mode

Page 42: Ch 11. Data Link Control

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

Page 43: Ch 11. Data Link Control

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