ns(1)配置

Contents

严格按官网来.第一个坑就会出现:

install boost

自己去boost的官网下载编译.一切完成以后再重启:

1
2
3
4
5
6
7
8
9
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/tender/ndnSIM/boost_1_64_0
The following directory should be added to linker library paths:
/home/tender/ndnSIM/boost_1_64_0/stage/lib

现在boost是1.64.0;ndnsim是2.23;ns-3是3.26;py是2.7;
然后出现第二发:

module not enableed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---- Summary of optional NS-3 features:
Build profile : optimized
Build directory :
Python Bindings : not enabled (PyBindGen version not correct and newer version could not be retrieved)
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite))
NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
GtkConfigStore : not enabled (library 'gtk+-2.0 >= 2.12' not found)
XmlIo : not enabled (library 'libxml-2.0 >= 2.7' not found)
Threading Primitives : enabled
Real Time Simulator : enabled
File descriptor NetDevice : enabled
Tap FdNetDevice : enabled
Emulation FdNetDevice : enabled
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
MPI Support : not enabled (option --enable-mpi not selected)
ndnSIM : not enabled (Required boost libraries not found)
NS-3 OpenFlow Integration : not enabled (Required boost libraries not found)
SQlite stats data output : enabled
Tap Bridge : enabled
PyViz visualizer : not enabled (Python Bindings are needed but not enabled)
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
Build tests : not enabled (defaults to disabled)
Build examples : not enabled (defaults to disabled)
GNU Scientific Library (GSL) : not enabled (GSL not found)
'configure' finished successfully (12.123s)

出现问题的原因是pybindgen没编译:

1
sudo ./waf configure --boost-includes=/opt/boost_1_64_0 --boost-libs=/opt/boost_1_64_0/stage/lib --enable-examples

然后各种正常 嗯

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---- Summary of optional NS-3 features:
Build profile : debug
Build directory :
Python Bindings : not enabled (PyBindGen version not correct and newer version could not be retrieved)
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite))
NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
GtkConfigStore : not enabled (library 'gtk+-2.0 >= 2.12' not found)
XmlIo : not enabled (library 'libxml-2.0 >= 2.7' not found)
Threading Primitives : enabled
Real Time Simulator : enabled
File descriptor NetDevice : enabled
Tap FdNetDevice : enabled
Emulation FdNetDevice : enabled
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
MPI Support : not enabled (option --enable-mpi not selected)
ndnSIM : enabled
NS-3 OpenFlow Integration : not enabled (OpenFlow not enabled (see option --with-openflow))
SQlite stats data output : enabled
Tap Bridge : enabled
PyViz visualizer : not enabled (Python Bindings are needed but not enabled)
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
Build tests : not enabled (defaults to disabled)
Build examples : enabled
GNU Scientific Library (GSL) : not enabled (GSL not found)
'configure' finished successfully (10.225s)

抓重点:gtk和libxml是找不到的;pybindgen是版本不对的
解决方案非常狗血:直接改version.py….握草…把版本号改了就编译过去了…

现在再去编译ns-3的结果就是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
lr-wpan lte mesh
mobility mpi ndnSIM
netanim (no Python) network nix-vector-routing
olsr point-to-point point-to-point-layout
propagation sixlowpan spectrum
stats tap-bridge test (no Python)
topology-read uan virtual-net-device
visualizer wave wifi
wimax
Modules not built (see ns-3 tutorial for explanation):
brite click openflow

貌似用ndnSIM的话也用不上brite吧.of明摆着sdn的梗
click是一个构建可配置路由器的软件架构,通过使用称之为元素element(即包处理单元)的不同组合,click路由器能够执行特定功能,这种灵活性提供了测试和实验不同协议的优良平台。需要吗???
brite是自动生产拓扑的 ndnsSIM是否需要他,我也很怀疑呢

loading libraries

然后编译scenario出现:
error while loading shared libraries: libboost_graph.so.1.64.0: cannot open shared object file: No such file or directory

解决方法:修改/etc/ls.so.conf,添加/usr/local/lib;
这个库存的是编译时动态连接库的路径(编译器默认存的是/lib和/usr/lib)
保存后在etc下执行ldconfig 然后无误.
ldconfig是root用户的操作,用来把动态连接库缓存到cache(换句话说,改完ls.so.conf就应该ldconfig)

现在可以在ns-3目录下直接

1
./waf --run=<scanario> --vis

deploy my scanario

最后一个可有可无的锅 爱背不背
如果直接把文件写到example里不会有问题了.但是如果像git一样另开一个文件专注于仿真:
按照git上的模板来,会有以下error:

1
2
3
4
5
6
7
Checking for ns3-core : not found
NS-3 or one of the required NS-3 modules not found
NS-3 needs to be compiled and installed somewhere. You may need also to set PKG_CONFIG_PATH variable in order for configure find installed NS-3.
For example:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH ./waf configure
(complete log in /home/tender/ndnSIM/my-simulations/build/config.log)

事情很简单了:添加PKG_CONFIG_PATH.关于ns-3的所有信息
我找了找应该是在/usr/local/lib64/pkgconfig
但是没有用 哎
我跟你讲我把所有的pkgconfig都添加进去都没用

更刺激的是,打开文件的log:

1
2
3
4
5
6
7
8
9
10
11
12
13
Checking for program 'pkg-config'
/usr/bin/pkg-config
find program=['pkg-config'] paths=['/root/.nvm/versions/node/v4.7.0/bin', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/home/tender/ccn-lite-0.3.0/bin'] var='PKGCONFIG' -> ['/usr/bin/pkg-config']
------------------------------------------
Checking for pkg-config version >= '0.0.0'
['/usr/bin/pkg-config', '--atleast-pkgconfig-version=0.0.0']
yes
------------------------------------------
Checking for ns3-core
['/usr/bin/pkg-config', '--cflags', '--libs', 'libns3-dev-core-optimized']
out: -pthread -I/usr/local/include/ns3-dev -L/usr/local/lib64 -Wl,-Bdynamic -lns3-dev-core-optimized -lrt -lpthread
yes

所以你都找到了???那是发生了什么??

1
2
3
4
5
6
7
8
Checking for ns3-ndnSIM
['/usr/bin/pkg-config', '--cflags', '--libs', 'libns3-dev-ndnSIM-optimized']
err: Package libns3-dev-ndnSIM-optimized was not found in the pkg-config search path.
Perhaps you should add the directory containing `libns3-dev-ndnSIM-optimized.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libns3-dev-ndnSIM-optimized' found
not found

缺一个文件 可他在哪啊
把前面的所有流程核对了一遍
发现编译ns-3的时候只注意了boost,没有加d -optimized.
再来一遍!!!…
waf完以后记得./waf install
然后ldconfig!!!(目测问题在这)
然后过!!!神tm居然过了!!!!!!

run my scanario

随便运行一个cpp

1
build/ndn-simple: error while loading shared libraries: libns3-dev-core-optimized.so: cannot open shared object file: No such file or directory

之前加的是PKG 估计是LG的路径吧
gedit ~/.bashrc
直接改!劳资知道你在哪! /usr/local/lib64 (找PKG的时候不小心看见的 哈哈哈)
发出了幸福的哭声
宝宝终于搭完环境了!!!

后来:
我不懂为什么那个bug又出现了…
所以运行了LD_LIBRARY_PATH=/usr/local/lib64 ./waf –run ndn-simple –vis
解决方案是source ~/.bashrc