Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 THE DATA LINK LAYER

Similar presentations


Presentation on theme: "Chapter 3 THE DATA LINK LAYER"— Presentation transcript:

1 Chapter 3 THE DATA LINK LAYER
We will study the principles and functions of layer 2, the data link layer. It is the layer above the lowest layer, physical layer, which concern: Physical interface between data transmission device (e.g. computer) and transmission medium or network Characteristics of transmission medium Signal levels Data rates etc. Introduction To Data Communications

2 Hybrid Model The hybrid reference model to be used in this book.
Introduction To Data Communications

3 Functions of the Data Link Layer
The process of Data link layer transfer the data between the network layerand physical layer. It encapsulates data packet from the network layer into frames (header, payload and trailer). Fragmentation Large block of data may be split into small frames Limited buffer size Errors detected sooner (when whole frame received) On error, retransmission of smaller frames is needed Prevents one station occupying medium for long periods Stop and wait becomes inadequate Introduction To Data Communications

4 Data Link Layer Design Issues
Services Provided to the Network Layer Framing (Packetizing) Physical addressing Error Control Flow Control Access control. Framing. The data link layer divides the stream of bits received from the network layer into manageable data units called frames. Physical addressing. If frames are to be distributed to different systems on the network, the data link layer adds a header to the frame to define the physical address of the sender (source address) and/or receiver (destination address) of the frame. If the frame is intended for a system outside the sender's network, the receiver address is the address of the device that connects one network to the next. Flow control. If the rate at which the data are absorbed by the receiver is less than the rate produced in the sender, the data link layer imposes a flow control mechanism to prevent overwhelming the receiver. Error control. The data link layer adds reliability to the physical layer by adding mechanisms to detect and retransmit damaged or lost frames. It also uses a mechanism to prevent duplication of frames. Error control is normally achieved through a trailer added to the end of the frame. Access control. When two or more devices are connected to the same link, data link layer protocols are necessary to determine which device has control over the link at any given time. Introduction To Data Communications

5 Services Provided to Network Layer
Unacknowledged connectionless service. No acknowledgement, no logical connection, used in very low error rate channel and real-time traffic. Acknowledged connectionless service. each frame acknowledged, used in unreliable channel Acknowledged connection-oriented service a connection established, frames are numbed.reliable transmission guaranteed.

6 Four methods are used to break the bit stream.
For the data link layer, break the bit stream up into discrete frames and computer the checksum for each frame (error control). Four methods are used to break the bit stream. Character count. (rarely used) Flag bytes with byte stuffing Starting and ending flags, with bit stuffing. Physical layer coding violations. Introduction To Data Communications

7 Framing (packetizing)
For the data link layer, break the bit stream up into discrete frames and computer the checksum for each frame (error control). Four methods are used to break the bit stream. Character count. Flag bytes with byte stuffing Starting and ending flags, with bit stuffing. Physical layer coding violations. If lost synchronisation, no way to get in control again. Retransmission is helpless. It is rarely used anymore. Introduction To Data Communications

