Data Link Control. Dr. Indranil Sen Gupta Data Link Control Slide 1

Data Link Control Dr. Indranil Sen Gupta Data Link Control Slide 1 Introduction • We have so far looked into the issue of sending signals over a ...
Author: Myron Henry
2 downloads 0 Views 257KB Size
Data Link Control

Dr. Indranil Sen Gupta

Data Link Control

Slide 1

Introduction • We have so far looked into the issue of sending signals over a transmission link. • We now concentrate on sending data over a communication link. – Data Link Control: A layer of logic added above the physical interface in order to achieve the necessary control. – Data Link: The transmission medium between systems, when a data link control protocol is used.

Communication Link Dr. Indranil Sen Gupta

Data Link Control

Slide 2

Why Data Link Control? • Frame synchronization: The beginning and end of a data block (called frame) should be recognizable. • Flow control: The sender should not send frames at a rate faster than the receiver can receive and process them. • Error control: Any bit errors introduced by the transmission system should be corrected. • Addressing: On a multipoint link (line LAN), the identity of sender and receiver must be specified. • Control and data on same link: The receiver must be able to distinguish control information from the data being transmitted. • Link management: Procedures for the management of the initiation, maintenance, and termination of a sustained data exchange. Dr. Indranil Sen Gupta

Data Link Control

Slide 3

Frame Synchronization • When data are transferred from the transmitter to the receiver, unless steps are taken to provide synchronization, the receiver may start interpreting the data erroneously. • Two common approaches: – Asynchronous Transmission – Synchronous Transmission

Dr. Indranil Sen Gupta

Data Link Control

Slide 4

Asynchronous Transmission • Data are transmitted one character at a time (5-8 bits). – Timing or synchronization must only be maintained within each character. – The receiver has the opportunity to resynchronize at the beginning of each new character.

• When no character is being transmitted, the line between transmitter and receiver is in an idle state. – Start, stop, and parity bits. Start

P

Stop

Data Dr. Indranil Sen Gupta

Data Link Control

Slide 5

Synchronous Transmission • Here, a block of bits is transmitted in a steady stream without start and stop codes. – The block may be arbitrarily long. – To prevent timing drift between transmitter and receiver, clock signal is embedded in the data signal (e.g. Manchester encoding).

• There is another level of synchronization required, so as to allow the receiver to determine the beginning and end of a block of data. – Every block begins with a preamble bit pattern, and generally ends with a postamble bit pattern

Dr. Indranil Sen Gupta

Data Link Control

Slide 6

Synchronous Transmission (contd.) • A typical synchronous frame format: – – – – –

8-bit flag (preamble) Control fields Data field Control fields 8-bit flag (postamble)

• For sizable blocks of data, synchronous transmission is far more efficient than asynchronous mode. – Asynchronous transmission requires 20% or more overhead. – The control information, preamble and postamble in synchronous transmission are typically less than 100 bits. Dr. Indranil Sen Gupta

Data Link Control

Slide 7

Flow Control • A technique for assuring that a transmitting station does not overwhelm the receiving station with data. – Receiver typically allocates a data buffer of some maximum length. – After receiving data, the receiver must do a certain amount of processing before passing the data on to the higher level software.

• We first look at flow control techniques in the absence of errors.

Dr. Indranil Sen Gupta

Data Link Control

Slide 8

Model of Frame Transmission

Dr. Indranil Sen Gupta

Data Link Control

Slide 9

Stop-and-Wait Flow Control • The simplest form of flow control. – The source transmits a data frame. – After receiving the frame, the destination indicates its willingness to accept another frame by sending back an ACK frame acknowledging the frame just received. – The source must wait until it receives the ACK frame before sending the next data frame.

• Works fine when a message is sent in a few large frames. • Often the source splits a large message and transmits it in many frames. – Buffer size of the receiver may be limited. – Handling errors for smaller frames is cheaper. – On a shared medium like LAN, large frame sizes are not desirable. Dr. Indranil Sen Gupta

Data Link Control

