ns3笔记

来源:互联网 发布:mac的hosts文件在哪 编辑:程序博客网 时间:2024/05/16 01:14

ns3 installation

https://www.nsnam.org/wiki/Installation

———————-9月30日 更————————————-

在使用FlowMonitor模块的时候,关于include哪个头文件的问题。

当我

#include "ns3/flow-monitor-module.h"

的时候,给我报错。
error: ‘ns3::FlowMonitorHelper::FlowMonitorHelper(const ns3::FlowMonitorHelper&)’ is private
还有../scratch/goal-topo.cc:164:84: error: within this context
Simulator::Schedule (nSamplingPeriod, &CheckThroughput, flowmon, monitor, dataset);

这里写图片描述
当我

#include "ns3/flow-monitor-helper.h"

的时候,又给我报这个错误。
这里写图片描述
不知道到底是什么鬼。。。
以上已解决。

去掉Simulator::Stop(stopTime);之后

这里写图片描述
Simulation不会停止,而且不能显示吞吐量。

把Simulator::Schedule()从CheckThroughput()函数里拿出来放到main()之后

这里写图片描述
依然不能测得吞吐量。
———————–9月24日更————————————-
今天临晨试着在ubuntu-14.04上再装一下openflow integration。最后用另外一种方式./bake安装好了openflow integration.
记住目录结构是这样的。
这里写图片描述
草!终于尼玛安装成功了。
这里写图片描述
———————–9月24日更————————————–

参考:
http://www.cnblogs.com/yibobo-blog/p/4924340.html
ns-3的API:
https://www.nsnam.org/docs/release/3.17/doxygen/
一些学习的视频:
ns3 overview
ns3share’s channel
tutorial-ns3
Building Simple Network Topologies p2

Main

——————7月8日更新———————————–
我拿着这个bug在网上半天找不到答案,突然找到一个Google Group里面的回答,发现跟我之前装ns3的方式不一样。于是在之前ns3的兄弟目录装了一个他们说的那种版本的ns3.
http://mailman.isi.edu/pipermail/ns-bugs/2015-February/011975.html
并按照这里面的内容改了一下几个文件(其实就是在一个.cc文件里面include了某个头文件,而在另一个文件.h里取消了include那个头文件,然后改了一下wscript)。
这里写图片描述
编译这两千个.cc文件也是不简单给ubuntu的2.2G内存用完了,结果还碰到一个g++编译器的问题,得用swap,于是在本来就不多的硬盘上给了1G用作swap,sudo dd if=/dev/zero of=/swapfile bs=64M count=16sudo mkswap /swapfile
sudo swapon /swapfile
。编译完成之后删除sudo swapoff /swapfile
sudo rm /swapfile
。其实就是在『bindings/ns3module.cc』这个文件编译的时候超级吃内存(感觉得要2G),这种文件编译完了立马内存就释放了。
http://skypacer210.github.io/2014/12/26/building-ns-3-on-ubuntu/
这里写图片描述
这里写图片描述
OK,在这种下载ns3的方式下,编译成功了。
这里写图片描述
————————-我是分割线——————————–
最近准备建一些混杂的拓扑(有WIFI,有点对点,有CSMA以太网),但是OpenNet这个库是刚出来的,有一些小bug,不太好用,于是跟Gilani交流后,他说ns-3可以做,于是我上网找了一些视频开始学习。
看视频里面的代码的一个示例:tutorial4.cc
这里写图片描述
这里是要建立的拓扑:
这里写图片描述
实际上每个节点(由NodeDeviceContainer建立的)是按照创建顺序然后依次排入一个NodeList中,用来为没个节点建立数字索引。
这里写图片描述
每个网卡(API里面叫NetDevice,比如回环网卡LoopbackNetDevice, 点对点网卡PointToPointNetDevice等)

这里写图片描述
一个物理的网络设备可以有安装多个网卡
这里写图片描述

————————–9月1日————————-
现在要监控网络流量,测速。要用到ns3/flow-monitor-helper.h
但是网上看到的例子
https://groups.google.com/forum/#!topic/ns-3-users/9_X3qWt3dBI里面碰到一个issue。
这里写图片描述
然后发现可以这样解决。

For ns-3.15 or later, you should be doing instead:
onOffHelper.SetAttribute (“OnTime”, StringValue
(“ns3::ConstantRandomVariable[Constant=20]”));
This was an API change from ns-3.14 to ns-3.15.

https://groups.google.com/forum/#!topic/ns-3-users/iG9Y3KBx29U

————-9月18日 更————————–

设置NS_LOG环境变量

原来得在命令行里设置环境变量,那些NS_LOG_INFO()才会生效。

$ export NS_LOG=GoalTopoScript=info

其中GoalTopoScript这个值是在我的那个goal-topo.cc文件开头定义的。
这里写图片描述

// 用于命令行操作 `$ export NS_LOG=GoalTopoScript=info`NS_LOG_COMPONENT_DEFINE ("GoalTopoScript");

设置好NS_LOG环境变量之后,再运行,就可以看到NS_LOG_INFO()的消息了。
这里写图片描述

————————9月20日 更—————————–
『./ns3/log-macros-enabled.h:156:11: error: ‘g_log’ was not declared in this scope』
当我运行

$ ./waf --run wifi-wired-bridging

的时候,他给我报这个错。
这里写图片描述
查了下google groups里面说的,
https://groups.google.com/forum/#!topic/ns-3-users/i9HijXJADKU
原来是没有在using namespace ns3int main()之间加

NS_LOG_COMPONENT_DEFINE ("wifiWiredBridgingScript");

加上之后,果然编译成功了。
这里写图片描述
然后查看一下.pcap抓包文件。

$ tcpdump -tt -nn -r wifi-wired-bridging-0-2.pcap |grep -E "192.168.0.6|192.168.0.2"#或者 grep -e "192.168.0.6" -e "192.168.0.2"

这里写图片描述

1 0
原创粉丝点击