java.UDP network topology
am example of an implement of a program that read an ICT script with each node identify its neighbors in the network and the routing protocol should be able to find the other nodes in the network and the next hop to these nodes. The routing protocol should also detect topology changes and react to them by determining new shortest-path routes. the program should also deal with topology changes such node failure or link failure
void mergeRoute (Route *new) { int i; for (i = 0; i < numRoutes; ++i) { if (new->Destination == routingTable[i].Destination) { if (new->Cost + 1 < routingTable[i].Cost) { /* found a better route: */ break; } else if (new->NextHop == routingTable[i].NextHop) { /* metric for current next-hop may have changed: */ break; } else { /* route is uninteresting---just ignore it */ return; } } } if (i == numRoutes) { /* this is a completely new route; is there room for it? */ if (numRoutes < MAXROUTES) { ++numRoutes; } else { /* can`t fit this route in table so give up */ return; } } routingTable[i] = *new; /* reset TTL */ routingTable[i].TTL = MAX_TTL; /* account for hop to get to next node */ ++routingTable[i].Cost; }
Get Answers For Free
Most questions answered within 1 hours.