Download presentation

Presentation is loading. Please wait.

Published byBranden Tripp Modified over 3 years ago

1
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 1 Chapter 3 The Data Link Layer user A user B reliable transmission over unreliable physical link

2
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 2 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues Providing a well-defined service interface to the network layer Determining how the bits of the physical layer are grouped into frames Dealing with transmission errors Regulating the flow of frames so that slow receivers are not swamped by fast senders Functions of Data Link Layer

3
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 3 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues Relationship between packets and frames

4
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 4 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Model used

5
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 5 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Three reasonable possibilities for data link services: 1. Unacknowledged connectionless service 2. Acknowledged connectionless service 3. Acknowledged connection-oriented service Why not unacknowledged connection-oriented service?

6
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 6 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Unacknowledged connectionless service 1. The source sends independent frames to the destination without the destination acknowledging them. 2. No connection is established beforehand or released afterward 3. If a frame is lost due to noise on the line, no attempt is made to recover it in the data link layer 4. Appropriate when the error rate is very low 5. Appropriate for real-time traffic, such as speech, in which late data are worse than bad data 6. Most LANs use unacknowledged connectionless service

7
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 7 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Acknowledged connectionless service Each frame sent is individually acknowledged. In this way, the sender knows whether or not a frame has arrived safely. If it has not arrived within a specified time interval, it can be sent again. It is perhaps worth emphasizing that providing acknowledgements in the data link layer is just an optimization, never a requirement. The network layer can always send a packet and wait for it to be acknowledged.

8
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 8 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Acknowledged connectionless service The trouble with this strategy is that if the average packet is broken up into, say, 10 frames, and 20 percent of all frames are lost, it may take a very long time for the packet to get through. If individual frames are acknowledged and retransmitted, entire packet get through much faster. On reliable channels, such as fiber, the overhead of a heavyweight data link protocol may be unnecessary, but on wireless channels it is well worth the cost due to their inherent unreliability.

9
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 9 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Acknowledged connection-oriented service 1. The source and the destination establish a connection before and data are transferred. 2. Each frame sent over the connection is numbered 3. The data link layer guarantees that each frame sent is indeed received. 4. Furthermore, it guarantees that each frame is received exactly once and that all frames are received in the right order. 5. Connection-oriented service provides the network layer with the equivalent of a reliable bit stream.

10
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 10 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network layer Role of Data Link Protocol The routing code frequently wants the job done right by data link protocol.

11
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 11 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing The data link uses the services provided by the physical layer. The physical layer will not be perfect. It is up to the data link layer to detect, and if necessary, correct errors. The usual approach is for the data link layer to break the bit stream up into discrete frames and compute the checksum for each frame. When a frame arrives at the destination, the checksum is recomputed. If the newly computed checksum is different from the one contained in the frame, the data link layer knows that an error has occurred and takes steps to deal with it.

12
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 12 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Breaking the bit stream up into frames is more difficult than it first appears. Four methods: 1. Character count. 2. Flag bytes with byte stuffing. 3. Flag bits with bit stuffing. 4. Physical layer coding violations.

13
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 13 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Character count Without error With one error

14
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 14 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Character count Even if the checksum is incorrect so the destination knows that the frame is bad, it still has no way of telling where the next frame starts. Sending a frame back to the source asking for a retransmission does not help either, since the destination does not know how many characters to skip over to get to the start of the retransmission.

15
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 15 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Character (or) byte-oriented

16
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 16 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Starting and ending characters A major disadvantage of using this framing method is that it is closely tied to 8-bit characters in general and the ASCII character code in particular. We need a technique to allow arbitrary sized characters.

17
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 17 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Flags (01111110) at the beginning and end Bit-oriented framing with bit stuffing

18
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 18 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.2 Framing Physical layer coding violations This method of framing is only applicable to networks in which the encoding on the physical medium contains some redundancy. For example, some LANs encode 1 bit of data by using 2 physical bits. Normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The combinations high-high and low-low are not used for data and they can be used as frame boundaries.

19
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 19 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.3 Error Control The usual way to ensure reliable delivery is to provide the sender with some feedback about what is happening at the other end of the line. Sender Data Frame Receiver Acknowledgement (ACK) Or negative Acknowledgement (NAK)

20
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 20 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.3 Error Control An additional complication comes from the possibility that hardware troubles may cause a frame to vanish completely. In this case, the receiver will not react at all. This possibility is dealt with by introducing timers into the data link layer.

