Distance Vector Routing Algorithm Program In Java

For modeling ad-hoc wireless routing (AODV etc) Dijkstra's is the way to go. Seriously, it would be quicker doing it yourself than locating/shoehorning someone else's code. Doing it yourself will also give you a better appreciation of some the problems of using distance vector routing algorithms in ad-hoc networks. Descriptions of distance-vector and link-state routing algorithms. Cormen, Leiserson, and Rivest, Introduction to Algorithms, pp. 465, 470, and 527. Graph representation, breadth-first searches, and Dijkstra's shortest-path algorithm. Javadoc API documentation for the routing simulator.

  1. Distance Vector Routing Algorithm Program In Java Programming
  2. Distance Vector Routing Algorithm Program In Java Tutorial
  3. Distance Vector Routing Algorithm Program In Java
  4. Distance Vector Routing Algorithm Program In Java Download
  5. Distance Vector Routing Algorithm Program In Java Free

Distance Vector Algorithm is a decentralized routing algorithm that requires that each router simply inform its neighbors of its routing table. For each network path, the receiving routers pick the neighbor advertising the lowest cost, then add this entry into its routing table for re-advertisement. To find the shortest path, Distance Vector Algorithm is based on one of two basic algorithms: the Bellman-Ford and the Dijkstra algorithms.
Routers that use this algorithm have to maintain the distance tables (which is a one-dimension array — “a vector”), which tell the distances and shortest path to sending packets to each node in the network. The information in the distance table is always upd by exchanging information with the neighboring nodes. The number of data in the table equals to that of all nodes in networks (excluded itself). The columns of table represent the directly attached neighbors whereas the rows represent all destinations in the network. Each data contains the path for sending packets to each destination in the network and distance/or time to transmit on that path (we call this as “cost”). The measurements in this algorithm are the number of hops, latency, the number of outgoing packets, etc.
The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. It is slower than Dijkstra’s algorithm for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers. Negative edge weights are found in various applications of graphs, hence the usefulness of this algorithm. If a graph contains a “negative cycle” (i.e. a cycle whose edges sum to a negative value) that is reachable from the source, then there is no cheapest path: any path that has a point on the negative cycle can be made cheaper by one more walk around the negative cycle. In such a case, the Bellman–Ford algorithm can detect negative cycles and report their existence.

CNT4704: Analysis of Computer Communication Networks

Fall 2013

Programming Assignment 3: Distributed Simulation of Distance Vector Routing protocol
(Assigned: Nov. 4th, Due: Nov. 18th midnight, Late submission by Nov. 24th with 20 points off)

Distance Vector Routing Algorithm Program In Java Programming

Overview

In this lab, you will be writing a 'distributed' set of procedures that implement a distributed asynchronous distance vector routing for the network shown in Figure 1. This project is implemented in the similar way as in project 2---a simulator is provided (prog3.c) and your task is to complete the coding for several function calls that will be called by the simulator in a statistical way. To complete the project, you need to understand well the example shown on Page 32,33 in lecture notes Chapter4-part2.ppt.


Figure 1: Network topology and link costs for DV routing project

The routines you will write:

Routing

You are to write the following routines which will ``execute' asynchronously within the emulated environment that the textbook authors have written for this assignment.

For node 0, you will write the following two routines:

  • rtinit0() This routine will be called once at the beginning of the emulation. rtinit0() has no arguments. It should initialize the distance table in node 0 to reflect the direct costs of 2, 4 and 8 to nodes 1, 2 and 3, respectively. It should also initialize its linkCost0[] to all other nodes since this linkcost will be used in calculation all the time. In Figure 1, all links are bi-directional and the costs in both directions are identical. After initializing the distance table, and any other data structures needed by your node 0 routines, it should then send its directly-connected neighbors (in this case, 1, 2 and 3) the cost of it minimum cost paths to all other network nodes. This minimum cost information is sent to neighboring nodes in a routing packet by calling the routine sendrtp(), as described below. The format of the routing packet is also described below.
  • rtupdate0(struct rtpkt *rcvdpkt). This routine will be called when node 0 receives a routing packet that was sent to it by one if its directly connected neighbors. The parameter *rcvdpkt is a pointer to the packet that was received.

rtupdate0() is the 'heart' of the distance vector algorithm. The values it receives in a routing packet from some other node i contain i's current shortest path costs to all other network nodes. rtupdate0() uses these received values to update its own distance table (as specified by the distance vector algorithm). If its own minimum cost to another node changes as a result of the update, node 0 informs its directly connected neighbors of this change in minimum cost by sending them a routing packet. Recall that in the distance vector algorithm, only directly connected nodes will exchange routing packets. Thus nodes 1 and 2 will communicate with each other, but nodes 1 and 3 will not communicate with each other.

As we saw in class (example in Page 32 in Chapter4-part2.ppt), the distance table inside each node is the principal data structure used by the distance vector algorithm. It is declared as a 4-by-4 array of int's, where the i-th row is the distance vector of node i. If the node i is not directly connected to the current node, this i-th row entry can be ignored. We will use the convention that the integer value 99 is ``infinity', which is defined as micro in all code files.

