You are to write the
clientInput()
,clientOutput()
,clientTimerInterrupt()
,clientCanSendMorePkt()
,clientInit()
,clientEnd()
,serverInput()
,serverInit()
, andserverEnd()
functions which together will implement a stop-and-wait (aka alternating bit) protocol, (which Kurose and Ross refer to as rdt3.0) unidirectional transfer of data from the client-side (A) to the server-side (B).
You must write your routines in your own copies of the client.c and server.c files.
Your protocol should use ACK messages. (You may use and NAK messages too but they can be simulated using ACKs instead).
In a real socket, if there is data passed from above that cannot be sent to the other host, because there is an unacknowledged packet in transit, the socket code would either buffer the data so that it could be sent later, or (if there was no more space available in the buffer) it would ignore the data. Losing data is contrary to the principles of reliable data transport so your program should buffer data that cannot be sent out immediately, and send it out as soon as possible.
The simulation provides a queue for your outgoing data. To
use it all your code has to do is use
clientCanSendMorePkt()
and
sendToNWSLayer()
. Specifically:
clientCanSendMorePkt()
return true
when every packet that has been sent
has been acknowledged and false at all other times.
sendToNWSLayer()
when you have packets to
pass to the server.
clientCanSendMorePkt()
function
indicates that there are unacknowledged packets in transit,
then the simulation's sendtoNWSLayer()
function
will buffer the new packet for you and send it as soon as it
can. But if your function says that your client is not
waiting for any acknowledgments then the the packet will be
sent immediately.
Write your functions so that they print out a message whenever an event occurs at your sender or receiver (a message/packet arrival, or a timer interrupt) as well as any action taken in response.