Presentation is loading. Please wait.

Presentation is loading. Please wait.

Part III. Data Link Layer

Similar presentations


Presentation on theme: "Part III. Data Link Layer"— Presentation transcript:

1 Part III. Data Link Layer
Chapter 10. Error Detection COMP 3270 Computer Networks Computing Science Thompson Rivers University

2 Learning Objectives Describe the general idea of error detection, using redundancy Determine parity bit with a given data word. Determine CRC redundancy with a given data word and divisor. Determine checksum with a given data word.

3 Position of the data-link layer
☺ Main responsibility/role: ? [Reliable] node-to-node delivery of packets called frames

4 Data link layer duties Framing Physical address or MAC address
Slow receiver Shared medium Error detection and retransmission Error control is used in the network layer and the transport layer as well. Flow control is used in the transport layer as well.

5 LLC and MAC sublayers Hardware independent Not standardized
in the Internet society Then where? Hardware dependent

6 IEEE standards for LANs
Connectionless service: - No flow and error control, or - Just acknowledgement Connection-oriented service: - ARQ for flow and error controls Ethernet 802.11: 2.4GHz; 2Mbps 802.11a: 5GHz; 54 Mbps 802.11b: 2.4GHz; 11Mbps; Wi-Fi 802.11g: 2.4GHz; 54Mbps

7 Some applications require that errors be detected and retransmitted.
Data can be corrupted during transmission due to attenuation, distortion and noise. Some applications require that errors be detected and retransmitted.

8 Chapter Outline Introduction Parity check Cyclic codes Checksum

9 1. INTRODUCTION Topics discussed in this section:
Let us first discuss some issues related, directly or indirectly, to error detection. Topics discussed in this section: Redundancy Detection

10 ☺ What is the basic idea to detect errors?
Redundancy To detect or correct errors, we need to send extra (redundant) bits with data. ☺ What does this mean? ☺ What is the basic idea to detect errors?

11 Basic Idea of Error Detection
Algorithm Same algorithm

12 Codeword is defined as dataword + redundancy

13 Error Detection Methods
Serial line Ethernet, hardware Internet protocols software

14 3. PARITY CHECK

15 Parity Check To make the number of bit 1s even

16 In parity check, a parity bit is added to every data unit so that the total number of 1s is even (or odd for odd-parity).

17 Example: Suppose the sender wants to send the word world. In ASCII the five characters are coded as When even parity check is used, the actual bits sent: ? ? ? ? When odd parity check is used, the actual bits sent: ? ? ? ?

18 Example: Assuming even parity check, now suppose the word world in the previous Example is received by the receiver without being corrupted in transmission. The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). The data are accepted.

19 Example: Assuming even parity check, now suppose the word world in the previous Example is corrupted during transmission. 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. How to correct? Then, the receiver discards them, and asks for retransmission somehow.

20 Simple parity check can detect all single-bit errors.
It can detect burst errors only if the total number of errors in each data unit is odd. Simple, but not powerful algorithm

21 4. CYCLIC CODES

22 Cyclic Redundancy Check
CRC encoder and decoder With a leading bit 1

23 Division in CRC encoder
XOR X xor ??? X xor ??? X or ??? X or ??? X and ??? X and ???

24 Division in the CRC decoder for two cases

25 Example: Suppose the following dataword is sent:
Find the CRC redundancy when the divisor is used. 1011 | 1011 1100

26 Standard polynomials Divisors 1 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 1 1 0

27 5. CHECKSUM Topics discussed in this section:
The last error detection method we discuss here is called the checksum. The checksum is used in the Internet by several protocols (IP, UDP, TCP) although not at the data link layer. However, we briefly discuss it here to complete our discussion on error checking. Topics discussed in this section: Idea One’s Complement Internet Checksum

28 Idea Suppose our data is a list of five 4-bit numbers that we want to send to a destination. In addition to sending these numbers, we send the sum of the numbers. For example, if the set of numbers is (7, 11, 12, 0, 6), we send (7, 11, 12, 0, 6, 36), where 36 is the sum of the original numbers. The receiver adds the five numbers and compares the result with the sum. If the two are the same, the receiver assumes no error, accepts the five numbers, and discards the sum. Otherwise, there is an error somewhere and the data are not accepted.

29 We can make the job of the receiver a bit easier if we send the negative (complement) of the sum, called the checksum. In this case, we send (7, 11, 12, 0, 6, −36). The receiver can add all the numbers received (including the checksum). If the result is 0, it assumes no error; otherwise, there is an error.

30 One’s Complement 1 1 1

31 Internet Checksum Sender site:
The message is divided into 16-bit words. The value of the checksum word is set to 0. All words including the checksum are added using one’s complement addition. The sum becomes the checksum. The checksum is sent with the data.

32 Receiver site: The message (including checksum) is divided into 16-bit words. All words are added using one’s complement addition. The sum is complemented and becomes the new checksum. If the value of checksum is 0, the message is accepted; otherwise, it is rejected.

33 Example: Suppose the following block of 16 bits is to be sent using a checksum of 8 bits. The codeword is:

34 Example: Now suppose the receiver receives the pattern sent in the previous example and there is no error. 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. Sum Complement means that the pattern is OK.

35 Example: Now suppose there is a burst error of length 5 that affects 3 bits. When the receiver adds the three sections, it gets Sum Complement the pattern is corrupted.

36 Example: some very useful bit operations
How to check if the 18th bit from the right is 1 or 0? How to make a 16 bit integer from two bytes? How to store a 16 bit integer into two bytes? How to reset the right 14 bits from a 32 bit integer? How to obtain the 24th, 23rd, 22nd, and 21st bits?

37 C code – 16 bit checksum: Can you complete it?
(Play the slide to see the code!) int checksum = 0; unsigned char data[MAX]; // even number of bytes unsigned short delta; // 16 bits int i; ... // checksum  for (i = 0; i < MAX/2; i++) { delta = (data[2*i] << 8) + data[2*i + 1]; checksum += delta; if (checksum & 0x10000) { // if there is a carry       checksum &= 0xffff; // reset the carry       checksum++; // add 1 } } checksum = ~checksum; // 1’s complement // store the checksum into a packet packet[i] = (unsigned char)((checksum >> 8) & 0xff); packet[i+1] = (unsigned char)(checksum & 0xff);

38 Can you write C code of 8 bit checksum?


Download ppt "Part III. Data Link Layer"

Similar presentations


Ads by Google