I am using the following code to get the number of hops from the current node to the target node. The problem is that the number of hops is very large (inf) whent I cast it to string. Also, it gives me the same number of hops to all nodes :
cTopology topo;
topo.extractByModulePath(cStringTokenizer("*.router*").asVector());
cTopology::Node *thisNode = topo.getNodeFor(getParentModule());
broadcastmsg=1;
for (int i = 0; i < topo.getNumNodes(); i++) {
if (topo.getNode(i) == thisNode) continue; // skip ourselves
{cModule *targetModule =topo.getNode(i)->getModule();
EV_INFO << "We are "<<topo.getNode(i)->getDistanceToTarget()<<"hops to to target.\n";
}
}
Help is much appreciated