Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 The Data Link Layer (60 % practical part)

Similar presentations


Presentation on theme: "Chapter 3 The Data Link Layer (60 % practical part)"— Presentation transcript:

1 Chapter 3 The Data Link Layer (60 % practical part)

2 The Introduction The study of it deals with the algorithms for achieving reliable, efficient, communication between two adjacent machines The machines are physically connected by a communication channel that acts conceptually like a wire

3 Data Link Layer Functions 1.Provide a well defined service interface to the network layer 2.Framing: Determine how the bits of the physical layer are grouped into frames 3.Error Control: Dealing with transmission errors 4.Flow Control: Regulate the flow of frames so that slow receivers are not swamped by fast senders

4 Relationship between Packets and Frames Relationship between packets and frames.

5 Services Provided To NL Transferring data from the NL on the source to the NL on the destination On the source machine entity (process), in the NL, that hands some bits to DLL On the destination machine the data link layer hands it over to network layer

6 Virtual and Actual Communication The actual transmission follows thru physical layer but it can be neglected here

7 Services Provided by DLL 1. Unacknowledged connectionless service 2. Acknowledged connectionless service 3. Acknowledged Connection-oriented service

8 1… Unacknowledged CL Service Least reliable but faster than all other The source machine sends independent frames to the destination machine without having the destination machine ack them No connection is established beforehand or released afterwards If a frame is lost due to noise burst in the channel, no attempt is made in the data link layer to recover the same

9 Continue… This is very appropriate when the error rate is very low and recovery is left to higher layers It is also appropriate for real-time traffic where late data is worse then bad data Many LANs have unacknowledged connectionless service in their DLL

10 2… Acknowledged CL Service Here each frame is individually acked If the ack frame is not arrived in some specific time interval, sender may resend Each frame sent over the connection is numbered This service is useful over unreliable medium such as wireless channel

11 3… Connection Oriented Service It is the most sophisticated service provided by the data link layer With this service the sender and receiver establishes a connection before any data can be transmitted The choice of CO or CL service is to be determined by the reliability of media

12 Continue… When C.O. services is used, three phases are involved in transfer In the first phase the connection is established by having both sides initialize variables and counters needed to keep track of which frames have been received In the second phase one or more frames are actually transmitted

13 Continue… In the third and final phase, the connection is released, freeing up the buffers, variables and other resources used to maintain the connection. The communication between the network layer and the data link layer uses the standard OSI service primitives, request, indication, response and confirm.

14 Placement of the DLL Protocol

15 Framing The PL provides DLL continuous bit stream of raw data without any error checking DLL breaks raw stream of data into frames and compute the checksum for each frame When a frame arrives checksum is recomputed error report or ack be sent

16 Ways of framing To insert time gaps between frames –As like spaces in words –it is possible these gaps might be squeezed out or other gaps might be inserted during transmission. –So four other methods are used 1.Character count. 2.Flag bytes with byte stuffing. 3.Starting and ending flags, with bit stuffing. 4.Physical layer coding violations

17 1… Character Count It uses a field in the header to specify the number of characters in the frame If count is garbled by the transmission, it can make the receiver go out of sync

18 A Character Stream With and Without Errors

19 2… Flag bytes with byte stuffing. Here each frame starts and ends with flag byte When binary or floating point data is being transmitted, flag byte may occur in data Sender's data link layer insert a special escape byte (ESC) just before each ''accidental'' flag byte in the data This is called byte stuffing or character stuff

20

21 Continue… It is closely tied to 8 bit characters in general and ASCII in particular Not all character code use 8 bit chars. –Ex: Unicode uses 16 bit chars. Embedding the character code having different length in the framing mechanism is not possible New technique for allowing arbitrary sized characters must be needed

22 3… Starting and ending flags, with bit stuffing. It allows character codes with an arbitrary number of bits per character Each frame begins and ends with a special bit pattern, namely 01111110 What will happen if data also contain 01111110 bit pattern –???

23 3… Starting and ending flags, with bit stuffing. It allows character codes with an arbitrary number of bits per character Each frame begins and ends with a special bit pattern, namely 01111110 What will happen if data also contain 01111110 bit pattern –Whenever the sender’s data link layer encounters five consecutive 1s it stuffs a 0

24 Continue… This bit stuffing is analogous to character stuffing When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically destuffs the 0 bit

25 Bit Stuffing Example

26 4… Physical Layer Coding Violations It is applicable to NWs where the encoding on the physical medium contains some redundancy Some LAN encodes 1 bit data using 2 physical bits I.e. 1 and 0 are represented using HL and LH combination in Manchester encoding Here H and L can’t occur in data So no need of stuffing if H or L is used as a flag

27 Continue… Many data link protocols use combination of character count with other techniques It provides two ways to check for the length of frame and provides extra safety

28 Error control To ensure reliable delivery is to provide the sender with feedback of other end Receiver sends back special control frames for +ve or –ve acks If a frame is lost, then receiver does not react and do not send any acks at all –Timers are introduced in the data link layer to combat this problem

