第三章数据链路层(2) 3.3数据链路协议 3.4协议描述与验证 3.5链路通信规程举例
第三章 数据链路层 (2) ◼ 3.3 数据链路协议 ◼ 3.4 协议描述与验证 ◼ 3.5 链路通信规程举例
可靠递交 差错帧: ■丢失帧:比如比较长的突发噪声造成帧完全 丢失 ■毁坏帧:帧到达接收者,但是帧的检验和不 对 ARQ: Automatic Repeat request 对收到的帧发送确认 ■如果超时并且没有收到确认,则重传帧
可靠递交 ◼ 差错帧: ◼ 丢失帧:比如比较长的突发噪声造成帧完全 丢失 ◼ 毁坏帧:帧到达接收者,但是帧的检验和不 对 ◼ ARQ:Automatic Repeat Request ◼ 对收到的帧发送确认 ◼ 如果超时并且没有收到确认,则重传帧
停等协议(1) 停等协议( Stop-and-Wait) 发送者在发送一个帧之后停下来,等待对方确认后继续发送 下一帧。如果确认在一段时间后无返回,发送者超时,重传 帧 Sender 简单版本(协议有问题!) while(1)i Receiver transmit(frame 1) receive(frame) transmit(ack) receive(ack) 3 catch(timeout)i continue H++; break
停等协议(1) ◼ 停等协议(Stop-and-Wait) ◼ 发送者在发送一个帧之后停下来,等待对方确认后继续发送 下一帧。如果确认在一段时间后无返回,发送者超时,重传 帧。 Sender ◼ 简单版本(协议有问题!) while (1) { transmit (frame i); try { receive (ack); } catch (timeout) { continue; } i++; break; } Receiver receive (frame); transmit (ack);
发送者 接收者 发送者 接收者 Frame Frame 超 超 时ACK 时 Frame ACK 发送者 接收者 发送者 接收者 Frame F 超 ACK 超 ACK 时 Frame Frame ACK ACK
发送者 超 时 接收者 Frame ACK 发送者 超 时 接收者 Frame ACK Frame ACK 发送者 超 时 接收者 Frame ACK Frame ACK 发送者 超 时 接收者 Frame Frame ACK
停等协议(2) 帧中包含顺序号(1比特)字段,确认也包含顺序号 发送方维护 next frame to send,接收方维护 frame_expected Sender Receiver while(1)i transmit (frame next frame to send frame_expected=0; try i while (1) while (1)i receive(ack n) receive(frame n) if(n=nextframe_to_send continue; ack(frame n) break if(n =frame_expected) i catch(timeout)i continue; continue? break next frame to send++ break: frame_expected +
停等协议(2) ◼ 帧中包含顺序号(1比特)字段,确认也包含顺序号 ◼ 发送方维护next_frame_to_send,接收方维护frame_expected Sender while (1) { transmit (frame next_frame_to_send); try { while (1) { receive (ack n); if (n != next_frame_to_send) continue; break; } } catch (timeout) { continue; } next_frame_to_send ++; break; } Receiver frame_expected = 0; while (1) { receive (frame n); ack (frame n); if (n != frame_expected) continue; break; } frame_expected ++;