README.md
1# Virtual Hub
2
3The idea of virtual-hub is to setup a 802.15.4 network for multiple
4QEMU nodes running zephyr application. It receive packets from QEMU
5pipes and redirect them to other QEMUs simulating a physical
6environment.
7
8This component has a similar idea of running zephyr applications with
9`make server` and `make client` which connects both virtual machines
10with a simbolic link. Here we try to expand this concept to how many
11virtual nodes do you want.
12
13The virtual-hub is a basic cmake application. To build it, follow
14the steps:
15```
16mkdir build && cd build
17cmake ..
18make
19```
20
21To run the virtual-hub you will need to pass an csv file
22as an argument:
23```
24./hub ../input.csv
25```
26
27The csv file represents a graph (conection matrix). It enables the
28possibility to simulate different topologies between the QEMU nodes.
29There is an example file in virtual-hub's directory for 3 nodes full
30connected.
31
32When building the matrix you can simulate packet drop rate:
33- 0 means that no packets will be delivered
34- 1 means that all packets will be delivered
35- If you set 0.7 means 70% of packets will be delivered
36
37When building the zephyr application it is necessary to enable the
38QEMU pipes management mechanism. To do this we must set QEMU_PIPE_STACK
39to 1 on CMakeLists.txt from the target projects.
40
41Finally, We need to setup the pipe id using `QEMU_PIPE_ID` to reference
42the pipe which will be used by the QEMU instance. Basically, this
43operation mode will create a different linux pipe for each QEMU
44based on `QEMU_PIPE_ID`.
45
46To make this, we can use cmake parameters:
47```
48cd zephyr-application
49mkdir build-1 && cd build-1
50cmake -DQEMU_PIPE_ID=1 ..
51make
52make node
53```
54
55The `QEMU_PIPE_ID` defined for each zephyr-application represents a line in
56the connection matrix from `input.csv`. This way the first line and column
57from the file refers to the node with `QEMU_PIPE_ID` defined with 1. In the
58same way the second line and column from the file refers to the node with
59`QEMU_PIPE_ID` 2, and so on.
60
61The `make node` command assure the node will setup the pipe correctly.
62Remember to run all the QEMU nodes you want to be present in the network
63before starting the virtual-hub.
64