Slide 10

Link Utilization in Stop-and-Wait • With the use of multiple frames for a single message, the stop-and-wait protocol does not perform well. – Only one frame at a time can be in transit.

Dr. Indranil Sen Gupta

Data Link Control

Slide 11

Link Utilization:: Performance Issues Consider a half-duplex point-to-point line using stop-and-wait scheme. Suppose that a long message has to be sent as a sequence of frames F1, F2, …, Fn. The total time to send the data can be expressed as: T = n.TF, where TF = tprop + tframe + tproc + tprop + tack + tproc tprop :: propagation time from source to destination, and vice-versa tframe :: time to transmit a frame tack :: time to transmit an acknowledgement tproc :: frame processing time at each station.

Assuming that processing time is negligible, and ACK frame is very small compared to a data frame, we get T = n(2tprop + tframe) Dr. Indranil Sen Gupta

Data Link Control

Slide 12

Of that time, only n.tframe is actually spent transmitting data and the rest is overhead. The utilization or efficiency of the line is U = n.tframe / [n.(2tprop + tframe)] = tframe / (2tprop + tframe) Defining the parameter a = tprop / tframe , we get U = 1 / (1 + 2a) • Illustrative Example: – a 1: • Sender completes transmission of the entire frame before the leading bits of the frame arrive at the receiver. Dr. Indranil Sen Gupta

Data Link Control

Slide 13

Stop-and-Wait Link Utilization

Dr. Indranil Sen Gupta

Data Link Control

Slide 14

Sliding Window Flow Control • In stop-and-wait flow control, if a>1, serious inefficiencies result. – Efficiency can be greatly improved by allowing multiple frames to be in transit at the same time.

• Suppose two stations A and B are connected by a fullduplex link. A

Dr. Indranil Sen Gupta

B

Data Link Control

Slide 15

Sliding Window (contd.) • Station B allocates buffer space for n frames. – Thus B can accept n frames, and A is allowed to send n frames without waiting for any acknowledgement.

• Each frame in labeled with a sequence number. – To keep track of the frames which have been acknowledged. – B acknowledges a frame by sending an ACK that includes the sequence number of the next frame expected. This also explicitly announces that B is prepared to receive the next n frames, beginning with the number specified.

• This scheme can be used to acknowledge multiple frames. – B could receive frames 2,3,4 but withhold ACK until frame 4 has arrived. By returning an ACK with sequence number 5, B acknowledges frames 2,3,4 at one time. Dr. Indranil Sen Gupta

Data Link Control

Slide 16

Sliding Window (contd.) • Sender maintains a list of sequence numbers that it is allowed to send (sender window). • Receiver also maintains a list of sequence numbers that it is prepared to receive (receiver window). • Since the sequence number to be used occupies a field in the frame, it is clearly of bounden size. – For a k-bit field, the range of sequence numbers is 0 through 2k-1, and frames are numbered modulo 2k.

• The next slide shows a depiction of the sliding-window for 3-bit sequence numbers. Dr. Indranil Sen Gupta

Data Link Control

Slide 17

Sliding Window Depiction

Dr. Indranil Sen Gupta

Data Link Control

Slide 18

Example of a Sliding-Window Protocol

Dr. Indranil Sen Gupta

Data Link Control

Slide 19

Sliding Window (contd.) • The actual window size need not be the maximum possible size for a given sequence number length. – For a 3-bit sequence number, a window size of 4 can be configured.

• If two stations exchange data, each need to maintain two windows. To save communication capacity, a technique called piggybacking is used. – Each data frame includes a field that holds the sequence number of that frame plus a field that holds the sequence number used for ACK. – If a station has an ACK but no data to send, it sends a separate ACK frame. Dr. Indranil Sen Gupta

Data Link Control

Slide 20

Error Detection • Transmission errors are inevitable, resulting in the change of one or more bits in a transmitted frame. • Some notations: pb: probability of a single bit error (called bit error rate) p1: probability that a frame arrives with no bit errors p2: probability that a frame arrives with one or more undetected bit errors. P3: probability that a frame arrives with one or more detected bit errors but no undetected bit errors. – F: number of bits in a frame – – – –

