CS 640 Introduction
to Computer Networks
Programming
Assignment 2: Routing Protocol
Please check this page for FAQs and frequent updates on instructions.
Note:
It is import for your server being able to communicate with servers created by
other people under the same protocol. If your server can only communicate with
servers used your program, your server probably have little chance to survive
in current world. Thus, we will try to test the communication between your
server and servers created by other groups in the class.
TA will set up a communication between two servers. One is used your program
and the other is from other groups. If your server can decode the routing
update packet from other group, your server will get a mark. The more mark
your server can get, the better your server is. Part of your score in this
project will come from this test.
Frequently Asked Questions:
(1) You should be able to run the commands (update, step,
packets, display, disable, crash) while the servers are
running.
Use the select( ) call and add the fd of
the standard input/output as show below:
FD_ZERO(&socket_set);//clears
it out
FD_SET(sockfd,&socket_set);//places our socket into the set
FD_SET(0,&socket_set);//add fd of standard input/output
results = select(FD_SETSIZE, &socket_set, (fd_set *) 0, (fd_set *)
0,NULL);
(2) For sending periodic updates you will have to use
setitimer( ) and
sigaction( ). Look at the man pages
for usage.
- When using signact(), it may cause some problem in using select() function.
If you use printf("%m\n", errno); to print out the
error message, it will show "Interrupted system call".
Please use the following code to check whether the error is caused by
system interruption. If so, please just neglect it.
result = select(...);
if(result < 0){
if(errno != EINTR){
printf("Erros is not caused by system interrupt\n");
}
}
(3) Here are the topology files for the example topology. You can use
them to test your code. Right click and save the files. top1.txt is for
server 1, top2.txt for server 2 and so
on. You will have to modify the IP addresses and the port numbers in
the files.
top1.txt
top2.txt
top3.txt
top4.txt
top5.txt
- The topology file is complete and thus it contain the IP address and port
of the server which read this topology file. You may get your IP address
and port by using server ID and the server list in the toopoly file
(4) Do
appropriate error
checks.
How is update work?
You must distinguish between the cost from routing protocol and
the cost you have physically connected. In this project, the physical
cost between two connected servers will not change unless you use update
or crash command. Thus, the routing protocol will update the costs to
that server according to the update packet. However, no matter how the routing
cost change, your reserver needs to remember the direct linked neighbors and
their cost.
3
2----4
7/ \3
/ \
1---- 3
3
Here I gave a simple example. Before I receive the update command, the data
in server one should look like this. ID: the server ID, Cost: the routing cost,
Via: next hup, Direct: whether is my direct neighbor, DCost: the physical cost
ID Cost Via Direct DCost
1 0 1 * 0
2 6 3 * 7
3 3 3 * 3
4 10 2
I use the update command at server 1 and 2. So the physical cost of 2 will change from
7 to 3 and I check with the routing cost 6 > 3 and thus I need to update the routing
cost to 3 and next hup to 2. I also need to go through my routing table to see any server
is routed via 2 and their cost must also change accordingly. After the update
the table should look like this
ID Cost Via Direct DCost
1 0 1 * 0
*2 3 2 * 3
3 3 3 * 3
*4 6 2
Similarly, when crash happens, you should do the similar update. I crash server 2 from previous
example. The data in server 1 should look like this
ID Cost Via Direct DCost
1 0 1 * 0
*2 inf 0 * inf
3 3 3 * 3
*4 inf 0
Submission
Instructions:
What to submit:
You will need to submit the
source
code along with the Makefile in a
single tar.gz file (name it p2.tar.gz). The extracted directory p2 should contain the server code
and the Makefile.
Do not submit object files, or
compiled executables. The Makefile should have two rules: clean and all.
clean will delete previous .o
files, executables, etc.
all should produce a single
executable called server.
How to submit:
First
add the following line to your .cshrc.local file if you have not done
that before(located in your home
directory):
set path =
($path /s/handin/bin)
Then
run the following command at the shell prompt:
source
~/.cshrc.local
Finally,
to handin your files, enter the following command:
handin -c
cs640-1 -a PA2 -d <directory>
where
<directory> is the path to the directory where p2.tar.gz is
located
handin
will go through the specified directory and hand in the tar ball.
Make sure both the group members
submit the same code.