The following was tested on Ubuntu 14.04. Install some tools
sudo apt-get install gcc-multilib bridge-utils
Clone the RIOT repo:
git clone https://github.com/RIOT-OS/RIOT.git
cd RIOT/examples/posix_sockets
make BOARD=native
Create two bridged TAP devices:
cd RIOT
./dist/tools/tapsetup/tapsetup -c 2
Build the UDP example:
cd RIOT/examples/posix_sockets
make BOARD=native
This should produce ./bin/native/posix_sockets.elf
.
In a first terminal, start node 1:
oberstet@thinkpad-t430s:~/scm/3rdparty/RIOT/examples/posix_sockets$ sudo make term
[sudo] password for oberstet:
/home/oberstet/scm/3rdparty/RIOT/examples/posix_sockets/bin/native/posix_sockets.elf tap0
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: 2016.03-devel-1699-g0aa0-thinkpad-t430s)
RIOT socket example application
All up, running the shell now
> help
help
Command Description
---------------------------------------
udp send data over UDP and listen on UDP ports
reboot Reboot the node
ps Prints information about running threads.
random_init initializes the PRNG
random_get returns 32 bit of pseudo randomness
ifconfig Configure network interfaces
txtsnd Sends a custom string as is over the link layer
ncache manage neighbor cache by hand
routers IPv6 default router list
> ifconfig
ifconfig
Iface 5 HWaddr: ce:c7:93:47:8a:94
MTU:1500 HL:64
Source address length: 6
Link type: wired
inet6 addr: ff02::1/128 scope: local [multicast]
inet6 addr: fe80::ccc7:93ff:fe47:8a94/64 scope: local
inet6 addr: ff02::1:ff47:8a94/128 scope: local [multicast]
> udp
udp
usage: udp [send|server]
> udp server start 9000
udp server start 9000
Success: started UDP server on port 9000
> ps
ps
pid | name | state Q | pri | stack ( used) | location
1 | idle | pending Q | 15 | 8192 ( 6240) | 0x8070180
2 | main | running Q | 7 | 12288 ( 9312) | 0x806d180
3 | ipv6 | bl rx _ | 4 | 8192 ( 6240) | 0x807d3c0
4 | udp | bl rx _ | 5 | 8192 ( 6240) | 0x8081200
5 | gnrc_netdev2_tap | bl rx _ | 4 | 8192 ( 6240) | 0x807b380
6 | UDP server | bl rx _ | 6 | 8192 ( 6240) | 0x8079200
| SUM | | | 53248 (40512)
> Received data: hello, world!
In a second terminal start node 2:
oberstet@thinkpad-t430s:~/scm/3rdparty/RIOT/examples/posix_sockets$ sudo PORT=tap1 make term
[sudo] password for oberstet:
/home/oberstet/scm/3rdparty/RIOT/examples/posix_sockets/bin/native/posix_sockets.elf tap1
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: 2016.03-devel-1699-g0aa0-thinkpad-t430s)
RIOT socket example application
All up, running the shell now
> udp send fe80::ccc7:93ff:fe47:8a94 9000 "hello, world!"
udp send fe80::ccc7:93ff:fe47:8a94 9000 "hello, world!"
Success: send 13 byte to fe80::ccc7:93ff:fe47:8a94:9000
>