21
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 21 retransmit if time-out ACK if correct correct and ordered packet error code ack error code network layer network layer physical layer physical layer SenderReceiver Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.3 Error Control

22
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 22 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.3 Error Control However, when frames may be transmitted multiple times there is a danger that the receiver will accept the same frame two or more times, and pass it to the network layer more than once. (When will this happen?) To prevent this from happening, it is generally necessary to assign sequence numbers to outgoing frames, so that the receiver can distinguish retransmissions from originals.

23
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 23 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.4 Flow Control What to do with a sender that systematically wants to transmit frames faster than the receiver can accept them? The usual solution is to introduce flow control to throttle the sender into sending no faster than the receiver can handle the traffic. This throttling generally requires some kind of a feedback mechanism, so the sender can be made aware of whether or not the receiver is able to keep up.

24
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 24 Chapter 3 The Data Link Layer 3.1 Data Link Layer Design Issues 3.1.4 Flow Control Various flow control schemes are known, but most of them use the same basic principle. The protocol contains well-defined rules about when a sender may transmit the next frame. These rules often prohibit frames from being sent until the receiver has granted permission, either implicitly or explicitly. Feedback-based flow control Rate-based flow control

25
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 25 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction Transmission errors are going to be a fact of life for many years to come. (in local loop, in wireless communications) As a result of the physical processes that generate them, errors on some media (e.g., radio) tend to come in bursts rather than singly.

26
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 26 error model: bursty errors every packet would be in error bursty error, only one packet is incorrect Chapter 3 The Data Link Layer 3.2 Error Detection and Correction Advantage: Disadvantage: They are much harder to detect and correct than isolated errors.

27
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 27 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes m data bitsr check bits codeword There are 2 n possible codewords and 2 m possible data messages. Hamming distance between codewords: min d(C 1,C 2 )=number of (same bit position) bits which differ d(10010010,00010001)=3 n=m+r, code rate=m/n If two codewords are a hamming distance d apart, it will require d single-bit errors to convert one into the other.

28
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 28 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes In most data transmission applications, all 2 m possible data messages are legal, but due to the way the check bits are computed, not all 2 n possible codewords are used. Given the algorithm for computing the check bits, it is possible to construct a complete list of codewords, and from this list find the two codewords whose Hamming distance is minimum. This distance is the Hamming distance of the complete code.

29
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 29 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes To detect d errors, you need a distance d+1 code. d+1 radius=d bits distance

30
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 30 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes <2d+12d+1 radius=d bits To correct d errors, you need a distance 2d+1 code.

31
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 31 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes Parity check is a code with distance 2. Therefore, it can detect single-bit error. Consider a code with only 4 valid codewords: 0000000000, 0000011111, 1111100000, 1111111111 This code has a distance of 5, which means that it can detect double errors. If the codeword 0000000111 arrives and we know at most two bits are in error, the receiver knows that the original must have been 0000011111. If, however, a triple error changes 0000000000 into 0000000111, the error will not be corrected properly.

32
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 32 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes m data bitsr check bits In a block code, the r check bits are computed solely as a function of the m data bits with which they are associated. In a systematic code, the m data bits are sent directly, along with the check bits, rather than being encoded themselves before they are sent. In a linear code, the r check bits are computed as a linear function of the m data bits.

33
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 33 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes A 1-bit error correcting code (Hamming code) m data bitsr check bits n=m+rn=m+r Each of the 2 m legal messages has n illegal codewords at a distance 1 from it. Thus each of the 2 m legal messages requires n+1 bit patterns dedicated to it. Therefore,

34
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 34 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes A 1-bit error correcting code (Hamming code) Given m, this puts a lower limit on the number of check bits needed to correct single errors. This theoretical lower limit can, in fact, be achieved using a method due to Hamming. The bits of codewords are numbered consecutively, starting with bit 1 at the left end. The bits that are power of 2 (1, 2, 4, 8, …) are check bits. The rest are filled up with the data bits. Each check bit forces the parity of some collection of bits, including itself, to be even (or odd).

35
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 35 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes A 1-bit error correcting code (Hamming code) Correct 12-bit burst errors by transmitting vertically.

36
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 36 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes A 1-bit error correcting code (Hamming code) When a codeword arrives, the receiver initializes a counter to zero. It then examines each check bit, k, to see if it has the correct parity. If not, it adds k to the counter. If the counter is zero afterwards, the codeword is accepted as valid. If the counter is nozero, it contains the number of the incorrect bit. (Using even parity)

