The functions described in the student code are the ones that you will write. They should call the following functions (which have been written for you):
void startTimer(float howlong)
howlong
specifies how many simulated
time units should pass before the timer interrupts. To give
you an idea of the appropriate increment value to use: a
packet sent into the network takes an average of 5 time units
to arrive at the other side when there are no other messages
in the medium.
void cancelTimer(void)
The client and the server can each have at most one timer set at any time. If you have set the timer before then you must call this function to cancel the previous timer before you can set a new one.
void sendToNWSlayer(packet)
This function will send the packet through the network to the other entity (the client will send to the server, and the server will send to the client). Note that some packets will be lost in the network, and some will arrive corrupted. Packets will not be re-ordered in the network.
void deliverToAppLayer(char datasent[])
With unidirectional data transfer, you would only be calling this from the server side (to send the message that was received (as packets) from the client).
This function will cause data to be passed up to the top layer (the application layer, #5).
A call to sendToNWSlayer()
sends packets into the
network services layer (layer #3). Your functions
clientInput()
and serverInput()
are
called when a packet is to be delivered from the network
services layer to your protocol layer (the transport layer, #4).
The simulated network can corrupt and lose packets. When you compile and link your code and simulation code and run the resulting program, you will be asked to specify these parameters of the network:
Once this number of messages have been passed down from layer #5 and all events in the simulation's event queue have been simulated then the entire network simulation will stop. For more details about how the simulation works, see the overview.
You can set this value to any positive value. Note that the smaller the value you choose, the faster packets will be be arriving at your sender (in reality, not in the simualtion).
Setting a tracing value of 1 or 2 will print out useful information about what is going on inside the simulation (for example, what's happening to packets and timers). A tracing value of 0 will turn this off. A tracing value greater than 2 will display all sorts of odd messages that are for debugging the simulation. A tracing value of 2 may be helpful to you in debugging your code.
You should keep in mind that real network implementors do not have underlying networks that provide such nice information about what is going to happen to their packets.