-
Notifications
You must be signed in to change notification settings - Fork 31
Running a virtual emb6
The virtualization in emb::6 is a mechanism to compile and run the stack on a Linux machine, instead of an embedded device. The radio interface is virtualized to use Lightweight Communication and Marshalling (LCM). This enables developers to experiment with emb::6 with out the need to have the necessary embedded hardware.
Currently it is possible to run a virtualization of emb::6 within a linux machine. Therefore it is required to install the Lightweight Communication and Marshalling (LCM) modules and libraries.
LCM provides a publish/subscribe message passing model. With two network nodes in place, LCM creates a communication channel that is similar with a bus topology. Any message sent on the channel is broadcasted on the bus and received by the other node. When creating a topology with multiple nodes or multiple channels the same logic is extended to result in multiple bus topologies along with broadcast on each topology.
To create a specific topology a configuration describing the nodes and the channel it subscribes to has to be created in the configuration file. The virtual topology is created in the lcmnetwork.conf configuration file. For two nodes, shown below, that are connected to each other the following configuration is necessary:
+-------------+
| 0x00AA |
+------^------+
|
|
+------v------+
| 0x00BB |
+-------------+
# Configuration
##############################
# Node Address TRx Channel #
##############################
0x00AA 0x00BB
0x00BB 0x00AA
As the configuration shows it is only required to have the node address and in parallel the address of the node(s) it is connected to. The left column represents a given node and the right column represents the nodes that it's connected to.
A second example is shown below and more example can be found in lcmnetwork.conf.
+-------------+
| 0x00AA |
+------^------+
|
+-------------+ | +-------------+
| 0x00CC <------------o-----------> 0x00DD |
+-------------+ | +-------------+
|
+------v------+
| 0x00XX |
+-------------+
# Configuration
########################################
# Node Address TRx Channel #
########################################
0x00AA 0x00BB,0x00CC,0x00DD
0x00BB 0x00AA,0x00CC,0x00DD
0x00CC 0x00AA,0x00BB,0x00DD
0x00DD 0x00AA,0x00BB,0x00CC
To compile a demo application for a target that uses the virtual radio interface, a bsp called 'native' in emb::6, there are few configurations as a starting point. There are two configurations that run the UDP server and client demos using the virtual radio interface. To build for such a target it is as simple as executing scons with the necessary building parameters.
Before going to the build step it is necessary to install LCM on the Linux machine. More description on how to do this can be found on the LCM documentation. After the installation is completed, to compile emb::6 for a topology with two nodes as described above - node 0x00AA as UDP server and node 0x00BB as UDP client - it can be done with the commands shown below. The --logger option is used to enable debugging to demonstrate the messages exchanged on the radio interface. In addition, the LOGGER_RADIO macro in emb6_conf.h has to be set to TRUE to enable debugging at the radio level.
scons --demos=UDPSrv --bsp=native --net=rpl-dagroot --os=none --mac=0x00AA --logger=3 --ccflags=MODULATION=MODULATION_2FSK50,LOGGER_DEMO_UDP_SOCKET=TRUE scons --demos=UDPCli --bsp=native --net=rpl-router --os=none --mac=0x00BB --logger=3 --ccflags=MODULATION=MODULATION_2FSK50,LOGGER_DEMO_UDP_SOCKET=TRUE
The last step is to run the executables as shown below.
#./bin/UDPSrv-rpl-dagroot-native-none_0x00AA.elf #./bin/UDPCli-rpl-router-native-none_0x00BB.elf
By running the demo applications the logging from the radio interface can be used for further analyzing the stack.
Virtual radio interface log - client
Virtual radio interface log - server
Border Router Virtualization shows how to interface 6LBR complied on a Linux PC with a SLIP radio running on the same local machine, instead of separate embedded devices. Virtual Border Router Interface is developed based on pseudo terminal (pty) to provide a bidirectional channel between 6LBR and SLIP radio.
-
6LBR is installed with release version 1.3.3
-
The following patch (slip-dev.patch) is used for noting the difference between the original 6LBR source code and the 6LBR source code used in this virtualization. In this case, specially, it is necessary to delete one condition check of the original 6LBR module to build communication of sides of pty.
diff --git a/examples/6lbr/platform/native/slip-dev.c b/examples/6lbr/platform/native/slip-dev.c
index c4741f5..ff29981 100644
--- a/examples/6lbr/platform/native/slip-dev.c
+++ b/examples/6lbr/platform/native/slip-dev.c
@@ -442,12 +442,6 @@ stty_telos(int fd)
LOG6LBR_FATAL("tcsetattr() : %s\n", strerror(errno));
exit(1);
}
-
- i = TIOCM_DTR;
- if(ioctl(fd, TIOCMBIS, &i) == -1) {
- LOG6LBR_FATAL("ioctl() : %s\n", strerror(errno));
- exit(1);
- }
#endif
usleep(10 * 1000); /* Wait for hardware 10ms. */
In oder to apply file .patch in Linux PC, we use this following command:
git apply slip-dev.patch
It should be taken into account that the name of the slave side pty changes anytime when running the demo. That might require to change value of the parameter DEV_RADIO in the 6LBR.conf configuration file. Since its more usable if the file file 6LBR.conf is fixed, the name of slave side of pty is symlinked to '/dev/6lbr/if' by employing symlink in this demo. It means that it is not necessary to change value of parameter DEV_RADIO in the 6LBR.conf anytime when running the demo. Instead it can be fixed to '/dev/6lbr/if'.
So, in order to run this symlink on your computer, it is very important to change the directory mode bits of "/dev/6lbr". To do this, firstly, a 6lbr directory is created in '/dev/'. Secondly, the file mode bits are changed as fllows:
sudo mkdir dev/6lbr sudo chmod 777 dev/6lbr
In this demo, configurations of target and application are defined in targets.scons. In particular, the external interface application 'exif' runs on the target 'if_lux' that simulates Linux PC. To build and run this demo on PC Linux, for example, the following commands are implemented:
scons --target=if_lux --mac=0x00BB --logger=3 build/if_lux_0x00BB/if_build_0x00BB.elf
This example assigns 0x00BB to MAC address. The '--logger' option is used to enable debugging to demonstrate the messages exchanged. And it is optional. In this case, all of LOGGER_xxx macros in emb6_conf.h are set to FALSE.
Then, to know for certain about whether or not the symlink exits, it is necessary to check the symlink in the '/dev/6lbr' by the following command:
ls -l dev/6lbr
The next step is to run 6LBR module on Linux PC. In order to start/stop 6LBR, the executables are shown as follows:
cd / cd etc/6lbr sudo service 6lbr start sudo service 6lbr stop
or restart 6LBR.
sudo service 6lbr restart
The logfile of 6LBR that records the communication can be seen with the following commands:
cd /var/log tail -f 6lbr.log