ns3--TapBridge, TapNetDevice,FdNetDevice等

./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添加网桥

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值