29 Continue… When the sender transmits a frame, it generally also starts a timer If timer runs out, it warns the sender The destination may receive more then one copy of a single frame –A seq number is attached to solve the same

30 Flow Control When sender sends data faster then receiver can accept them, flow control becomes imp The protocol contains well defined rules about when sender may send the next frame This rules generally prohibits the sender to send the frame until the receiver permits

31 Two approaches are commonly used Feedback-based flow control – the receiver sends back information to the sender giving it permission to send more data Rate-based flow control –the protocol has a built-in mechanism that limits the rate at which senders may transmit data,

32 Error Detection and Correction Transmission errors are fact of life so the only option available to us is to learn how to deal with them Transmission without error is not possible at all

33 Error Types Singly Error –Just one bit interchanged –Easy to catch and correct Burst Error –More than one bit interchanged –Difficult to catch and correct –If in 1000 bit long frame 35 th no bit and 134 th no bit has interchanged than it is the burst error of length 100.

34 Strategies For Handling Errors 1.Error Correcting Codes  include enough redundant information along with each block of data sent  So that the receiver can deduce what the transmitted data must have been.  Also known as forward error correction  No need of retransmission 2.Error Detecting Codes  include only enough redundancy to allow the receiver to deduce that an error occurred  Must be retransmitted

35 Where to use What On channels that are highly reliable, such as fiber retransmission is better –Error detection should be used On channels such as wireless links that make many errors retransmission is costly –Error correction strategy should be used

36 Error Correcting and Detecting Codeword –Data bits + Check bits –If Frame contains ‘m’ data bit and ‘r’ redundant bits, –Length is m + r = n

37 Error Correcting and Detecting Hamming distance –The number of bit positions in which two codewords differ is the Hamming distance –Given any two code words, say 10001001 and 10110001 it is possible to determine how many bits differ, using EXOR Ans = ???

38 Error Correcting and Detecting Hamming distance –The number of bit positions in which two codewords differ is the Hamming distance –Given any two code words, say 10001001 and 10110001 it is possible to determine how many bits differ, using EXOR Ans = 3

39 Hamming Distance of Whole code For m bit frame 2 m frames are possible –So 2 m legal codewords Because for n bit codewords –2 n codewords are possible In the list of all legal codewords two codewords having the minimum distance is hamming distance of whole code

40 Significance of Hamming Distance Hamming distance (d) tells that one codeword need ‘d’ single bit errors to be converted to another codeword To detect d errors, you need a distance d + 1 code to correct d errors, you need a distance 2d + 1 code

41 Error correcting code (Hamming code) 1.Count down the no of check bits satisfying formula (m+r+1)<=2 r 2.Check bits = 1,2,4,8,16,32,64…. 3.Data bits = 3,5,6,7,9,10,11,12,13,14,15…. 4.1 is responsible for the parity of 1,3,5,7… 5.2 = 2,3,6,7,10,11,14,15… 6.4 = 4,5,6,7,12,13,14,15… 7.8 = 8,9,10,11,12,13,14,15….

42 (Hamming code) Send the data At the receiving side from the received codeword calculate the parity of each check bit Add all the check bits which does not have right parity Answer is the bit where the error has occurred

43 Example A byte of data: 10011010 Create the data word, leaving spaces for the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0 Calculate the parity for each parity bit (a ? represents the bit position being set): Position 1 checks bits 1,3,5,7,9,11: ? _ 1 _ 0 0 1 _ 1 0 1 0. Even parity so set position 1 to a 0: 0 _ 1 _ 0 0 1 _ 1 0 1 0 Position 2 checks bits 2,3,6,7,10,11: 0 ? 1 _ 0 0 1 _ 1 0 1 0. Odd parity so set position 2 to a 1: 0 1 1 _ 0 0 1 _ 1 0 1 0

44 Example Position 4 checks bits 4,5,6,7,12: 0 1 1 ? 0 0 1 _ 1 0 1 0. Odd parity so set position 4 to a 1: 0 1 1 1 0 0 1 _ 1 0 1 0 Position 8 checks bits 8,9,10,11,12: 0 1 1 1 0 0 1 ? 1 0 1 0. Even parity so set position 8 to a 0: 0 1 1 1 0 0 1 0 1 0 1 0 Code word: 011100101010.

45 Example At the receiving side verify each check bit. Write down all the incorrect parity bits. suppose the codeword we received is 011100101011 instead of 011100101010. Parity bits 1,2 are correct Parity bits 4,8 are incorrect So at 4+8=12 th bit error has occurred.

46 Using Hamming Code for Burst Errors

47 Checking For Burst Errors k codewords are arranged as a matrix Instead of sending codeword send columns Receiver will reconstruct the matrix If burst error occurred of length k than at most one bit per codeword is incorrect and can be corrected

48 Burst Error Correction using Hamming Code

49 Error detecting codes To detect single bit error –Add parity bit to each bloke To detect burst error of length k –Divide the block in k words –Arrange k words in sequence to form matrix –Add parity bit for each column –Send the block Row-wise.

