Implement your own route_d

In this question you will implement a version of the route_d process used by RIP and described in section 4.6.1 of the text.

Write a UDP client that starts by reading in a textfile in the following format:

hostname1 port1 distance1
hostname2 port2 distance2
....

Each line in the file represents a node in the network, given by its hostname, the port that its route_d process is listening on, and its distance from the current node. The first line represents the node that the route_d process is running on, so its distance should be 0. Nodes that have distance at least 1000 are considered to be at distance infinity (that is, they are not neighbors of the current node). Nodes that have distance 1 to 999 are direct neighbors of the current node.

Recall that each node in RIP (or DV) maintains its own distance vector and those of its neighbors. The first thing the process should do after initialization is to send its distance vector to its neighbors. Such messages should have the following format:

origin_host origin_port
hostname1 port1 distance1
hostname2 port2 distance2
....

The first line tells the recipient whose distance vector it is receiving. The remaining lines give the known distances from the origin node to all other nodes. When a node receives this distance vector, it should store it and update its own distance vector appropriately. If its own distance vector changes, it must send it out to its neighbors.

If all goes well, we will test your route_d processes by running them together on a given network and checking that all nodes converge to the correct distances.

One more thing: for testing purposes, please print out the node's own distance vector whenever it changes. You can print it in the same format as the messages sent to other nodes.