在 ns-3 模拟器中何时使用 p2p 节点、wifistanodes 和 csmanodes

In ns-3 simulator when to use p2p nodes, wifistanodes and csmanodes

我正在尝试使用 NS-3 模拟器在随机航路点模型和其他一些模型之间进行一些测试。在模拟过程中,我发现当需要 运行 模拟时,我们需要使用名为

的 class 来启动模型

MobilityHelper

下面的代码是我正在使用的代码的一部分。在初始化过程中,需要预先创建一些节点,例如

p2pNodes

csmaNodes

那么这些节点是什么意思,需要在什么情况下使用呢?他们是否指定某些特定的移动模型?如果可以,请详细说明,非常感谢!

  NodeContainer p2pNodes;
  p2pNodes.Create (3);

  PointToPointHelper pointToPoint;
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

  NetDeviceContainer p2pDevices;
  p2pDevices = pointToPoint.Install (p2pNodes);

  NodeContainer csmaNodes;
  csmaNodes.Add (p2pNodes.Get (1));
  csmaNodes.Create (nCsma);

  CsmaHelper csma;
  csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
  csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));

  NetDeviceContainer csmaDevices;
  csmaDevices = csma.Install (csmaNodes);

p2pNodes 和 csmaNodes 只是此特定示例中使用的 NodeContainer 的变量名称,以便跟踪两个 newtorks(点对点和 CSMA)的节点。您将它们命名为 p2pNodes 或 csmaNodes 只是为了您的方便。重要的是他们安装的 NetDevice 类型。

无论如何,这与您安装的 MobilityModel 无关。 P2P 和 CSMA 都是有线网络,我不会考虑在这些网络上添加随机移动性。用一根电线四处走动是没有意义的..!

请注意,上面的示例代码会崩溃,因为您创建了 3 个 p2pNode,并且点对点 link 只能在两个节点之间实例化。

我建议学习 ns-3 教程以了解节点、NodeContainers(即节点向量)、NetDevices(即网络 card/type)、MobilityModel 等的概念