750 likes | 1.08k Views
The Data Link Layer. Chapter 3. The Model. transport layer protocol. hostA. hostB. DLL protocol. DLL protocol. node1. node2. node3. logical path. Logical path. physical path. physical path. data link/logical link = ( physical ) link + procedure.
E N D
The Data Link Layer Chapter 3
The Model transport layer protocol hostA hostB DLL protocol DLL protocol node1 node2 node3 logical path Logical path physical path physical path data link/logical link= (physical)link + procedure digital channel provided by DLL physical line DLL protocol
Data Link Layer Design Issues(p176) • Services Provided to the Network Layer • Framing • Error Control • Flow Control
Functions of the Data Link Layer(p176) • Provide service interface to the network layer • Dealing with transmission errors • Regulating data flow • Slow receivers not swamped by fast senders
Functions of the Data Link Layer (2) Relationship between packets and frames.
Services Provided to Network Layer (a) Virtual communication. (b) Actual communication.
Services Provided to Network Layer(2) • Unacknowledged connectionless service • Low error-rate line or real-time traffic • Acknowledged connectionless service • Wireless system • Acknowledged connection-oriented service • Transfer have 3 phases: connection setup, transmit & receive, connection release
Services Provided to Network Layer (3) Placement of the data link protocol.
Framing method(p179) • Character count • Starting and ending characters, with character stuffing • Starting and ending flags, with bit stuffing • Physical layer coding violations
Character count A character stream. (a) Without errors. (b) With one error.
Character stuffing (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing.
Character stuffingBisync SYN SYN DLE STX A DLE DLE B DLE DLE C DLE ETX 同步字符 帧首 数据 帧尾 传输帧 填充字符
Bit stuffing 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.
Bit stuffingHDLC 帧首 数据 帧尾 01111110 01111110 01111101101111100 填充位
Physical layer coding violation Manchester differential Manchester
Error control(p182) • Provide sender with some feedback( positive or negative acknowledgements) • When sender transmit a frame, it starts a timer • To prevent duplicate frames accepted by receiver, sender assignssequence numbers to each frame
Flow control • Fast sender could swamp the slow receiver • Throttle the sender with a kind of feedback mechanism
Error Detection and Correction • Error-Correcting Codes • Error-Detecting Codes
Error-Correcting Codes • Hamming distance The number of bit positions in which two codeword differ • To detect d errors, you need a distance d + 1 code • A code with a single parity bit has a distance 2, so it can be used to detect single errors • To correct d errors, you need a distance 2d + 1code • Consider n bits codeword with m bits message bits and r check bits, each 2m legal messages requires n+1 bit patterns, total number of bit patterns is 2n ,so we must have (n + 1)2m <=2n ,or (m+r+1)2m<=2n
Error-Correcting Codes-1 Use of a Hamming code to correct burst errors.
Error-Correcting Codes-2 • m=7, r=4, the bits that are power of 2 are check bits • Since 3=1+2, 5=1+4, 6=2+4, 7=1+2+4, 9=1+8, 10=2+8, 11=1+2+8 • Compute check bits using following equation • b1=b3+b5+b7+b9+b11 • b2=b3+b6+b7+b10+b11 • b4=b5+b6+b7 • b8=b9+b10+b11 • Hamming codes can only correct single errors, we can use interleave method to correct burst errors,
Error-Detecting Codes • Generator polynomial G(x) • Algorithm for computing the checksum: • Let r be the degree of G(x). Append r zero bits to the low-order end of the frame so it now contains m+r bits and corresponds to the polynomial xrM(x). • Divide the bit string corresponding to G(x) into the bit string corresponding to xrM(x), using modulo 2 division. • Substract the remainder (which is always r or fewer bits) from the bit string corresponding to xrM(x) using modulo 2 substration. The result is the checksummed frame to be transmitted. Call its polynomial T(x).
Error-Detecting Codes-1 Calculation of the polynomial code checksum.
Elementary Data Link Protocols • An Unrestricted Simplex Protocol • A Simplex Stop-and-Wait Protocol • A Simplex Protocol for a Noisy Channel
Protocol Definitions(p194) Continued Some definitions needed in the protocols to follow. These are located in the file protocol.h.
Protocol Definitions(ctd.) Some definitions needed in the protocols to follow. These are located in the file protocol.h.
Unrestricted Simplex Protocol 结点A 结点B 从 主 机 取 数 据 DATA1 DATA2 上 交 主 机 DATA3 DATA4 理想信道
Simplex Stop-and-Wait Protocol 结点A 结点B 从 主 机 取 数 据 DATA1 上 交 主 机 ACK DATA2 ACK 具有简单流量控制的数据链路层协议
A Simplex Protocol for a Noisy Channel 超时 超时 发送方 frame i+2 ACKi+1 frame i ACK i+2 ACK i+3 framei+3 frame i+2 framei+3 ACKi frame I+1 ACK i+3 接收方 ACK丢失 帧丢失 重发, 丢弃重复帧 重发
A Simplex Protocol for a Noisy Channel(p201) A positive acknowledgement with retransmission protocol. Continued
A Simplex Protocol for a Noisy Channel (ctd.) A positive acknowledgement with retransmission protocol.
Sliding Window Protocols • A One-Bit Sliding Window Protocol • A Protocol Using Go Back N • A Protocol Using Selective Repeat
Sliding Window Protocols (2)(p204) A sliding window of size 1, with a 3-bit sequence number. (a) Initially. (b) After the first frame has been sent. (c) After the first frame has been received. (d) After the first acknowledgement has been received.
A One-Bit Sliding Window Protocol(p205) Continued
A One-Bit Sliding Window Protocol (2)(p207) 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.
A Protocol Using Go Back N(p208) Pipelining and error recovery. Effect on an error when (a) Receiver’s window size is 1. (b) Receiver’s window size is large.
Sliding window Premise: In ARQ protocol,we must limit the maximum frames sent continuously, because sequence also take frame space Sending window: size is WT , the maximum frames can be sent before ACK frame received Receiving window: size is WR , the maximumframes can be received WT+WR<=2n WT<=2n-1
Sliding window(2) Frames sent without receiving ACK and frames will be send Frames sent successfully Sending buffer 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 sequence lower upper Frames received correctly Frames will be received Receiving buffer 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 upper lower sequence
Sliding window(3) 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0,1,2 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ACK3 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 3,4,5,6 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ACK7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Sliding window(4) T T H 0 7 0 7 6 1 6 1 5 2 5 2 4 4 3 3 H T T 0 7 0 7 6 1 6 1 H 5 2 5 2 4 4 3 3 H T 7 0 7 0 6 1 6 1 T 5 5 2 H 2 4 3 4 3 H WT = 5 WR = 1 initially Initially receive 0, send ACK0 send 0 and 1 send 2, receive ACK0 receive 1, send ACK1
Sliding window(5) T 7 0 7 0 1 6 6 1 T 5 5 H 2 2 4 3 4 3 H T 7 0 7 0 6 1 6 1 T 5 5 H 2 2 4 3 4 3 H H 7 0 7 0 6 1 6 1 T 5 5 2 2 4 3 4 3 T H Receive 3, but not 2 send 3, 4 discard 3 接收到重传 的帧1 timeout, retransmit 1 discard 1, retransmit ACK1 receive 2 receive ACK1
Sliding Window Protocol Using Go Back N(p210) Continued
Sliding Window Protocol Using Go Back N Continued
Sliding Window Protocol Using Go Back N Continued
Sliding Window Protocol Using Go Back N (2)(p213) Simulation of multiple timers in software.
A Sliding Window Protocol Using Selective Repeat(p216) Continued