(OK)(OK) running two Android-x86 in VirtualBox, they connect to NS3(MANETs) via "ethernet bridge"

--------------------------------------------------------------------------
running two Android-x86 in VirtualBox, they connect to NS3(MANETs) via "ethernet bridge"
--------------------------------------------------------------------------

-----------
in HOST
-----------
tunctl -t tap-1
ip link set up dev tap-1
brctl addbr br-android1
brctl addif br-android1 tap-1
ip link set up dev br-android1
ip addr add 10.1.1.1/24 dev br-android1
ip route add 10.1.1.0/24 dev br-android1

-----------
tunctl -t tap-2
ip link set up dev tap-2
brctl addbr br-android2
brctl addif br-android2 tap-2
ip link set up dev br-android2
ip addr add 10.1.1.2/24 dev br-android2
ip route add 10.1.1.0/24 dev br-android2

-----------

ifconfig br-android1 down
brctl delif br-android1 tap-1
brctl delbr br-android1
ifconfig tap-1 down
tunctl -d tap-1

ifconfig br-android2 down
brctl delif br-android2 tap-2
brctl delbr br-android2
ifconfig tap-2 down
tunctl -d tap-2

-----------

[root@localhost virtualbox-os]# pwd
/run/media/root/158a840e-63fa-4544-b0b8-dc0d40c79241/virtualbox-os

[root@localhost virtualbox-os]# ll -h
总用量 11G
-rw-------. 1 root root 5.1G 6月  14 21:24 android-x86-6.0-rc1-1.vdi
-rw-------. 1 root root 5.1G 6月  14 21:17 android-x86-6.0-rc1-2.vdi
[root@localhost virtualbox-os]#

-----------

// Virtual Box > Settings > Network > Adapter 1 > bridge, br-android1.

// in android-x86-6.0-rc1-1
ifconfig eth0 down
ifconfig eth0 10.1.1.10 netmask 255.255.255.0 up


-----------

// Virtual Box > Settings > Network > Adapter 1 > bridge, br-android2.

// in android-x86-6.0-rc1-2
ifconfig eth0 down
ifconfig eth0 10.1.1.20 netmask 255.255.255.0 up


-----------

-----------------------
running NS3
-----------------------
[root@localhost ~]# cd /opt/tools/network_simulators/ns3/ns-allinone-3.25/ns-3.25

[root@localhost ns-3.25]# gedit scratch/manet-docker.cc
//----------------
  TapBridgeHelper tapBridge;
  tapBridge.SetAttribute ("Mode", StringValue ("UseLocal"));
  tapBridge.SetAttribute ("DeviceName", StringValue ("tap-1"));
  tapBridge.Install (nodes.Get (0), devices.Get (0));

  tapBridge.SetAttribute ("DeviceName", StringValue ("tap-2"));
  tapBridge.Install (nodes.Get (1), devices.Get (1));
//----------------

[root@localhost ns-3.25]# ./waf --run scratch/manet-docker --vis

android-x86-6.0-rc1-1 can ping android-x86-6.0-rc1-2, and vice verse





-----------------------
So far, all is OK
-----------------------
原文地址:https://www.cnblogs.com/ztguang/p/12646362.html