您的位置:首页 > 其它

ns3--TapBridge, TapNetDevice,FdNetDevice等

2016-11-01 17:37 141 查看
./src/tap-bridge/examples/tap-wifi-dumbbell.cc
目录下的这个文件,

其拓扑图为:



默认为
ConfigureLocal
模式



1) 程序编译运行之后在得到的shell中ping某个与AP在同一个WIFI网络的节点 10.1.1.3

$ ./waf --run tap-wifi-dumbbell&
$ ping 10.1.1.3


我是说怎么能在代码编译之后用
ping 10.1.1.3
呢,原来是在编译成功之后得到的一个shell中就配置好了一个名叫
thetap
的网卡设备,IP为
10.1.1.1
,相当于它是AP,然后就可以通过它来ping与它同网段的
10.1.1.3
了。

这些结果就是想表明,

一个实际的linux主机可以ping一个在ns-3中的节点!!!

注意这里的编译运行的时候,要用
sudo
,因为涉及到操作网卡,要用高权限的
sudo




这次之所以无法ping通是因为之前已经用那个源文件里的第四步配置了一个bridge。



2) 在linux主机上配置一条路由,以便使AP(10.1.1.1)ping得通CSMA网络的10.1.3.4

$ ./waf --run tap-wifi-dumbbell&
$  sudo route add -net 10.1.3.0 netmask 255.255.255.0 dev thetap gw 10.1.1.2
$  ping 10.1.3.4


发现,当ping一个CSMA节点(即通过P2P连接之后的节点)时,延迟非常大,达到了几百ms。

这里是AP(10.1.1.1)将10.1.1.2设置为其ping 10.1.3.4时的临时『网关』,从这里(10.1.1.2)路由到10.1.3.4 这里的10.1.1.2是与AP同一个节点n0的另外一个网卡。



The Tap Bridge lives in a kind of a gray world somewhere between a Linux host and an ns-3 bridge device. From the Linux perspective, this code appears as the user mode handler for a TAP net device. In ConfigureLocal mode, this Tap device is automatically created by the ns-3 simulation. When the Linux host writes to one of these automatically created /dev/tap devices, the write is redirected into the TapBridge that lives in the ns-3 world; and from this perspective, the packet write on Linux becomes a packet read in the Tap Bridge. In other words, a Linux process writes a packet to a tap device and this packet is redirected by the network tap mechanism toan ns-3 process where it is received by the TapBridge as a result of a read operation there. The TapBridge then writes the packet to the ns-3 net device to which it is bridged; and therefore it appears as if the Linux host sent a packet directly through an ns-3 net device onto an ns-3 network.

Tap Bridge存在于某个在Linux主机与ns-3的Bridge Device之间的灰色空间。从Linux角度看,代码看起来像Tap NetDevice的处理器。在
ConfigureLocal
模式下,这个Tap NetDevice是由ns-3模拟器自动创建的。。。。(未完待续)

参考:

https://www.nsnam.org/docs/release/3.17/models/singlehtml/index.html#emulation-overview

tunctl添加虚拟网卡TUN/TAP与brctl添加网桥
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ns3