Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3 The Data Link Layer. Data Link Layer Describes how a shared communication channel can be accessed, and how a data frame can be reliably transmitted.

Similar presentations


Presentation on theme: "Chapter 3 The Data Link Layer. Data Link Layer Describes how a shared communication channel can be accessed, and how a data frame can be reliably transmitted."— Presentation transcript:

1 Chapter 3 The Data Link Layer

2 Data Link Layer Describes how a shared communication channel can be accessed, and how a data frame can be reliably transmitted. We’ll just concentrate on transmission issues. Channel access is discussed in Chapter 4

3 Topics Design Issues Framing Reliable Transmission  Error Control  Flow Control  Six Protocols HDLC PPP

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

5 Functions of the Data Link Layer Provide a well-defined service interface to the network layer Dealing with transmission errors Regulating data flow  Slow receivers not swamped by fast senders

6 3.1.1 Services Provided to Network Layer

7 DLL Between Routers

8 The DDL and PHY The PHY delivers raw sequence of bits.  Unreliable service. The DLL must detect and, in some cases, correct errors.

9 Services Provided to Network Layer (2) Basic services commonly provided by data link layer:  unacknowledged connectionless service (LANs)  acknowledged connectionless service (Wireless systems).  acknowledged connection-oriented service (WANs).

10 3.1.2 Framing The physical layer doesn’t do much: it just pumps bits from one end to the other. But things may go wrong The data link layer needs a means to do retransmissions. The unit of retransmission is a frame (which is just a fixed number of bits). Four methods for breaking up a bit stream into frames: Character count, Flag bytes with byte stuffing, Starting and ending flags with bit stuffing and Physical layer coding violations.

11 framing End node End node frame

12 Character Count This method uses a field in the header to specify the number of characters in the frame. When the data link layer at the destination sees the character count, it knows how many characters follow and hence where the end of the frame is. The trouble with this algorithm is that the count can be garbled by a transmission error. The character count method is rarely used anymore.

13 Flag bytes with byte stuffing This method gets around the problem of resynchronization after an error by having each frame start and end with special bytes (flag byte). Byte stuffing: when flag byte's bit pattern occurs in the data, insert a special escape byte (ESC) just before each ''accidental'' flag byte in the data. (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing.

14 Starting and ending flags with bit stuffing Each frame begins and ends with a special bit pattern, 01111110 (in fact, a flag byte) Bit stuffing: Whenever the sender's data link layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit into the outgoing bit stream. (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.

15 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 use Manchester  Encoding where a 1 bit is a high-low pair and a 0 bit is a low-high pair. And the combinations high- high and low-low are not used for data but are used for delimiting frames in some protocols.

16 例如采用曼彻斯特编码或差分曼彻斯特编码中 1/2 位周期处不跳变的违例码来标示帧边界。 使用差分曼彻斯特编码的 IEEE 802.5 令牌环网 中: 帧的起始符: JK0JK000 帧的结束符: JK1JK1IE 其中 J 为 “1” 的违例码; K 为 “0” 的违例码; I 表 示后继帧位; E 为差错检测位。 帧的其它地方绝对不会出现这样的边界码字。

17 3.1.3 Error Control Reliable delivery.  Hop-by-hop! Detecting errors. Detecting and correcting errors.

18 Error Control(2) Acknowledgment: receiver will send back special control frames bearing positive or negative acknowledgements about the incoming frames. If the sender receives a positive acknowledgement about a frame, it knows the frame has arrived safely. On the other hand, a negative acknowledgement means that something has gone wrong, and the frame must be transmitted again. Timer: when the sender transmits a frame, it generally also starts a timer. The timer is set to expire after an interval long enough for the frame to reach the destination, be processed there, and have the acknowledgement propagate back to the sender. If either the frame or the acknowledgement is lost, the timer will go off, alerting the sender to retransmission

19 3.1.4 Flow control Feedback-based flow control Rate-based flow control

20 3.2 Error Detection and Correction Error Detection and Retransmission: to include only enough redundancy to allow the receiver to deduce that an error occurred, but not which error (error-detecting codes ), and have it request a retransmission. Forward Error Correction: to include enough redundant information along with each block of data sent (error-correcting codes ), to enable the receiver to deduce what the transmitted data must have been. Consider a frame (or codeword) consists of m data bits and r redundant, or check, bits (let n = m + r). 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 of the 2 n possible codewords are used.

21 A Simplex Protocol for a Noisy Channel Let’s drop the assumption that the channel is error free. We do assume that damaged frames can be detected, but also that frames can get lost entirely. Problems: A sender doesn’t know whether a frame has made it (correctly) to the receiver. Solution: let the receiver acknowledge undamaged frames. Frame (acknowledgments) may get lost. Solution: let the sender use a timer by which it simply retransmits unacknowledged frames after some time. The receiver cannot distinguish duplicate transmissions. Solution: use sequence numbers. Sequence numbers cannot go on forever: we can (and need) only use a few of them. In our example: we need only two (0 & 1).

