William Stallings Data and Computer Communications 7th Edition Chapter 7 Data Link Control Protocols Data Link Control Protocol (DLCP) • DLCP is a layer of logic above the physical layer used to control the sending of data over a data communication link. • Requirements and objectives of data link control: —Frame synchronization: to recognize beginning and end of the frame. —Flow control: can't send frames faster than the receiver can handle. —Error control: correct data should be delivered. —Addressing: on multipoint line, identify the destination. —Control and data on same link. —Link management: initiation, maintenance, and termination of data exchange. Flow Control • The receiver must do a certain amount of processing before passing the data to the higher-level software. • Flow control technique ensures that sending entity does not overwhelm the receiving entity with data —Preventing buffer overflow • Transmission time —Time taken to emit all bits of a frame onto the medium. —Proportional to the length of the frame. • Propagation time —Time for a bit to traverse the link between source and destination. Model of Frame Transmission Stop and Wait Flow Control • The simplest form of flow control, is stop-and-wait: —Source transmits frame —Destination receives frame and replies with acknowledgement signal. —Source waits for ACK before sending next frame. —If an error occurs, destination can stop flow by not send ACK signal. • Works well for a few large frames —Few waiting times for ACK. Fragmentation • Large block of data may be split into small frames, due to: —Limited buffer size on the receiver. —With smaller frames, errors detected sooner (when whole frame received) —On error, retransmission of smaller frames is needed (better) —Prevents one station from occupying a shared medium for long periods • Stop and wait becomes inadequate, with the use of multiple frames for a single message. —Only one frame at a time can be in transit. Link utilization • Bit length of a link: B R d V —B = number of bits present on the link when a stream of bits fully occupies the link. —R = data rate of the link, in bps. —d = length, or distance, of the link in meters. —V = velocity of propagation, in m/s. • In situations where the bit length of the link is greater that the frame, serious inefficiencies result. Stop and Wait Link Utilization Figure 7.2 Stop-and-wait link utilization (transmission time = 1; propagation time = a) Sliding-Window Flow Control • The essence of the problem in the stop-and-wait, is that only one frame at a time can be in transit. • Sliding-window allows multiple frames to be in transit at the same time. • Receiver has buffer (window) space for W frames. • Transmitter can send up to W frames without ACK. • To keep track of which frames have been acknowledged, each frame has a sequence number. • ACK includes sequence number of next frame expected • Sequence number bounded by size of field (k bits) —Range of sequence numbers is 0 through 2k – 1. —Window size is needed to be less than 2k. Sliding Window Diagram Example Sliding Window Sliding Window Enhancements • Receiver can acknowledge frames without permitting further transmission Receive Not Ready (RNR) • Must send a normal acknowledge to resume • If two stations exchange data, each needs to maintain two windows, one for transmit and one for receive. • Each side needs to send the data and ACK to the other. • To provide efficient support, use piggybacking —Each data frame includes a field that holds a sequence number of the frame plus a sequence number used for ACK. —If no data to send, use acknowledgement frame —If data but no acknowledgement to send, send last acknowledgement number again. Error Control • Error control refers to both functions of detection and correction of errors. • Possibility of two types of errors: —Lost frames: a frame fails to arrive to the destination. —Damaged frames: bit error. • Components of error control techniques: —Error detection —Positive acknowledgment for error-free frames. —Retransmission after timeout (in case of lost frames) —Negative acknowledgement and retransmission for frames received with errors Error Detection • Additional bits added by transmitter for error detection code • Parity —Value of parity bit is such that character has even (even parity) or odd (odd parity) number of ones. —Even number of bit errors goes undetected • Cyclic Redundancy Check (CRC) —For a block of k bits transmitter generates n bit sequence, known as frame check sequence (FCS). —Transmit k+n bits which is exactly divisible by some number —Receiver divides frame by that number, if no remainder, assume no error Cyclic Redundancy Check • • • • T = n-bit frame to be transmitted. D = k-bit block of data, or message, the first k bits of T. F = (n-k)-bit FCS, the last (n-k) bits of T. P = pattern of n-k+1 bits; this is the predetermined divisor. • We would like T/P to have no remainder. It should be clear that: T = 2n-kD+F CRC Example • Given: —Message D = 1010001101 (10-bits) —Pattern P = 110101 (6-bits) —FCS R = to be calculated (5 bits) • Thus, n = 15, k = 10, and (n-k) = 5. • The message is multiplied by 25, yielding 101000110100000. • This product is divided by P, remainder R = 01110. • R is added to 25D to give T = 101000110101110, which is transmitted. • On the receiver, the received frame is divided by P, if R=0 then it is assumed that there have been no errors. Error Control Mechanisms: Automatic Repeat Request (ARQ) • The effect of ARQ is to turn an unreliable data link into reliable one. • Three versions of ARQ have been standardized: —Stop-and-wait ARQ —Go-back-N ARQ —Selective-reject ARQ Stop and Wait • Based on stop-and-wait flow control technique. • Source transmits single frame and then waits for ACK. • Tow sorts of errors could occur: —Frame that arrives at the destination could be damaged • Transmitter has timeout • If no ACK within timeout, retransmit —If ACK damaged, transmitter will not recognize it • Transmitter will retransmit • Receiver gets two copies of frame • To avoid duplication, frames are alternately labeled with 0 or 1. Use ACK0 and ACK1 • Advantage: simplicity. • Disadvantage: inefficient line use. Stop and Wait Diagram Go-Back-N ARQ • Based on sliding-window flow control. • The number of unacknowledged frames outstanding is determined by window size. • If no error, the destination will ACK incoming frames as usual with (RR = receive ready) • If the destination detects an error, send a negative ACK (REJ = rejection); explained as follows: —Discard that frame and all future frames until the error frame received correctly —When the transmitter receives a REJ, it must go back and retransmit that frame and all subsequent frames Go-Back-N Contingencies: 1. Damaged Frame • Frame received with error —Receiver detects an error in frame i —Receiver sends REJ i —Transmitter gets REJ i —Transmitter retransmits frame i and all subsequent • Lost Frame (same as Damaged REJ) —Frame i lost —Transmitter sends i+1 —Receiver gets frame i+1 out of sequence —Receiver send REJ i —Transmitter retransmits frame i and all subsequent Go-Back-N - Lost Frame (Last frame) • Frame i lost and no additional frame sent (frame i last frame). • Receiver gets nothing and returns neither ACK nor REJ. • Transmitter times out and sends ACK frame with that includes a bit known as P bit set to 1. • Receiver interprets this as command which it acknowledges with the number of the next frame it expects (frame i ). • Transmitter then retransmits frame i. Go-Back-N Contingencies : 2. Damaged RR • Receiver gets frame i and send RR (i+1) which is lost. • Acknowledgements are cumulative, e.g. RR 6 means that all frames through 5 are acknowledged. • Transmitter may receive a subsequent RR > RR (i+1) before the timer associated with frame i expires. • If transmitter times out, it sends acknowledgement with P bit set as before. • This can be repeated a number of times before a reset procedure is initiated. Go-Back-N Diagram • In this example 3-bit sequence number field is used. • Maximum window size = 23-1 = 7. Selective Reject • Also called selective retransmission • Only rejected (negative acknowledged SREJ) frames are retransmitted, or those that time out. • Subsequent frames are accepted by the receiver and buffered • Advantage: —More efficient than go-back-N because it minimizes retransmission. • Disadvantages: —Receiver must maintain large enough buffer —More complex logic to be able to send s frame out of sequence. Selective Reject Diagram High Level Data Link Control (HDLC) • • • • The most important data link control protocol. ISO 33009, ISO 4335 It is widely used. It is the basis for many other important data link control protocols. • To satisfy a variety of applications, HDLC defines three types of stations, two link configurations, and three data transfer modes of operation. Basic characteristics of HDLC: 1. Station Types • Primary station —Controls operation of link —Frames issued by primary station are called commands —Maintains separate logical link to each secondary station • Secondary station —Under control of primary station —Frames issued called responses • Combined station —May issue commands and responses Basic characteristics of HDLC: 2. HDLC Link Configurations • Unbalanced Configurations —Consists of one primary and one or more secondary stations —Supports full duplex and half duplex transmission • Balanced Configurations —Consists of two combined stations —Supports full duplex and half duplex HDLC Data Transfer Modes (I) • Normal Response Mode (NRM) —Unbalanced configuration —Primary initiates data transfer to secondary —Secondary may only transmit data in response to command from primary —Used on multi-drop lines, where host computer as primary and terminals as secondary HDLC Data Transfer Modes (II) • Asynchronous Balanced Mode (ABM) —Balanced configuration (two combined stations) —Either station may initiate transmission without receiving permission from the other combined station. —Most widely used; —It makes more efficient use of a full-duplex point-topoint link because there is no polling overhead HDLC Data Transfer Modes (III) • Asynchronous Response Mode (ARM) —Unbalanced configuration —Secondary may initiate transmission without explicit permission from primary —Primary responsible for line —rarely used HDLC Frame Structure • HDLC uses Synchronous transmission • All transmissions in frames • Single frame format for all types data and control exchanges Frame Structure Flag Fields • Flag fields delimit frame at both ends with a unique pattern 01111110. • A single flag may close one frame and open another • Receiver hunts for flag sequence to synchronize • Bit stuffing used to avoid confusion with data containing 01111110 —0 inserted after every sequence of five 1s —If receiver detects five 1s it checks next bit —If 0, it is deleted —If 1 and seventh bit is 0, accept as flag —If sixth and seventh bits 1, sender is indicating abort Bit Stuffing • Example with possible error • (a) bit stuffing • (b) 1-bit error splits it in two. • (c) 1-bit error merges two frames into one. Address Field • Identifies secondary station that sent or will receive frame • Usually 8 bits long, but may be extended to multiples of 7 bits —LSB of each octet indicates that it is the last octet (1) or not (0) • All ones (11111111) is broadcast Control Field • First one or two bits of control filed identify frame type • Can identify three types: —Information frames: data to be transmitted to user (next layer up) • Flow and error control are piggybacked on information frames —Supervisory frames: provide the ARQ mechanism when piggybacking not used. —Unnumbered frames: supplementary link control • P/F: —In command frames (P bit): set to 1 to solicit a response frame from a peer HDLC entity. —In response frames (F bits): set to 1 to indicate the response frame transmitted as a result of a soliciting command. Control Field Diagram Information and FCS Fields • Information field: —Present only in information and some unnumbered frames —Must contain an integral number of octets —Variable length up to some system-define maximum. • FCS field: —Error detection detecting code calculated from the remaining bits of the frame (exclusive of flags) —16 bit CRC —Optional 32 bit CRC, depends to line reliability. HDLC Operation • HDLC operation consists of the exchange of information, supervisory and unnumbered frames • The operation involves three phases —Initialization: one side initializes the data link to exchange frames in an orderly fashion. —Data transfer: exchange user data and control information. —Disconnect: termination of the operation. Some HDLC commands and responses • Information (I) C/R • Supervisory (S) —Receive ready (RR) C/R —Receive not ready (RNR) C/R —Reject (REJ) C/R —Selective reject (SREJ) C/R • Unnumbered (U) —Set asynchronous balanced/extend mode (SABM/SABME) C —Disconnect (DISC) C —Unnumbered acknowledgment (UA) R Examples of Operation (1) Examples of Operation (2)