data link control - NET 331 and net 221 | NET 331 and net

Download Report

Transcript data link control - NET 331 and net 221 | NET 331 and net

11.1

Chapter 11 Data Link Control

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Data Link Control

● Two main functions of the data link layer are data link control and media access control Data link control •Data must be checked and processed before they can be used.

•The rate of such processing is often slower than the rate of transmission.

•For this reason , each receiver has a buffer to store incoming data until they are processed.

If buffer begin to fill up, the sender must slow or halt transmission.

Flow control refers to a set of procedures used to restrict the amount of data that the sender can send before waiting for acknowledgment.

Data link control functions:

•Framing •Flow and error control •Software implemented protocols for smooth and reliable transmission of frames between nodes

data link control

Error control: is both error detection and correction. Error correction in data link layer is implemented simply: anytime an error is detected in exchange, specified frames are retransmitted. This process is called Automatic Repeat Request

Note

Error control in the data link layer is based on automatic repeat request, which is the retransmission of data.

Framing

● Separates a message from one source to destination, or from other messages to other destinations by adding a sender address and a destination address ● go Destination address tells where the frame is to ● Sender address helps the recipient acknowledge the receipt ● A very large frame makes flow and error control very inefficient retransmission a single bit error requires

Framing

● Fixed-size framing - no need to define boundaries of the frames; ex. ATM networks ● Variable-size framing - need to define the end of the frame and beginning of the next; used in most networks Character-oriented Bit-oriented

Character-Oriented Protocols

● Data to be carried are 8-bit characters from a coding system such as ASCII ● Header and trailer are multiples of 8 bits ● 8-bit (1 byte) flag and end of a frame is added at the beginning

Character-Oriented Protocols

● Byte-Stuffing - Prevents data from being interpreted as flag ● A special byte, called escape character (ESC) , is added to the data section of the frame when there is a character with the same pattern as the flag

Byte Stuffing

Bit-Oriented Protocols

● Data section of frame is a sequence of bits be interpreted by the upper layer as text, graphic, audio, video, etc.

to ● Delimiter is a special bit pattern: 01111110

Bit Stuffing

● Adds one extra 0 whenever five consecutive 1s follow a 0 in the data

Flow and Error Control

● Flow control coordinates the amount of data that can be sent before receiving an acknowledgment ● Error control correction is both error detection and error ● Automatic Repeat Request (ARQ) - any time an error is detected in an exchange, specified frames are retransmitted

Protocols

Now let us see how the data link layer can combine framing, flow control, and error control to achieve the delivery of data from one node to another.

The protocols are normally implemented in software by using one of the common programming languages. To make our discussions language-free, we have written in pseudocode a version of each protocol that concentrates mostly on the procedure instead of delving into the details of language rules.

Protocols

● Focus is on unidirectional transfer ● Specialized frames ACK - acknowledgment NAK - negative acknowledgment ● Piggybacking the data frame - NAKs and ACKs included in ● Implemented in software

Simplest Protocol

● No flow or error control

Simplest Protocol

Simplest Protocol

Example 11.1

11.

18

Figure 11.7 shows an example of communication using this protocol. It is very simple. The sender sends a sequence of frames without even thinking about the receiver. To send three frames, three events occur at the sender site and three events at the receiver site. Note that the data frames are shown by tilted boxes; the height of the box defines the transmission time difference between the first bit and the last bit in the frame.

Simplest Protocol

Stop-and-Wait Protocol

● If the data frames arrive at the receiver site faster than they can be processed, the frames must be stored until their use ● Sender sends one frame, until it receives confirmation from the receiver and then sends next frame

Stop-and-Wait Protocol

Stop-and-Wait Protocol

Stop-and-Wait Protocol

Example 11.2

11.

24

Figure 11.9 shows an example of communication using this protocol. It is still very simple. The sender sends one frame and waits for feedback from the receiver. When the ACK arrives, the sender sends the next frame. Note that sending two frames in the protocol involves the sender in four events and the receiver in two events.

Stop-and-Wait Protocol

Stop-and-Wait ARQ

● Adds redundancy bits to data frame ● At the receiver end, if a frame is corrupted, it is silently discarded ● Numbering frames ( sequence numbers ) allows detection of lost frames ● Corrupted and lost frames must be resent ● Sender maintains a copy of sent frame and starts a timer ● If timer expires and no ACK received, resend ● ACK frames can also be corrupted

Stop-and-Wait ARQ

● Sequence numbers Select the smallest range that provides unambigous communication; also to minimize frame size If m bits long, sequence number start from 0 then are repeated to 2 m -1 and If we have used x to use x+1 as a sequence number; we need only (modulo-2) ● Acknowledgment numbers Announces the next sequence number (modulo-2) expected

