【问题标题】:In NS-3, How to do you assign node id and how to retrive/display them in the terminal?在 NS-3 中,如何分配节点 ID 以及如何在终端中检索/显示它们?
【发布时间】:2018-06-09 22:36:29
【问题描述】:

我想显示 20 个具有唯一 ID 的节点。我通过以下命令使用 for 循环创建了 20 个节点。

NodeContainer c;
c.Create (20);
int j;
for(j = 0; j < 20; j++)
{   
  m.Install (c.Get(j));
}
std::count << "Node Id: %d" << ??? <<std::endl;

以上代码创建了 20 个节点,并在仿真工具 Netanim 中看到。现在我需要在终端中显示每个具有唯一 ID 的节点。

谁能告诉我如何分配节点ID?

【问题讨论】:

标签: node.js network-programming ns2 ns-3


【解决方案1】:
 NodeContainer c;
 c.Create (20);
 for (uint32_t i = 0; i < 20; ++i)
 {
    std::ostringstream os;
    os << "node-" << i;   
 }

尝试使用上面的代码在终端中显示每个节点,而不是您的代码。这适用于我的网络。 谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-21
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 2021-12-05
    相关资源
    最近更新 更多