50

51 Polynomial Code or CRC Method (Second method to detect burst errors) Polynomial codes are based upon treating bit strings as representations of polynomials with coefficients of 0 and 1 only 110001 is x 5 +x 4 +x 0 In this method a generator polynomial is first agreed upon by receiver and the sender Both high and low order bits of the generator polynomial must be one

52 The Standard Polynomials Certain polynomials have become international standards. The one used in IEEE 802 is a polynomial code with r check bits will detect all burst errors of length <= r.

53 G(x) and Checksum The frame must be bigger then the generator polynomial G(x) Append the frame by 0’s No of 0’s = degree of generator polynomial G(x) The frame is divided by G(x) remainder is subtracted form frame yielding T(x) When the receiver gets the frame, it tries to divide the frame by G(x)

54 Is replaced by reminder

55 CRC at Sender Side

56 CRC at Receiver Side

57 Protocols Unidirectional Protocols –An Unrestricted Simplex Protocol –A Simplex Stop-and-Wait Protocol –A Simplex Protocol for a Noisy Channel Bidirectional Protocols (sliding window) –A One-Bit Sliding Window Protocol –A Protocol Using Go Back N –A Protocol Using Selective Repeat

58

59

60 Unidirectional Protocols An Unrestricted Simplex Protocol –No flow control –No error control A Simplex Stop-and-Wait Protocol –Flow control –No error control A Simplex Protocol for a Noisy Channel –Flow control –Error control

61 1… An Unrestricted Simplex Protocol Data are transmitted in one direction only. Both the transmitting and receiving NLs are always ready the communication channel between the data link layers never damages or loses frames thoroughly unrealistic protocol

62 Algorithm

63 Sender Receiver f2F3f4 f1 f5 to_phisical_layer(&s) from_phisical_layer(&s) No Flow Control An Unrestricted Simplex Protocol

64 2... A Simplex Stop-and-Wait Protocol Flow control –Receiver will send acknowledgement for each received frame Error control –Not present

65 Algorithm

66 Sender Receiver a0 f1 a1 to_phisical_layer(&s) from_phisical_layer(&s) With Flow Control f0 a0 A Simplex Stop-and-Wait Protocol Time 0 N

67 3… A Simplex Protocol for a Noisy Channel Flow control –Acknowledgement from receiver Error control –Lost frames Timer timeout and retransmission –Lost Acknowledgements Same but problem of duplication –Duplication Sequence no added to each frame header

68

69

70

71 Sender Receiver to_phisical_layer(&s) from_phisical_layer(&s) With Flow Control + Error Control A Simplex Protocol for a Noisy Channel a0 f1 a1 f0 a0 Normal Transmission Time 0 N

72 Case 1:- Frame Lost Sender Receiver to_phisical_layer(&s) from_phisical_layer(&s) a0 f1 a1 f0 f1 Time 0 N

73 Case 1:- Ack Lost & Duplication Sender Receiver to_phisical_layer(&s) from_phisical_layer(&s) a0 f1 a1 f0 a1 f1 Time 0 N a1

74 Sliding Window Protocols (Bidirectional Transmission) It is for bi-directional transmission Piggybacking –Ack for received frame is sent in data frame to be sent. –Frame = Data + Seq_no + Ack_no

75 Window No of buffers to store sending or receiving frame Whenever frame is sent it is stored in sending window’s buffers Whenever frame received it is stored in receiving window’s buffers

76 Window When expected ack comes from receiver, frame is discarded from sending window Whenever frame is passed to NL it is removed from receiving window

77 a) initially b) after the first frame has been sent c) after the first frame has been received d) after the ack is received A Sliding window of size 1 with three bit seq no.

78 1… A One Bit Sliding Window Protocol Bidirectional transmission Only one frame can be sent Second can be sent only after the ack of first Window size = 1 buffer only –Because only 1 bit is allotted for seq no (0 to 1) Timer is started after transmission of each frame

79 A B 0,0,b1 1,0,a2 1,1,b2 to_phisical_layer(&s) from_phisical_layer(&s) 0,1,a3 0,1,a1 0,0,b3 Time 0 N

80 A One Bit Sliding Window Protocol

81

82 Comparison

83 Moving to more sophisticated protocols Time between frame sent & ack received is considerable in real situations Pipelining:- –If sender can send frame before getting acknowledgement channel utilization increases To do this sender will need buffers to store the sent frames

84 Effect of Error

85 Sliding Window Diagram

86 Go Back N

87

88

89

90

91

92 A Protocol Using Selective Repeat Receiver is also provided by receiving window So if expected frame doesn’t come receiver can receive frame out of order instead of discarding it.

93 Algorithm

94

95

96

97

98 Window Management a) Initial Situation with WS 7 b) After 7 frames sent but not acked c ) Initial situation with a window size of four d) After four frames sent and received but not acked


Download ppt "Chapter 3 The Data Link Layer (60 % practical part)"

Similar presentations


Ads by Google