Stop-and-Wait ARQ

It is the simplest flow and error control mechanism. A transmitter sends a frame then stops and waits for an acknowledgment.

Stop and Wait ARQ has the following features:

 The sending device keeps a copy of the sent frame transmitted until it receives an acknowledgment( ACK)  The sender starts a timer when it sends a frame. If an ACK is not received within an allocated time period, the sender resends it  Both frames and acknowledgment (ACK) are numbered alternately 0 and 1( two sequence number only)  The acknowledgment number defines the number of next expected frame. (frame 0 received ACK 1 is sent)  A damage or lost frame treated by the same manner by the receiver  f the receiver detects an error in the received frame, or receives a frame out of order it simply discards the frame  The receiver send only positive ACK for frames received safe; it is silent about the frames damage or lost.

 The sender has a control variable S that holds the number of most recently sent frame (0 or 1). The receiver has control variable R , that holds the number of the next frame expected (0,or 1)

● Design

Stop-and-Wait ARQ

Algorithm 11.5

Sender-site algorithm for Stop-and-Wait ARQ

11.

31

Algorithm 11.6

Receiver-site algorithm for Stop-and-Wait ARQ Protocol

Example 11.3

11.

32

Figure 11.11 shows an example of Stop-and-Wait ARQ .

Frame 0 is sent and acknowledged. Frame 1 is lost and resent after the time-out. The resent frame 1 is acknowledged and the timer stops. Frame 0 is sent and acknowledged, but the acknowledgment is lost. The sender has no idea if the frame or the acknowledgment is lost, so after the time-out, it resends frame 0, which is acknowledged.

F ● Flow

Stop-and-Wait ARQ

la

Stop-and-Wait ARQ

● Inefficient if channel is thick and long : large bandwidth and round-trip delay is long ● Recall: bandwidth-delay product volume of pipe in bits (BDP) ● BDP is a measure of the number of bits we can send out of our system while waiting for news from the receiver

Stop-and-Wait ARQ

● Given a bandwidth of 1Mbps and 1 bit takes 20 ms to make a round trip. What is BDP? If the length of frames is 1000 bits in length, what is the percentage utilization of the link?

BDP=(1 x 10 6 ) x (20 x 10 -3 ) = 20,000 bits PU=1000/20000 = 5%

Example 11.5

11.

36

What is the utilization percentage of the link in Example 11.4 if we have a protocol that can send up to 15 frames before stopping and worrying about the acknowledgments?

Solution The bandwidth-delay product is still 20,000 bits. The system can send up to 15 frames or 15,000 bits during a round trip. This means the utilization is 15,000/20,000, or 75 percent. Of course, if there are damaged frames, the utilization percentage is much less because frames have to be resent.

Pipelining

Pipelining: A task is begun before the previous task has ended  There is no pipelining in stop and wait ARQ because we need to wait for a frame to reach the destination and be acknowledged before the next frame can be sent  Pipelining improves the efficiency of the transmission

Go-Back-N ARQ

● Multiple frames must be in transit while waiting for ACK pipelining ● We keep a copy of the frames in transit until acknowledgment arrives ● Sequence numbers :  Sent frames are numbered sequentially  sequence number is stored in the header of the frame  If the header of the frame allow mbits for the sequence number, the sequence numbers range from 0 to (2 m -1).

If m = 3, sequence number range from 0 to 7( 8 numbers): 0, 1, 2 , 3, 4, 5, 6, 7, 0 , 1 ,…..

● Sliding window defines the range of sequence numbers that is the concern of the sender and receiver sender and receiver deals with only a part of the range of sequence numbers ● ACKs are cumulative - more than one frame can be acknowledged by a single ACK

F

Go-Back-N ARQ

● Send window for Go-Back-N ARQ; S , S , S f n size 

The sender window is an abstract concept defining an imaginary box of size 2 m − 1 ( sequence numbers –1)

The sender window can slide one or more slots when a valid acknowledgment arrives.

F

Go-Back-N ARQ

● Send window for Go-Back-N ARQ; S , S , S f n size lla

Go-Back-N ARQ

Send window size must be less than 2 m ; receiver window size is 1

F

Go-Back-N ARQ

● Receive window for Go-Back-N ARQ; R  single variable Rn.  n The receive window is an abstract concept defining an imaginary box of size 1 with one The window slides when a correct frame has arrived; sliding occurs one slot at a time.

lla