Figure. 2 provides a conceptual view of the relationship of the procedures inside node 0.

Similar routines are defined for nodes 1, 2 and 3. Thus, you will write 8 procedures in all: rtinit0(), rtinit1(), rtinit2(), rtinit3(),rtupdate0(), rtupdate1(), rtupdate2(), rtupdate3()


Figure 2: Relationship between procedures inside node 0

Software Interfaces

The procedures described above are the ones that you will write. The following routines have been provided in the simulator (prog3.c) that can be called by your routines:

sendrtpkt(int srcid, int destid, int mincosts[])

It will create a packet containing the distance vector mincosts[] (4 entries) and send to destination node destid (specifying that it is sent from the source node srcid). And at the same time print out information of such event. After a simulated time delay, the rtupdate?() function of the destination node destid will be called to process this received packet.

The packet is the following structure, which is already declared for you.

printdt0()
will pretty print the distance table saved on node 0. printdt0() and the structure declaration for the node 0 distance table are declared in the file node0.c. Similar pretty-print routines are defined for you in the files node1.c, node2.c node3.c for the other 3 nodes.

The Simulated Network Environment

Distance vector routing algorithm program in java programming

Distance Vector Routing Algorithm Program In Java Tutorial

Distance

Your procedures rtinit0(), rtinit1(), rtinit2(), rtinit3() and rtupdate0(), rtupdate1(), rtupdate2(), rtupdate3() send routing packets (whose format is described above) into the medium. The medium will deliver packets in-order, and without loss to the specified destination. Only directly-connected nodes can communicate. The delay between a sender and a receiver is statistically variable (and unknown).

When you compile your procedures and the provided prog3.c procedures together and run the resulting program, you will be asked to specify only one value regarding the simulated network environment:

  • Tracing. Setting a tracing value of 1 or 2 will print out useful information about what is going on inside the emulation (e.g., what's happening to packets and timers). A tracing value of 0 will turn this off. A tracing value greater than 2 will display all sorts of odd messages that are for my own emulator-debugging purposes.

A tracing value of 2 may be helpful to you in debugging your code. You should keep in mind that real implementors do not have underlying networks that provide such nice information about what is going to happen to their packets!

Distance Vector Routing Algorithm Program In Java

The Required Content in Project Report

Distance Vector Routing Algorithm Program In Java

You are to write the procedures rtinit0(), rtinit1(), rtinit2(), rtinit3() and rtupdate0(), rtupdate1(), rtupdate2(), rtupdate3() which together will implement a distributed, asynchronous computation of the distance tables for the topology and costs shown in Figure 1.

You should put your procedures for nodes 0 through 3 in files called node0.c, .... node3.c. You are NOT allowed to declare any global variables that are visible outside of a given C file (e.g., any global variables you define in node0.c. may only be accessed inside node0.c). This is to force you to abide by the coding conventions that you would have to adopt is you were really running the procedures in four distinct nodes. To compile your routines use (under the department's Eustis machine): cc -o dvSim prog3.c node0.c node1.c node2.c node3.c , which will generate the executable program called dvSim. Prototype versions of these files are here: node0.c, node1.c, node2.c, node3.c. Note that do not pay attention to the empty function linkhandler0(linkid, newcost) in the above 4 nodes' code files. It is used by the textbook authors for advanced graduate course teaching.

This assignment can be completed on any machine supporting C. It makes no use of UNIX features.

You are expected to submit in the four code file (code0.c ~ code3.c), and the generated executable code. And a project report file with a sample output (with a screenshot image showing the simulator running procedure/result). You are not supposed to modify the simulator code prog3.c

For your sample output, your procedures should call printdt?() at the end of rtinit?(), and call printdt?() whenever your node needs to send out a distance vector update message in rtupdate?().

The sample output should be an output listing with a TRACE value of 2. Highlight the final distance table produced in each node. Your program will run until there are no more routing packets in-transit in the network, at which point the emulator will terminate.

JAVA Version Of This Assignment

The java environment can be found in the author's website here. Here are the individual files you'll need:
Entity.java, Entity0.java, Entity1.java, Entity2.java, Entity3.java, NetworkSimulator.java, Event.java, Packet.java, EventList.java, EventListImpl.java, Project.java
You'll write the constructors ofEntity0.java, Entity1.java, Entity2.java, and Entity3.javawhich are analogous to rtinit0(), rtinit1(), rtinit2()andrtinit3() in the C version. You will also need to write the update()methods for Entity0.java, Entity1.java, Entity2.java, and Entity3.java which are analogous to rtupdate0(), rtupdate1(), riupdate2() and rtupdate3() in the C version.

Note that the Java code will allow you to hang yourself by sending incorrect packets via thetoLayer2()method of NetworkSimulator. So please be extra careful there.

Distance Vector Routing Algorithm Program In Java Download


Distance Vector Routing Algorithm Program In Java Free