Data Link Control: Lecture Notes of Computer Communications and Networks Prepared by DR - Eng. Ziyad Tariq Al-Ta'i
Data Link Control: Lecture Notes of Computer Communications and Networks Prepared by DR - Eng. Ziyad Tariq Al-Ta'i
Introduction:
Communication requires at least two devices working together, one to send and one to receive. Even such a basic arrangement requires a great deal of coordination an exchange to occur. For example, in half duplex transmission, it is essential that only one device transmit at a time. If both ends of the link put signals on the line simultaneously, they collide, leaving nothing on the line but noise. The coordination of half duplex transmission is part of a procedure called line discipline. In addition to line discipline, data link control includes the functions: flow control and error control.
Line Discipline:
Line discipline answers the question, who should send now? Line discipline can be done in two ways: 1- ENQuiry/ACKnowledgment (ENQ/ACK): ENQ/ACK is used primarily in systems where there is no question of the wrong receiver getting the transmission, that is, when there is a dedicated link between two devices so that the only device capable of receiving the transmission is the intended one. ENQ/ACK coordinates which device may start a transmission and whether or not the intended recipient is ready and enabled. How it Works: The initiator first transmits a frame called an enquiry (ENQ) asking if the receiver is available to receive data. The receiver must answer either with an acknowledgement (ACK) frame if it is ready to receive or with a negative acknowledgment (NAK) frame if it is not. By requiring a response even if the answer is negative, the initiator knows that its enquiry was in fact received even if the receiver is currently unable to accept a transmission. If neither an 43
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
ACK nor a NAK is received within a specified time limit, the initiator assumes that the ENQ frame was lost in transmit, disconnects, and sends a replacement. An initiating system ordinarily makes three such attempts to establish a link before giving up. If the response to the ENQ is negative for three attempts, the initiator disconnects and begins the process again at another time. If the response is positive, the initiator is free to send its data. Once all of its data have been transmitted, the sending system finishes with an end of transmission (EOT) frame. This process is illustrated in following figure.
Station A
Station B
Establishment
Data Transfer
. . .
Data ACK
Termination
EOT
Time
Time
44
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
2- Poll/Select: The poll/select method of line discipline works with topologies where one device is designed as a primary station and the other devices are secondary stations. Multipoint systems must coordinate several nodes, not just two. The question to be determined in these cases, therefore, is more than just, Are you ready? It is also, which of the several nodes has the right to use the channel? How it Works: Whenever a multipoint link consists of a primary device and multiple secondary devices using a single transmission line, all exchanges must be made through the primary device even when the ultimate destination is a secondary device. The primary device controls the link; the secondary devices follow its instructions. It is up to the primary to determine which device is allowed to use the channel at a given time as shown in following figure. Primary Secondary A Secondary Secondary B C
The primary, therefore, is always the initiator of a session. If the primary wants to receive data, it asks the secondaries if they have anything to send; this function is called polling. If the primary wants to send data, it tells the target secondary to get ready to receive; this function is called selecting. Every device on a link has an address that can be used for identification. Poll/select protocols identify each frame as being either to or from a specific device on the link. Each secondary device has an address that differentiate it from the others. 45
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Flow Control:
Flow control refers to a set of procedures used to restrict the amount of data the sender can send waiting for acknowledgment. Two methods have been developed to control the flow of data across communications links:
Sender
Receiver
Wait Time
Data ACK
Wait Time
Time
Time
The advantage of stop and wait is simplicity: each frame is checked and acknowledged before the next frame is sent. The disadvantage is inefficiency: stop and wait is slow. Each frame is alone on the line. If the distance between devices is long, the time spent waiting for ACKs between each frame can add significantly to the total transmission time. 46
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
2- Sliding Window:
In the sliding window method of flow control, several frames can be in transmit at a time. The sliding window refers to imaginary boxes at both the sender and receiver. This window can hold frames at either end and provides the upper limit on the number of frames that can be transmitted before requiring an acknowledgment. Frames may be acknowledged at any point without waiting for the window to fill up and may be transmitted as long as the window is not yet full. To keep track of which frames have been transmitted and which received, sliding window introduces an identification scheme based on the size of the window. The frames are numbered modulo-n, which means they are numbered from 0 to n-1. For example, if n=8, the frames are numbered 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, .. The size of the window is n-1 (in this case 7), In other words, the window cannot cover the whole modulo (8 frames); it covers one frame less. When the receiver sends an ACK, it includes the number of the next frame it expects to receive. In other words, to acknowledge the receipt of a string of frames ending in frame 4, the receiver sends an ACK containing the number 5. When the sender an ACK with the number 5, it knows that all frames up through number 4 have been received. The window can hold n-1 frames at either end; therefore, a maximum of n-1 frames may be sent before an acknowledgement is required. Conceptually, the sliding window of the sender shrinks from the left when frames of data are sent. The sliding window of the sender expands to the right when acknowledgment are received. Conceptually, the sliding window of the receiver shrinks from the left when frames of data are received. The sliding window of the receiver expands to the right when acknowledgment are sent.
Example: The following figure shows a sample transmission that uses sliding window flow control with a window of seven frames. In this example, all frames arrive undamaged.
47
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Sender
Receiver
4 5
. .
0
Data 0
1 2
. .
4 5
. .
Data 1
1 2
. .
4 5
. .
ACK 2
1 2
. .
4 5
. .
0
Data 2
1 2
. .
4 5
. .
0
ACK 3
1 2
. .
4 5
. .
0
Data 3
1 2
. .
4 5
. .
0
Data 4
1 2
. .
4 5
. .
0
Data 5
1 2
. .
4 5
. .
1 2
. .
ACK 6
4 5
. .
1 2
. .
48
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
At the beginning of transmission, both sender and receiver windows are fully expanded to include seven frames ( seven transmittable frames in the sender window, seven placeholder frames in the receiver window). The frames within the window are numbered 0 through 7 and are part of larger data buffer, 13 of which are shown here.
Error Control:
Error correction is implemented simply: anytime an error is detected in an exchange, a negative acknowledgement (NAK) is returned and the specified frames are retransmitted. This process is called Automatic Repeat Request (ARQ). Error control refers to methods of error detection and retransmission. Error control is based on Automatic Repeat Request (ARQ), which means retransmission of data in three cases: damaged frame, lost frame, and lost acknowledgment. ARQ error control is implemented as an adjunct to flow control. In fact, stop and wait flow control is usually implemented as stop and wait ARQ and sliding window is usually implemented as one of two variants of sliding window ARQ, called (go back n) or (selective reject).
49
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
3- If an error is discovered in a data frame, indicating that it has been corrupted in transit, a NAK frame is returned. NAK frames, which are not numbered. Tell the sender to retransmit the last frame sent. 4- The sending device is equipped with a timer. If an expected acknowledgment is not received within an allotted time period, the sender assumes that the last data frame was lost in transit and sends it again.
Damaged Frames:
As shown in following figure: Sender Receiver
Data 0 ACK 1 Data 1 ACK 0 Data 0 Error in frame 0 NAK Data 0 ACK 1
Time
Time
Lost Frame:
An of the frame types can be lost in transit:
50
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Sender
Receiver
Time
Time
Lost Acknowledgement:
As shown in following figure: Sender Receiver
Data 0
Time out
Lost
Time
Time
51
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Go Back n ARQ:
In this sliding window go back n ARQ method, if one frame is lost or damaged, all frames sent since the last frame acknowledged are retransmitted. 52
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Damaged Frames:
As shown in following figure: Sender Receiver
Error,Discarded Discarded
NAK 3 Data 5
Discarded
Time
Time
53
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Sender
Receiver
Discarded
Discarded
Time
Time
54
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
Sender
Receiver
Lost
ACK 3
Time
Time
55
Dr.Eng.Ziyad Tariq Al-Ta'i
Lecture Notes of Computer Communications and Networks Prepared by Dr.Eng. Ziyad Tariq Al-Ta'i
2-
3-
4-
5-
The sending device must contain a searching mechanism that allows it to find and select only the requested frame for retransmission. A buffer in the receiver must keep all previously received frames on hold until all retransmissions have been sorted and any duplicate frames have been identified and discarded. To aid selectivity, ACK numbers, like NAK numbers, must refer to the frame received (or lost) instead of the next frame expected. This complexity requires a smaller window size than is needed by the go back n method if it is to work efficiently. It is recommended that the window size be less than or equal to (n+1)/2, where n-1 is the go back n window size.
56
Dr.Eng.Ziyad Tariq Al-Ta'i