22 A Simplex Protocol for a Noisy Channel A positive acknowledgement with retransmission protocol.

23 A Simplex Protocol for a Noisy Channel (ctd.)

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

25 From Simplex to Duplex Problem: We want to allow symmetric frame transmission between two communicating parties, rather than transmission in one direction. Don’t waste channels, so use the same channel for duplex communication. Principle: Just transmit frames, but distinguish between data, acknowledgments (acks), and possibly negative acks (nacks) in the frame’s type field. piggybacking: The technique of temporarily delaying outgoing acknowledgements so that they can be hooked onto the next outgoing data frame

26 Sliding Windows Principle: Rather than just sending a single frame at a time, permit the sender to transmit a set of frames Sending window: maintains a set of sequence numbers corresponding to frames that have been sent but are as yet not acknowledged. Receiving Window: maintains a set of sequence numbers corresponding to frames it is permitted to accept

27 Sliding Windows (2)

28 A One-Bit Sliding Window Protocol

29 A One-Bit Sliding WindowProtocol (ctd.)

30 A One-Bit Sliding Window Protocol (2)

31 Pipelining The rule requiring a sender to wait for an acknowledgement before sending another frame could lead to low bandwidth efficiency for long roundtrip communications Pipelining: allowing the sender to transmit up to w frames before the first acknowledgement arrives Pipelining could achieve much better efficiency. With an appropriate choice of w, pipelining can be used to keep the line busy (i.e. 100%efficiency) If the channel capacity is b bps, the frame size l bits, and the round-trip propagation time R sec, the efficiency for stop- and-wait is l/(l+bR), and the maximum window size for pipelining is [ (l+bR)/l ].

32 Error Control in Pipelining What should the receiver do if a frame in the middle of a long stream is damaged or lost when large numbers of succeeding frames will arrive at the receiver before the sender even finds out that anything is wrong? Go-Back-N: Simply request retransmission of all frames starting from frame #N. If any other frames had been received in the meantime (and stored in the receiver’s window), they’ll just be ignored Selective Repeat: Request just retransmission of the damaged frame, and wait until it comes in before delivering any frames after that Selective repeat is often combined with having the receiver send a Negative Acknowledgement (NAK) when it detects an error. NAKs stimulate retransmission before the corresponding timer expires and thus improve performance.

33 Sliding Window Protocol (3) — continuous ARQ

34

35

36 Selective repeat ARQ

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57 Example Data Link Protocols HDLC – High-Level Data Link Control PPP – The Point-to-Point Protocol Recall the Data Link Layer Protocols: The data link layer is responsible for transmitting frames from sender to receiver. It can use only the physical layer, which supports only transmission of a bit at a time. The DLL has to take into account that transmission errors may occur=>error control (ACKs, NACKs, checksums, etc.) The DLL has to take into account that sender and receiver may operate at different speeds =>flow control (windows, frame numbers, etc.)

58 High-Level Data Link Control HDLC: A pretty old, but widely used protocol for point- to-point connections. Is bit-oriented. Frame format for bit-oriented protocols. Address: 0 unicast address 1: multicast address

59 High-Level Data Link Control (2)-cont The protocol uses a sliding window, with a 3-bit sequence number. The Seq field is the frame sequence number. The Next field is a piggybacked acknowledgement. The various kinds of Supervisory frames are distinguished by the Type field. E.g. Type 0 is an acknowledgement frame, Type 1 is a negative acknowledgement frame, Type 2 is RECEIVE NOT READY, and Type 3 is the SELECTIVE REJECT.

60 command(B) response(B) command(B/C/D) Command (B) Command (A) Response (B) Response (A) response(B) response(C) response(D) Primary A Secondary B Secondary C Secondary D Compound ACompound B Unbalancing config : point-point Unbalancing config : point-multi point Balancing config HDLC (High Level Data Link Control)

61 HDLC frame format F InfoCAFFCS 8 位 16> 08 8 8 Check field  flag : F“01111110”indentify start and stop of the frame  Address A : unbalancing mode , secondary’s address balancing mode , response station’s address  FCS : CRC-CCITT16 , G(x) = x 16 + x 12 + x 5 + 1  Control C : identify the type of the frame , and supplementary control informaiton

62 Control field

