如何在 NS2 中查找节点 ID

How to find node id in NS2?

本文关键字:查找 节点 ID NS2      更新时间:2023-10-16

我想知道如何获取正在处理数据包的节点ID。

我尝试了 name(),但它没有给出节点的 id,就像跟踪文件中显示的那样,其中显示了数据包跃点的源和目标。在 format() 的跟踪文件中,源和目标可用,但如何访问它们,这也可能有助于了解当前处理在哪个节点上进行。

这是关于 NS2 的。有人可以提供一些帮助。

MobileNode *thisnode = (MobileNode *) ((Node::get_node_by_address(id)));
printf("%dn",thisnode->address());

你可以得到这个节点的id!试试吧。

试试这个:

Node *thisnode = Node::get_node_by_address(id);
printf("%dn",thisnode->nodeid());

其中 id 只是节点的数字:例如,节点(1):

Node *thisnode = Node::get_node_by_address(1)
printf("%dn",thisnode->nodeid());