A Utopian Simplex Protocol

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.

你可能感兴趣的:(Computer,Networks)