Skip to content

Distance Vector routing protocol implemented using C by reading topology files

Notifications You must be signed in to change notification settings

ameyapat/DVRP-MNC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DVRP-MNC

Distance Vector routing protocol implemented using C by reading topology files

CODE DOCUMENTATION

CODE FILE NAME : dvrp.c

TO RUN: gcc dvrp.c -o dvrp ./dvrp

The program first reads the topology file and saves information in a struct known as topo topl_file. It saves no. of servers (1st line of topology file), no. of edges (2nd line), [server ids, ip addresses and port nos]. The program gets it's own id and neighbour ids and costs to them from the topology file. From its own id it Find own IP address and Port-no. from topology file and initialize a socket.

The program maintains three tables

A Neighbor table, cost table and a Routing table.

Neighbor table: struct neigh [LINE NO. - 32 in dvrp.c] neigh_id, neigh_cost, val, rec_count, disabled.

Cost Table: [LINE NO. - 41 in dvrp.c] cost_table[5][5].

Routing Table: struct routab - [LINE NO. - 43 in dvrp.c] dest, nxthop, noh

On reading topology file it stores neighbour details in the neighbour table and fills the cost table and routing table from the file.

UPDATE MESSAGE: [LINE NO. - 50 to 71 in dvrp.c] The message is a struct fmsg which is a combination of two structs : struct m1 and struct m2

struct m1 stores details no of updates, source port and source IP struct m2 stores ip , next port, padding and cost.

Timeout is implemented using select()'s last argument.

calc_table() - applies the Bellman Ford equation by storing the cost from source to neighbour in one array c1 and cost from neighbour to destination in another array c2. Temp array is used to store sum of c1 and c2 . The array temp is then passed into least() function which gives the minimum cost of the sums. Hence the next hop is also determined as neighbour in least cost path.

About

Distance Vector routing protocol implemented using C by reading topology files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages