Motivation
If you are interested in contributing to or testing the mesh stack, you should consider using hwsim interfaces plus the wireless medium userspace tool. Why?
With hwsim/wmediumd you can create a multi node mesh network on a single host and simulate all sorts of topologies.
Tutorial
Let's start with a simple example. Imagine that you want to see multi-hopping at work. The simplest possible topology to achieve that would be a triangle:
To make it more interesting, let's also assume that you want to simulate different probability losses over different links. For this example we will use 1.0 loss probability between nodes 0 and 2, 0.8 loss probability between nodes 1 and 2, and 0.0 (no losses) between nodes 0 and 1.
1. Patch your kernel
Now the hwsim userspace extensions have been accepted in wireless-testing kernel development tree, if you plan to use a diferent kernel branch, and until the changes make it upstream, you'll need to patch your kernel with this patch.
It's also very useful to apply the send-to-self patch ( http://www.ssi.bg/~ja/#loop) to be able to ping between the mesh nodes you'll create in the next step. A version of the patch for 2.6.39-rc1 is available here
2. Create 3 hwsim radios and create a mesh
As root, do the following:
modprobe mac80211 modprobe mac80211_hwsim radios=3 for i in `seq 0 3` do iw phy phy$i interface add mesh$i type mp mesh_id bazooka echo 1 > /proc/sys/net/ipv4/conf/mesh$i/loop ifconfig mesh0 192.168.77.1$i done
And confirm that nodes are all connected.
iw dev mesh0 station dump | grep -e Sta -e plink Station 42:00:00:00:02:00 (on mesh0) mesh plink: ESTAB Station 42:00:00:00:01:00 (on mesh0) mesh plink: ESTAB
3. Get wmediumd
Clone it from here. Then compile it.
4. Create a configuration file
Now there are two methods available to create configurations files; directly, using wmediumd, or using wconfig, this new tool provides a visual and easier way to create and modify mesh simulation topologies for wireless medium daemon (wmediumd).
We recommend the creation/edition of mesh topologies using the Wmediumd Configuration Tool [link], but you can create your own configuration files by hand following this guide [link]
4.1. Using wconfig
First of all check that your system has installed a Java Runtime Environment (JRE), if not you can download from Java website download
Once is completely installed you can get your copy of wconfig tool here
To launch the tool from command line, go to the folder where you downloaded the tool and execute next java command
java -jar wconfig.jar
A new window called 'Wmedimd config tool' should appear in your Desktop. There are three main functionalities available on 'File' menu:
- New file, discards all previous configuration on the tool, and provides an empty drawing area to work over it.
- Load file, opens a File chooser dialog, opens desired configuration file, parses it and if it's correctly defined shows in the drawing area.
- Save as, opens a File chooser dialog, and saves layout to this file using the wmediumd configuration file schema.
How to use it and generate a configuration file:
Check that the tool is running in Editing mode, go to Edit menu and set the combo box to Editing.
To create a new Node just do a click over the drawing area, auto ids are given starting from 0.
To create a second Node just do a new click over the drawing area.
To create a link between two nodes, just click on the start node and drag to the end node.
Bidirectional links are created by default.
To detach a bidirectional link in two directional links, just right-click over the link and check the Asymmetric box.
- To convert a directional link into a bidirectional, as previous just right-click over the link and uncheck the Asymmetric box.
- If you want to create directly a unidirectional link between nodes, just click shift key while dragging between both nodes.
To edit link quality, do right click over desired link, and select "Edit link properties".
A new property dialog will appear to modify per rate loss probabilites.
Depending on the loss probabilities of each link the link dashes will be more or less separated.
ADVICE: Mesh links where loss probabilities at all rates are set to 1.0 (100%), won't be shown on the visual tool.
To delete a Link/Node?, just right-click over the item and select "Delete node" or "Delete link" for each case.
The tool provides two additional running modes:
- Edit menu -> Transforming, allows the user to transform the graph visualization.
- Edit menu -> Picking, allows the to select any node and modify the graph distribution over the drawing area while maintaining all established items.
4.2. Using wmediumd
./wmediumd -o foo.cfg Output configuration file: foo.cfg How many interfaces are active? 3 # # wmediumd sample config file # ifaces : { count = 3; ids = [ "42:00:00:00:00:00", "42:00:00:00:01:00", "42:00:00:00:02:00" ]; }; # # probability matrices are defined in a rowcentric way # probability matrices are ordered from slower to fastest, check wmediumd documentation for more info # prob : { rates = 12; matrix_list = ( [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ], [ -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 ] ); }; New configuration successfully written to: foo.cfg
Now edit foo.cfg. For the chosen example topology, the probability matrix will be:
prob : { rates = 12; matrix_list = ( [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ], [ -1.0, 0.0, 1.0, 0.0, -1.0, 0.8, 1.0, 0.8, -1.0 ] ); };
To understand this configuration, it helps to reformat the file a bit. Each row corresponds to a different rate, from 1 Mbps to 54 Mbps, and corresponds to the following probability matrix:
TX \ RX | mesh0 | mesh1 | mesh2 |
mesh0 | N/A (-1) | 0.0 | 1.0 |
mesh1 | 0.0 | N/A (-1) | 0.8 |
mesh2 | 1.0 | 0.8 | N/A (-1) |
So, traffic from mesh0 to mesh1 will be applied a ploss probability of 0.0, from mesh1 to mesh2 0.8 and so on.
5. Test
Ping from 0 to 2.
# ping -I mesh0 192.168.77.12 -f -c 100 PING 192.168.77.12 (192.168.77.12) from 192.168.77.10 mesh0: 56(84) bytes of data. ............................................................................................ --- 192.168.40.30 ping statistics --- 100 packets transmitted, 8 received, 92% packet loss, time 1326ms rtt min/avg/max/mdev = 4210.147/4244.457/4285.209/25.063 ms, pipe 9, ipg/ewma 13.398/4253.676 ms
Note that direct link loss probability between 0 and 2 is 1.0 but we still see frames flowing between the two nodes. (The probability loss above is 92%).
The first entry in the path table below shows that that traffic is actually re-routed via node 1:
# iw dev mesh0 mpath dump DEST ADDR NEXT HOP IFACE SN METRIC QLEN EXPTIME DTIM DRET FLAGS 42:00:00:00:02:00 42:00:00:00:01:00 mesh0 66 304 0 572662306 400 2 0x4 42:00:00:00:01:00 42:00:00:00:01:00 mesh0 101 152 0 572662306 100 0 0x10
More Advanced Uses
Here we've shown a very basic topology. wmediumd can be used for larger networks and can simulate more realistic channel properties like asymmetric links and different loss probabilities depending in the rate. For instance, one can easily simulate links with increasing losses at higher rates (a typical behavior in links with low interferences) or link losses to total frame transmission time (i.e. simulate a congested channel).
Acknowledgements
wmediumd was written by Javier Lopez in collaboration with cozybit folks.
Attachments
- text3752-5.png (29.1 KB) - added by javier 9 months ago.
- file_menu.png (36.4 KB) - added by javi_lopex 7 months ago.
- edit_menu.png (68.8 KB) - added by javi_lopex 7 months ago.
- edit_menu.2.png (53.6 KB) - added by javi_lopex 7 months ago.
- one_node.png (66.8 KB) - added by javi_lopex 7 months ago.
- two_nodes.png (67.4 KB) - added by javi_lopex 7 months ago.
- bidirect_link_ok.png (71.1 KB) - added by javi_lopex 7 months ago.
- edge_prop.png (71.8 KB) - added by javi_lopex 7 months ago.
- assym_link.png (74.0 KB) - added by javi_lopex 7 months ago.
- edit_edge.png (74.2 KB) - added by javi_lopex 7 months ago.
- loss_prob.png (16.7 KB) - added by javi_lopex 7 months ago.
- assym_link_prob.png (73.1 KB) - added by javi_lopex 7 months ago.
- delete_edge.png (41.4 KB) - added by javi_lopex 7 months ago.
- delete_vertex.png (70.6 KB) - added by javi_lopex 7 months ago.