-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Tutorial: RIOT and Multi Hop Routing with RPL
Please have a look at the Quick-Start-Guide and Creating-your-first-RIOT-project.
For routing capabilities it is necessary that the RPL implementation is compiled into your RIOT application.
This can be achieved by adding gnrc_rpl to the USEMODULE variable in your application's Makefile. You can consult this Makefile for a complete example.
For the following tutorials the gnrc_networking example will be used. All commands listed here will be issued from within the examples/gnrc_networking directory. You may use your own application after adjusting the Makefile accordingly as described in the Preparation.
Information about the native port of RIOT can be found in Family:-native and Board:-native
The native RIOT instances communicate through tap interfaces. We provide a script that supports the setup and cleanup of such interfaces.
To setup tap interfaces and a bridge that connects each tap interface:
$ ../../dist/tools/tapsetup/tapsetup -c 4
With the -c parameter you can specify how many tap interfaces you want to create (default 2).
To delete all tap interface you can execute:
$ ../../dist/tools/tapsetup/tapsetup -d
See the help for further information about additional parameters:
$ ../../dist/tools/tapsetup/tapsetup -h
You can verify that the tap interfaces have been created successfully by looking at the output of ip l.
This list should include the new interfaces tapbr0, tap0, tap1, tap2 and tap3.
$ make clean all
Type the following command in three different terminals, by using tap0, tap1 and tap2 respectively.
$ make term PORT=tap{0,1,2}
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: XXX)
RIOT network stack example application
All up, running the shell now
>
You will be greeted by RIOT's shell in all three terminals.
In order to use RPL we have to choose a RPL root node. I will choose the node that is using the tap0 interface as RPL root.
With the ifconfig command we can get the configured interfaces for a particular RIOT node. On my system the output is as follows for the node on tap0.
> ifconfig
Iface 6 HWaddr: d2:61:59:ce:b3:5d
MTU:1280
Source address length: 6
Link type: wired
inet6 addr: ff02::1/128 scope: local [multicast]
inet6 addr: fe80::d061:59ff:fece:b35d/64 scope: local
inet6 addr: ff02::1:ffce:b35d/128 scope: local [multicast]
inet6 addr: ff02::2/128 scope: local [multicast]
At first, we need to configure a global IPv6 address for the root node
> ifconfig 6 add 2001:db8::1
success: added 2001:db8::1/64 to interface 6
> ifconfig
Iface 6 HWaddr: d2:61:59:ce:b3:5d
MTU:1280
Source address length: 6
Link type: wired
inet6 addr: ff02::1/128 scope: local [multicast]
inet6 addr: fe80::d061:59ff:fece:b35d/64 scope: local
inet6 addr: ff02::1:ffce:b35d/128 scope: local [multicast]
inet6 addr: ff02::2/128 scope: local [multicast]
inet6 addr: 2001:db8::1/64 scope: global
inet6 addr: ff02::1:ff00:1/128 scope: local [multicast]
Now, RPL must be initialized on that particular interface for all nodes (tap0-3):
> rpl init 6
successfully initialized RPL on interface 6
On the root node (tap0 in this tutorial), type:
> rpl root 1 2001:db8::1
successfully added a new RPL DODAG
Note however, that the DODAG ID 2001:db8::1 matches a global IPv6 address configured on an interface, like it was done in [Initializing RPL](### Initializing RPL). The 1 before 2001:db8::1 is the Instance ID and can be adjusted if so desired.
To see the RPL status, type rpl.
> rpl
instance table: [X] [ ]
dodag table: [X] [ ] [ ] [ ]
parent table: [ ] [ ] [ ] [ ] [ ] [ ]
instance [1 | mop: 2 | ocp: 0 | mhri: 256 | mri 0]
dodag [2001:db8::1 | R: 256 | CL: 0s | TR(I=[8,20], k=10, c=0, TC=3s, TI=4s)]
The root node has a rank of R: 256.
Now type rpl in the other terminals (here an example for tap1):
> rpl
instance table: [X] [ ]
dodag table: [X] [ ] [ ] [ ]
parent table: [X] [ ] [ ] [ ] [ ] [ ]
instance [1 | mop: 2 | ocp: 0 | mhri: 256 | mri 0]
dodag [2001:db8::1 | R: 512 | CL: 0s | TR(I=[8,20], k=10, c=0, TC=2s, TI=4s)]
parent [addr: fe80::d069:49ff:fede:b38c | rank: 256 | lifetime: 118s]
This node is part of the RPL-DODAG with the DODAG-ID 2001:db8::1 and Instance Id 1.
Furthermore, this node's rank is R: 512, and the preferred parent has the link-local IPv6 address fe80::d069:49ff:fede:b38c. This parent's rank is rank: 256, therefore we know that this must be the root of this RPL-DODAG.
Note that all participating nodes in the RPL-DODAG have configured automatically a global IPv6 address matching the prefix from the DODAG-ID. Verify with ifconfig.
RPL should now start to fill the FIB (Forwarding Information Base) table, which is consulted when forwarding packets. On the root node (tap0):
> fibroute
Destination Flags Next Hop Flags Expires Interface
2001:db8::1063:a9ff:fe84:34ac 0x0003 fe80::1063:a9ff:fe84:34ac 0x0003 68.6131236
and on the participating node (tap1):
> fibroute
Destination Flags Next Hop Flags Expires Interface
:: 0x0003 fe80::d069:49ff:fede:b38c 0x0003 68.6874646
Because all nodes are connected via the tapbr0 bridge, all nodes are reachable to each other within a single hop. Therefore, it is not possible to test real multi-hop communication with the previous method. Virtual-riot-network describes how native nodes can be deployed with a virtualized network topology using tap interfaces. However, currently it is not possible to use RIOT together with desvirt. See RIOT#3908 and desvirt#17 for more information.
TODO