COSC 4377 - Introduction to Computer NetworksSpring 2012MW 1:00-2:30pm at PGH347
Homework 7 : Packet ForwardingDue: midnight March 21, 2012In this assignment, we will create a network and write forwarding logic to forward packets between arbitrary pair of nodes in the network (as long as there is a valid route between them). Part 1 - Setting up the network In this part, we setup the network of processes. In a real network, these proceses are run on different machines but in this assignment, we run all the processes in a single machine to simplify the homework and standardize the testing environment. We provide the code for most of this part. Each node is represented by a process. The sample code reads the file that lists all the neighbors of each node. It also sets up the basic flow for a pthreads-based driver, receiver, and sender implementation. The comments in the code tell you about the major missing pieces. You will need to setup the server socket on the nodes to read packets sent by neighboring nodes. We will launch the "node" executable for each node in the network. If we have a network consisting of 5 nodes, we will launch "node" five times with arguments identifying the node. Each node reads a "links" file, which has a list of its neighbors -- their id and port.
./node nodeid port Node's address or id is given by nodeid. The node listens for incoming packets on the port.Lets learn how to setup a topology that looks like: 1----2----5 | | 3---------4We need to specify the links for each node on the links file. We will have five links file with names link1, link2, link3, link4, and link5. These files list all the neighbors for the respective nodes. The first column is nodeid and the second column is the port on which that neighbor is listening for packets. Then, we lanuch the nodes like this: ./node 1 101 & ./node 2 102 & ./node 3 103 & ./node 4 104 & ./node 5 105 &Make sure the ports used to launch the nodes is the same as the ones listed on the links file. Each node process, when launched, should setup a UDP (not TCP) socket to read packets sent by its neighbors. You might find it more convenient to use connectionless UDP socket setup so that you can use a single function or thread to read packets sent by all the neighbors. Part 2 - Routing In this homework, we will use static routing to determine the paths between the nodes in the network. We will learn how to do dynamic routing in next homework. When the "node" executable is launched, it expects a route file that lists all the destination (first column) and next hop (second column). It is not necessary for all the nodes to have routes to all the nodes in the network. Some nodes might not have any route. We are providing route1, route2, route3, route4, route5 as examples for the topology described above. In these examples, you all notice that not all the nodes have routes to all the nodes. With the route file, you should be able to create loops, shortest paths, sub-optimal paths, etc. Although the provided code has skeleton for reading the route file, you need to define data structure to store, update, and lookup the tables. Part 3 - Forwarding Now that the topology and the routes are setup, we are ready to forward some packets. We have already defined the structure for packet. When we discuss forwarding, we need to describe the tasks performed by three types of nodes:
Node Control TerminalThe skeleton code provides a way for you to interact with the node but you should fill in some missing pieces. When you launch "node", it waits for these commands from the user:
InstrumentationYou can use printfs and other standard debugging techniques to debug your code. For example, if you want to understand if forwarding is working correctly, you can printf the key details about the packets being received and trasnmitted by each node. These printf outputs can get confusing if you have a number of node processes writing to stdout. It might be easier to track the packets if you open multiple terminals and launch one node process per terminal. This setup will allow you to "see" the packets traversing the terminals as it traverses the network.We also require that each node also creates a file logx.txt where x is the node id. For example, node 25 would create log25.txt. Each line in the log file should be one of:
SEND origin:25 dst:5 seq:12 nexthop:5 RCV origin:8 dst:5 seq:4 prevhop:3 FWD origin:8 dst:5 seq:4 nexthop:5 RCV origin:8 dst:5 seq:5 prevhop:3 FWD origin:8 dst:5 seq:5 nexthop:5 RCV origin:8 dst:5 seq:6 prevhop:3 FWD origin:8 dst:5 seq:6 nexthop:5The log file above shows that node 25 originated a packet to the destination 5. Then it received three packets, also to destination 5, from node 3. It forwarded these packets to node 5 immediately after receiving them. The sequence in which these messages should indicate the sequence of packet events that occurr at node 25. Each time you need to log a packet event, please open the log file, append to it, and close the file. Thus, we will have the log file with all the contents intact even if the nodes crash or forget to close the file before terminating. SubmissionPut your source code (node.c) into a folder with the name: uhid_hw7, where uhid is the prefix of your .uh.edu email address. There should be a single Makefile in that directory. When we run make on that directory, it should produce one executable called node. Put a README.txt in the directory describing anything unusual (e.g., limitations) of your implementation. Then, zip the directory and upload the zip file using Blackboard. |