π Lecture 34 β Error Detection And Correction Methods
π Overview: This lecture explores two powerful methods for error detection in data communication: Longitudinal Redundancy Check (LRC) and Cyclic Redundancy Check (CRC). LRC adds a block of parity bits to detect burst errors, while CRC uses binary division to achieve a much higher detection capability, becoming the most robust redundancy check technique.
ποΈ Topics Covered
The lecture covers Longitudinal Redundancy Check (LRC) with its calculation methodology and performance limitations, introduces Cyclic Redundancy Check (CRC) as the most powerful checking technique based on binary division, explains the qualities and process of CRC generator and checker, defines the polynomial representation of CRC divisors, discusses the selection criteria for polynomials, lists popular CRC polynomials, and analyzes the overall performance of CRC.
π Lecture Summary
Longitudinal Redundancy Check (LRC)
In Longitudinal Redundancy Check (LRC), a block of bits is organized into a table of rows and columns. For example, instead of using 32 bits, we organize them in a table made of 4 rows and 8 columns. We then calculate the Parity bit for each column and create a new row of 8 bits which are the parity bits for the whole block. The first parity bit in the 5th row is calculated based on all the first bits, the second parity bit is calculated based on all the second bits, and so on. We then attach the 8 parity bits to the original data and send them to the receiver. The receiver checks the LRC; if some bits do not follow the even parity rule, the whole block is discarded.
π Example: The following block is sent: 10101001, 00111001, 11011101, with LRC: 10101010. It is hit by a burst of length 8 and some bits are corrupted, becoming: 10100011, 10001001, 11011101, 11100111, with LRC: 10101010. Because the LRC parity bits no longer match the data, the receiver detects the error and discards the block.
Performance of LRC
Burst errors can be detected more often with LRC. An LRC of βnβ bits can easily detect a burst error of βnβ bits. A burst error of more than βnβ bits is also detected by LRC with a very high probability. However, one pattern of errors remains elusive: if two bits in one data unit are changed and two bits in exactly the same place in another data unit are also damaged. For example, original data units 11110000 and 11000011 become changed data units 01110001 and 01000010.
Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC) is the most powerful of checking techniques. While VRC and LRC are based on addition, CRC is based on binary division. A sequence of redundant bits called CRC remainder is appended to the end of the data unit, so that the resulting data unit becomes exactly divisible by a second predetermined binary number. At its destination, the data unit is divided by the same number. If at this step, there is no remainder, the incoming data unit is assumed to be intact and is therefore accepted. A remainder indicates that a data unit has been damaged and therefore must be rejected.
Qualities of CRC
To be valid, the CRC must have two qualities: it must have exactly one less bit than the divisor, and appending it to the end of the data must make the resulting bit sequence exactly divisible by the divisor.
First, a string of n 0βs is appended to the data unit. The number βnβ is one less than the number of bits in the predetermined divisor, which is n+1 bits. Second, the newly elongated data unit is divided by the divisor using a process called binary division. The remainder resulting from this division is the CRC. Third, the CRC of βnβ bits replaces the appended 0βs at the end of the data unit. Note that CRC may consist of all zeros. The data unit arrives at the receiver followed by the CRC. The receiver treats the whole string as a unit and divides it by the same divisor that was used to find the CRC remainder. If the string arrives without an error, the CRC checker yields a remainder of zero and the data unit passes. If the string has been changed in transit, the division yields a non-zero remainder and the data unit does not pass.
The CRC Generator
The CRC Generator uses Modulo-2 Division.
Polynomials
The CRC generator (the divisor) is most often represented not as a string of 1βs and 0βs but as an algebraic polynomial. The polynomial format is useful for two reasons: it is short and can be used to prove the concept mathematically.
Selection of a Polynomial
A polynomial should have the following properties: it should not be divisible by βxβ, and it should be divisible by βx+1β. The first condition guarantees that all burst errors of a length equal to the degree of the polynomial are detected. The 2nd condition guarantees that all burst errors affecting an odd number of bits are detected.
Popular Polynomials for CRC
Performance of CRC
CRC can detect all burst errors that affect an odd number of errors. CRC can detect all burst errors of length less than or equal to the degree of the polynomial. CRC can detect with a very high probability burst errors of length greater than the degree of the polynomial.
π Example 9.6: The CRC-12 (xΒΉΒ² + xΒΉΒΉ + xΒ³ + xΒ² + x + 1) has a degree of 12. It will detect:
- All burst errors affecting odd no. of bits
- All burst errors with a length equal to or less than 12
- 99.97% of the time burst errors with a length of 12 or more
β Key Takeaways
CRC is the most powerful error detection method discussed, based on binary division rather than parity addition. The CRC remainder is appended to the data so the entire unit becomes divisible by a predetermined divisor. The success of CRC relies on proper polynomial selection: it must not be divisible by βxβ (to catch burst errors up to the degree) and must be divisible by βx+1β (to catch odd numbers of bit errors). LRC, while useful for detecting burst errors of length n, has a specific vulnerability where paired bit errors in two different data units can cancel each other out. For the exam, remember that CRC-12 (degree 12) will detect all burst errors of length β€ 12 and all odd-numbered bit errors with very high probability (99.97% for longer bursts).
π§ Quick Revision Questions
- What is the fundamental difference between how LRC and CRC perform error checking (addition vs. division)?
- What specific pattern of errors can LRC fail to detect, and why?
- What two properties must a CRC polynomial have to be considered valid?
- In CRC, what does a non-zero remainder at the receiver indicate?
- For CRC-12, what types of errors is it guaranteed to detect, and what is its detection probability for longer bursts?
π Lecture 35 β Error Correction And Detection Method
π Overview: This lecture covers the Checksum error detection method used by higher layers of the network, followed by an introduction to Error Correction techniques. It explains how single-bit errors can be corrected using Hamming Code and why error correction requires more redundancy bits than error detection.
ποΈ Topics Covered
The lecture begins with Checksum, an error detection method used by higher layers based on redundancy and oneβs complement arithmetic. It covers the Checksum generator and receiver processes, with examples of error detection and an undetectable error pattern. The second half introduces Error Correction, comparing it to error detection, discussing Single-bit Error Correction, and explaining Hamming Code including how redundancy bits are calculated and used.
π Lecture Summary
Checksum
Checksum is an error detection method used by the higher layers. Like VRC, LRC, and CRC, Checksum is also based on the concept of redundancy. It uses oneβs complement arithmetic, which inverts every 1 to 0 and 0 to 1. In oneβs complement, +A = 1010 gives -A = 0101, and +0 = 0000 gives -0 = 1111.
The sender subdivides data units into equal segments of βnβ bits (typically 16 bits). These segments are added together using oneβs complement arithmetic. The total (sum) is then complemented and appended to the end of the original data unit as redundancy bits called CHECKSUM. The extended data unit is transmitted across the network. The receiver subdivides the data unit as above, adds all segments together, and complements the result. If the intended data unit is intact, the total value found by adding the data segments and the checksum field should be zero. If the result is not zero, the packet contains an error and the receiver rejects it.
Checksum Generator Figure
The process involves a Checksum Generator at the sender side and a Checksum Checker at the receiver side, as illustrated in the lecture figure.
Performance of Checksum
Checksum detects all errors involving an odd number of bits and most errors involving an even number of bits. However, one pattern remains elusive: an error is invisible if a bit inversion is balanced by an opposite bit inversion in the corresponding digit of another segment.
π Definition β Oneβs Complement: A binary representation where negative numbers are obtained by inverting all bits (0β1, 1β0). The sum of a number and its oneβs complement yields all 1s.
π Formula: Checksum = Complement(Sum of data segments) β The checksum is the oneβs complement of the arithmetic sum of all data segments. Receiver check: Complement(Sum of all segments including checksum) = 0 means no error.
π Example 9.7: Suppose a block of 16 bits needs to be sent: 10101001 00111001
- Data segments:
10101001and00111001 - Sum:
10101001 + 00111001 = 11100010 - Checksum (complement of sum):
00011101 - Sent pattern:
10101001 00111001 00011101
π Example 9.8 (No error case):
- Segment 1:
10101001, Segment 2:00111001, Checksum:00011101 - Sum:
11111111, Complement:00000000β No error detected.
π Example 9.8 (Burst error case β detected):
- Segment 1:
10101111, Segment 2:11111001, Checksum:00011101 - Sum:
11000110, Complement:00111001β Error detected (not zero).
π Example 9.8 (Undetected error case):
- Segment 1:
10111101, Segment 2:00101001, Checksum:00011001 - Sum:
11111111, Complement:00000000β Error is undetected because bit inversions balanced each other.
π‘ Why this matters: Checksum is simple and efficient for higher-layer protocols (like TCP/UDP), but is vulnerable to balanced bit inversions across segments.
ERROR CORRECTION
The mechanisms studied so far (VRC, LRC, CRC, Checksum) all detect errors but do not correct them. Error correction can be done in two ways:
- The receiver can ask the sender for re-transmission (Re-TX).
- The receiver can use an error-correcting code, which automatically corrects certain errors.
Error correcting codes are more sophisticated than error detecting codes. They require more redundancy bits. The number of bits required to correct multiple-bit or burst errors is so high that in most cases it is inefficient. Error correction is typically limited to 1, 2, or 3 bits.
π Definition β Error Correction: The process of locating and correcting errors in transmitted data without requiring retransmission.
π‘ Why this matters: Error correction is essential for real-time applications (like voice/video) where retransmission is impractical, but it comes at the cost of extra redundancy bits.
Single-bit Error Correction
This is the simplest case of error correction. Error correction requires more redundancy bits than error detection. One additional bit can detect single-bit errors (like the parity bit in VRC). One bit gives two states: error or no error. To correct the error, more bits are required. Error correction locates the invalid bit or bits. For 7-bit data, there are 8 possible states: no error, error in bit 1, and so on. Three bits of redundancy might seem adequate, but what if an error occurs in the redundancy bits themselves? The number of states must account for errors in data bits AND redundancy bits.
Hamming Code
Hamming Code is a method for single-bit error correction. The redundancy bits (r) must be able to indicate at least m+r+1 states (where m = number of data bits). These m+r+1 states must be coverable by 2^r. Therefore: 2^r β₯ m+r+1. For example, if m=7, then r=4 because 2^4 = 16 β₯ 7+4+1 = 12.
Each r bit is the VRC bit for one combination of data bits. Each r bit is calculated using all bit positions whose binary representation includes a 1 in the first (second, third, etc.) position. This creates overlapping parity checks that uniquely identify the location of an error.
π Definition β Hamming Code: An error-correcting code that uses multiple parity bits calculated over overlapping subsets of data bits to detect and correct single-bit errors.
π Formula: 2^r β₯ m+r+1 β To correct a single-bit error in m data bits, you need r redundancy bits such that 2^r is at least m+r+1.
π Example: For m=7 data bits, r=4 because 2^4=16 β₯ 7+4+1=12.
π‘ Why this matters: Hamming Code is a foundational error correction technique used in memory systems (ECC RAM) and communication protocols where single-bit errors are the primary concern.
β Key Takeaways
Checksum is an error detection method for higher layers using oneβs complement arithmetic, where the sender adds segments, complements the sum to form the checksum, and the receiver checks if the total complemented sum equals zero. Checksum cannot detect errors where bit inversions in one segment are balanced by opposite inversions in another segment. Error correction requires more redundancy bits than error detection because it must both detect and locate errors. Hamming Code uses r parity bits such that 2^r β₯ m+r+1 to correct single-bit errors, with each parity bit covering a specific subset of bit positions. The fundamental tradeoff is that error correction is more powerful but less efficient than error detection due to the extra redundancy required.
π§ Quick Revision Questions
- What arithmetic operation is used to compute a Checksum, and what is the final step after summing all segments?
- In the Checksum scheme, what value should the receiver obtain after complementing the sum of all segments (including the checksum) to confirm no errors?
- Why is Checksum unable to detect some errors involving an even number of bit inversions across multiple segments?
- What is the inequality that determines the number of redundancy bits (r) needed for single-bit error correction with m data bits using Hamming Code?
- For 7 data bits, how many redundancy bits are needed according to the Hamming Code formula, and why?
π Lecture 36 β Hamming Code
π Overview: This lecture covers the Hamming Code error detection and correction method, focusing on how redundancy bits are calculated and positioned. It then introduces the Data Link Layer, its key functions (Line Discipline, Flow Control, and Error Control), and details two methods for Line Discipline: ENQ/ACK and Poll/Select.
ποΈ Topics Covered
The lecture begins with Hamming Code, explaining redundancy bits calculation and how each r bit is the VRC bit for a specific combination of data bits. It then transitions to the Data Link Layer, covering its introduction and three main functions: Line Discipline (ENQ/ACK and Poll/Select), Flow Control, and Error Control.
π Lecture Summary
Hamming Code
The Hamming Code is an error correction method that adds redundancy bits (r) to data bits (m) to allow the receiver to detect and correct single-bit errors. The number of redundancy bits must be sufficient to indicate at least m+r+1 states, because each of the m+r bit positions could be in error, plus one state for no error.
π Definition β Redundancy Bits (r): Extra bits added to data bits to enable error detection and correction.
π Formula: 2^r β₯ m + r + 1 β The number of states that r bits can represent (2^r) must be at least the total number of bits (data + redundancy) plus one state for no error.
π Example: If m = 7 data bits, then r = 4 because 2^4 = 16 β₯ 7 + 4 + 1 = 12.
Each r bit is the VRC (Vertical Redundancy Check) bit for a specific combination of data bits. The r1 bit is calculated using all bit positions whose binary representation includes a 1 in the first position (least significant bit), the r2 bit uses positions with a 1 in the second position, and so on. This allows the receiver to identify the exact position of an error.
π‘ Why this matters: Hamming Code is a powerful single-bit error correction method used in memory systems and data communication where retransmission is costly.
Data Link Layer
Introduction Unless accurately received by a second device, a signal transmitted over a wire is a waste of electricity. Transmission alone provides:
- No way of controlling which device will receive the signal.
- No way of knowing if the intended receiver is ready and able to receive.
- No way of keeping a second device from transmitting at the same time.
Communication requires at least two devices working together: a Sender and a Receiver. Even this basic arrangement requires coordination. For example, in Half Duplex transmission, only one device can transmit at a time. If both transmit, signals collide, leaving only Noise on the line. This coordination is part of a procedure called Line Discipline, a function of the Data Link Layer (Layer 2 of the OSI Model).
In addition to Line Discipline, the most important functions in the Data Link Layer are Flow Control and Error Control. Collectively, these three functions are called Data Link Control.
Data Link Layer & its Functions
Data Link Control consists of three functions:
- Line Discipline: Coordinates the link systems β determines which device can send and when it can send.
- Flow Control: Controls the amount of data that can be sent before receiving an acknowledgement. It also provides the receiverβs acknowledgement for frames received intact, so it is linked to Error Control.
- Error Control: Allows the receiver to inform the sender of any frames lost or damaged in transmission and coordinates Retransmission of those frames by the sender.
Line Discipline
No device should be allowed to transmit until it has evidence that the intended receiver is able to receive and prepared to accept the transmission. Without a way to determine the status of the intended receiver, the transmitting device may waste time sending data to a non-functioning receiver.
The Line Discipline functions oversee:
- The establishment of links.
- The right of a particular device to transmit at a given time.
Line Discipline is done in two ways:
- Enquiry/Acknowledgement (ENQ/ACK): Used in Peer-to-Peer Communication.
- Poll/Select: Used in Primary-Secondary Communication.
β Key Takeaways
The number of redundancy bits (r) for Hamming Code must satisfy 2^r β₯ m + r + 1, and for m=7, r=4. Each r bit is a VRC bit for all positions with a specific binary pattern, enabling single-bit error correction. The Data Link Layer provides coordination through three key functions: Line Discipline (who can send and when), Flow Control (data amount before acknowledgement), and Error Control (detection and retransmission of lost/damaged frames). Line Discipline has two methods: ENQ/ACK for peer-to-peer and Poll/Select for primary-secondary communication. Without these functions, transmission would be unreliable and chaotic.
π§ Quick Revision Questions
- What is the formula to determine the number of redundancy bits (r) required for Hamming Code for
mdata bits? - How many redundancy bits are needed for 7 data bits in Hamming Code, and why?
- Name the three functions that collectively constitute Data Link Control.
- What are the two ways to implement Line Discipline, and what type of communication does each method serve?
- What happens if both devices transmit at the same time in a half-duplex system?
π Lecture 37 β Line Discipline
π Overview: This lecture covers the first aspect of data link controlβline disciplineβwhich determines which device can transmit data at a given time. It explains two primary methods: ENQ/ACK for dedicated point-to-point links and Poll/Select for multipoint topologies. The lecture concludes with an introduction to flow control as the second aspect of data link control.
ποΈ Topics Covered
The lecture covers Enquiry/Acknowledgement (ENQ/ACK) for establishing sessions on dedicated links between two devices, including how it works in half-duplex and full-duplex transmission. It then details Poll/Select for primary-secondary communication in multipoint topologies, covering addressing conventions, the SELECT mode for when the primary wants to send data, and the POLL mode for when the primary wants to receive data from secondary devices. Finally, it introduces Flow Control as the second aspect of data link control.
π Lecture Summary
Line Discipline β Enquiry / Acknowledgement (ENQ/ACK)
ENQ/ACK is a line discipline method used primarily in systems with a dedicated link between two devices, where the only device that can receive data is the intended one. It coordinates who may start a transmission and whether the intended recipient is ready and enabled. Using ENQ/ACK, a session can be initiated by either station on a link as long as both are of equal rankβfor example, a printer cannot initiate communication with a CPU.
In both half-duplex and full-duplex transmission, the initiating device establishes the session. In half-duplex, the initiator sends its data while the responder waits, and the respondent may take over the link when the initiator is finished or has requested a response. In full-duplex, both devices can transmit simultaneously once the link has been established.
The receiver must answer either with an acknowledgement (ACK) frame if it is ready to receive, or with a negative acknowledgement (NAK) frame if it is not. By requiring a response, even if the answer is negative, the initiator knows that its enquiry was received. If neither an ACK nor a NAK is received within a specified time limit, the initiator assumes the ENQ frame was lost, disconnects, and sends a replacement. An initiating system ordinarily makes 3 such attempts before giving up. If the response to the ENQ is negative for 3 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.
π Definition β ENQ/ACK (Enquiry/Acknowledgement): A line discipline method used on dedicated point-to-point links where one device sends an enquiry frame to ask if the receiver is available to receive data, and the receiver responds with ACK (ready) or NAK (not ready).
π Definition β ENQ (Enquiry frame): A frame transmitted by the initiator asking if the receiver is available to receive data.
π Example: An initiator sends an ENQ frame. If the receiver is busy, it replies with NAK. The initiator waits and tries again up to 2 more times (3 total attempts). If the receiver is ready, it replies with ACK, and the initiator begins sending data. Once all data is transmitted, the sending system finishes with an End of Transmission (EOT) frame.
Primary-Secondary communication β Poll / Select
This method works with topologies where one device is designed as a primary device and the other devices are secondary stations. Multipoint systems must coordinate several nodes, not just two. The questions are not only "Are you ready?" but also "Which device has the right to use the channel?"
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, and 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. The primary is always the initiator of the session.
If the primary wants to receive data, it asks the secondaries if they have anything to sendβthis 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.
π Definition β Primary device: The device that controls the link and determines which secondary device is allowed to use the channel at a given time. π Definition β Secondary device: A device that follows the instructions of the primary and cannot transmit data until asked.
ADDRESSING
For point-to-point configuration, there is no need for addressingβany transmission put onto the link by one device can be intended only for the other. For the primary device in a multipoint topology to identify and communicate with a specific secondary device, there must be some addressing convention. Every device on the link has an address that can be used for identification. In any transmission, this address will appear in a specified portion of each frame, called the Address Field or Header, depending upon the protocol. If the transmission comes from a secondary device, the address indicates the originator of the data.
π Definition β Address Field (Header): A specified portion of each frame that contains the address of the intended device for identification in multipoint topologies.
SELECT
The select mode is used whenever the primary device has something to send. The primary controls the link, and if the primary is not sending or receiving data, it knows the link is available. If it has something to send, it sends it. As a frame makes its way to the intended device, each of the other devices checks the address field. Only when the device recognizes its own address does it open the frame and read the data.
In case of a SEL frame, the enclosed data consists of an alert that data is forthcoming. The primary does not know if the target device is ready to receive (ON), so it must alert the secondary to the upcoming transmission and wait for an acknowledgement of the secondary's ready status. The primary sends a SEL frame, one field of which includes the address of the intended receiver. If the secondary is awake and running, it returns an ACK frame to the primary. The primary then sends one or more data frames, each addressed to the intended secondary.
π Definition β SEL (Select) frame: A frame sent by the primary to alert a secondary that data is forthcoming and to request an acknowledgement of the secondary's ready status.
π Example: Primary wants to send data to secondary device 3. Primary sends a SEL frame with address of device 3. Device 3 checks the address, recognizes it, and sends back an ACK. Primary then sends one or more data frames addressed to device 3.
POLL
The poll mode is used by the primary device to receive transmissions from the secondary devices. The secondaries are not allowed to transmit data until asked. By keeping control with the primary, the multipoint system guarantees that only one transmission can occur at a time.
When the primary wants to receive data, it must ask (POLL) each device in turn if it has anything to send. When the first secondary is approached, it responds either with a NAK frame if it has nothing to send, or with data if it does. If the response is negative, the primary then polls the next secondary. When the secondary has received data, it acknowledges by sending an ACK frame.
Two possibilities for termination exist: a secondary sends all its data and finishes with an EOT frame, or the primary says "Time is Up."
π Definition β POLL (Polling): A method used by the primary device to ask each secondary device in turn if it has anything to transmit.
π Example: Primary polls secondary device 1, which responds with NAK (no data). Primary then polls secondary device 2, which has data and sends it. Once device 2 finishes sending all its data, it ends with an EOT frame.
Flow Control β Definition
The second aspect of data link control is Flow Control. In most protocols, flow control is a set of procedures that tells the sender how much data it can transmit before it must wait for an acknowledgement (ACK) from the receiver. The flow of data must not be allowed to overwhelm the receiver.
π Definition β Flow Control: A set of procedures that tells the sender how much data it can transmit before it must wait for an acknowledgement from the receiver, preventing the receiver from being overwhelmed.
Summary
Line discipline methods covered: ENQ/ACK and POLL/SELECT. Flow control methods introduced: Stop-and-Wait and Sliding Window.
β Key Takeaways
A student must remember that line discipline determines which device can transmit at a given time, and there are two primary methods: ENQ/ACK for dedicated point-to-point links and Poll/Select for multipoint topologies. In ENQ/ACK, the initiator sends an ENQ and awaits ACK or NAK, making up to 3 attempts before giving up. In Poll/Select, the primary device controls all communicationβSELECT is used when the primary wants to send data, and POLL is used when the primary wants to receive data from secondary devices. Addressing is essential in multipoint topologies but not needed in point-to-point configurations. Finally, flow control is the second aspect of data link control that prevents the receiver from being overwhelmed.
π§ Quick Revision Questions
- What are the two main line discipline methods, and what topology does each primarily serve?
- In ENQ/ACK, how many attempts does an initiator make before giving up, and what happens after a negative response is received 3 times?
- In a multipoint topology using Poll/Select, what is the difference between the SELECT mode and the POLL mode?
- Why is addressing necessary in multipoint topologies but not in point-to-point configurations?
- What is the purpose of flow control in data link control?
π Lecture 38 β Control- Explanation
π Overview: This lecture explains the fundamental concepts of flow control and error control in data communication. It covers the two main flow control methodsβStop-and-Wait and Sliding Windowβand introduces Automatic Repeat Request (ARQ) for error control, which is essential for reliable data transmission.
ποΈ Topics Covered
The lecture begins with an explanation of flow control, why it is needed, and the role of buffers. It then details the Stop-and-Wait flow control method with its advantages and disadvantages, followed by the Sliding Window flow control method including window representation and numbering. The lecture concludes with error control mechanisms, specifically Stop-and-Wait ARQ, covering damaged frame handling and lost frame scenarios.
π Lecture Summary
Flow Control Explanation
Any receiving device has a limited speed at which it can process incoming data and a limited amount of memory for storing incoming data. The receiving device must be able to inform the sending device before those limits are reached and request that the transmitter send fewer frames or stop temporarily.
π Flow Control: A mechanism that regulates the rate of data transmission so that a receiving device is not overwhelmed by faster transmission from a sending device.
Flow Control-Buffer
Incoming data must be processed and checked before it can be used. The rate of such processing is often slower than the rate of transmission. Therefore, each receiving device has a block of memory called BUFFER, reserved for storing incoming data until it is processed. If the buffer begins to fill up, the receiver must be able to tell the sender to halt the transmission until it is once again able to receive.
Methods for Flow Control
Two methods have been developed to control the flow of data across communication links:
- Stop and Wait
- Sliding Window
Stop and Wait
In this method, the sender waits for an ACK after every frame it sends. Only when an ACK has been received is the next frame sent. This process of alternately sending and waiting repeats until the sender transmits an EOT (End of Transmission) frame.
π Example: An officer giving dictation to a typist. He says a word, the typist says OK, he says the next word, the typist says OK, and so on.
Advantages of Stop and Wait
- SIMPLICITY: Each frame is checked and acknowledged before the next frame is sent.
Disadvantages of Stop and Wait
- INEFFICIENT (Slow): Each frame must travel all the way to the receiver and an ACK must travel all the way back before the next frame can be sent. If the distance between devices is long, the time spent waiting for ACKs between each frame can be significant.
Sliding Window
In this method, the sender can transmit several frames before needing an ACK. Frames can be sent one right after another, meaning the link can carry several frames at once and its capacity can be used efficiently. The receiver uses a single ACK to confirm the receipt of multiple data frames. Sliding Window refers to imaginary boxes at both the sender and the receiver. This window can hold frames at either end and provides the upper limit on the number of frames that can be sent before requiring an ACK.
Frames may be ACKed 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, meaning from 0 to n-1.
π Example: If n=8, frames are numbered 0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,...
When the receiver sends the ACK, it includes the number of the next frame it expects to receive.
π Example: To ACK the receipt of a string of frames ending in frame 4, the receiver sends an ACK with number 5. The window can hold n-1 frames at either end, therefore a maximum of n-1 frames may be sent before an ACK is required.
At the beginning of a transmission, the sender's window contains n-1 frames. As frames are sent out, the left boundary of the window moves inward, shrinking the size of the window. When an ACK is received, the window expands to allow in a number of new frames equal to the number of frames acknowledged by that ACK.
At the beginning of transmission, the receiver window contains n-1 spaces for frames. As new frames come in, the size of the receiver window shrinks. The receiver window therefore does not show the frames that are received, but the frames that may still be received before an ACK is sent.
π‘ Why this matters: Sliding Window dramatically improves link utilization compared to Stop-and-Wait, especially over long distances or high-bandwidth links.
ERROR CONTROL
Error Control refers primarily to error detection and correction. Error control in the data link layer is implemented simply: anytime an error is detected in an exchange, a negative acknowledgement (NAK) is returned and the specified frames are retransmitted. This mechanism is called Automatic Repeat Request (ARQ).
Stop and Wait ARQ
Stop and Wait ARQ is a form of stop-and-wait flow control extended to include retransmission of data in case of lost or damaged frames. For retransmission to work, 4 features are added to the basic flow control mechanism:
- The sending device keeps a copy of the last frame transmitted until it receives the ACK for that frame.
- Both data and ACK frames are numbered 0 and 1 alternately.
- A data 0 frame is acknowledged by an ACK 1 frame, indicating that the receiver has received data 0 and is now expecting data 1.
- If an error is discovered in a data frame, an NAK frame is returned. NAK frames which are not sent tell the sender to retransmit the last frame. The sending device is equipped with a Timer. If an expected ACK is not received within an allotted time period, the sender assumes that the last frame sent is lost and resends the frame.
Damaged Frame
In the event of a damaged frame, the receiver detects the error and sends an NAK back to the sender, requesting retransmission of the damaged frame.
Lost Frame
Any of the 3 frame types can be lost in transit:
- Lost Data Frame
- Lost ACK Frame
- Lost NAK Frame
When a data frame is lost, the sender's timer expires because no ACK or NAK is received, triggering retransmission. If an ACK frame is lost, the sender's timer also expires, causing unnecessary retransmission. If an NAK frame is lost, the sender continues sending new frames until an error is detected in a later frame or the timer expires.
β Key Takeaways
Flow control prevents a fast sender from overwhelming a slow receiver. Stop-and-Wait is simple but inefficient because it requires an ACK for every frame, causing long idle times. Sliding Window is more efficient as it allows multiple frames in transit and uses a single ACK for several frames. Error control is implemented through Stop-and-Wait ARQ, which adds retransmission capability using frame numbering, timers, and NAK frames. The window size in Sliding Window is modulo-n, where at most n-1 frames can be unacknowledged at any time. Both damaged frames and lost frames (data, ACK, or NAK) are handled through timer-based retransmission and negative acknowledgements.
π§ Quick Revision Questions
- What is the fundamental difference between Stop-and-Wait and Sliding Window flow control?
- In Sliding Window, if n=8, what is the maximum number of frames that can be sent before requiring an ACK?
- What does a receiver's ACK with number 5 indicate in Sliding Window?
- What four features are added to basic flow control to create Stop-and-Wait ARQ?
- What happens if an ACK frame is lost during Stop-and-Wait ARQ transmission?
π Lecture 39 β LID ARQ SING WINDOW
π Overview: This lecture continues the study of error control protocols, specifically focusing on Sliding Window ARQ mechanisms. It explains the two main protocolsβGo-Back-N ARQ and Selective Reject ARQβdetailing their operation in handling damaged frames, lost data frames, and lost acknowledgments, and concludes with an introduction to Data Link Protocols and the XMODEM asynchronous protocol.
ποΈ Topics Covered
The lecture covers the features added to sliding window flow control for retransmission, the detailed mechanisms of Go-Back-N ARQ (including handling damaged frames, lost data frames, and lost ACKs), and Selective Reject ARQ. It then compares these two sliding window protocols and introduces the categories of Data Link Protocols, focusing on Asynchronous Protocols with a deep dive into the XMODEM protocol, its frame format, and transmission procedure.
π Lecture Summary
Sliding Window ARQ
The lecture begins by introducing two important error control protocols: Go-back-n ARQ and Selective Reject ARQ. These are built upon the sliding window flow control mechanism by adding three key features to allow for retransmission of lost or damaged frames.
π Definition β Sliding Window ARQ Features:
- The sending device keeps copies of transmitted frames until they are all acknowledged.
- The receiver can send NAK frames if data is received damaged, in addition to ACK frames.
- Because sliding window is a continuous transmission mechanism, both ACK and NAK frames must be numbered for identification. ACK frames carry the number of the next frame expected (e.g., ACK 5 tells the sender that all frames up to frame 5 are received). NAK frames carry the number of the damaged frame itself (e.g., if data frames 4 and 5 are damaged, NAK 4 and NAK 5 must be sent).
- The sender is equipped with a timer to deal with lost ACKs.
Go Back n ARQ
In Go Back n ARQ, if one frame is lost or damaged, all frames sent since the last acknowledged frame are retransmitted.
π Definition β Go Back n ARQ: A sliding window error control protocol where, upon detection of a damaged or lost frame, the sender retransmits that frame and all subsequent frames that were already sent.
- Go Back n β Damaged Frame: The receiver detects a damaged frame and sends a NAK. The sender, upon receiving the NAK, retransmits that frame and all frames sent after it.
- Go Back n β Lost Data Frame: Sliding window requires data frames to be transmitted sequentially. If one or more frames are so noise corrupted that they become lost in transit, the next frame to arrive at the receiver will be out of sequence.
- Go Back n β Lost ACK: If an ACK is not received before the sender's timer expires (when the window capacity is reached and all frames have been sent), the sender retransmits all frames since the last ACK.
π‘ Why this matters: Go-Back-N is simpler to implement but less efficient, as it can waste bandwidth by retransmitting many frames that the receiver may have already correctly received.
Selective Reject ARQ
In Selective Reject ARQ, only the specific damaged or lost frame is retransmitted. If a frame is corrupted in transit, a NAK is returned and the frame is resent out of sequence.
π Definition β Selective Reject ARQ: A sliding window error control protocol where only the damaged or lost frame is retransmitted, requiring the receiver to reorder frames.
Selective Reject ARQ differs from Go Back n in the following ways:
- The receiving device must contain sorting logic to enable it to reorder frames received out of sequence.
- 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 stored.
- To avoid selectivity, the ACK number, like NAK numbers, must refer to the frame received instead of the next expected frame.
- A smaller window size is required because of this added complexity.
- Selective Reject ARQ β Lost Frame: The receiving device must be able to sort frames and insert the retransmitted frame into the proper place. Lost ACK/NAK are treated exactly the same way as by Go Back n.
Selective Reject ARQ vs Go Back n
Although retransmitting only specific damaged or lost frames may seem more efficient than resending all the frames, because of the complexity of sorting and storage required by the receiver and the exact logic needed by the sender to select specific frames for retransmission, selective reject ARQ is expensive and not often used. Selective reject gives better performance, but in practice it is usually discarded in favor of Go-Back-N for simplicity of implementation.
Protocols
A protocol is defined as a set of rules or conventions for executing a particular task. In data communications, a protocol is a set of rules or specifications used to implement one or more layers of the OSI model.
π Definition β Data Link Protocols: Set of specifications used to implement the data link layer. They contain rules for: β Line Discipline β Flow Control β Error Control
Categories of Data Link Protocols
Data link protocols can be divided into two sub-groups: Asynchronous Protocols and Synchronous Protocols.
π Definition β Asynchronous Protocols: Treat each character in a bit stream independently. π Definition β Synchronous Protocols: Take the whole bit stream and chop it into characters of equal size.
Asynchronous protocols are employed mainly in modems. Their inherent slowness is a disadvantage as they require addition of start and stop bits and extended spaces between frames, so these are mainly replaced with high-speed synchronous mechanisms. They are not complex and are inexpensive to implement, and transmission does not require timing coordination as timing is done by using extra bits.
XMODEM
A variety of asynchronous protocols have been developed. In 1979, Ward Christiansen designed a file transfer protocol for telephone-line communication between PCs called XMODEM. It is a Half Duplex and Stop-and-Wait ARQ protocol.
π Definition β XMODEM Frame Format:
- The first field is a One Byte start of header (SOH) field.
- The second field is a two-byte Header. The first header byte, the Sequence number, carries the frame number. The second header byte is used to check the validity of the sequence number.
- The fixed data field holds 128 bytes of data.
- The last field is CRC that checks for errors in the data field only.
π Definition β Transmission in XMODEM:
- Transmission begins with the sending of a NAK frame from the receiver to the sender.
- Each time the sender sends a frame, it must wait for an ACK before sending the next frame.
- If a NAK is received instead of ACK, the last frame is sent again.
- A frame is also resent if no response arrives from a receiver after a fixed time period.
- A sender can also receive a cancel (CAN) to abort the transmission.
π Definition β Control Frames in XMODEM: Control frames from the receiver include:
- ACK: Acknowledgement
- NAK: Error or start of transmission
- CAN: Aborts the transmission
β Key Takeaways
The lecture's core is understanding how sliding window protocols handle errors. Go-Back-N ARQ retransmits all frames from the point of error, making it simpler but potentially wasteful. Selective Reject ARQ retransmits only the damaged frame, which is more efficient but requires complex sorting and buffering at both sender and receiver, making it expensive. General protocols are sets of rules, while data link protocols specifically handle line discipline, flow, and error control. These are categorized as asynchronous or synchronous, with XMODEM being a key example of an asynchronous, stop-and-wait protocol using a specific frame structure and control frames like ACK, NAK, and CAN for management.
π§ Quick Revision Questions
- What are the three key features added to sliding window flow control to create sliding window ARQ?
- In Go-Back-N ARQ, what happens when a single data frame is lost due to noise?
- What are the main differences between Selective Reject ARQ and Go-Back-N ARQ regarding sender logic and receiver capability?
- What are the two main sub-groups of Data Link Protocols, and what is the primary disadvantage of the asynchronous type?
- Describe the frame structure of the XMODEM protocol and explain how its transmission process is initiated.
π Lecture 40 β YMODEM
π Overview: This lecture completes the discussion of asynchronous file transfer protocols by introducing YMODEM, ZMODEM, and Kermit. It then transitions into synchronous protocols, focusing on character-oriented protocols with IBM's Binary Synchronous Communication (BSC) as the primary example. Understanding these protocols is crucial for grasping how data link layer functions operate in different networking environments.
ποΈ Topics Covered
The lecture covers YMODEM protocol and its improvements over XMODEM, ZMODEM as a newer protocol combining features of XMODEM and YMODEM, and Kermit as a widely used asynchronous protocol. It then introduces synchronous protocols, their two main classes (character-oriented and bit-oriented), and provides detailed coverage of IBM's BSC protocol including its frame types (control frames, data frames, data frames with headers, and multiblock frames), along with the purposes of control frames in establishing, maintaining, and terminating connections.