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]

The routines you will write

The routines you will write are for the sending entity (the client) and the receiving entity (the server). You must simulate data transfer (from client to server) and (positive or negative) acknowledgment from the server to client. Such routines would in real-life be part of the operating system, and would be called by other routines in the operating system.

The functions you will write will be called by (and will call) network emulation routines in the KRnet files. The network emulation routines have been written for you — you do not need to read them or understand how they work.


Client Functions (client.c)

All of the client functions are to be defined in the client.c file. Those functions are:

void clientInit(void)

The simulation will call this function only once, before any of your other sending-side routines are called. It can be used to do any initialization you think is needed.

void clientEnd(void)

The simulation will call this function only once. It is the last function called. It can be used to clean-up any state that you have, for instance if you are using a file to hold debugging output then you might open the file in clientInit() and close it here.

void clientOutput(message_t msg)

msg is a message containing data to be sent to the server-side of the connection.

The simulated operating system will call this function will be called whenever the upper layer at the sending side (Client) has a message to send. It is the job of your protocol to ensure that the data in such a message is delivered in-order, and correctly, to the receiving side's application layer.

void clientInput(packet_t pkt)
pkt is a (possibly corrupt) packet from the server-side of the connection

The simulation will call this function whenever a packet sent from the server arrives at the client-side.

void clientTimerInterrupt(void)
The simulation will call this function when the sending-side's timer expires (and generates a timer interrupt). You'll probably want to use this routine to control the retransmission of packets.
int clientCanSendMorePkt(void)
The simulation will call this function before trying to send a packet from application layer to the server. If this function returns a nonzero value (true) then a new data unit will be passed to your protocol layer, otherwise the data will be put into a buffer (a queue in fact) until there is another opportunity to send a packet to the server.

Server Functions (server.c)

All of the server functions are to be defined in the server.c file. Those functions are:

void serverInit(void)

The simulation will call this function only once, before any of your other server-side routines are called. It can be used to do any initialization you think is needed.

void serverEnd(void)

The simulation will call this function only once, just before it ends. This function can be used to clean-up any state that you have, for instance if you are using a file to hold debugging information then you might open the file in serverInit() and close it here.

void serverInput(packet_t pkt)

pkt is a (possibly corrupt) packet that was sent by the client-side.

The simulated operating system will call this function whenever a packet sent from the client arrives at the server-side. (The client sends the packet by calling client_output() function which tells the simulated operating system to make packets using its sendToNWSlayer() function.)

void serverOutput(message_t msg)

msg is a message containing data to be sent to the client-side of the connection.

void serverTimerInterrupt(void)

The simulation will call this function when the receiving-side's timer expires (and generates a timer interrupt).

This function is only needed for bidirectional connections (where data, not only acknowledgments, can be sent from the server to the client).

int serverCanSendMorePkt(void)

The simulation will call this function before trying to send data from the server's application layer to the client. If serverCanSendMorePkt() returns a nonzero (true) value then the oldest unsent packet will be sent to the client, otherwise the newest packet will be put in a buffer that will be checked the next time it is possible to send data to the client.

This function is only needed for bidirectional connections (where data, not only acknowledgments, can be sent from the server to the client).

See Also

Make sure you read the advice in the overview webpage.

The code that is provided for you is described in the KRnet webpage.

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/stucode.shtml
Version:
Sunday, 27-Jul-2003 13:36:32 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]