• If no error detection scheme is used, p3=0, and – p1 = (1 - pb)F – p2 = 1 - p1

• Clearly, longer frame and higher pb leads to lower p1. Dr. Indranil Sen Gupta

Data Link Control

Slide 21

Error Detection (contd.) • An illustrative example – A defined specification for ISDN connections is that the bit error rate on a 64Kbps channel should be less than 10-6 on at least 90% of observed 1-minute intervals. – Suppose we want that at most one frame with an undetected bit error should occur per day on a continuously used 64Kbps channel, with a frame length of 1000 bits. • No. of frames transmitted per day = (64K/1000)*60*60*24 = 5.5x106 • Desired frame error rate p2 = 1/(5.5x106) = 0.18x10-6

– But if we assume pb=10-6, then • p1 = (0.999999)1000 = 0.999 • Therefore, p2 = 10-3, which is about three orders of magnitude too large to meet our requirements.

• This necessitates the use of error detection techniques. Dr. Indranil Sen Gupta

Data Link Control

Slide 22

Error Detection Principle Data

Data′ E = f(Data)

E ′ = f(Data ′) Compare

Data k bits

RECEIVER

n bits

TRANSMITTER Dr. Indranil Sen Gupta

Data Link Control

Slide 23

Error Detection: Parity Check • The simplest error detection scheme. – Appends a parity bit to the end of a block of data. – Odd number of bit errors can be detected. – If an even number of bits are inverted due to error, an undetected error occurs.

• The technique is not foolproof, as noise impulses are often long enough to destroy more than one bit, particularly at high data rates.

Dr. Indranil Sen Gupta

Data Link Control

Slide 24

Error Detection: Cyclic Redundancy Check (CRC) • One of the most common and powerful error detecting codes. • The method works as follows: – Given a k-bit block of bits, the transmitter generates an n-bit sequence, known as a frame check sequence (FCS), so that the resulting frame, consisting of k+n bits, is exactly divisible by some predetermined number. – The receiver divides the incoming frame by that number and, if there is no remainder, assumes there was no error.

Dr. Indranil Sen Gupta

Data Link Control

Slide 25

CRC (contd.) • The CRC process can be very easily implemented in hardware using Linear Feedback Shift Register (LFSR). • The LFSR divides a message polynomial by a suitably chosen divisor polynomial; the remainder constitutes the FCS. • Commonly used divisor polynomials: – CRC-16 = X16 + X15 + X2 + 1 – CRC-CCITT = X16 + X12 + X5 + 1 – CRC-32 = X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 + X8 + . X7 + X5 + X4 + X2 + 1 Dr. Indranil Sen Gupta

Data Link Control

Slide 26

LFSR Implementation of CRC Logic

Figure 6.6 from the book by Stallings

Dr. Indranil Sen Gupta

Data Link Control

Slide 27

Error Control • Model of frame transmission: – Data are sent as a sequence of frames. – Frames arrive at the same order as they are sent. – Each transmitted frame suffers an arbitrary and variable amount of delay before reception.

• In addition to above, following two types of errors may occur: – Lost frame: A frame fails to arrive at the other side. • A noise burst may damage a frame to such an extent that the receiver is not aware that a frame has been transmitted.

– Damaged frame: A recognizable frame does arrive, but some of the bits are in error. Dr. Indranil Sen Gupta

Data Link Control

Slide 28

Error Control (contd.) • Most common techniques for error control are based on some or all of the following: – Error detection: As discussed before. – Positive acknowledgement: The destination returns a positive acknowledgement to successfully received error-free frames. – Retransmission after timeout: The source retransmits a frame that has not been acknowledged after a predetermined amount of time. – Negative acknowledgement and retransmission: The destination returns a negative acknowledgement to frames in which an error is detected. The source retransmits such frames.

Dr. Indranil Sen Gupta

