Presentation is loading. Please wait.

Presentation is loading. Please wait.

11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Similar presentations


Presentation on theme: "11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."— Presentation transcript:

1 11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

2 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

3 11-1 FRAMING The data link layer needs to pack bits into frames, so that each frame is distinguishable from another. Our postal system practices a type of framing. The simple act of inserting a letter into an envelope separates one piece of information from another; the envelope serves as the delimiter. Fixed-Size Framing Variable-Size Framing Topics discussed in this section:

4 Figure 11.1 A frame in a character-oriented protocol

5 Figure 11.2 Byte stuffing and unstuffing An 8-bit character used to separate frames

6 Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the text. Note

7 Figure 11.3 A frame in a bit-oriented protocol

8 Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so that the receiver does not mistake the pattern 0111110 for a flag. Note

9 Figure 11.4 Bit stuffing and unstuffing

10 10 Byte Stuffing Four examples of byte sequences before and after byte stuffing

11 11 Bit Stuffing Bit stuffing: (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in the receiver’s memory after destuffing.

12 11-2 FLOW AND ERROR CONTROL The most important responsibilities of the data link layer are flow control and error control. Collectively, these functions are known as data link control. Flow Control Error Control Topics discussed in this section:

13 Flow Control Flow control coordinates the amount of data that can be sent before receiving acknowledgement It is one of the most important functions of data link layer. Flow control is a set of procedures that tells the sender how much data it can transmit before it must wait for an acknowledgement from the receiver. Receiver has a limited speed at which it can process incoming data and a limited amount of memory in which to store incoming data. Receiver must inform the sender before the limits are reached and request that the transmitter to send fewer frames or stop temporarily. Since the rate of processing is often slower than the rate of transmission, receiver has a block of memory (buffer) for storing incoming data until they are processed.

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

15 Error Control Error control includes both error detection and error correction. It allows the receiver to inform the sender if a frame is lost or damaged during transmission and coordinates the retransmission of those frames by the sender. Error control in the data link layer is based on automatic repeat request (ARQ). Whenever an error is detected, specified frames are retransmitted.

16 11.16 Figure 11.5 Taxonomy of protocols discussed in this chapter

17 11.17 11-3 PROTOCOLS All the protocols are unidirectional in the sense that the data frames travel from one node, called the sender, to another node, called the receiver. Although special frames, called acknowledgment (ACK) and negative acknowledgment (NAK) can flow in the opposite direction for flow and error control purposes, data flow in only one direction. In a real-life network, the data link protocols are implemented as bidirectional; data flow in both directions. In these protocols the flow and error control information such as ACKs and NAKs is included in the data frames in a technique called piggybacking. Because bidirectional protocols are more complex than unidirectional ones.

18 11.18 11-4 NOISELESS CHANNELS Let us first assume we have an ideal channel in which no frames are lost, duplicated, or corrupted. We introduce two protocols for this type of channel. Simplest Protocol Stop-and-Wait Protocol Topics discussed in this section:

19 11.19 11-4 NOISELESS CHANNELS Simplest Protocol it is one that has no flow or error control. it is a unidirectional protocol in which data frames are traveling in only one direction-from the sender to receiver. The data link layer of the receiver immediately removes the header from the frame and hands the data packet to its network layer, which can also accept the packet immediately. In other words, the receiver can never be overwhelmed with incoming frames

20 11.20 Figure 11.6 The design of the simplest protocol with no flow or error control Extrac t data

21 11.21 Algorithm 11.1 Sender-site algorithm for the simplest protocol

22 11.22 Algorithm 11.2 Receiver-site algorithm for the simplest protocol

23 11.23 Figure 11.7 Flow diagram for Example 11.1

24 11.24 If data frames arrive at the receiver site faster than they can be processed, the frames must be stored until their use. Normally, the receiver does not have enough storage space, especially if it is receiving data from many sources. This may result in either the discarding of frames or denial of service. To prevent the receiver from becoming overwhelmed with frames, we somehow need to tell the sender to slow down. There must be feedback from the receiver to the sender. Stop-and-Wait Protocol

25 11.25 The protocol is called the Stop-and-Wait Protocol because the sender sends one frame, stops until it receives confirmation from the receiver (okay to go ahead), and then sends the next frame. We still have unidirectional communication for data frames, but auxiliary ACK frames (simple tokens of acknowledgment) travel from the other direction. We add flow control to our previous protocol.

26 11.26 Figure 11.8 Design of Stop-and-Wait Protocol

27 11.27 Algorithm 11.3 Sender-site algorithm for Stop-and-Wait Protocol

28 11.28 Algorithm 11.4 Receiver-site algorithm for Stop-and-Wait Protocol

29 11.29 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. Example 11.2

30 11.30 Figure 11.9 Flow diagram for Example 11.2

31 11.31 11-5 NOISY CHANNELS Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, noiseless channels are nonexistent. We discuss three protocols in this section that use error control. Stop-and-Wait Automatic Repeat Request Go-Back-N Automatic Repeat Request Selective Repeat Automatic Repeat Request Topics discussed in this section:

32 Error and Flow Control Mechanisms Stop-and-Wait Go-Back-N ARQ Selective-Repeat ARQ

33 Stop-and- Wait  Sender keeps a copy of the last frame until it receives an acknowledgement.  For identification, both data frames and acknowledgements (ACK) frames are numbered alternatively 0 and 1.  Sender has a control variable (S) that holds the number of the recently sent frame. (0 or 1)  Receiver has a control variable ® that holds the number of the next frame expected (0 or 1).  Sender starts a timer when it sends a frame. If an ACK is not received within a allocated time period, the sender assumes that the frame was lost or damaged and resends it  Receiver send only positive ACK if the frame is intact.  ACK number always defines the number of the next expected frame

34 Stop-and-Wait ARQ, lost frame When a receiver receives a damaged frame, it discards it and keeps its value of R. After the timer at the sender expires, another copy of frame 1 is sent.

35 Stop-and-Wait, lost ACK frame If the sender receives a damaged ACK, it discards it. When the timer of the sender expires, the sender retransmits frame 1. Receiver has already received frame 1 and expecting to receive frame 0 (R=0). Therefore it discards the second copy of frame 1.

36 Stop-and-Wait, delayed ACK frame The ACK can be delayed at the receiver or due to some problem It is received after the timer for frame 0 has expired. Sender retransmitted a copy of frame 0. However, R =1 means receiver expects to see frame 1. Receiver discards the duplicate frame 0. Sender receives 2 ACKs, it discards the second ACK.

37 Piggybacking A method to combine a data frame with ACK. Station A and B both have data to send. Instead of sending separately, station A sends a data frame that includes an ACK. Station B does the same thing. Piggybacking saves bandwidth.

38 11.38 Figure 11.11 Flow diagram for Example 11.3

39 Disadvantage of Stop-and-Wait In stop-and-wait, at any point in time, there is only one frame that is sent and waiting to be acknowledged. This is not a good use of transmission medium. To improve efficiency, multiple frames should be in transition while waiting for ACK. Two protocol use the above concept, – Go-Back-N ARQ – Selective Repeat ARQ

40 Go-Back-N ARQ We can send up to W frames before worrying about ACKs. We keep a copy of these frames until the ACKs arrive. This procedure requires additional features to be added to Stop-and-Wait ARQ.

41 Sequence Numbers Frames from a sender are numbered sequentially. We need to set a limit since we need to include the sequence number of each frame in the header. If the header of the frame allows m bits for sequence number, the sequence numbers range from 0 to 2 m – 1. for m = 3, sequence numbers are: 1, 2, 3, 4, 5, 6, 7. We can repeat the sequence number. Sequence numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, …

42 Sender Sliding Window At the sending site, to hold the outstanding frames until they are acknowledged, we use the concept of a window. The size of the window is at most 2 m -1 where m is the number of bits for the sequence number. Size of the window can be variable, e.g. TCP. The window slides to include new unsent frames when the correct ACKs are received

43 Figure 7-4 Sender Sliding Window

44 Figure 7-5 Receiver Sliding Window

45 Size of the window at the receiving site is always 1 in this protocol. Receiver is always looking for a specific frame to arrive in a specific order. Any frame arriving out of order is discarded and needs to be resent. Receiver window slides as shown in fig. Receiver is waiting for frame 0 in part a.

46 Control Variables Sender has 3 variables: S, S F, and S L S holds the sequence number of recently sent frame S F holds the sequence number of the first frame S L holds the sequence number of the last frame Receiver only has the one variable, R, that holds the sequence number of the frame it expects to receive. If the seq. no. is the same as the value of R, the frame is accepted, otherwise rejected.

47 Acknowledgement Receiver sends positive ACK if a frame arrived safe and in order. If the frames are damaged/out of order, receiver is silent and discard all subsequent frames until it receives the one it is expecting. The silence of the receiver causes the timer of the unacknowledged frame to expire. Then the sender resends all frames, beginning with the one with the expired timer. For example, suppose the sender has sent frame 6, but the timer for frame 3 expires (i.e. frame 3 has not been acknowledged), then the sender goes back and sends frames 3, 4, 5, 6 again. Thus it is called Go-Back-N-ARQ The receiver does not have to acknowledge each frame received, it can send one cumulative ACK for several frames.

48 Go-Back-N ARQ, normal operation The sender keeps track of the outstanding frames and updates the variables and windows as the ACKs arrive.

49 Go-Back-N ARQ, lost frame Frame 2 is lost When the receiver receives frame 3, it discards frame 3 as it is expecting frame 2 (according to window). After the timer for frame 2 expires at the sender site, the sender sends frame 2 and 3. (go back to 2)

50 Go-Back-N ARQ, damaged/lost/delayed ACK If an ACK is damaged/lost, we can have two situations: If the next ACK arrives before the expiration of any timer, there is no need for retransmission of frames because ACKs are cumulative in this protocol. If ACK1, ACK2, and ACk3 are lost, ACK4 covers them if it arrives before the timer expires. If ACK4 arrives after time-out, the last frame and all the frames after that are resent. Receiver never resends an ACK. A delayed ACK also triggers the resending of frames

51 Go-Back-N ARQ, sender window size Size of the sender window must be less than 2 m. Size of the receiver is always 1. If m = 2, window size = 2 m – 1 = 3. Fig compares a window size of 3 and 4. Accepts as the 1 st frame in the next cycle- an error

52 Selective Repeat ARQ, sender and receiver windows Go-Back-N ARQ simplifies the process at the receiver site. Receiver only keeps track of only one variable, and there is no need to buffer out-of-order frames, they are simply discarded. However, Go-Back-N ARQ protocol is inefficient for noisy link. It bandwidth inefficient and slows down the transmission. In Selective Repeat ARQ, only the damaged frame is resent. More bandwidth efficient but more complex processing at receiver. It defines a negative ACK (NAK) to report the sequence number of a damaged frame before the timer expires.

53 Selective Repeat ARQ, lost frame Frames 0 and 1 are accepted when received because they are in the range specified by the receiver window. Same for frame 3. Receiver sends a NAK2 to show that frame 2 has not been received and then sender resends only frame 2 and it is accepted as it is in the range of the window.

54 Selective Repeat ARQ, sender window size Size of the sender and receiver windows must be at most one-half of 2 m. If m = 2, window size should be 2 m /2 = 2. Fig compares a window size of 2 with a window size of 3. Window size is 3 and all ACKs are lost, sender sends duplicate of frame 0, window of the receiver expect to receive frame 0 (part of the window), so accepts frame 0, as the 1 st frame of the next cycle – an error.

55 55 KEY POINTS Framing is performed by breaking the information into small frames. Each frame uses preamble and postamble to indicate the start and end. Error detection is performed by calculating an error-detecting code that is a function of the bits being transmitted. Error correction operates in a fashion similar to error detection but is capable of correcting certain errors.

56 56 KEY POINTS Data link control protocol provides functions such as flow control, error detection, and error control. Flow control enables a receiver to regulate the flow of data from a sender so that the receiver’s buffers do not overflow. In a data link control protocol, error control can achieved by retransmission of damaged frames that have not been acknowledged or for which the other side requests a retransmission.

57 Figure 7-1 Categories of Flow Control

58 Figure 7-2 Stop-and-Wait

59 Figure 7-3 Sliding Window

60 Figure 7-6 Example of Sliding Window

61 Figure 7-7 Categories of Error Control

62 Figure 7-8 Stop-and-Wait ARQ, Damaged Frame

63 Figure 7-9 Stop-and-Wait ARQ, Lost Frame

64 Figure 7-10 Stop-and-Wait ARQ, Lost ACK

65 Figure 7-11 Go-Back-n, Damaged Frame

66 Figure 7-12 Go-Back-n, Lost Frame

67 Figure 7-13 Go-Back-n, Lost ACK

68 Figure 7-14 Selective-Reject, Damaged Frame


Download ppt "11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."

Similar presentations


Ads by Google