Skip to content
Jose Daniel Britos edited this page Feb 1, 2015 · 42 revisions

Welcome to Network mesh emulator wiki!

Introduction

The purpose of this network emulator is to test evaluate and debug mesh network protocols how the B.A.T.M.A.N. ADV protocol. This network emulator is a front end for virtualbox openwrt machines connected trough a vde-switch and wirefilter emulating a wireless link. The front end is writed in python with pygtk gui. The python program monitor the openwrt machines with snmp protocol, showing in the main screen transmited packets for each interface, and originators interfaces for batmam-adv protocol. The vde-switches have tap interfaces connected with the host machine, this permit monitor the packet traffic with the Wire-shark program, the eth0 interface of the openwrt machines are connected to the host via the vboxnet interface of the host, in this way is possible to access to the openwrt console for management purpose. The mesh is integrate with nodes and wireless connection. Each node diagram is show in the folowing figure.

Architecture

The architecture is basically compound of two elements Nodos and Links (Wirefilter) as shown in the figure 1.

Mesh diagram

Figure 1

The nodos are shon in figure 2 this are more complex and have the folowing elements:

  • OpenWrt, kamikaze trunk version for x86 with minimal modifications (see below)
  • VirtualBox (unmodified) the version must suport vde-switch.
  • Vde_switch must run two instance for nodo to support 2.4 GHz and 5.0 GHz networks. The vde-switch have a patch colorfull see below.

Vde switch diagram

Figure 2

##OpenWrt A standard OpenWrt can be downloaded and configured for X86. Once that virtual machine is runining some packages must be download (ip, snmpd, tcpdump, netcat, kmod-batman-adv, batctl).

For an automatic configuration of the network interfaces devices setup on boot must be use the following script and save it as './files/etc/rc.local' in your local OpenWrt build directory):


#!/bin/sh
# pass ip config trough ethernet mac address
RED=$(ifconfig eth1 | sed '1,1!d' | sed 's/.*HWaddr //'| sed 's/.\{11\}://'| sed 's/.\{5\}$//')
NUM=$(ifconfig eth1 | sed '1,1!d' | sed 's/.*HWaddr //'| sed 's/.*://'| sed 's/[\n\ ].*//')
#delete bridge
ifconfig br-lan down
brctl delbr br-lan
#delete eth0
ip link delete eth0
ip addr add 192.168.100.$NUM/24 dev eth0
ip link set dev eth1 mtu 1532 up
ip link set dev eth2 mtu 1532 up
batctl -m bat0 interface add eth1
batctl -m bat0 interface add eth2
ip addr add 192.168.$RED.$NUM/24 dev bat0
ip link set dev bat0 address 90:$NUM:$NUM:$NUM:$NUM:$NUM
ip link set dev bat0 up
batctl -m bat0 originators

In virtualBox is difficult to pas the IP address for the interfaces this is accomplished setting the mac address in VirtualBox and int the "rc.local" script read the mac address and set the ip in the interfaces.

##VirtualBox

The VirtualBox version must by 4.3 or higher. To verify VDE-Switch support in the network windows select in Attached to: "Generic Driver" in the Name: box verify that exist VDE. The configuration of the virtual machines openwrt is made trough console with the VBoxManage command.

##vde_switch The main advantage of vde_switch over uml_switch is that any clients can be attached to this virtual switch: VirtualBox, UML, tap interfaces, virtual interconnections, and not just UML instances.

If the vde_switches were just connected with wirefilter "patch cables" without modification, we would end up creating a broadcast domain and switch loops which we don't want: The goal is to allow the packets to travel only from one host to it's neighbor, not farther.

To accomplish this, the vde_switch needs to be modified to have "coloured" ports. The idea is:

  • each port has a "colour" (an integer number)
  • packets are only passed from ports to others with DIFFERENT colours.
  • packets are dropped on outgoing ports if it has the SAME colour (same number) as the incoming port.

In this concept, the host port can have colour 1 the TAP port colour 2, while the interconnection ports have colour 0. In this way, packets can only travel from the host to (all of) the interconnection ports, or from one interconnection port to the host port. However packets can not travel between the interconnection ports, thus only allowing "one hop" connections and avoiding switch loops and shared broadcast domains. The concept is illustrated in figure 2. The patch against vde2-2.3.2 (current latest stable version) to add this colour patch can be find here: vde2-2.3.2_colour.patch

##wirefilter The wirefilter program is a tool where its posiblen simulate various link defects and limits:

  • packet loss
  • burst loss
  • delay
  • duplicates
  • bandwidth
  • Interface speed
  • Chanel capacity
  • noise (damage to packets)
  • mtu

However as the links are only set up bidirectional, interferences can unfortunately not be simulated with this system.

For advanced testing it might be necessary to apply the aforementioned link defects to some packets only whereas other packets are able to traverse the emulated environment unharmed. Once you applied the 'ethertype' patch you can specify an ethertype which wirefilter will simply forward. To apply a packet loss of 50% to all packets except batman-adv packets, run:


wirefilter --ether 0x4305 -l 50

This patch also allows to filter batman-adv packet types. To apply a packet loss of 50% to all packets except batman-adv ICMP packets, run:


wirefilter --ether 0x4305:02 -l 50

You can specify up to 10 packet types (separated by colon). The patch against vde2-2.3.1 (current latest stable version) can be found here:


vde2-2.3.1-wirefilter-ethertype.patch
Clone this wiki locally