ns-3脚本初识——WIFI无线网络:third脚本

ns-3脚本初识——WIFI无线网络:third脚本

ps:本文所有文件和目录的默认根目录均为ns-3.29/。

正如在构建点到点拓扑时看到的点到点拓扑和CSMA拓扑助手对象一样,将在本节中看到等效的WiFi拓扑助手。

在examples/tutorial目录中提供了一个示例脚本。此脚本建立在second.cc脚本的基础上,并添加Wi-Fi网络。

该脚本默认拓扑结构如下:

   Wifi 10.1.3.0
                 AP
  *    *    *    *
  |    |    |    |    10.1.1.0
 n5   n6   n7   n0 -------------- n1   n2   n3   n4
                   point-to-point  |    |    |    |
                                   ================
                                     LAN 10.1.2.0

n0和n1实现点到点通信(与first.cc中相似),n1~n4是个CSMA有线局域网(与second.cc中相似)。如图左侧所示,我们创建了许多无线STA(station)节点来填充新的10.1.3.0网络,向点到点链接左侧的节点n0添加一个新的网络设备,该点为无线接入点AP。

1.代码规范

2.头文件

#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"              //移动模块
#include "ns3/csma-module.h"                  //CSMA模块
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"             //Wi-Fi模块
#include "ns3/ssid.h"                         //SSID模块

SSID是Service Set Identifier的缩写,意思是:服务集标识。SSID技术可以将一个无线局域网分为几个需要不同身份验证的子网络,每一个子网络都需要独立的身份验证,只有通过身份验证的用户才可以进入相应的子网络,防止未被授权的用户进入本网络。

3.命名空间

using namespace ns3;

4.日志

NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");

5.主函数声明

int 
main (int argc, char *argv[])
{
…
}

6.主函数准备工作

主程序和second.cc一样,通过添加一些命令行参数来启用或禁用日志记录组件以及更改创建的设备数量来启动。

  //定义bool变量,用于决定是否开启2个UdpApplication的Logging日志组件,默认true开启
  bool verbose = true;
  uint32_t nCsma = 3;//变量,用于定义csma网络中额外有多少个node,此处为3
  uint32_t nWifi = 3;//变量,用于定义wifi网络中有多少个station node,此处为3
  bool tracing = false;//若要开启跟踪文件,则需改为true

  CommandLine cmd;//命令行
  cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
  //“nCsma”参数控制着脚本中CSMA网络中额外节点的数量,其对应的C++同名变量是非整型数nCsma
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
   //同样地,“nWifi”参数控制着脚本中WIFI网络中STA节点的数量
  cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
  //“verbose”参数设置是否开启logging
  cmd.AddValue ("tracing", "Enable pcap tracing", tracing);

  cmd.Parse (argc,argv);

18的底层限制是由于网格位置分配器的配置,如果提供的节点超过18个,网格布局将超过边界框。

  if (nWifi > 18)
    {
      std::cout << "nWifi should be 18 or less; otherwise grid layout exceeds the bounding box" << std::endl;
      return 1;
    }

  if (verbose)
    {
      LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
    }

7.创建网络拓扑

1)P2P链路

  //创建使用P2P链路的两个节点
  NodeContainer p2pNodes;
  p2pNodes.Create (2);

  PointToPointHelper pointToPoint;//PPP信道助手类
  //配置PPP信道属性
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));//传输速率属性 
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));//传播迟延属性

  //安装P2P网卡到P2P网络节点
  NetDeviceContainer p2pDevices;//创建网络设备
  p2pDevices = pointToPoint.Install (p2pNodes);//连接节点与信道

2)csma网络

  //创建csma网络节点
  NodeContainer csmaNodes;
  csmaNodes.Add (p2pNodes.Get (1));//将P2P的节点1加到CSMA网络中
  csmaNodes.Create (nCsma);//再创建额外的3个节点

  CsmaHelper csma;//CSMA信道助手类
  //设置CSMA传输速率和传播延迟
  csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
  csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));

  //安装CSMA网卡到CSMA网络节点
  NetDeviceContainer csmaDevices;
  csmaDevices = csma.Install (csmaNodes);

3)wifi网络

  //创建WIFI网络节点
  NodeContainer wifiStaNodes;
  wifiStaNodes.Create (nWifi);//创建3个STA节点
  NodeContainer wifiApNode = p2pNodes.Get (0);//用点到点链接的最左端节点作为AP

