COSC 4377 - Introduction to Computer Networks

MW 1:00-2:30pm at PGH347

 Instructor Omprakash Gnawali

Homework 8 : Routing

Due: midnight March 28, 2012

In this assignment, we will implement a routing protocol and incorporate the protocol with forwarding logic we wrote in HW7 to build a complete router that computes routes and forwards packets.

Distance Vector Routing

We will use distance vector routing protocol to compute the routes. In this protocol, each node advertises a list of (destination, cost). All the nodes in the network are also destinations. This means, all the nodes should be able to find paths to all the destinations. We will use hop-count as cost.

Each node has a routing table. Each entry in the table has following elements: (destination, nexthop, cost). When a node receives an advertisement from its neighbor, it checks to see if the advertised path for the given destination is better than the path stored in its routing table. If the advertised path is better, it updates the routing table.

Lets imagine, node B has this entry in its routing table for destination D: (D, E, 5). When it receives an advertisement (D, 3) from node A, node B should update its entry to: (D, A, 4) because the new path is shorter: cost of 1 to node A + cost of 3 from node A. So, the new cost is 4. The new nexthop is A because we prefer the path through A (cost of 4) over the path through E (cost of 5). Next time, when it is B's turn to advertise its routes, it advertises: (D, 4).

Your routing entry should also contain an "age" field so that you when it is time to time out an entry. An entry that is more than a minute old should be timed out.

Your router should also implement split horizon with poison reverse. You can use the cost of 10 to represent infinity. Before you implement split horizon with poison reverse, you should try to create a count-to-infinity problem to get a concrete understanding of this problem.

Implementation Guide

You should define the data structures for the packet and the routing table. We will standardize the data structure for the packet:

```
typedef struct entry {
uint16_t destination;
uint16_t cost;
} entry_t;

typedef struct dvinfo {
uint16_t num_entries;
entry_t entries[10];
} dvinfo_t;

```

Remember to put the DV routing information in the payload portion of the packet we defined in HW7.

The routing table data structure can be same as the one you used in the previous assignment, except we will provide empty route file as input. Thus, you should be able to add entries to the routing table as your router learns about the neighbors. It should be able to mark certain entries as timed out or invalid when the link goes down. It should also be able to update the nexthop and cost fields when the router learns about new routes.

As with HW7, connectionless sockets will make your implementation easier. Just before sending a packet, make sure you memcopy your data to the payload of the packet. Here are the places where you will need to send packets:

1. Send beacons every 30 seconds
2. Send a packet when the user issues the "send" command on the terminal
3. Send a packet while forwarding a data packet

It should be adequate to have one place to receive the packets. When you receive a packet, you need to cast the payload portion of the data into packet_t. If the type is "1", you can process that packet as data. If the type is "2", you can process that packet as a beacon.