您的位置:首页 > 其它

!!!Chapter 3 The Data Link Layer

2013-12-12 02:33 363 查看

3.1 Data Link Layer Design Issues

Providing a well-defined service interface to the network layer.
Dealing with transmission errors.
Regulating the flow of data so that slow receivers are not swamped by fast senders.
The data link layer takes the packets it gets from the network layer and encapsulate them intoframes for transmission.

A frame contains a frame header, a payload field and a frame trailer.

3.1.1 Services Provided to the Network Layer

数据链路层使用物理层提供的服务,为网络层提供服务。
数据链路层提供的服务可以归为以下三种基本服务:

(1) 无确认的无连接服务 Unacknowledged connectionless service:

源机器向目的机器发送独立的帧,而目的机器对收到的帧不作确认。事先没有建立连接,事后也不存在释放。传输质量不可靠,这类服务适用于误码率很低的情况。大多数局域网在数据链路层都使用无确认的无连接服务.

(2)有确认的无连接服务 Acknowledged connectionless service:
不建立连接,但所发送的帧都进行确认。所以发送方知道帧是否安全到达。这类服务适用于无线系统之类的不可靠信道。

(3)有确认的面向连接的服务 Acknowledged connection-oriented service:
建立连接,在连接上发送帧,所发送的每一帧都被编上号,数据链路层保证所发送的每一帧都是安装顺序已收到一次。这种服务最可靠,但最复杂,不容易实现。

3.1.2 Framing

Byte count
Flag bytes with byte stuffing
Flag bits with bit stuffing
Physical layer coding violation
http://www.baike.com/wiki/%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82

3.1.3 Error Control

接收方发回特殊的控制帧,作为帧正确与否的确认帧。但是更糟糕的不是仅仅帧有错,而是帧完全没有到达,发送方可用计时器来解决这个问题。当发送一帧时,启动计时器,一定时间内帧被正确接收并返回确认帧,则计时器清零。有了超时重传,可能会造成同一帧的多次重传,这时可以给各帧编号,以解决这个问题。

3.1.4 Flow Control

通过某种反馈机制,使发送方了解接收方的接收能力,从而调整发送

3.2 Error Detection and Correction

Error-correcting codes: include enough redundant information to enable the receiver to deduce what the transmitted data must have been.
Error-detecting codes: include enough only enough redundancy to allow the receiver to deduce that an error has occurred and have it request a retransmission.

3.3 Elementary Data Link Protocols

The physical layer process and some of the data link layer process run on dedicate hardware called aNIC (Network Interface Card) 网卡

The rest of the link layer process and the network layer process run on the main CPU as part of the operating system, with the software for the link layer process often taking the form of a device driver.  驱动程序



协议设计

(1)物理层服务:

               to_physical_layer();               //用于发送帧

               from_physical_layer();             //用于接收帧

(2)数据链路层:

               wait_for_event(&event);          //等待事件发生(如帧的到来),event返回发生事情。

(3)网络层:

               from_network_layer();             //接收从网络层来的分组

               to_network_layer();                 //将分组返回给网络层

(4)数据结构:

             #define MAX_PKT 1024                                                //分组最大长度

             typedef unsigned int seq_nr;                                        //给帧编号

             typedef enum {false,true} boolean;

             typedef struct {unsigned char data[MAX_PKT];}packet;//分组数据结构

             typedef enum{data,ack,nak}frame_kind;                       //帧类型

             typedef struct{

                 frame_kind kind;

                 seq_nr seq;

                 seq_nr ack;

                 packet info;

             }frame;                                                                         //帧的数据结构

Utopian simplex protocol
simplex stop-and-wait protocol for an error-free channel

3.4 Sliding Window Protocols

piggybacking(捎带): The technique of temporarily delaying outgoing acknowledgements so that they can be hooked onto the next outgoing data frame.

双工通信:

(1)帧头部要加上一个kind字段,以区分数据帧和确认帧。

(2)确认帧附加在数据帧上:当一个数据帧到达后,接收过程不是立即发送一个独立的控制帧,而是等到网络层有分组传来,让后把确认信息附加上去一起发送出去。这种技术叫捎带(piggybacking),捎带能较好的利用有效的信息带宽。但是,如果网络层一直没有要服务的分组,那么就会一直等待,改进的方案就是等待一个固定的毫秒数,如果等不到,数据链路层只好法一个单独的确认帧了.
滑动窗口(sliding window)协议:每一个要发出的帧都包含一个序号,范围从0到某个最大值(通常是

,这样序号就为n,特殊的,停-等滑动窗口协议n=1,限制序号为0和1)。任何时刻,发送进程都保持一组序号,对应于允许发送的帧。这些帧称作在发送窗口(sending
window)之内。接收过程也维持一个接收窗口(receiving window),对应一组允许接收的帧。
缓冲区:用于保存已发送但是未收到确认的帧,以被重传。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: