A Utopian Simplex Protocol

介绍了一种理想化的简单数据链路协议'Utopia',该协议仅支持单向数据传输,假定通信信道无错误且接收方能无限快地处理所有输入。发送方持续不断地将数据发送到线路中,而接收方则等待帧的到来并将数据传递给网络层。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

We will consider a Utopian simplex data link protocol that is as simple as it can be  because it does not worry about the possibility of anything going wrong. Data are  transmitted in one direction only. Both the transmitting and receiving network  layers are always ready. Processing time can be ignored. Infinite buffer space is  available. And best of all, the communication channel between the data link layers  never damages or loses frames. This thoroughly unrealistic protocol, which  we will nickname "Utopia", is simply to show the basic structure on which we  will build. Its implementation is shown below.
// Protocol 1 (Utopia) provides for data transmission in one direction only, from
//   sender to receiver. The communication channel is assumed to be error free
//   and the receiver is assumed to be able to process all the input infinitely quickly.
// Consequently, the sender just sits in a loop pumping data out onto the line as
//   fast as it can.
typedef enum {frame_arrival} event_type;
#include "protocol.h"
void sender1(void)
{
		frame s; 					            // Buffer for an outbound frame 
		packet buffer; 	                        // Buffer for an outbound packet
		while (true) {
				from_network_layer(&buffer);	// Go get something to send
				s.info = buffer; 		        // Copy it into s for transmission
				to_physical_layer(&s); 		    // Send it on its way
		}	
}

void receiver1(void)
{
		frame r;
		event_type event; 				    // Filled in by wait, but not used here
		while (true) {
				wait_for_event(&event); 	// Only possibility is frame_arrival
				from_physical_layer(&r); 	// Go get the inbound frame
				to_network_layer(&r.info); 	// Pass the data to the network layer
		}
}
    The protocol consists of two distinct procedures, a sender and a receiver. The sender runs in the data link layer of the source machine, and the receiver runs in the data link layer of the destination machine.
      The sender is in an infinite while loop just pumping data out onto the line as fast as it can. The body of the loop consists of three actions: go fetch a packet from the network layer, construct an outbound frame using the variable s, and send the frame on its way. Only the info field of the frame is used by this protocol, because the other fields have to do with error and flow control and there are no errors or flow control restrictions here.
     The receiver is equally simple. Initially, it waits for something to happen, the only possibility being the arrival of an undamaged frame. Eventually, the frame arrives and the procedure wait_ for_event returns, with event set to frame arrival. The call to  from_ physical_layer removes the newly arrived frame from the hardware buffer and puts it in the variable r, where the receiver code can get at it. Finally, the data portion is passed on to the network layer, and the data link layer settles back to wait for the next frame, effectively suspending itself until the frame arrives.

      The utopia protocol is unrealistic because it does not handle either flow control or error correction. Its processing is close to that of an unacknowledged connectionless service that relies on higher layers to solve these problems, though even an unacknowledged connectionless service would do some error detection.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值