J. Blustein

Network Computing

[Crs | Ann | Mats | Res]

Kurose & Ross's Network Simulation Code

[Assignment | Documentation | Source Code ]

Documentation: [Overview | KRnet | stucode | message_t | packet_t | queue_t ]

[Include contents frame]

Programmer's Interface to Network Simulation

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):

Timer Functions

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.

Between Layer Functions

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).

Simulation Parameters

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:

Number of messages to simulate

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.

Loss
You are asked to specify a packet loss probability. A value of 0.1 would mean that (on average) one in ten packets will be lost.
Corruption
You are asked to specify a packet loss probability. A value of 0.2 would mean that (on average) one in five packets will be corrupted. Note that the contents of payload, sequence, ACK, or checksum fields can be corrupted. So your checksum should include the data, sequence, and ACK fields.
Tracing

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.

Documentation: [ Overview | KRnet | stucode | message_t | packet_t |queue_t ]


http://web.cs.dal.ca/~jamie/course/CS/3171/Materials/KR_1e/Code/Chapter3/doc/simulation.shtml
Version:
Sunday, 27-Jul-2003 13:34:39 ADT
CS 3171 Prof.:
J. Blustein <jamie@cs.dal.ca>

This webpage uses valid XHTML 1.0

Based on
document at <URL:http://occawlonline.pearsoned.com/bookbind/pubbooks/kurose-ross1/chapter4/custom12/deluxe-content.html> (copied on 05 July 2002). That document is © 2000-2001 by Addison Wesley Longman A division of Pearson Education

[Include contents frame]