Unit-Iii Datalink Layer: Error Detection and Correction
Total Page:16
File Type:pdf, Size:1020Kb
UNIT-III DATALINK LAYER: ERROR DETECTION AND CORRECTION Error-Correcting Codes Error control in computer networks is typically achieved by error detecting using cyclic redundancy check (CRC), which is the checksum inside a frame, combined with retransmission For this purpose, systematic cyclic or polynomial generated codes are often used, which are special linear block codesSome basic concepts in error control coding are first reviewedAn n-bit frame, which consists of m-bit data and r check bits, is called a codeword. AllCode words form the codebook Hamming distance between two code words is number of bits in which two code words differ For example, 10001001 and 10110001 have a Hamming distance of 3, where is bit-wise exclusive OR (modulo 2) The minimum Hamming distance d min of a codebook is the smallest Hamming distance between any pair of code words in the codebook A codebook with dmin can detect up to dmin − 1 errors and correct up to (dmin − 1)/2 errors in each codeword. Use of a Hamming code to correct burst errors Hamming codes can only correct single errors. However, there is a trick that can be used to permit Hamming codes to correct burst errors. A sequence of k consecutive codewords is arranged as a matrix, one codeword per row. Normally, the data would be transmitted one codeword at a time, from left to right. To correct burst errors, the data should be transmitted one column at a time, starting with the leftmost column. When all k bits have been sent, the second column is sent, and so on. 2.6.2 Error-Detecting Codes Error detection is most commonly realized using a suitable hash function (or checksum algorithm). A hash function adds a fixed-length tag to a message, which enables receivers to verify the delivered message by recomputing the tag and comparing it with the one provided. There exists a vast variety of different hash function designs. However, some are of particularly widespread use because of either their simplicity or their suitability for detecting certain kinds of errors A repetition code is a coding scheme that repeats the bits across a channel to achieve error-free communication. Given a stream of data to be transmitted, the data is divided into blocks of bits. Each block is transmitted some predetermined number of times. For example, to send the bit pattern "1011", the four-bit block can be repeated three times, thus producing "1011 1011 1011". However, if this twelve-bit pattern was received as "1010 1011 1011" – where the first block is unlike the other two – it can be determined that an error has occurred. A parity bit is a bit that is added to a group of source bits to ensure that the number of set bits (i.e., bits with value 1) in the outcome is even or odd. It is a very simple scheme that can be used to detect single or any other odd number (i.e., three, five, etc.) of errors in the output. An even number of flipped bits will make the parity bit appear correct even though the data is erroneous. A checksum of a message is a modular arithmetic sum of message code words of a fixed word length (e.g., byte values). The sum may be negated by means of a ones'- complement operation prior to transmission to detect errors resulting in all-zero messages. A cyclic redundancy check (CRC) is a single-burst-error-detecting cyclic code and non- secure hash function designed to detect accidental changes to digital data in computer networks. It is not suitable for detecting maliciously introduced errors. It is characterized by specification of a so-called generator polynomial, which is used as the divisor in a polynomial long division over a finite field, taking the input data as the dividend, and where the remainder becomes the result. ELEMENTARY DATA LINK PROTOCOLS 1. Physical, data link, and network layer are independent processes that communicate by passing messages - Each layer can operate simultaneously with the other. 2. A reliable, connection-oriented service between machines is desired - Essentially, the network layers of two machines can communicate on the assumption that whatever sent is received correctly (i.e. same sequence, no duplicates, no other errors). 3. The sender always has an infinite supply of data to send - When the data link layer of the sender asks for data, the network layer always has some available. 4. Data link assumes that the entire packet from network layer is data - When the data link layer receives a network layer packet it only need add header information for communication with the receiving machine's data link layer. Communication between A and B machines physically occurs vertically through the network, data link, and physical layers but logically through the virtual connections between peer layers. Transmitting the message "Hello" from A to B network layer is illustrated in the following diagram, note the header information added to the message at each layer for communication with its peer. An Unrestricted Simplex Protocol - Protocol 1 Assumptions 1. Simplex - Communication is one direction only. 2. Reliable channel - The communication channel never introduces errors (i.e. no duplicate, no missing, or damaged frames). 3. Receiver never gets behind, it can process incoming data infinitely fast (no need for flow control). Important points of note are: 1. Independent processes - Both sender and receiver are independent processes whether running on different or the same machine. 2. Infinite execution - Both processes are assumed to start at the same time (in reality, receiver B must start before sender A to avoid missing frames sent by A), and run forever due the while(true) execution loop in each. 3. Frame - The data link layer passes frames between the physical layer. A frame contains a network layer packet. 4. Packet - The data link layer passes packets between the network layer. A packet is network layer data. The frame sent uses only an info field containing the network packet: A Simplex Stop-and-Wait Protocol - Protocol 2 The key assumptions are: 1. Simplex - Communication is one direction only. 2. Reliable channel - The communication channel never introduces errors (i.e. no duplicate, no missing, or damaged frames). 3. The most unrealistic assumption that is dropped: Receiver never gets behind, it can process incoming data infinitely fast. The main problem then is to prevent the sender from overwhelming the receiver, this is commonly known as flow control. A simple solution is to require that the sender never transmits a new frame until the receiver has confirmed it has processed the previous frame. Data is still only sent in one direction but an empty frame is transmitted by the receiver as confirmation requiring the sender to wait before sending another data frame. sender frame uses only the info field containing the network packet: receiver frame sent is empty: Improvements: 1. Flow control by requiring sender to wait for a confirmation from receiver. Problems: 1. Deadlock when either transmit or confirmation frame lost. No way to stop waiting on either sender2 or receiver2. 2. Delay while sender2 waits for confirmation, under-utilizing the channel. A Simplex Protocol for a Noisy Channel - Protocol 3 The assumption is: Simplex - Data communication is one direction only. The assumption dropped: Reliable channel - The communication channel never introduces errors (i.e. no duplicate, no missing, or damaged frames). Deadlock was possible in Protocol 2 over an unreliable channel where lost frames can occur. Protocol 3 does not deadlock in the face of errors but does still force the sender to wait until a confirmation arrives. There are two essential implications: 1. After a fixed wait the sender will timeout and retransmit the data. This avoids deadlock when frames are lost. 2. Each frame sent is numbered 0 or 1 and a new data frame is not sent until the previous frame is confirmed. This prevents lost or out of sequence data frames. Sender frame - The seq and info field are used : Receiver frame - The ack field is used : Improvements: 1. No deadlock due to the use of a timer on the sender. If the sender does not receive a confirmation within the allocated time, the same frame is resent. 2. No duplicates due to the use of sequence numbers (0 and 1). If the sender receives a confirmation to a frame sequence number different than the most recently transmitted, the same frame is resent. Using a binary sequence number allows only one outstanding frame at a time. Problems: 1. With only one outstanding frame, the utilization of the channel is not optimal (below 100%). 2. Timeout should be longer than the round trip time (the time a frame travels to the receiver and a confirmation returns). Otherwise, time wasted sending duplicate messages unnecessarily. 2.8 SLIDING WINDOW PROTOCOLS The main problem addressed by sliding window protocols is the poor channel utilization due to the need of the sender to await confirmation to the one outstanding frame before another can be transmitted. The solution is to have several frames outstanding at a time rather than only one, the optimum number dependent upon the round trip time for the frame to travel from the sender and its acknowledgement to return. For example, if the full round trip time was 10 seconds and only a single frame was outstanding at a time, the wait would be 10 seconds for the acknowledgement to fully arrive, utilization would be only 10% for a frame of one second duration. With multiple outstanding frames and acknowledgments, for one second long frames the channel could hold 5 one second long frames from the sender and 5 acknowledgments coming back to completely fill the channel, utilization would be 100%.