Corporate and Professional Publishing Group

An Engineering Approach to Computer Networking

by S. Keshav

ISBN 0-201-63442-2 * Hardcover * 688 pages * 1997


Book Description · Preface · Glossary · Bibliography · Solutions · Slides · Simulator · Exercises · Errata · Cover (73K) · Ordering Information · C&P Welcome Page.


Sockets to REAL

Goal

Your assignment is to build a node function that implements both the client and the server in the socket programming assignment. Similar to the socket programming assignment, the client sends the server a command, which is either integer '0' or integer '1'. The server executes either the 'ls' or the 'date' command, as before, and returns the results to the client, which prints it out. To get you started with REAL, I have provided a template file called ecn_dummy.c that can also be found in the sim/sources directory. This is a fully working node function to which you can add code to do this assignment.

Details

In REAL both the client and the server run as threads within a single process. So, it is easy to write a single node function that does both client and server side processing. The node function checks its node number. If it is 1, it does client side processing, and if it is 2, it does server side processing.

The client begins by sending sending node 2, the server, a DATA packet whose data field contains the command as a 1-byte ASCII character. It then waits for a reply and, on receipt, displays the result on the screen. The client finds which command it should send by reading the global policy array, indexed by its node number (i.e. sprintf(&command, "%c", policy[get_node_id()]). You will need to set the node's policy in the input file ecn/socket.l.

The server, on getting the request, reads the message sent to it, executes the corresponding command using the Unix system system call and writes the result to a temporary file. It then opens the file for reading, reads the result, and writes the results back to the client in ACK packets. As before, the first 10 bytes of each message from the server are the length of the message, in ASCII. For example, if the length of the reply is 15 bytes, the first 10 bytes would be ASCII 1, ASCII 5 and eight \0s (use the sprintf call to convert from binary to ASCII). The server may send multiple messages, and the client should be prepared to accept and print multiple messages from the server, reading the length each time.

The client and server should be linked with a transmission link that has a bandwidth of 1000 bits/sec and 0 s delay (this is described in the input file called socket.l, which can be found in the ecn directory).

Sample output can be found here.

How to do the assignment

1) Use the 'lndir' command to create a shadow directory tree that shadows ~cs519/course/sim  on turing. Break the links to sim/simulate and sim/sources/ecn_dummy.c and copy the actual files to your directory. In general, you should break and copy
any files that you change.

2) Read documentation to understand how to modify the simulator.

3)  Locate the file ecn_dummy.c in the directory sim/sim/sources. Modify it to do the assignment.

4) Rebuild the simulator using make in the sim/sim directory.

5) Test whether your modifications were correct by running the simulator (type simulate ecn/socket.l) and comparing with the correct output (this shows the output when policy = 0, the output for policy = 1 is similar).

6) The TA has solved the assignment from the instructions on this page and put together a FAQ . If you have further questions, please send mail to Rachit.

Grading

Grading will be based as follows: Send your copy of ecn_dummy.c to the TA, who will compile the simulator with your submission, and compare the output with the standard one. If they match, you will get full credit, otherwise, you will get none. We will check your code so that you do not just put in a whole bunch of printfs!

Hints on using the simulator

Please read the online users manual and programmers manual.