8 Framing (2) Can resynchronisation after an error by having each frame start and end with special bytes. It is used of 8-bit characters (Bytes). (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing. Introduction To Data Communications

9 Framing (3) Flag: All more than 5 1-bit string will be inserted a 0-bit to distinguish from the flag – bit stuffing. When the receiver sees 5 consecutive incoming 1 bits, followed by a 0 bit, it delete the 0 bit. (destuffing.) Flag sequence can be used to resynchronisation. Bit stuffing (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in receiver’s memory after destuffing. Introduction To Data Communications

10 Flow Control Ensuring the sending entity does not overwhelm the receiving entity Feedback-based flow control Rate-based flow control (network layer)

11 Stop and Wait Only one frame at a time can be in transit.
Source transmits frame Destination receives frame and replies with acknowledgement (if it is correct, otherwise send NAK.) Source waits for ACK before sending next frame Destination can stop flow by not send ACK Source can retransmit if got a NAK. Works well for a few large frames Inefficient line utilization for small frames Only one frame at a time can be in transit. Source transmits frame Destination receives frame and replies with acknowledgement (if it is correct, otherwise send NAK.) Source waits for ACK before sending next frame Destination can stop flow by not send ACK Destination can retransmit if got a NAK. Works well for a few large frames Inefficient line utilization for small frames If the frame length is short than than the bit length of the link, serious inefficiencies results. Efficiency can be greatly improved by allowing multiple frames to be in transit at the same time. Consider the noise channel Introduction To Data Communications

12 Sliding Window Protocols
Allow multiple frames to be in transit Receiver has buffer W long Transmitter can send up to W frames without ACK Each frame is numbered ACK includes number of next frame expected Sequence number bounded by size of field (k) Frames are numbered modulo 2k Allow multiple frames to be in transit Receiver has buffer W long Transmitter can send up to W frames without ACK Each frame is numbered ACK includes number of next frame expected Sequence number bounded by size of field (k) Frames are numbered modulo 2k Introduction To Data Communications

13 Example Sliding Window
Let us examine how this might work for two stations, A and B, connected via a full-duplex link. Station B allocates buffer space for W frames. Thus, B can accept W frames, and A is allowed to send W frames without waiting for any acknowledgments. To keep track of which frames have been acknowledged, each is labeled with a sequence number. B acknowledges a frame by sending an acknowledgment that includes the sequence number of the next frame expected. This acknowledgment also implicitly announces that B is prepared to receive the next W frames, beginning with the number specified. This scheme can also be used to acknowledge multiple frames. For example, B could receive frames 2, 3, and 4, but withhold acknowledgment until frame 4 has arrived. By then returning an acknowledgment with sequence number 5, B acknowledges frames 2, 3, and 4 at one time. A maintains a list of sequence numbers that it is allowed to send, and B maintains a list of sequence numbers that it is prepared to receive. Each of these lists can be thought of as a window of frames. The operation is referred to as sliding-window flow control. Several additional comments need to be made. Because the sequence number to be used occupies a field in the frame, it is clearly of bounded size. For example, for a 3-bit field, the sequence number can range from 0 to 7. Accordingly, frames are numbered modulo 8; that is, after sequence number 7, the next number is 0. In general, for a k-bit field the range of sequence numbers is 0 through 2 k - 1, and frames are numbered modulo 2 k, Figure 7.3 is a useful way of depicting the sliding-window process. It assumes the use of a 3-bit sequence number, so that frames are numbered sequentially from 0 through 7, and then the same numbers are reused for subsequent frames. The shaded rectangle indicates the frames that may be sent; in this figure, the sender may transmit seven frames, beginning with frame 0. Each time a frame is sent, the shaded window shrinks; each time an acknowledgment is received, the shaded window grows, Frames between the vertical bar and the shaded window have been sent but not yet acknowledged. As we shall see, the sender must buffer these frames in case they need to be retransmitted. Introduction To Data Communications

14 Sliding Window Protocols (2)
Duplex communication: each station needs to maintain two windows Piggyback: num of frame and num of ack are included in one frame. Sliding-window flow control is more efficient than stop-and-wait flow control. So far, we have discussed transmission in one direction only. If two stations exchange data, each needs to maintain two windows, one for transmit and one for receive, and each side needs to send the data and acknowledgments to the other. To provide efficient support for this requirement, a feature known as piggybacking is typically provided. Each data frame includes a field that holds the sequence number of that frame plus a field that holds the sequence number used for acknowledgment. Thus, if a station has data to send and an acknowledgment to send, it sends both together in one frame, saving communication capacity. Of course, if a station has an acknowledgment but no data to send, it sends a separate acknowledgment frame, such as RR or RNR. If a station has data to send but no new acknowledgment to send, it must repeat the last acknowledgment sequence number that it sent. This is because the data frame includes a field for the acknowledgment number, and some value must be put into that field. When a station receives a duplicate acknowledgment, it simply ignores it. Sliding-window flow control is potentially much more efficient than stop-and-wait flow control. The reason is that, with sliding-window flow control, the transmission link is treated as a pipeline that may be filled with frames in transit. In contrast, with stop-and-wait flow control, only one frame may be in the pipe at a time. Introduction To Data Communications

15 Detection and correction of errors
ERROR CONTROL Detection and correction of errors Lost frames: a frame failed to arrived to the other side. Damaged frames: some bits are in error. Automatic repeat request Error detection Positive acknowledgment Retransmission after timeout Negative acknowledgement A timer is introduced in data link layer to control the interval for the frame to reach the destination, be processed there and then have acknowledgement propogate back to the sender. Introduction To Data Communications

16 ERROR DETECTION AND ERROR CORRECTION
Additional bits added by transmitter for error detection and/or error correction code Error detection is more often used in protocol with ARQ. High code rate, high reliability. Error correction is used in specific situation. (no reverse channel) Hybrid ARQ: combination of error detection and correction.

17 ERROR CONTROL SCHEME

18 STOP-AND –WAIT ARQ Source transmits single frame Wait for ACK
If received frame damaged, discard it Transmitter has timeout If no ACK within timeout, retransmit If ACK damaged, transmitter will not recognise it, Transmitter will retransmit Receive gets two copies of frame Use ACK0 and ACK1 Simple but Inefficient Source transmits single frame Wait for ACK If received frame damaged, discard it Transmitter has timeout If no ACK within timeout, retransmit If ACK damaged, transmitter will not recognize it Transmitter will retransmit Receive gets two copies of frame Use ACK0 and ACK1 Simple but Inefficient Introduction To Data Communications

19 Go Back N Based on sliding window
If no error, ACK as usual with next frame expected Use window to control number of outstanding frames If error, reply with rejection Discard that frame and all future frames until error frame received correctly Transmitter must go back and retransmit that frame and all subsequent frames

20 SELECTIVE REJECT (RETRANSMISSION)
Only rejected frames are retransmitted Subsequent frames are accepted by the receiver and buffered Minimizes retransmission Receiver must maintain large enough buffer to reordering. More complex login in transmitter

21 Example Data Link Protocols
HDLC – High-Level Data Link Control The Data Link Layer in the Internet HDLC is an actual protocol designed to support both half-duplex and full-duplex communication over point-to-point and multipoint links. It implements the ARQ mechanisms we discussed in this charpter. Introduction To Data Communications

22 High-Level Data Link Control
HDLC defines three type of frames: Information frames (I-frames) – for user data and control information relating user data, supervisory frames (S-frames) – flow and error control information, and unnumbered frames (U-frames) – system management. Each type of frame works as an envelope for the transmission of a different type of message. Bit-oriented protocols use bit-stuffing. Flag field: Address field: used to identify one of the terminals on lines with multiple terminals. For point-to-point lines it is sometimes used to distinguish commands from response. FCS: Frame Check Sequence. 16 bit CRC Optional 32 bit CRC Frame format for bit-oriented protocols. Introduction To Data Communications

23 High-Level Data Link Control (2)
HDLC uses a sliding window, with 3-bit sequence number. Up to seven unacknowledged frames may be outstanding at any instant. N(S): frame sequence number; N(R): piggybacked acknowledgement. P/F: Poll/Final, all the frame sent by the terminal, except the final one, have the P/F bit set to P. The final one is set to F. S: defines the type of supervisor frames. 00: acknowledgement frame (receive ready) used when no piggyback. 01: negative acknowledgement frame (Reject). Error detected, retransmission required. 10: receive not ready. Stop sending until further information. 11: selective reject: call for retransmission of only the frame specified. Introduction To Data Communications

24 The contents of an HDLC frame are shown in the following table:
Flag Address Control Information FCS 8 bits 8 or more bits 8 or 16 bits Variable length, 0 or more bits 16 or 32 bits

25 The Data Link Layer in the Internet
Point-to-point lines play a major role in the internet. PPP is the data link protocol used in Internet for router-to-router traffic and user-to-ISP traffic. PPP (Point-to-point protocol) handles error detection, supports multiple protocols, allows IP addresses to be negotiated at connection time. Introduction To Data Communications

26 PPP – Point to Point Protocol
The PPP full frame format for unnumbered mode operation. Address: PPP is used for a point-to-point connection, it uses the broadcast address of HDLC. Control: uses the format of the U-frame in HDLC. The frame does not contain any sequence numbers and there is no flow and error control. Protocol: what kind of packet is in the payload field. payload: variable length. Introduction To Data Communications

27 Performance of ARQ Stop-and-Wait Flow Control
The total time to send the data as T = n(2tprop + tframe) The utilization, or efficiency, of the line is It is useful to define the parameter a = tprop/tframe . Then Let us assume that the processing time is relatively negligible, and that the acknowledgment frame is very small compared to a data frame, both of which are reasonable assumptions. Then we can express the total time to send the data as T = n(2tprop + tframe) Of that time, only n * tframe is actually spent transmitting data and the rest is overhead. The utilization, or efficiency, of the line is It is useful to define the parameter a = tprop /tframe . Then This is the maximum possible utilisation of the link. Because the frame contains overhead bits, actual utilization is lower. Introduction To Data Communications

28 Error-free sliding-window flow control
where W is window size Typically, the sequence number is provided for in an n-bit field and the maximum window size is W = 2n – 1. Figure 7.16 shows the maximum utilization achievable for window sizes of 1, 7, and 127 as a function of a. A window size of 1 corresponds to stop and wait. A window size of 7 (3 bits) is adequate for many applications. A window size of 127 (7 bits) is adequate for larger values of a, such as may be found in high-speed WANs. Introduction To Data Communications


Download ppt "Chapter 3 THE DATA LINK LAYER"

Similar presentations


Ads by Google