37
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 37 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes A 1-bit error correcting code (Hamming code)

38
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 38 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes Convolutional Code Input=111, output=11 10 01 (assuming all internal states are 0) Code rate=1/2, constraint length=7 Decoding using Viterbi algorithm

39
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 39 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes Reed-Solomon Code RS codes are based on the fact that every n degree polynomial is uniquely determined by n+1 points. For m bit symbols, the codewords are 2 m -1 symbols long. m=8 for bytes, a codeword is then 255 bytes long. (255,223) code: add 32 redundant symbols to 223 data symbols

40
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 40 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.1 Error-Correcting Codes Low-Density Parity Check (LDPC) Code codeword Parity checks 8 possible 6-bit strings corresponding to valid codewords: (000000, 011001, 110010, 101011, 111100, 100101, 001110, 010111)

41
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 41 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes error control:error detection or error correction? assume error rate=1/10 6 data=1000 bits error detecting check bits: 1 bit (e.g. parity check) error correcting check bits: 10 bits (e.g. Hamming code) In 10 3 packets: error detecting overhead=10 3 +1001=2001 bits error correcting overhead=10*10 3 bits=10000 bits retransmission Therefore, error correction codes is used in some critical situation. For example, real-time memory system (in space shuttle).

42
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 42 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes Parity

43
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 43 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes Parity

44
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 44 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes Checksum

45
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 45 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes Checksum 479c+2=479e --->1’s complement --->b861 Computing checksum Checking checksum fffd+2=ffff --->1’s complement --->0000 An IP packet

46
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 46 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes CRC (Cyclic Redundancy Code) Treat bit strings as polynomials with coefficient 0 and 1. (E.g. 10001001:x 7 +x 3 +1, 01010111=x 6 +x 4 +x 2 +x+1) 1. Sender and receiver agree upon a polynomial of degree r. (the generating polynomial, G(x)) 3. When receiver receives T(x), it divides it by G(x). If there is a remainder, then an error has occurred. (All the above operations are done in modulo 2.)

47
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 47 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes

48
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 48 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes

49
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 49 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes error detecting capabilities of CRC E(x): error (E.g., E(x)=x 5 +x+1 means bits 0,1,6 are in error) Errors can go undetected if T(x)+E(x) can be divided by G(x) with no remainder. If there are k 1 bits in E(x), k single-bit errors have occurred. A single burst error is characterized by an initial 1, a mixture of 0s and 1s, and a final 1, with all other bits being 0.

50
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 50 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes error detecting capabilities of CRC 1. single bit error E(x)=x i if G(x) contains a constant term, then E(x)/G(x) will have remainder. 2. odd number of bits in error Assume E(x)=G(x)Q(x). If we let G(x) has even number of terms, then when x=1, E(1)=1 but G(1)=0, a contradiction. Or G(x) containing a factor of (x+1) will also do. CRC-CCITT: x 16 +x 12 +x 5 +1

51
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 51 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes error detecting capabilities of CRC 3. If there have been two isolated single-bit errors, E(x)=x i +x j, where i>j. E(x)=x i +x j =x j (x i-j +1) If we assume that G(x) is not divisible by x, a sufficient condition for all double errors to be detected is that G(x) does not divide x k +1 for any k up to the maximum value of i-j (i.e., up to the maximum frame length). Simple, low-degree polynomials that give protection to long frames are known. For example, x 15 +x 14 +1 will not divide x k +1 for any value of k below 32768.

52
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 52 Chapter 3 The Data Link Layer 3.2 Error Detection and Correction 3.2.2 Error-detecting Codes error detecting capabilities of CRC Finally, and most important, a polynomial code with r check bits will detect all burst errors of length less than r. If the burst length is r+1, the remainder of the division by G(x) will be zero if and only if the burst is identical to G(x), which has a probability of 1/2 r-1 (excluding the first and the last bits).

53
Local Area Networks by R.S. Chang, Dept. CSIE, NDHU 53 Chapter 3 The Data Link Layer Problems: 1, 2, 3, 4, 7, 9, 15, 16

Similar presentations

OK

PART III DATA LINK LAYER. Position of the Data-Link Layer.

PART III DATA LINK LAYER. Position of the Data-Link Layer.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on film industry bollywood dance Ppt on bluetooth hacking device Ppt on ministry of corporate affairs of india Ppt on origin of english language Ppt on care of public property auction Ppt on column chromatography youtube Ppt on network analysis Module architecture view ppt on android Ppt on economic growth Best ppt on motivation