Go-Back-N ARQ

 In Go-Back-N ARQ we use one timer for the first outstanding frame  The receiver sends a positive ACK if a frame has arrived safe and in order.

 if a frame is damaged or out of order ,the receiver is silent and will discard all subsequent frames  When the timer of an unacknowledged frame at the sender site is expired , the sender goes back and resend all frames , beginning with the one with expired timer.( that is why the protocol is called Go-Back-N ARQ)  The receiver doesn't have to acknowledge each frame received . It can send cumulative Ack for several frame  Example: The sender has sent frame 6 , and timer expires for frame 3( frame 3 has not been acknowledge); the sender goes back and resends frames 3, 4,5 and 6

Go-Back-N ARQ

Algorithm 11.7

Go-Back-N sender algorithm

Algorithm 11.8

Go-Back-N receiver algorithm

11.

46

Example 11.6

Figure 11.16 shows an example of Go-Back-N. This is an

11.

47

example of a case where the forward channel is reliable, but the reverse is not. No data frames are lost, but some ACKs are delayed and one is lost. The example also shows how cumulative acknowledgments can help if acknowledgments are delayed or lost. After initialization, there are seven sender events. Request events are triggered by data from the network layer; arrival events are triggered by acknowledgments from the physical layer. There is no time-out event here because all outstanding frames are acknowledged before the timer expires. Note that although ACK 2 is lost, ACK 3 serves as both ACK 2 and ACK 3.

Go-Back-N ARQ

Example when forward channel is reliable

Go-Back-N ARQ

● Lost frames ● Stop-and-Wai with send window size of 1

Selective Repeat ARQ

 Go-Back-N ARQ is inefficient of a noisy link .

 In a noisy link frames have higher probability of damage , which means the resending of multiple frames.

  this resending consumes the bandwidth and slow down the transmission.

Solution:

Selective Repeat ARQ protocol : resent only the damage frame  It defines a negative Acknolgment (NAK) that report the sequence number of a damaged frame before the timer expires  It is more efficient for noisylink, but the processing at the receiver is more complex

Selective Repeat ARQ, sender and receiver windows  The window size is reduced to one half of 2 m  Sender window size = receiver window size = 2 m /2  Window size = sequence number/2  if m = 2, Window size = 4/2=2  Sequence number = 0, 1, 2 , 3

Note

In Selective Repeat ARQ, the size of the sender and receiver window must be at most one-half of 2 m .

Selective Repeat ARQ

● Send window

Selective Repeat ARQ

● Receive window

Selective Repeat ARQ

Algorithm 11.9

Sender-site Selective Repeat algorithm

11.

55

11.

56

Algorithm 11.10

Receiver-site Selective Repeat algorithm

F ●

Selective Repeat ARQ

Window size must be at most one-half of 2 m la

Example 11.8

11.

58

This example is similar to Example 11.3 in which frame 1 is lost. We show how Selective Repeat behaves in this case.

Figure 11.23 shows the situation. One main difference is the number of timers. Here, each frame sent or resent needs a timer, which means that the timers need to be numbered (0, 1, 2, and 3). The timer for frame 0 starts at the first request, but stops when the ACK for this frame arrives. The timer for frame 1 starts at the second request, restarts when a NAK arrives, and finally stops when the last ACK arrives.

The other two timers start when the corresponding frames are sent and stop at the last arrival event.

Example 11.8 (continued)

11.

59

At the receiver site we need to distinguish between the acceptance of a frame and its delivery to the network layer.

At the second arrival, frame 2 arrives and is stored and marked, but it cannot be delivered because frame 1 is missing. At the next arrival, frame 3 arrives and is marked and stored, but still none of the frames can be delivered.

Only at the last arrival, when finally a copy of frame 1 arrives, can frames 1, 2, and 3 be delivered to the network layer. There are two conditions for the delivery of frames to the network layer: First, a set of consecutive frames must have arrived. Second, the set starts from the beginning of the window.

Example 11.8 (continued)

11.

60

Another important point is that a NAK is sent after the second arrival, but not after the third, although both situations look the same. The reason is that the protocol does not want to crowd the network with unnecessary NAKs and unnecessary resent frames. The second NAK would still be NAK1 to inform the sender to resend frame 1 again; this has already been done. The first NAK sent is remembered (using the nakSent variable) and is not sent again until the frame slides. A NAK is sent once for each window position and defines the first slot in the window.

Example 11.8 (continued)

11.

The next point is about the ACKs. Notice that only two ACKs are sent here. The first one acknowledges only the first frame; the second one acknowledges three frames. In Selective Repeat, ACKs are sent when data are delivered to the network layer. If the data belonging to n frames are delivered in one shot, only one ACK is sent for all of them.

Selective Repeat ARQ

Piggybacking

Piggybacking  Is a method to combine a data frame with an acknowledgment.  It can save bandwidth because data frame and an ACK frame can combined into just one frame