Note: The source files that you will need to modify can be found in the directory /afs/engin.umich.edu/class/f99/eecs489/assignments/pa1/source. It is possible that there may be bugs in the code. Please let us know asap if you suspect a bug.
a.engin% seeder -n 1 b.ummu% vrouted -S a.enginOnce you have debugged the single instance of your vrouted, you can test multiple instances of it. For example, to create a 4-node virtual network consisting of b.ummu, c.eecs, d.engin, and e.ummu, with the seeder running on a.engin, you do:
a.engin% seeder -n 4 b.ummu% vrouted -S a.engin c.eecs% vrouted -S a.engin d.engin% vrouted -S a.engin e.ummu% vrouted -S a.engin
a.engin% seeder -n 4 b.ummu% vrouted -S a.engin -p 7896 c.eecs% vrouted -S a.engin -p 7896 d.engin% vrouted -S a.engin -p 7896 e.ummu% vrouted -S a.engin -p 7896In case your seeder conflicts with another seeder on the same machine, the well-known port number of the seeder can also be changed. To use port number 8707 with your seeder, you do:
a.engin% seeder -n 4 -p 8707 b.ummu% vrouted -S a.engin -P 8707 -p 7896 c.eecs% vrouted -S a.engin -P 8707 -p 7896 d.engin% vrouted -S a.engin -P 8707 -p 7896 e.ummu% vrouted -S a.engin -P 8707 -p 7896To address each other, vrouted's use the virtual internetwork address (vin_addr_t henceforth) depicted in Fig. 1, where the IPv4 Address is the IPv4 address of the machine the vrouted runs on, the Port Number is the well-known port number the vrouted listens on, and the metric is the metric of the link to be interpreted by higher level protocols. All the numbers in a vin_addr_t must be kept in network byte-order at all times.
int vif_pullup(vif_t *vif, char *buf, int len); int vif_pullupn(vif_t *vif, char *buf, int len); int vif_output(vif_t *vif, u_short prot, vbuf_t *vbp);When a packet arrives for your vrouted, the vif on which the packet arrives parses the vif header of the packet and calls the appropriate upper layer protocols' APIs. You are to write several such upper layer protocols' APIs in this programming assignment (see Sections 5.1 and 5.2 below). Your upper layer protocol can call vif_pullup to its data from the virtual link just like you use recv(3N). Or it can call vif_pullupn to pull up n bytes. You call vif_output to put data on the virtual wire. See the function definitions in vif.c. In case you wonder at the choice of the API names, they are similar to what are used in the BSD kernel, so you get an experience of writing kernel code without most of the hassle usually associated with it.
VIP is a connectionless internetwork protocol. Fig. 3 depicts the packet header format of VIP. The Version field contains the version number, currently set to VIP_VERSION defined in vip.h . Packets with version number different from VIP_VERSION should be discarded. The Hop Limit field contains the number of hops a packet has traversed. At every router, this field should be decremented by one and the packet should be discarded if this field is <= 0. The Pkt Length field contains the size of packets in bytes, excluding the header. The Protocol field specifies whether this is a vcmp, vrp, or vtp packet. The protocol numbers of VRP, VCMP, and VTP are VIP_PROTOVCMP, VIP_PROTOVRP and VIP_PROTOVTP respectively, as defined in vip.h. VIP identifies a host by its vin_addr_t as described in Section 2. The Checksum field is used for error checking of the packet header. Packets with incorrect checksums should be discarded. Hint for checksum computation: The checksum field is at the very end of the VIP header, and vip_cksum() takes a parameter specifying the length over which you wish to calculate the checksum.
The version should be VCMP_VERSION and the error code one of the above listed. The VIP header of the packet encountering error is returned along with the error code. No error should be generated for VCMP packets.
The design of the router (vrouted) is depicted in Fig. 5.
In the figure, data structures are enclosed in rounded boxes and functions
in square boxes. You are to define and implement the functions depicted
in bold. Files with comments suggesting what the functions could contain
are available in the assignment directory. In the assignment directory
you will also find the object code for our version of the functions you
are to work on in this and the next programming assignments.
If the packet is not addressed to the current router, vip_input checks for packet integrity and hands the packet to vip_forw. vip_forw calls vrp_route to find the interface for the next hop towards the destination of the packet and send it out that interface by calling vif_output.
If a packet is addressed to the current router, vip_input hands the packet to either vtp_input, vcmp_input, or vrp_update depending on the protocol of the packet.
When an upper layer protocol calls vip_output and gives it some data to send out, vip_output marshalls a VIP header, calculates a checksum for the header, prepends the header to the data, and sends it out by calling vif_output.
If vip_input receives a packet with unknown version number or bad checksum, it should drop the packet by calling vip_drop. Packets with unknown protocol are also dropped. When forwarding a packet, the packet should be dropped if it encounters transmission error, the router doesn't know where to forward the packet, or the hop limit of the packet has been exceeded. Some of these errors should cause a VCMP packet to be sent back to the source of the packet, others shouldn't.
When a packet encounters one of the errors listed in Section 5.2, vcmp_output is called to create and send out a VCMP packet. A VCMP packet is also a VIP packet. So, your vcmp_output should call your vip_output to send out its VCMP packets.
Remember to comment your code. Insufficient comments will result in a loss of points. You should write enough comments to make it easy for someone else to follow your code.
To understand the ``normal'' behavior of vrouted and seeder, you may want to run our version on several machines first. You should allow the vrouteds to continue running even after the seeder tells you that it is done testing. The vrouteds continue to randomly send messages to randomly selected destinations. Hit Ctl-C when you're tired of seeing text scrolling on your windows.