Wednesday, April 13, 2016

Simple RIOT networking example

After starting to try out simple examples of RIOT, one important thing I was struggling to get working is some networking activity. It is unfortunate to mention that many examples and tutorials that I found in the web seems obsolete. Even in the official RIOT wiki pages, most of the guidelines are obsolete and the developers seems too busy to update them. Anyway, after trying different ways finally I decided to write down about how to get a simple networking example working.

In various places over the web, it is mentioned that the default example can be used with the tapsetup to send simple packets between two RIOT instances on native platform. It was mentioned that txtsnd command can be used to send simple text strings between the RIOT instances connected via a TAP bridge. However it didn't work at least on my system and on few others. Finally I found in the mailing list that somebody has suggested to try it on gnrc_networking example instead of the default [1,2]. I tried that but txtsnd command still seems not working. However I found that I can at least ping from one instance to the other after setting IPv6 addresses on the two instances. So, in this article I will write down those steps.

cd RIOT
./dist/tools/tapsetup/tapsetup -c 2


cd RIOT/examples/gnrc_networking
make all term PORT=tap0
ifconfig
ifconfig 6 add 2001:db8::1/64


When setting the IP address, we need the name of the networking interface. In the above command sequence, we got to know that the networking interface name is 6 by first checking with ifconfig. That's why we used it to set IP address in the next line.

Open a new terminal and goto the same example directory and run the following commands to start another instance.

make term PORT=tap1
ifconfig
ifconfig 6 add 2001:db8::2/64



Now from the shell of second RIOT instance, we can ping to the first RIOT instance using the IPv6 address as follows.

ping6 2001:db8::1

Now, we should receive ping responses. To exit from the two instances, we have to give Ctrl+C on the shell. Moreover, it is necessary to stop the virtual network
interfaces as follows.

./dist/tools/tapsetup/tapsetup -d


References:

[1] https://github.com/RIOT-OS/RIOT/wiki/Virtual-riot-network
[2] http://article.gmane.org/gmane.os.riot.user/580

No comments:

Post a Comment