280 likes | 824 Views
Data Link Control. Physical layer is only responsible for data transmission Data link control is responsible for converting transmission to communication Line Discipline: Who should send now? Flow Control: How much data may be sent?
E N D
Data Link Control • Physical layer is only responsible for data transmission • Data link control is responsible for converting transmission to communication • Line Discipline: Who should send now? • Flow Control: How much data may be sent? • Error Control: How should the errors be detected / corrected? ECE 766 Computer Interfacing and Protocols
Line Discipline • Determine the direction of communication • Make sure that receiver is ready to accept or signal the sender to start • Two ways: • Enquiry / Acknowledgment (ENQ/ACK)Dedicated line between hosts • Poll / SelectMultipoint connections ECE 766 Computer Interfacing and Protocols
ENQ/ACK • Dedicated line between hosts, no problem of addressing • Coordinates which device may start transmission, and if the receiver is ready and enabled • If both hosts have equal ranks, either can initiate the process • Otherwise, only higher-ranked host is allowed to start the transmission request • Can be run in either half-duplex or full-duplex modes ECE 766 Computer Interfacing and Protocols
Host A Host B ENQ Establishment ACK Data ACK … DataTransfer Data ACK EOT Termination ENQ/ACK • Establishment: Host B responds either with ACK or NAK • Host A tries to send ENQ three times before concluding that Host B is down ECE 766 Computer Interfacing and Protocols
Poll / Select • Multipoint connections • One primary and multiple secondary hosts • Communication between secondary devices go over the primary • Select mode is used when primary has something to send to a secondary (downstream) • Poll mode is used to solicit transmissions from a secondary to the primary (upstream) • Address must be contained in all packets ECE 766 Computer Interfacing and Protocols
Primary Sec. A Sec. B SEL ACK Data ACK … Data ACK Poll / Select • Select mode • SEL packet contains address of B • B can response either by ACK or NAK • Primary sends one or more data packets, which are ACKed by B ECE 766 Computer Interfacing and Protocols
Primary Sec. A Sec. B Poll NAK Poll Data ACK Poll / Select • Poll mode • Poll packet contains address of recipient • If the intended secondary has no data to send, replies with NAK • Data is ACKed by the primary • How to terminate? ECE 766 Computer Interfacing and Protocols
Flow Control • Restrict the amount of data to send before waiting for acknowledgment • Controls the flow of the data as not to overwhelm the receiver • Categories: • Stop-and-WaitWait for an ACK before sending the next frame • Continous (Sliding Window)Can send several windows before requiring an ACK ECE 766 Computer Interfacing and Protocols
Stop-and-Wait • Send frame, then wait until you get ACK back • Advantage: Simplicity • Disadvantage: Inefficiency • l-bit frame, b bits/sec transmission speed, R seconds roundtrip time, infinitely short ACK • Utilization = l / (l + bR) • Not suited for high bandwidth-delay product lines ECE 766 Computer Interfacing and Protocols
Sliding Window • Send multiple frames before waiting for ACK • Several frames can be in transit at a time • Sender window vs. receiver window • Frames can be ACKed without waiting for the receiver window to fill up • Frames may be sent as long as there are unsent packets in the sender window ECE 766 Computer Interfacing and Protocols
Sliding Window • Sliding window scheme uses modulo-n arithmetic • The addresses range between 0 and n-1 • The size of the window is n-1 to prevent ambiguity in ACKs, which contains sequence number of next frame expected • Assume window size is n-1 • Sender can sends frames 0 to n-2 to start • Receiver ACKs frame 0 • Does it mean that it is ready for the next frames? ECE 766 Computer Interfacing and Protocols
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Sliding Window • Sender window: • Shrink from left as frames are sent • Expand from right as you receive ACKs • Receiver window: • Shrink from left as frames are received • Expand from right as ACKs are sent ECE 766 Computer Interfacing and Protocols
Error Control • Error control in data link layer is based on retransmissions (backward Error Control) • Any time an error is detected, a NAK is returned to sender • Automatic Repeat Request (ARQ) • Retransmission in case of damaged frame, lost frame, and lost ACK • Stop-and-Wait ARQ • Sliding Window ARQ • Go-Back-n • Selective Repeat ECE 766 Computer Interfacing and Protocols
Stop-and-Wait ARQ • Number frames as 0 and 1 alternately • Keep a copy of the last sent frame • Receiver ACKs the receipt of frame 0 by sending ACK 1 (waiting for frame 1) • If NAK is received, resend the last frame (no numbering necessary) • Takes care of damaged data frames • Start a timer for every frame sentIf it expires before an ACK is received, resend the frame • Takes care of lost data frame and lost ACKs / NAKs • Receiver discards duplicate frames in case ACK is lost ECE 766 Computer Interfacing and Protocols
Sliding Window ARQ • Number frames modulo n • Keep a copy of all unACKed frames • Single ACK for multiple frames • If last ACK was for 2 (waiting for 3) and new ACK is for 6, frames 3, 4, 5, and 6 are ACKed • Timers are used to signal retransmissions • Response to NAKs and expiring timers determine the style of ARQ • Go-Back-n • Selective Repeat ECE 766 Computer Interfacing and Protocols
Go-Back-n ARQ • All frames after damaged or lost frame are discarded • Damaged Frames: • Say, frames 0-5 are sent and all but frame # 3 is correctly received • Receiver sends NAK 3 and discards subsequent frames • This signals to sender that frames 0, 1, and 2 are correctly received and frame 3 is damaged • Sender retransmits frames 3, 4, and 5 • Same procedure for lost data frames ECE 766 Computer Interfacing and Protocols
Host A Host B Data 0 Data 1 Data 2 Data 3 Data 4 Error, discard NAK 3 Data 5 Discard Discard Data 3 Data 4 Data 5 Go-Back-n ARQ Error in data frame 3 Window size 7 ECE 766 Computer Interfacing and Protocols
Go-Back-n ARQ • Lost ACK: • When sender reaches window capacity, it starts a timer • If timer expires, it resends all outstanding (unACKed) frames • The receiver discards possible duplicate frames and sends another ACK ECE 766 Computer Interfacing and Protocols
Host A Host B Go-Back-n ARQ Data 0 Lost ACK case Data 1 Data 2 ACK 3 Timer expires Lost Data 0 Data 1 Data 2 Window Size 3 ECE 766 Computer Interfacing and Protocols
Selective Repeat ARQ • Only damaged and lost frames are retransmitted • ACK numbers refer to the last correctly received frame, not next frame expected! • If go-back-n window size is n-1, SR widow size must be at most n/2 (why?) • Damaged Frames: • After receiving a damaged frame, receiver sends a NAK and continues accepting other frames • Sender only retransmits the missing frame ECE 766 Computer Interfacing and Protocols
Host A Host B Selective Repeat ARQ Error in data frame 3 Data 0 Data 1 Data 2 Data 3 Data 4 Error, discard NAK 3 Data 5 Data 3 Data 6 Window size 7 ECE 766 Computer Interfacing and Protocols
Selective Repeat ARQ • Lost Data Frames: • Out-of-sequence delivery is permitted, but out-of-sequence ACK is not • When a lost frame is detected, NAK is sent • If last frame is lost, then receiver does nothing • Lost ACK: • Handled the same way as in go-back-n ECE 766 Computer Interfacing and Protocols