NS3 实验脚本的编写步骤

第一步:配置主机,安装模块

  • (1)创建N个节点:
NodeContainer nodes; nodes.Creat(N);

比如我目前接触到的PointToPoint,N就是2

  • (2)利用拓扑助手Helper设置链路:
NetDeviceContainer devices;
devices = pointtopointHelper.Install(nodes);
  • (3)安装协议栈:
InternetStackHelper stack;
stack.Install( nodes );
  • (4)分配IP地址:
Ipv4AddressHelper addressHelper;
addressHelper.SetBase( "10.1.1.0", "255.255.255.252" );
Ipv4InterfaceContainer interfaces = addressHelper.Assign( devices );  //interfaces
  • (5)创建路由节点(还不熟悉)
Ipv4GlobalRoutingHelper::PopulateRoutingTables()

第二步:安装应用

  • (1)Application.Creat(); //根据不同的要求配置不同的应用
  • (2)Node.Install(MyApp);
  • (3)Simulator::Run();
原文地址:https://www.cnblogs.com/qq952693358/p/5669562.html