adhoc 通信程序的路径为:~/tarballs/ns-allinone-3.36.1/ns-3.36.1/scratch
1. 脚本运行
在 ns-3.36.1 目录下运行 adhoc 脚本
$ ./ns3 run scratch/adhoc
2. 利用NetAnim实现可视化
(有关NetAnim的安装与编译此处不进行介绍)
使用NetAnim前需要在脚本中加入头文件
#include "ns3/netanim-module.h"
在脚本中语句 Simulator::Run()前添加如下代码
AnimationInterface anim("adhoc.xml");
随后再次运行脚本以生成xml文件
使用命令行进入netanim目录,在该目录下使用如下语句运行NetAnim
$ ./NetAnim
在NetAnim界面中打开之前编译生成的xml文件
随后便可进行可视化仿真
仿真结果如下