设置Channel和WifiPhy。
用到两个助手类YansWifiChannelHelper和YansWifiPhyHelper。

  //默认传播迟延模型:ConstantSpeedPropagationDelayModel
  //默认损耗模型:LogDistancePropagationLossModel
  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
  
  //默认无码率模型:NistErrorRateModel
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  
  phy.SetChannel (channel.Create ());//使用默认的PHY层配置和信道模型

PHY(Port Physical Layer),中文可称之为端口物理层,是一个对OSI模型物理层的共同简称。

设置WifiMac并在节点中安装NetDevice。
用到两个助手类WifiHelper和WifiMacHelper。

  WifiHelper wifi;
  //SetRemoteStationManager方法告诉助手类使用哪种速率控制算法,此处为AARF算法
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");

  WifiMacHelper mac;
  //创建IEEE 802.11服务集标识符(SSID)对象,用来设置MAC层的“SSID”属性值
  Ssid ssid = Ssid ("ns-3-ssid");
  
  mac.SetType ("ns3::StaWifiMac",//移动节点
               "Ssid", SsidValue (ssid),
               "ActiveProbing", BooleanValue (false));//助手类创建的MAC将不会发送探测请求

  //安装移动节点
  NetDeviceContainer staDevices;
  staDevices = wifi.Install (phy, mac, wifiStaNodes);

  mac.SetType ("ns3::ApWifiMac",//AP节点
               "Ssid", SsidValue (ssid));

  //安装AP节点
  NetDeviceContainer apDevices;
  apDevices = wifi.Install (phy, mac, wifiApNode);

设置移动模型
我们希望STA节点是移动的,在一个边界框内漫游,并且希望使AP节点保持静止。
ns-3使用笛卡尔坐标系标识节点位置,助手类是MobilityHelper。

  MobilityHelper mobility;

  //为移动节点设置移动模型
  //移动节点模型设置分为两部分:初始位置分布,后续移动轨迹模型
  //初始位置分布器:GridPositionAllocator
  //按照设置好的行列参数把节点等间距放在一个二维笛卡尔坐标系中
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
                                 //起始坐标(0,0)
                                 "MinX", DoubleValue (0.0),
                                 "MinY", DoubleValue (0.0),
                                 "DeltaX", DoubleValue (5.0),//X轴节点间距:5m
                                 "DeltaY", DoubleValue (10.0),//Y轴节点间距:10m
                                 "GridWidth", UintegerValue (3),//每行最大节点数
                                 "LayoutType", StringValue ("RowFirst"));

  //移动轨迹模型:RandomWalk2dMobilityModel
  //节点在一个指定大小的长方形区域内按照随机速度(默认取值范围是[2,4]m/s)和方向移动
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
  mobility.Install (wifiStaNodes);

  //为AP节点设置移动模型
  //使用固定位置移动模型ConstantPositionMobilityModel,这个模型的AP节点二维坐标为(0,0)
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility.Install (wifiApNode);

下图为该脚本中AP节点和移动及节点初始位置分布以及节点移动区域的示意图:
ns-3脚本初识——WIFI无线网络:third脚本_第1张图片

8.安装TCP/IP协议族

  //安装TCP/IP协议栈
  InternetStackHelper stack;
  stack.Install (csmaNodes);
  stack.Install (wifiApNode);
  stack.Install (wifiStaNodes);

  Ipv4AddressHelper address;//为网络设备分配IP地址

  //安排P2P网段的地址
  address.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer p2pInterfaces;
  p2pInterfaces = address.Assign (p2pDevices);

  //安排CSMA网段的地址
  address.SetBase ("10.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer csmaInterfaces;
  csmaInterfaces = address.Assign (csmaDevices);

  //安排WIFI网段的地址
  address.SetBase ("10.1.3.0", "255.255.255.0");
  address.Assign (staDevices);
  address.Assign (apDevices);

9.安装应用层

  UdpEchoServerHelper echoServer (9);//服务端设置端口号

  //在最右端的节点n4中安装服务端程序
  ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (10.0));

  //配置客户端程序属性
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

  
  //在最后创建的STA节点n7中安装客户端程序
  ApplicationContainer clientApps = 
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
  clientApps.Start (Seconds (2.0));
  clientApps.Stop (Seconds (10.0));

10.设置路由

 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

11.使模拟器停止

刚刚创建的模拟永远不会“自然”停止。这是因为要求无线接入点生成beacons。它将永远生成beacons,导致模拟器事件会无限期出现,所以我须告诉模拟器停止,即使它可能已经安排了beacons生成事件。

