Suggestions/Tips
- Start small. Implement a skeleton manager process that simply
creates one child process, waits for the child to exit and then exits
itself. Have the child print a "hello world" message and exit. Then
make sure all processes have exited gracefully. Use the "ps" command to
check. Hint: write different parent and child functions. Once you fork,
have the parent process call the parent () function and the child
process call the child () function (see the tutorial on fork). This way
you can have the code for parent and child in separate files. This
means you will have a main () function that calls parent () and child
(). The main function will also use the wait () call after the parent
and the child have exited.
- Have the manager and the child print their pid on the terminal.
Then, have them print it in a file. Note that you can have the manager
create the file before forking the child, and the child will inherit
the file descriptor. Now both the parent and the child can write to the
same file.
- Once you have your manager working with one process, add a loop
to create N processes. Read N from a file. Make sure all processes
print "hello world" and exit gracefully. Test the kill command if they
don't. Note that it is safe to run the kill command if the pids do not
exist.
- Write simple client-server programs using TCP sockets. Have the
client send a simple message such as "Hi" to the server, and the server
send a simple reply back. Have both programs print a trace of what they
are doing at each step (e.g., created socket, connected to the server,
sent message "Hi", received reply "Hi to you too"). Then, add a
timestamp before each message. Finally, have the messages go to
different output files, one for the client and one for the server.
- Make the client portion your router and the server portion your
manager. Have each router contact the manager as soon as it is created
and ask for an ID. Create a ID.out file as soon as you learn your ID
and start logging mesages there. Send that ID back to the manager and
exit.
- Have the manager accept connections from all the routers, send
them their ID and print their response. Then make sure you can print
these messages in the trace file.
- Test to ensure you can create N processes, where N is less than
10. Start small, test with one child process first, then two, etc.
- Now it's time to implement the shortest path tree algorithm.
Decide on the data structures first, because this will determine how to
write your code. Implement the LS algorithm as a fuction. Pass it an
adjacency matrix (typically a NxN array with costs between all the
nodes) and a pointer to the forwarding table so that the next hop
fields can be filled.
- Implement a lookup function that takes as arguments the pointer
to the forwarding table and the destination address and returns the
link id the packet needs to go out on.
- We will add more hints as we get feedback from you.