(OK)(OK) seem-tools-CLI-manual.sh

来源:互联网 发布:mysql执行sql文件 最快 编辑:程序博客网 时间:2024/05/21 11:21


#------------------------------------------------------------------------------------------# (OK)(OK)(All in CLI) Fedora23 + Docker(busybox) + NS3 + MANETs - testing#------------------------------------------------------------------------------------------systemctl start docker.service# docker search image_name# docker pull image_name# docker images# docker rmi image_name# docker run --privileged -i -t -d --net=none --name docker-$id $docker_image -t $type -i $id# docker psdocker run -it --rm --net='none' --name docker-1 busybox /bin/shdocker run -it --rm --net='none' --name docker-2 busybox /bin/sh# get PID of CONTAINER[root@localhost ~]# docker inspect -f "{{.State.Pid}}" docker-131321[root@localhost ~]# docker inspect -f "{{.State.Pid}}" docker-231357# [root@localhost ~]# man ip-netns#       By convention a named network namespace is an object at /var/run/netns/NAME that can be opened. The file#       descriptor resulting from opening /var/run/netns/NAME refers to the specified network namespace. Holding that#       file descriptor open keeps the network namespace alive. The file descriptor can be used with the setns(2) sys‐#       tem call to change the network namespace associated with a task.#------------------------------------------------------------------------------------------# https://www.nsnam.org/wiki/HOWTO_Use_Linux_Containers_to_set_up_virtual_networks# http://yaxin-cn.github.io/Docker/docker-container-use-static-IP.html#[root@localhost ~]# brctl addbr br_d_1brctl addbr br_d_2ip link add veth_1 type veth peer name Xbrctl addif br_d_1 veth_1ip link set veth_1 upip link set X netns 31321ip link add veth_2 type veth peer name Ybrctl addif br_d_2 veth_2ip link set veth_2 upip link set Y netns 31357tunctl -t tap_d_1tunctl -t tap_d_2ifconfig tap_d_1 0.0.0.0 promisc upifconfig tap_d_2 0.0.0.0 promisc upbrctl addif br_d_1 tap_d_1ifconfig br_d_1 upbrctl addif br_d_2 tap_d_2ifconfig br_d_2 upmkdir /var/run/netnsln -s /proc/31321/ns/net /var/run/netns/31321ln -s /proc/31357/ns/net /var/run/netns/31357ip netns exec 31321 ip link set dev X name eth0ip netns exec 31321 ip link set eth0 upip netns exec 31321 ip addr add 172.17.0.1/16 dev eth0ip netns exec 31357 ip link set dev Y name eth0ip netns exec 31357 ip link set eth0 upip netns exec 31357 ip addr add 172.17.0.2/16 dev eth0cd /proc/sys/net/bridgefor f in bridge-nf-*; do echo 0 > $f; donecd -# ip netns exec 31321 ip route add default via 172.17.42.1# ip netns exec 31357 ip route add default via 172.17.42.1# [root@localhost ~]# brctl show# / # route -n# You will also have to make sure that your kernel has ethernet filtering (ebtables, bridge-nf, arptables) disabled. If you do not do this, only STP and ARP traffic will be allowed to flow across your bridge and your whole scenario will not work.#-----------------------# 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_d_1"));  tapBridge.Install (nodes.Get (0), devices.Get (0));  tapBridge.SetAttribute ("DeviceName", StringValue ("tap_d_2"));  tapBridge.Install (nodes.Get (1), devices.Get (1));#----------------[root@localhost ns-3.25]# ./waf --run scratch/manet-docker --vis# ./waf --run tap-csma-virtual-machine# ./waf --run tap-wifi-virtual-machine------------------------------------------------------172.17.0.2 can ping 172.17.0.1 successfully------------------------------------------------------ifconfig br_d_1 downifconfig br_d_2 downbrctl delif br_d_1 tap_d_1brctl delif br_d_2 tap_d_2brctl delbr br_d_1brctl delbr br_d_2ifconfig tap_d_1 downifconfig tap_d_2 downtunctl -d tap_d_1tunctl -d tap_d_2#------------------------------------------------------------------------------------------# So far, OK OK OK#------------------------------------------------------------------------------------------#--------------------------------------------------------------------------# (OK)(OK)(All in CLI) running two Android-x86 which connect to NS3(MANETs) via "ethernet bridge"#--------------------------------------------------------------------------#-----------# in HOST#-----------tunctl -t tap_a_1ip link set up dev tap_a_1brctl addbr br_a_1brctl addif br_a_1 tap_a_1ip link set up dev br_a_1ifconfig br_a_1 up# ip addr add 10.1.1.1/24 dev br_a_1# ip route add 10.1.1.0/24 dev br_a_1#-----------tunctl -t tap_a_2ip link set up dev tap_a_2brctl addbr br_a_2brctl addif br_a_2 tap_a_2ip link set up dev br_a_2ifconfig br_a_2 up# ip addr add 10.1.1.2/24 dev br_a_2# ip route add 10.1.1.0/24 dev br_a_2#-----------# adb devices# adb root# adb -s 192.168.56.101:5555 shellVBoxManage modifyvm android-x86-6.0-rc1-1 --memory 1024 --nic1 hostonly --nictype1 Am79C973 --hostonlyadapter1 vboxnet0  --nic2 bridged --bridgeadapter2 br_a_1VBoxManage startvm android-x86-6.0-rc1-1sleep 30adb connect 192.168.56.101sleep 1adb -s 192.168.56.101:5555 rootsleep 1adb connect 192.168.56.101sleep 1adb -s 192.168.56.101:5555 rootsleep 1adb connect 192.168.56.101adb -s 192.168.56.101:5555 shell ifconfig eth1 downadb -s 192.168.56.101:5555 shell ifconfig eth1 10.1.1.10 netmask 255.255.255.0 upadb -s 192.168.56.101:5555 shell ifconfig eth0 down# VBoxManage controlvm android-x86-6.0-rc1-1 poweroffVBoxManage modifyvm android-x86-6.0-rc1-2 --memory 1024 --nic1 hostonly --nictype1 Am79C973 --hostonlyadapter1 vboxnet0  --nic2 bridged --bridgeadapter2 br_a_2VBoxManage startvm android-x86-6.0-rc1-2sleep 30adb connect 192.168.56.102sleep 1adb -s 192.168.56.102:5555 rootsleep 1adb connect 192.168.56.102sleep 1adb -s 192.168.56.102:5555 rootsleep 1adb connect 192.168.56.102adb -s 192.168.56.102:5555 shell ifconfig eth1 downadb -s 192.168.56.102:5555 shell ifconfig eth1 10.1.1.20 netmask 255.255.255.0 upadb -s 192.168.56.102:5555 shell ifconfig eth0 down# VBoxManage controlvm android-x86-6.0-rc1-2 poweroff#-----------------------# 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_a_1"));  tapBridge.Install (nodes.Get (0), devices.Get (0));  tapBridge.SetAttribute ("DeviceName", StringValue ("tap_a_2"));  tapBridge.Install (nodes.Get (1), devices.Get (1));#----------------[root@localhost ns-3.25]# ./waf --run scratch/manet-docker --vis# ./waf --run tap-csma-virtual-machine# ./waf --run tap-wifi-virtual-machine#-------------------ifconfig br_a_1 downbrctl delif br_a_1 tap_a_1brctl delbr br_a_1ifconfig tap_a_1 downtunctl -d tap_a_1ifconfig br_a_2 downbrctl delif br_a_2 tap_a_2brctl delbr br_a_2ifconfig tap_a_2 downtunctl -d tap_a_2ifconfig vboxnet0 downifdown vboxnet0#-------------------#------------------------------------------------------------------------------------------# So far, All is OK#------------------------------------------------------------------------------------------


0 0
原创粉丝点击