下面的代码行告诉模拟器停止,否则会进入无限循环。

  Simulator::Stop (Seconds (10.0));

12.数据追踪

  if (tracing == true)
    {
      pointToPoint.EnablePcapAll ("third");
      phy.EnablePcap ("third", apDevices.Get (0));
      csma.EnablePcap ("third", csmaDevices.Get (0), true);
    }

13.启动与结束

  Simulator::Run ();
  Simulator::Destroy ();
  return 0;

14.上机实践

在ns-3.29(或其他的版本)目录下运行second模拟脚本(需要在编译时启动enable-examples选项,不然就将脚本放到scratch目录下)。

./waf --run third

编译结果如下:
ns-3脚本初识——WIFI无线网络:third脚本_第2张图片
可以看出,UDP回显客户端发送1024byte数据分组给地址为10.1.2.4的服务器,此时客户端在地址为10.1.3.3的无线网络处。当UDP回显服务器收到数据分组后,会发送相同的字节给回显客户端。

如果回到根目录ns-3.29/,将会发现4个跟踪文件,如下图所示:
跟踪文件
可以查看这四个跟踪文件:

tcpdump -nn -tt -r third-0-1.pcap

会看到链路类型是IEEE802.11(IEEE 802.11是现今无线局域网通用的标准),信息显示类此次跟踪的IP回显请求和回复数据分组,如下:

reading from file third-0-1.pcap, link-type IEEE802_11 (802.11)
0.032090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.120391 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.120407 Acknowledgment RA:00:00:00:00:00:08 
0.120539 Assoc Response AID(1) :: Successful
0.120683 Acknowledgment RA:00:00:00:00:00:0a 
0.120858 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.120874 Acknowledgment RA:00:00:00:00:00:07 
0.120988 Assoc Response AID(2) :: Successful
0.121132 Acknowledgment RA:00:00:00:00:00:0a 
0.121316 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.121332 Acknowledgment RA:00:00:00:00:00:09 
0.121437 Assoc Response AID(3) :: Successful
0.121581 Acknowledgment RA:00:00:00:00:00:0a 
0.134490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.236890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.339290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.441690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.544090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.646490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.748890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.851290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
0.953690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.056090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.158490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.260890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.363290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.465690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.568090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.670490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.772890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.875290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
1.977690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.006112 ARP, Request who-has 10.1.3.4 (ff:ff:ff:ff:ff:ff) tell 10.1.3.3, length 32
2.006128 Acknowledgment RA:00:00:00:00:00:09 
2.006233 ARP, Request who-has 10.1.3.4 (ff:ff:ff:ff:ff:ff) tell 10.1.3.3, length 32
2.006433 ARP, Reply 10.1.3.4 is-at 00:00:00:00:00:0a, length 32
2.006605 Acknowledgment RA:00:00:00:00:00:0a 
2.008151 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP, length 1024
2.008167 Acknowledgment RA:00:00:00:00:00:09 
2.031758 ARP, Request who-has 10.1.3.3 (ff:ff:ff:ff:ff:ff) tell 10.1.3.4, length 32
2.032017 ARP, Reply 10.1.3.3 is-at 00:00:00:00:00:09, length 32
2.032033 Acknowledgment RA:00:00:00:00:00:09 
2.032165 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP, length 1024
2.033701 Acknowledgment RA:00:00:00:00:00:0a 
2.080090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.182490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.284890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.387290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.489690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.592090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.694490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.796890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
2.899290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.001690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.104090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.206490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.308890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.411290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.513690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.616090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.718490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.820890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
3.923290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.025690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.128090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.230490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.332890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.435290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.537690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.640090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.742490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.844890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
4.947290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.049690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.152090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.254490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.356890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.459290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.561690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.664090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.766490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.868890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
5.971290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.073690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.176090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.278490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.380890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.483290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.585690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.688090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.790490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.892890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
6.995290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.097690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.200090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.302490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.404890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.507290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.609690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.712090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.814490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
7.916890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.019290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.121690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.224090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.326490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.428890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.531290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.633690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.736090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.838490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
8.940890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.043290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.145690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.248090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.350490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.452890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.555290 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.657690 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.760090 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.862490 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
9.964890 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS

其他几个跟踪文件查看方法相同,不再赘述。

输出可视化界面的代码如下:

./waf --run third --vis

ns-3脚本初识——WIFI无线网络:third脚本_第3张图片ns-3脚本初识——WIFI无线网络:third脚本_第4张图片

你可能感兴趣的:(ns-3示例脚本,ns-3)