The transport layer (UDP, TCP, etc) is accessed through conn
driver API
Look at the new modules in the Makefile
USEMODULE += gnrc_conn_udp
udp.c
utilizes conn_udp_sendto()
and conn_udp_recvfrom()
to exchange UDP packets
- Compile and run on two
native
instances - We have two new shell commands:
udps
to start a server andudp
to send a message.
> help
help
Command Description
---------------------------------------
udp send udp packets
udps start udp server
reboot Reboot the node
ps Prints information about running threads.
ping6 Ping via ICMPv6
random_init initializes the PRNG
random_get returns 32 bit of pseudo randomness
ifconfig Configure network interfaces
ncache manage neighbor cache by hand
routers IPv6 default router list
>
- Start a UDP server on port 8888 with
udps 8888
. Look at the output ofps
> ps
ps
pid | name | state Q | pri | stack ( used) | location
1 | idle | pending Q | 15 | 8192 ( 6240) | 0x806eb80
2 | main | running Q | 7 | 12288 ( 9312) | 0x806bb80
3 | ipv6 | bl rx _ | 4 | 8192 ( 6240) | 0x807bce0
4 | udp | bl rx _ | 5 | 8192 ( 6240) | 0x807f760
5 | gnrc_netdev2_tap | bl rx _ | 4 | 8192 ( 6240) | 0x8079ca0
6 | UDP Server | bl rx _ | 6 | 8192 ( 6240) | 0x8077c60
| SUM | | | 53248 (40512)
>
The new thread for the UDP server has the PID 6 in this example.
-
Get your IPv6 address using
ifconfig
> ifconfig ifconfig Iface 5 HWaddr: 22:7e:b9:04:9f:f0 MTU:1500 HL:64 Source address length: 6 Link type: wired inet6 addr: ff02::1/128 scope: local [multicast] inet6 addr: fe80::207e:b9ff:fe04:9ff0/64 scope: local inet6 addr: ff02::1:ff04:9ff0/128 scope: local [multicast]
-
From the second instance, send a udp packet with the
udp
command.> udp fe80::207e:b9ff:fe04:9fef 8888 hello udp fe80::207e:b9ff:fe04:9fef 8888 hello Success: send 5 byte to fe80::207e:b9ff:fe04:9fef
-
Compile and run on two
native
instances -
Start a UDP server on port 8888 with
udps 8888
. -
Send a packet to RIOT from Linux using
netcat
echo "hello" | nc -6u <RIOT-IPv6-addr>%tapbr0 8888
Note: on MAC use
bridge0
instead oftapbr0
. -
Start a UDP server on the host machine with
netcat
.nc -6lu 8888
And in RIOT ...
udp <tap0-IPv6-addr> 8888 hello
- Compile, flash and run on the board
BOARD=samr21-xpro make all flash term
- Send and receive UDP messages to and from your neighbors using
udp
andudps