Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Link Layer Savera Tanwir. Data Link Layer Design Issues Services Provided to the Network Layer Framing Error Control Flow Control.

Similar presentations


Presentation on theme: "Data Link Layer Savera Tanwir. Data Link Layer Design Issues Services Provided to the Network Layer Framing Error Control Flow Control."— Presentation transcript:

1 Data Link Layer Savera Tanwir

2 Data Link Layer Design Issues Services Provided to the Network Layer Framing Error Control Flow Control

3 Functions of the Data Link Layer Provide service interface to the network layer Dealing with transmission errors Regulating data flow Slow receivers not swamped by fast senders

4 Functions of the Data Link Layer (2) Relationship between packets and frames.

5 Services Provided to Network Layer (a) Virtual communication. (b) Actual communication.

6 Services Provided to Network Layer Unacknowledged Connectionless Service No logical connection is established beforehand and released No re-transmission in case of loss Appropriate when the error rate is very low Acknowledged connectionless Service Each frame is individually acknowledged Packet acknowledgement vs frame ack? Wireless systems Acknowledged Connection Oriented Service Connection establishment and termination

7 Services Provided to Network Layer (2) Placement of the data link protocol.

8 Framing A character stream. (a) Without errors. (b) With one error.

9 Framing (2) (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing.

10 Framing (3) Bit stuffing (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in receiver’s memory after destuffing.

11 In a single-bit error, only 1 bit in the data unit has changed. Errors

12 A burst error means that 2 or more bits in the data unit have changed.

13 Error detection/correction Error detection Check if any error has occurred Don’t care the number of errors Don’t care the positions of errors Error correction Need to know the number of errors Need to know the positions of errors More difficult

14 Error Detection and Correction Used on many link types Can be used anytime you don’t trust the media Caches,memories, disks Major Algorithmic Strategies: Parity 1 and 2 dimensional Hamming codes (Interleaved Parity Codes) Checksums Cyclic Redundancy Codes (CRC)

15 To detect or correct errors, we need to send extra (redundant) bits with data.

16 Parity Codes Single Bit Parity: Detect single bit errors Two Dimensional Bit Parity: Detect and correct single bit errors 0 0

17 Hamming Distance The Hamming distance between two words is the number of differences between corresponding bits. The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of words.

18 We can count the number of 1s in the Xoring of two words 1. The Hamming distance d(000, 011) is 2 because 2. The Hamming distance d(10101, 11110) is 3 because

19 Find the minimum Hamming distance of the coding scheme in Table 10.1. Solution We first find all Hamming distances. Example The d min in this case is 2.

20 Minimum Distance for Error Detection To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a block code must be d min = s + 1. Why?

21 The minimum Hamming distance for our first code scheme is 2. This code guarantees detection of only a single error. For example, if the third codeword (101) is sent and one error occurs, the received codeword does not match any valid codeword. If two errors occur, however, the received codeword may match a valid codeword and the errors are not detected. Example 10.7

22 Table has d min = 3. This code can detect up to two errors. When any of the valid codewords is sent, two errors create a codeword which is not in the table of valid codewords. The receiver cannot be fooled. What if there are three error occurrance? Example 10.8

23 Hamming Codes Want to be able to correct error with less overhead than 2D parity Hamming codes correct all single bit errors with only log(M) extra bits and detect double bit errors Uses an interleaved parity scheme

24 Calculating a Hamming Code Procedure: Place message bits in their non-power-of-two Hamming positions Build a table listing the binary representation for each of the message bit positions Calculate the check bits

25 Hamming Code Example Message to be sent: 1 0 1 1 1 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position

26 Hamming Code Example 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 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position

27 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 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position Hamming Code Example

28 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 10 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 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position Hamming Code Example

29 10 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 2 3 4 5 6 7 2 0 2 1 2 2 2 n : check bits Position Hamming Code Example

30 Original message = 1011 Sent message = 1011011 Now, how do we check for a single-bit error in the sent message using the Hamming code?

31 Using Hamming Codes to Correct Single-Bit Errors 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

32 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 Using Hamming Codes to Correct Single-Bit Errors

33 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 Using Hamming Codes to Correct Single-Bit Errors

34 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 Using Hamming Codes to Correct Single-Bit Errors

35 1 0 1 1 0 0 1 1 2 3 4 5 6 7 Position Finding the error’s location

36 No error in bits 1, 3, 5, 7 1 0 1 1 0 0 1 1 2 3 4 5 6 7 Position Finding the error’s location

37 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 Finding the error’s location

38 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 EENE 110 = 6 E = error in column NE = no error in column

39 Hamming Codes Hamming codes can be used to locate and correct a single-bit error If more than one bit is in error, then a Hamming code cannot correct it Hamming codes, like parity bits, are only useful on short messages

40 Error Detecting Codes Error correcting codes are simply too expensive for reliable links Usually we only use error detection combined with retransmissions CRC (Cyclic Redundancy Check) Frame bits are seen as polynomial M(x) e.g. 101001 => M(x) = x 5 + x 3 + 1 Sender/receiver use generator polynomial G(x) of degree r Append r ‘0’ bits to lower end of frame generated by M(x) Perform polynomial division using G(x) and append remainder to M(x), to get T(x) Receiver computes T(x) / G(x) and checks remainder

41 Error-Detecting Codes Calculation of the polynomial code checksum.

42 Standard Polynomials NamePolynomialApplication CRC-8x 8 + x 2 + x + 1ATM header CRC-10x 10 + x 9 + x 5 + x 4 + x 2 + 1ATM AAL ITU-16x 16 + x 12 + x 5 + 1HDLC 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 IEEE 802

43 Elementary Data Link Protocols An Unrestricted Simplex Protocol A Simplex Stop-and-Wait Protocol A Simplex Protocol for a Noisy Channel

44 Protocol Definitions Continued  Some definitions needed in the protocols to follow. These are located in the file protocol.h.

45 Protocol Definitions (ctd.) Some definitions needed in the protocols to follow. These are located in the file protocol.h.

46 Unrestricted Simplex Protocol Communication is simplex No errors take place on the physical channel The sender/receiver can generate/consume an infinite amount of data Infinite buffer space is available Processing time can be ignored Always ready for sending/receiving

47 Unrestricted Simplex Protocol

48 Simplex Stop-and-Wait Protocol Most unrealistic assumption is dropped i.e. receiver can process incoming data infinitely fast Channel is still assumed to be error free Data traffic is still simplex Problem: How to prevent the sender from flooding the receiver (Flow Control)? The receiver requires a time (  t) to execute Solution The sender must transmit at an average rate less than one frame per  t Calculate the worst case behavior of the receiver e.g. each frame encounters the same delay Problem: There will be no overruns, but the link utilization will be extremely poor Solution Sender ships one frame and then waits for acknowledgment (stop and wait) The contents of the acknowledgment frame are unimportant Data transmission cannot be one directional Requires Half-duplex physical channel

49 Simplex Stop-and- Wait Protocol

50 A Simplex Protocol for a Noisy Channel A positive acknowledgement with retransmission protocol. Continued 

51 A Simplex Protocol for a Noisy Channel (ctd.) A positive acknowledgement with retransmission protocol.

52 Unresolved Problems of Simplex Protocols Timer duration : How long should the timer be? What if too long? (inefficient) What if too short? (unnecessary retransmission) Poor Link Utilization results due to Stop-and-Wait

53 Sliding Window Protocols A One-Bit Sliding Window Protocol A Protocol Using Go Back N A Protocol Using Selective Repeat

54 Sliding Window Protocol There is a need for transmitting data in both directions Different channels for data in each direction Same channel for data in both directions For example, using a kind field in the header of an incoming frame, the receiver can tell if frame is data or ACK Piggybacking Instead of sending a separate control (ACK) frame, the ACK is attached to the outgoing data frame Advantage: Better use of the channel bandwidth (just a few extra bits) Issue: How long should the data link layer wait for a packet onto which to piggyback the acknowledgement?

55 Piggybacking

56 Sliding Window Protocol Concept behind all sliding window protocols Each frame contains a sequence number Maximum number is 2 n –1 (to fit in an n bit field) At any instant of time, the sender maintains a set of sequence numbers it is permitted to send called sending window The receiver also maintains a receiving window, corresponding to the frames it is permitted to accept Both windows need not have same upper and lower limits and can grow or shrink as frames are sent and received

57 Sliding Window Protocol Sender’s perspective The frames in the sender’s window represent frames that ‘have been sent but not yet acknowledged’ or ‘can be sent’ Frames in sender’s window may be lost or damaged, the sender must keep all these frames in its memory for possible retransmissions If max window size is n, the sender needs n buffer spaces to hold the unacknowledged frames Whenever a new packet arrives from the network layer, it is Given the next highest sequence number The upper boundary of the window is advanced by one When an acknowledgement comes in, the lower boundary is advanced by one

58 After receiving ACKs for Frame 0 and 1 Example – 3-bit Sender Sliding Window

59 Sliding Window Protocol Receiver’s Perspective The receiver’s window corresponds to the frames it may accept If a frame comes that lies outside the receiver’s window, its discarded If it receives a frame whose sq. no. matches its expectation, it is Passed to the NL ACK is generated Complete window is moved by 1 Receiver’s window always reserves its size NL is always given data in-order, regardless of receiver’s window size

60 Example – 1-bit Receiver Sliding Window After receiving Frame 0 from Sender

61 A One-Bit Sliding Window Protocol Continued 

62 A One-Bit Sliding Window Protocol (ctd.)

63 A One-Bit Sliding Window Protocol (2) Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet.

64 Link Utilization Problem In 1-bit protocol, the sender can only have one unACKed frame outstanding Consider a 50 kbps channel with 500 msec round-trip propagation delay used to send 1000 bit frames Transmission time t = 20 ms Frame will arrive at destination after 270 ms ACK will get back after 520 ms (Assuming no delay at receiver) So sender was idle for 500/520 ≈ 96% of the time Thus, a combination of long propagation delay, high bandwidth and short frame length destroys efficiency One solution, use larger frames, but the maximum size is limited by the bit error rate (BER) of the channel

65 Solution  Pipelining Allow more frames to be in transmission simultaneously, instead of just 1 frame If channel bandwidth is b bits/sec, frame length is ℓ bits & round-trip propagation is R sec Time to transmit single frame = ℓ /b bits Line utilization = ℓ /( ℓ + bR ) Issues with pipelining Provides more efficient use of bandwidth, but error handling is more complex If 20 frames are transmitted and only the 2 nd had an error Will frames 3 - 20 be ignored at receiver side? Will the sender have to retransmit all frames again?

66 A Protocol Using Go-Back-N Discard all subsequent frames, sending no acknowledgement for the discarded frames 0123456782345678910 0123456789 EDDDDDD discarded by receiver frame with error timeout interval ACK 0 ACK 1ACK 2 ACK 3 ACK 4 ACK 5 ACK 6 ACK 7 Time sender receiver

67 A Protocol Using Go-Back-N Corresponds to receive window size of 1 Go-back-N works fine if the retransmissions rarely occur Wastes a lot of bandwidth if error rate is high Requires lesser buffer size at the receiver

68 Selective-Repeat Receiver sends a NAK when it detects an error Sender sends the required frame on receiving NAK

69 Sliding Window Protocol Using Go Back N Continued 

70 Sliding Window Protocol Using Go Back N Continued 

71 Sliding Window Protocol Using Go Back N Continued 

72 Sliding Window Protocol Using Go Back N

73 Sliding Window Protocol Using Go Back N (2) Simulation of multiple timers in software.

74 A Sliding Window Protocol Using Selective Repeat Continued 

75 A Sliding Window Protocol Using Selective Repeat (2)

76 A Sliding Window Protocol Using Selective Repeat (3) Continued 

77 A Sliding Window Protocol Using Selective Repeat (4)

78 A Sliding Window Protocol Using Selective Repeat (5) (a) Initial situation with a window size seven. (b) After seven frames sent and received, but not acknowledged. (c) Initial situation with a window size of four. (d) After four frames sent and received, but not acknowledged.

79 Acknowledgements Ali Sajjad’s lectures


Download ppt "Data Link Layer Savera Tanwir. Data Link Layer Design Issues Services Provided to the Network Layer Framing Error Control Flow Control."

Similar presentations


Ads by Google