Data Link Control

Slide 29

Error Control (contd.) • Collectively, the mechanisms stated are referred to as automatic repeat request (ARQ). – Objective is to turn an unreliable data link into a reliable one.

• Three versions of ARQ have been standardized: – Stop-and-wait ARQ – Go-back-N ARQ – Selective-reject ARQ

Dr. Indranil Sen Gupta

Data Link Control

Slide 30

Stop-and-Wait ARQ • Based on the stop-and-wait flow control technique. – The source station transmits a single frame and then waits for an acknowledgement (ACK). – No other data frames can be sent until the destination station’s reply arrives at the source station.

• Two sorts of errors may occur: – The frame that arrives at the destination could be damaged. • Receiver can detect this using error detection techniques. • To account for this possibility, the source station can be equipped with a timer. If no recognizable ACK is received when the timer expires at the end of the time-out interval, then the same frame is sent again. • Requires that the transmitter maintain a copy of a transmitted frame until an ACK is received for it. Dr. Indranil Sen Gupta

Data Link Control

Slide 31

Stop-and-Wait ARQ (contd.) – The ACK frame may be damaged. • The sender will timeout and resend the same frame. • The receiver receives the same frame twice. – How to identify duplicate frames?

• A modulo-2 numbering scheme is used, wherein frames are alternately labeled with 0 or 1, and positive acknowledgements are of the form ACK0 or ACK1.

• The main advantage of stop-and-wait ARQ is its simplicity. Its main disadvantage is that it makes highly inefficient use of communication links.

Dr. Indranil Sen Gupta

Data Link Control

Slide 32

Stop-and-Wait ARQ: an example

Dr. Indranil Sen Gupta

Data Link Control

Slide 33

Go-back-N ARQ • Based on sliding window protocol. – Most commonly used.

• Basic concept: – A station may send a series of frames sequentially numbered modulo some maximum value. – The number of unacknowledged frames outstanding is determined by window size, using the sliding-window flow control technique. – While no error occurs, the destination will acknowledge incoming frames as usual (using receive ready or RR frames). – If the destination detects a frame error, or it receives a frame out of order, it sends a NAK for that frame (using reject or REJ frame). – The destination will discard the frame in error and all future frames until the frame in error is correctly received. – The source station, on receiving a REJ, must retransmit the frame in error plus all succeeding frames. Dr. Indranil Sen Gupta

Data Link Control

Slide 34

Go-back-N ARQ: an example

Dr. Indranil Sen Gupta

Data Link Control

Slide 35

Go-back-N ARQ: window size limit • For a k-bit sequence number field, the maximum window size must be limited to (2k-1). • Suppose that data are being exchanged in both directions. – Station B must send piggybacked acknowledgements to station A’s frames in the data frames being transmitted by B. • This is required even if the ACK has already been sent; since B must put some number in the ACK field of its data frame.

– Assuming 3-bit sequence number, suppose that a station • sends frame 0 and gets back an RR1, and then • sends frames 1,2,3,4,5,6,7,0 and gets another RR1. • This might either mean that RR1 is a cumulative ACK (all 8 frames received correctly), or all 8 frames were damaged, and the receiver is repeating its previous RR1.

– This problem can be solved if the maximum window size is kept at 7. Dr. Indranil Sen Gupta

Data Link Control

Slide 36

Selective Reject ARQ • Here the only frames retransmitted are those that receive a negative acknowledgement, in this case called SREJ, or that time out. • More efficient than go-back-N. – Receiver requires storage buffers to contain out-of-order frames until the frame in error is correctly received. – Receiver must also have the appropriate logic circuitry needed for reinserting the frames in the correct order. – Transmitter is more complex because it must be capable of sending frames out of sequence.

• Another drawback is that the maximum window size can be no more than half the range of sequence numbers. Dr. Indranil Sen Gupta

Data Link Control

Slide 37

Selective-reject ARQ: window size limit • Assume 3-bit sequence number, and a window size of 7. • Consider the following scenario: – – – – –

