39. (normally implemented in link layer) (used primarily by upper layers) 3 common error detection techniques Parity Check Cyclic Redundancy Check (CRC) Checksum (most basic)
40.
41.
42.
43. Data #1's in data P Total # 1's (data and P) 0110110 4 (Even) 0 4 (Even) 0011111 5 (Odd) 1 6 (Even) 0000000 0 (Even) 0 0 (Even) 1010100 3 (Odd) 1 4 (Even) 1111111 7 (Odd) 1 8 (Even) Even Parity Generator
44.
45. What is VRC and LRC? VRC is Character Parity LRC is Block Parity
46.
47.
48.
49. Example 1 Even Parity Suppose the sender wants to send the word world . In ASCII the five characters are coded as 1110111 1101111 1110010 1101100 1100100 The following shows the actual bits sent 1110111 0 1101111 0 1110010 0 1101100 0 1100100 1
50. Example 2 Even Parity Now suppose the word world in Example 1 is received by the receiver without being corrupted in transmission. 11101110 11011110 11100100 11011000 11001001 The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). The data are accepted.
51. Example 3 Even Parity Now suppose the word world in Example 1 is corrupted during transmission. 11111110 11011110 11101100 11011000 11001001 The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 5, 4, 4). The receiver knows that the data are corrupted, discards them, and asks for retransmission.
56. L ONGITUDINAL R EDUNDANCY C HECK (LRC) IN longitudinal redundancy check LRC, a block of bits is divided into rows and a redundant row of bits is added to the whole block
72. Example 6 Suppose the following block of 16 bits is to be sent using a checksum of 8 bits. 10101001 00111001 The numbers are added using one’s complement 10101001 00111001 ------------ Sum 11100010 Checksum 00011101 The pattern sent is 10101001 00111001 00011101
73. Example 7 Now suppose the receiver receives the pattern sent in Example 6 and there is no error. 10101001 00111001 00011101 When the receiver adds the three sections, it will get all 1s, which, after complementing, is all 0s and shows that there is no error. 10101001 00111001 00011101 ------------ Sum 11111111 Complement 00000000 means that the pattern is OK.
74. Example 8 Now suppose there is a burst error of length 5 that affects 4 bits. Original data 10101001 00111001 00011101 Corrupted data 10101 111 11 111001 00011101 When the receiver adds the three sections, it gets 10101111 11111001 00011101 Partial Sum 1 11000101 Carry 1 Sum 11000110 Complement 00111001 the pattern is corrupted.
83. Data and redundancy bits To calculate the no. of redundancy bits use : 2 r ≥ m + r + 1 Number of data bits m Number of redundancy bits r Total bits m + r 1 2 3 2 3 5 3 3 6 4 3 7 5 4 9 6 4 10 7 4 11
84. Positions of redundancy bits in Hamming code (11,7) * Check bits occupy positions that are powers of 2 In the Hamming code, each r bit is the VRC bit for one combination of data bits: r 1 is the VRC bit for one combination of data bits, r 2 is the VRC bit for another combination of data bits, and so on. The combinations used to calculate each of the four r values for a seven-bit data sequence are as follows: r 1 : bits 1, 3, 5, 7, 9, 11 r 2 : bits 2, 3, 6, 7, 10, 11 r 4 : bits 4, 5, 6, 7 r 5 : bits 8, 9, 10, 11
94. Example Question The data is 1011011 Add the parity bit. ??????????????? Consider the transmitted data to be 001 0 101 0 1 11 . Show how the error bit position is determined ???????????????
95.
96.
97.
98.
99. Hamming Code Example Message to be sent: 1 0 1 1 1 0 1 1 1 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position
100.
101. Hamming Code Example 1 Starting with the 2 0 position: Look at positions with 1’s in them Count the number of 1’s in the corresponding message bits If even, place a 1 in the 2 0 check bit, i.e., use odd parity Otherwise, place a 0 Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 + = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 Message to be sent: 1 0 1 1 1 0 1 1 1 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position
102. Hamming Code Example Repeat with the 2 1 position: Look at positions those positions with 1’s in them Count the number of 1’s in the corresponding message bits If even, place a 1 in the 2 1 check bit Otherwise, place a 0 1 0 Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 + = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 Message to be sent: 1 0 1 1 1 0 1 1 1 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position
103. Hamming Code Example 1 0 Repeat with the 2 2 position: Look at positions those positions with 1’s in them Count the number of 1’s in the corresponding message bits If even, place a 1 in the 2 2 check bit Otherwise, place a 0 1 Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 + = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 Message to be sent: 1 0 1 1 1 0 1 1 1 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position
106. Using Hamming Codes to Correct Single-Bit Errors Starting with the 2 0 position: Look at positions with 1’s in them Count the number of 1’s in both the corresponding message bits and the 2 0 check bit and compute the parity. If even parity, there is an error in one of the four bits that were checked. Odd parity: No error in bits 1, 3, 5, 7 Received message: 1 0 1 1 0 0 1 2 n : check bits Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 1 0 1 1 0 0 1 1 2 3 4 5 6 7 2 0 2 1 2 2 Position
107. Using Hamming Codes to Correct Single-Bit Errors Repeat with the 2 1 position: Look at positions with 1’s in them Count the number of 1’s in both the corresponding message bits and the 2 1 check bit and compute the parity. If even parity, there is an error in one of the four bits that were checked. Even parity: ERROR in bit 2, 3, 6 or 7! Received message: 1 0 1 1 0 0 1 2 n : check bits Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 1 0 1 1 0 0 1 1 2 3 4 5 6 7 2 0 2 1 2 2 Position
108. Using Hamming Codes to Correct Single-Bit Errors Repeat with the 2 2 position: Look at positions with 1’s in them Count the number of 1’s in both the corresponding message bits and the 2 2 check bit and compute the parity. If even parity, there is an error in one of the four bits that were checked. Even parity: ERROR in bit 4, 5, 6 or 7! Received message: 1 0 1 1 0 0 1 2 n : check bits Calculate check bits: 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 1 0 1 1 0 0 1 1 2 3 4 5 6 7 2 0 2 1 2 2 Position
110. Finding the error’s location No error in bits 1, 3, 5, 7 1 0 1 1 0 0 1 1 2 3 4 5 6 7 Position
111. Finding the error’s location ERROR in bit 2, 3, 6 or 7 ERROR in bit 4, 5, 6 or 7 Error must be in bit 6 because bits 3, 5, 7 are correct, and all the remaining information agrees on bit 6 erroneous bit, change to 1 1 0 1 1 0 0 1 1 2 3 4 5 6 7 Position
112. Finding the error’s location An Easier Alternative to the Last Slide 3 = 2 1 + 2 0 = 0 1 1 5 = 2 2 + 2 0 = 1 0 1 6 = 2 2 + 2 1 = 1 1 0 7 = 2 2 + 2 1 + 2 0 = 1 1 1 E E NE 1 1 0 = 6 E = error in column NE = no error in column
133. Standard polynomials Name Polynomial Application CRC-8 x 8 + x 2 + x + 1 ATM header CRC-10 x 10 + x 9 + x 5 + x 4 + x 2 + 1 ATM AAL ITU-16 x 16 + x 12 + x 5 + 1 HDLC ITU-32 x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x + 1 LANs
134.
135.
136.
137.
138.
139. Generating a CRC Example Message : 1011 1 x x 3 + 0 x x 2 + 1 x x + 1 = x 3 + x + 1 Code Polynomial : x 2 + 1 (101) Step 1 : Compute S(x) r = 2 S(x) = 101100
141. Generating a CRC Example (cont’d) Step 3 : Modulo 2 subtract the remainder from S(x) 101100 - 01 101101 Checksummed Message
142.
143. Decoding a CRC Example 101101 Checksummed message ( n = 6) 1011 Original message (if there are no errors) Remainder = 0 (No error detected) 101101 101 101 001 000 010 000 101 101 00 1001
154. NOISELESS CHANNELS Let us first assume we have an ideal channel in which no frames are lost, duplicated, or corrupted. We introduce two protocols for this type of channel. Protocol 1: Simplest Protocol Protocol 2: Stop-and-Wait Protocol Topics discussed in this section:
155. Protocol 1 : Design , Implementation and Coding of Simplest Protocol
156. Protocol 1 : The design of the simplest protocol with no flow or error control
164. 11. Algorithm 2 Sender-site algorithm for Stop-and-Wait Protocol
165. 11. Algorithm 2 Receiver-site algorithm for Stop-and-Wait Protocol
166. 11. Figure shows an example of communication using this protocol. It is still very simple. The sender sends one frame and waits for feedback from the receiver. When the ACK arrives, the sender sends the next frame. Note that sending two frames in the protocol involves the sender in four events and the receiver in two events. Example
169. 11. NOISY CHANNELS Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, noiseless channels are nonexistent. We discuss three protocols in this section that use error control. Protocol 3: Stop-and-Wait ARQ (Automatic Repeat Request) Protocol 4: Go-Back-N ARQ (Automatic Repeat Request) Protocol 5: Selective Repeat ARQ (Automatic Repeat Request) Topics discussed in this section:
170. Protocol 3 : Design , Implementation and Coding of Stop-and-Wait ARQ (Automatic Repeat Request)
171. Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and retransmitting of the frame when the timer expires. Note
172. In Stop-and-Wait ARQ, we use sequence numbers to number the frames. The sequence numbers are based on modulo-2 arithmetic . Note
173. In Stop-and-Wait ARQ, the acknowledgment number always announces in modulo-2 arithmetic the sequence number of the next frame expected. Note
174. Protocol 3 : Design of the Stop-and-Wait ARQ Protocol
175. Algorithm 3 Sender-site algorithm for Stop-and-Wait ARQ (continued)
176. Algorithm 3 Sender-site algorithm for Stop-and-Wait ARQ (continued)
177. Algorithm 3 Receiver-site algorithm for Stop-and-Wait ARQ Protocol
178. 11. Figure shows an example of Stop-and-Wait ARQ . Frame 0 is sent and acknowledged. Frame 1 is lost and resent after the time-out. The resent frame 1 is acknowledged and the timer stops. Frame 0 is sent and acknowledged, but the acknowledgment is lost. The sender has no idea if the frame or the acknowledgment is lost, so after the time-out, it resends frame 0, which is acknowledged. Example
189. Sliding Window Protocols Reason: sender can only have one unACKed frame outstanding. This cause the problem only when R is more larger than L/B first packet bit transmitted, t = 0 R last packet bit transmitted, t = L / B first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = R + L / B Sender Receiver U sender = L / B R + L / B = L RB + L
190.
191.
192. Protocols 4 : Design, Implementation and Coding of Sliding Window Protocol
193.
194.
195.
196.
197.
198.
199.
200. In the Go-Back-N Protocol, the sequence numbers are modulo 2 m , where m is the size of the sequence number field in bits. Note
205. The receive window is an abstract concept defining an imaginary box of size 1 with one single variable R n . The window slides when a correct frame has arrived; sliding occurs one slot at a time. Note
212. Example Figure shows an example of Go-Back-N. This is an example of a case where the forward channel is reliable, but the reverse is not. No data frames are lost, but some ACKs are delayed and one is lost. The example also shows how cumulative acknowledgments can help if acknowledgments are delayed or lost. After initialization, there are seven sender events. Request events are triggered by data from the network layer; arrival events are triggered by acknowledgments from the physical layer. There is no time-out event here because all outstanding frames are acknowledged before the timer expires. Note that although ACK 2 is lost, ACK 3 serves as both ACK 2 and ACK 3.
214. Figure shows what happens when a frame is lost. Frames 0, 1, 2, and 3 are sent. However, frame 1 is lost. The receiver receives frames 2 and 3, but they are discarded because they are received out of order. The sender receives no acknowledgment about frames 1, 2, or 3. Its timer finally expires. The sender sends all outstanding frames (1, 2, and 3) because it does not know what is wrong. Note that the resending of frames 1, 2, and 3 is the response to one single event. When the sender is responding to this event, it cannot accept the triggering of other events. This means that when ACK 2 arrives, the sender is still busy with sending frame 3. Example
215. The physical layer must wait until this event is completed and the data link layer goes back to its sleeping state. We have shown a vertical line to indicate the delay. It is the same story with ACK 3; but when ACK 3 arrives, the sender is busy responding to ACK 2. It happens again when ACK 4 arrives. Note that before the second timer expires, all outstanding frames have been sent and the timer is stopped. Example (continued)
227. 11. This example is similar to Example 11.3 in which frame 1 is lost. We show how Selective Repeat behaves in this case. Figure 11.23 shows the situation. One main difference is the number of timers. Here, each frame sent or resent needs a timer, which means that the timers need to be numbered (0, 1, 2, and 3). The timer for frame 0 starts at the first request, but stops when the ACK for this frame arrives. The timer for frame 1 starts at the second request, restarts when a NAK arrives, and finally stops when the last ACK arrives. The other two timers start when the corresponding frames are sent and stop at the last arrival event. Example 11.8
228. 11. At the receiver site we need to distinguish between the acceptance of a frame and its delivery to the network layer. At the second arrival, frame 2 arrives and is stored and marked, but it cannot be delivered because frame 1 is missing. At the next arrival, frame 3 arrives and is marked and stored, but still none of the frames can be delivered. Only at the last arrival, when finally a copy of frame 1 arrives, can frames 1, 2, and 3 be delivered to the network layer. There are two conditions for the delivery of frames to the network layer: First, a set of consecutive frames must have arrived. Second, the set starts from the beginning of the window. Example 11.8 (continued)
229. 11. Another important point is that a NAK is sent after the second arrival, but not after the third, although both situations look the same. The reason is that the protocol does not want to crowd the network with unnecessary NAKs and unnecessary resent frames. The second NAK would still be NAK1 to inform the sender to resend frame 1 again; this has already been done. The first NAK sent is remembered (using the nakSent variable) and is not sent again until the frame slides. A NAK is sent once for each window position and defines the first slot in the window. Example 11.8 (continued)
230. 11. The next point is about the ACKs. Notice that only two ACKs are sent here. The first one acknowledges only the first frame; the second one acknowledges three frames. In Selective Repeat, ACKs are sent when data are delivered to the network layer. If the data belonging to n frames are delivered in one shot, only one ACK is sent for all of them. Example 11.8 (continued)