63  The type of the supervisory frame S = 00 RR ( Receive Ready ), 准备接收下一帧, 确认 N(R)-1 及以前的各帧 01 RNR ( Receive Not Ready ), 暂停接收下一帧, 确认 N(R)-1 及以前的各帧 10 REJ ( Reject ), 否认自 N(R) 开始的帧 确认 N(R)-1 及以前的各帧 11 SREJ (Selective Reject), 只否认 N(R) 帧 确认 N(R)-1 及以前的各帧

64  P/F 位的意义(询问 / 终止) = 0 无意义 = 1 非平衡配置 正常响应方式 主站 S/I 帧 P=1 (命令) S/I 帧 (响应) I 中 F=1 ,表示最后一个数据帧 S 中 F=1 ,表示此时没有数据要发送 从站 NRM 异步响应方式 ARM 平衡配置 异步平衡方式 ABM P=1 (询问) F=1 (回答本站状态) 命令方 响应方

65 P/F 比特用法举例: 命令 (B/C) 响应 (B) 响应 (C) 主站 A 从站 B 从站 C A B,C B,RR0,P B,I00 B,I01 B,I02 B,I03,F B,RR4 C,RR0,P C,RR0,F

66  无编号帧,定义了 15 种,起控制作用  建立数据链路: 正常响应方式,置正常响应方式 SNRM 异步平衡方式,置异步平衡方式 SABM  拆除数据链路:断连命令 DISC  对命令的确认:无编号确认 UA  帧拒绝 FRMR :表示通过重发仍不能纠正的错误, 如收到非法命令,帧中的控制字段无效,数据字段过 长, N(R) 无效,监督帧或无编号帧长度错误等等  携带信息( I 字段)的无编号帧:无编号信息 UI , 用于数据链路层管理的数据

67  数据链路连接建立和拆除示例 B,SNRM,P B,UA,F 主站 A 从站 B , C A 与 B 建 立连接 A 与 C 建 立连接 C,SNRM,P C,UA,F 省略数据传送阶段 B,DISC,P B,UA,F C,DISC,P C,UA,F A 与 B 释 放连接 A 与 C 释 放连接 B,SABM,P B,UA,F A,DISC,P A,UA,F 复合站 A 复合站 B A 与 B 建 立连接 B 与 A 释 放连接 异步平衡方式 正常响应方式 省略数据传送阶段 Set Asynchronous Balanced Mode Set Normal Response Mode Unnumbered Acknowledgment

68 PPP – Point to Point Protocol The PPP (Point-to-Point Protocol) is used in the Internet for a variety of purposes, including router-to router traffic and home user-to-ISP traffic. PPP provides three features:  A framing method that unambiguously delineates the end of one frame and the start of the next one.  A Link Control Protocol (LCP) for bringing lines up, testing them, negotiating options, and bringing them down again gracefully when they are no longer needed.  The different NCP (Network Control Protocol) for each network layer supported to negotiate network-layer options in a way that is independent of the network layer protocol to be used.

69 PPP – Point to Point Protocol(2) The PPP frame format was chosen to closely resemble the HDLC frame format. The major difference between PPP and HDLC is that PPP is character oriented rather than bit oriented. PPP is a multiprotocol framing mechanism. The Protocol field is used to tell what kind of packet is in the Payload field. Codes are defined for LCP, NCP, IP, IPX, AppleTalk, and other protocols.

70 PPP Frame PPP 有一个 2 个字节的协议字段。  当协议字段为 0x0021 时, PPP 帧的信息字段就是 IP 数 据报。  若为 0xC021, 则信息字段是 PPP 链路控制数据。  若为 0x8021 ,则表示这是网络控制数据。 IP 数据报 1211 字节 12 不超过 1500 字节 PPP 帧 先发送 7EFF03 F A C FCS F 7E 协议 信 息 部 分 首部尾部

71 Character oriented 将信息字段中出现的每一个 0x7E 字节转变成为 2 字节序列 (0x7D, 0x5E) 。 若信息字段中出现一个 0x7D 的字节, 则将其转变 成为 2 字节序列 (0x7D, 0x5D) 。 若信息字段中出现 ASCII 码的控制字符(即数值 小于 0x20 的字符),则在该字符前面要加入一 个 0x7D 字节,同时将该字符的编码加以改变。 01111110  01111101,01011110 01111101  01111101.01011101

72 用户拨号入网的示意图 路由器 调制解调器 因特网服务提供者 (ISP) 用户家庭 拨号电话线 使用 TCP/IP 的 PPP 连接 使用 TCP/IP 的 客户进程 路由选择 进程 至因特网至因特网 … PC 机

73 Phase Diagram for PPP

74 Assignments 5,7,17,19

75


Download ppt "Chapter 3 The Data Link Layer. Data Link Layer Describes how a shared communication channel can be accessed, and how a data frame can be reliably transmitted."

Similar presentations


Ads by Google