Station A sends frames 0 through 6 to station B. B receives all 7 frames and cumulatively acknowledges with RR7. RR7 gets lost in transit. Station A times out and retransmits frame 0. B has already advanced its receive window to receive frames 7,0,1,2,3,4,5. – B wrongly assumes that frame 7 has been lost and that this is a new frame 0, and accepts it.

• Problem arose due to overlap between sending and receiving windows. – For k-bit sequence numbers, maximum window size is 2k-1. Dr. Indranil Sen Gupta

Data Link Control

Slide 38

Dr. Indranil Sen Gupta

Data Link Control

Slide 39

Performance Analysis of ARQ Schemes

See Appendix 6A in the book by Stallings

Dr. Indranil Sen Gupta

Data Link Control

Slide 40

High-Level Data Link Control (HDLC) • Most important data link protocol. – It is widely used. – It is also the basis for many other important data link control protocols.

• Three types of stations: – Primary Station: responsible for the operation of the link. • Frames issued by primary station are called commands.

– Secondary Station: operates under the control of primary station. • Frames issued are called responses. • Primary maintains a separate logical link with each secondary.

– Combined Station: combines the features of primary and secondary. • May issue both commands and responses.

Dr. Indranil Sen Gupta

Data Link Control

Slide 41

HDLC (contd.) • Two types of link configurations: – Unbalanced Configuration: consists of one primary and one or more secondary stations. – Balanced Configuration: consists of two combined stations.

• Three data transfer modes: – Normal response mode (NRM): used with unbalanced configuration. • Primary may initiate data transfer to a secondary. • A secondary may only transmit data in response to a command from primary.

– Asynchronous balanced mode (ABM): used with balanced configuration • Either combined station may initiate transmission.

– Asynchronous response mode (ARM): used with an unbalanced configuration. • Secondary may initiate transmission. • Primary still retains responsibility for the line (initialization, error control, etc) Dr. Indranil Sen Gupta

Data Link Control

Slide 42

Which data transfer mode to use? • NRM: – used on multidrop lines • e.g. a number of terminals connected to a host computer; the computer polls each terminal for input

– also used on point-to-point links • if the link connects a peripheral (say, terminal) to the computer

• ABM: – most widely used – makes most efficient use of a full-duplex point-to-point link, as there are no polling overheads

• ARM: – rarely used – may be used in very special situations where a secondary may need to initiate transmission Dr. Indranil Sen Gupta

Data Link Control

Slide 43

HDLC Frame Structure

Dr. Indranil Sen Gupta

Data Link Control

Slide 44

Function of Various Fields • Flag Fields: – each frame starts and ends with the special bit pattern 01111110 – bit stuffing is used to unambiguously identify the flag fields – when the same flag is used to mark both the beginning and the end, • a 1-bit error may merge two frames into one • a 1-bit error inside the frame could split it into two.

• Address Field: – identifies the secondary station that transmitted or is to receive the frame – this field is not needed for point-to-point links, but is included for the sake of uniformity – both single-octet and multi-octet addressing are possible.

Dr. Indranil Sen Gupta

Data Link Control

Slide 45

Bit Stuffing Illustration

Dr. Indranil Sen Gupta

Data Link Control

Slide 46

Contd. • Control Field: – defines three types of frames • Information frames (I-frames) carry the data to be transmitted; flow- and error-control information are also piggybacked using ARQ mechanism • Supervisory frames (S_frames) provide the ARQ mechanism when piggybacking is not used • Unnumbered frames (U-frames) provide supplemental link control functions • I- and S-frames use 3-bit sequence numbers.

• Information Field: – present in only I-frames and some U-frames – can contain any sequence of bits (multiple of 8), but is usually limited in length from considerations of error control – frames with empty I-field are transmitted continuously on idle point-topoint lines in order to keep the connection alive.

• Frame Check Sequence Field: – 16- or 32-bit CRC code computed using address, control & data fields. Dr. Indranil Sen Gupta

Data Link Control

Slide 47