ICMPv6 echo request/reply exchange between a RIOT native node and the Linux host.
ICMPv6 echo request/reply exchange between an iotlab-m3 node running RIOT and a Raspberry Pi running Linux with 6LoWPAN support.
UDP packet exchange between an iotlab-m3 node running RIOT and a Contiki node.
-
Get your hands on a CC2538DK evaluation board
-
Clone the Contiki repository to your machine
git clone http://github.com/contiki-os/contiki.git && cd contiki/
-
Go to the
udp-ipv6-echo-server
for the CC2538DK:cd examples/cc2538dk/udp-ipv6-echo-server
-
Apply the following patch
echo 'diff --git a/examples/cc2538dk/udp-ipv6-echo-server/Makefile b/examples/cc2538dk/udp-ipv6-echo-server/Makefile index 5bbbdd6..92ec1c5 100644 --- a/examples/cc2538dk/udp-ipv6-echo-server/Makefile +++ b/examples/cc2538dk/udp-ipv6-echo-server/Makefile @@ -1,8 +1,12 @@ +DEFINES+=PROJECT_CONF_H=\"project-conf.h\" CONTIKI_PROJECT = udp-echo-server all: $(CONTIKI_PROJECT) CONTIKI = ../../.. +CONTIKI_WITH_RIME = 0 CONTIKI_WITH_IPV6 = 1 CFLAGS += -DUIP_CONF_ND6_SEND_NS=1 +CFLAGS += -DRF_CHANNEL=26 +CFLAGS += -DIEEE802154_CONF_PANID=0x23 include $(CONTIKI)/Makefile.include diff --git a/examples/cc2538dk/udp-ipv6-echo-server/project-conf.h b/examples/cc2538dk/udp-ipv6-echo-server/project-conf.h new file mode 100644 index 0000000..1718ded --- /dev/null +++ b/examples/cc2538dk/udp-ipv6-echo-server/project-conf.h @@ -0,0 +1,4 @@ +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ +#define NETSTACK_CONF_RDC nullrdc_driver +#endif /* PROJECT_CONF_H_ */' | git apply
-
Build the application with
make
-
Switch to your RIOT repository
-
Switch the CC2538DK into bootloader mode by holding SELECT, then pressing EM RESET, and then releasing SELECT (there should be no LED blinking when you release RESET)
-
Use
dist/tools/cc2538-bsl/cc2538-bsl.py
to flash the Contiki application to the CC2538DK. You first need to fetch it from upstream.make -C examples/hello-world/ ${PWD}/dist/tools/cc2538-bsl/cc2538-bsl.py dist/tools/cc2538-bsl/cc2538-bsl.py -e -w -v -p /dev/ttyUSB1 \ "<contiki repo>"/examples/cc2538dk/udp-ipv6-echo-server/udp-echo-server.bin
Note: If you encounter any problems the cc2538dk documentation might help you.
-
Use either
pyterm
or a sniffer to find out the Contiki node's link local address. With the sniffer just copy the source address of the first RPL package you see (assuming there are no other IEEE 802.15.4 nodes around you 😉). Withpyterm
you will see something likeRime configured with address 00:12:34:56:78:9a:bc:de
in the output.
You might have seen this address also during flashing
Primary IEEE Address: 00:12:34:56:78:9A:BC:DE
You can get the IPv6 link local address of the node by toggling the second bit of the MSB of the address and prepending
fe80::
. So for the example above that would befe80::0212:3456:789a:bcde
. -
For the
iotlab-m3
side just use gnrc_networking or the gnrc_udp test application, whichever you prefer. There start a UDP server on port 3000 with> udp server start 3000
and send a UDP packet to port 3000 of the CC2538DK/Contiki node:
> udp send <contiki ll-addr> 3000 <data>
Every packet you send should be echoed by the CC2538DK/Contiki node and printed to the console (you might need to send more than once since the neighbor discovery of Contiki is not queueing packets for unknown destinations).
ICMPv6 echo request/reply exchange between an iotlab-m3 node running RIOT and an Linux Internet host using a Raspberry Pi running Linux with 6LoWPAN support as border router. Routes are configured statically.
Since Linux' 6Lo implementation doesn't support 6Lo-ND DAD yet, the RIOT image
needs to be compiled with CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=1
to be able to
fall back to classic SLAAC + DAD.
ICMPv6 echo request/reply exchange between an iotlab-m3 node running RIOT and an Linux Internet host using a RIOT node as border router. Routes are configured statically.
UDP over IPv6 packet exchange (payload length 8) between an iotlab-m3 node running RIOT with GNRC and an Linux Internet host using a RIOT node as border router. Routes are configured statically.
UDP over IPv6 packet exchange (payload length 200) between an iotlab-m3 node running RIOT with GNRC and an Linux Internet host using a RIOT node as border router. Routes are configured statically.
Link-local UDP over IPv6 packet exchange (payload length 8) between an iotlab-m3 node running RIOT with GNRC and an iotlab-m3 node running RIOT with lwIP (in both directions).
UDP packet exchange between an iotlab-m3 node running RIOT and a samr21-xpro node running Zephyr.
-
Follow the 'Getting Started' guide on Zephyr's documentation.
-
You will be using the
echo_server
example application. To compile and flash, connect the samr21-xpro board and in zephyr's root directory run:west build -p auto -b atsamr21_xpro samples/net/sockets/echo_server -- -DOVERLAY_CONFIG=overlay-802154.conf west flash
-
If everything is OK you should be able to connect to the serial output use any terminal program. For example:
minicom -D /dev/ttyACM0 -o
-
By pressing tab you should be able to see all available commands. Get the node's IPv6 by running the following on its shell:
# On samr21-xpro:zephyr node uart:~$ net ipv6 IPv6 support : enabled IPv6 fragmentation support : disabled Multicast Listener Discovery support : enabled Neighbor cache support : enabled Neighbor discovery support : enabled Duplicate address detection (DAD) support : enabled Router advertisement RDNSS option support : enabled 6lo header compression support : enabled Max number of IPv6 network interfaces in the system : 1 Max number of unicast IPv6 addresses per network interface : 3 Max number of multicast IPv6 addresses per network interface : 4 Max number of IPv6 prefixes per network interface : 2 IPv6 addresses for interface 0x20007d60 (IEEE 802.15.4) ======================================================= Type State Lifetime (sec) Address autoconf preferred infinite fe80::d419:100:7ae4:9b3b/128 manual preferred infinite 2001:db8::1/128
Similarly, to get the IEEE 802.15.4 PAN ID and channel, run:
# On samr21-xpro:zephyr node uart:~$ ieee802154 get_pan_id PAN ID 43981 (0xabcd) uart:~$ ieee802154 get_chan Channel 26
-
Flash the gnrc_networking example or the gnrc_udp test to the iotlab-m3 board test.
-
Set the channel and PAN ID to the same values as the Zephyr node:
# On iotlab-m3:riot node > ifconfig 6 set chan 26 ifconfig 6 set chan 26 success: set channel on interface 6 to 26 > ifconfig 6 set pan_id 0xabcd ifconfig 6 set pan_id 0xabcd success: set network identifier on interface 6 to 0xabcd
-
The UDP echo server application on the Zephyr node will be listening on port 4242, and echoing to the source port of the incoming packet. As both gnrc_networking example and gnrc_udp test applications use the destination port as the source port for the
udp send
command, we need to start a server on port 4242:# On iotlab-m3:riot node > udp server start 4242 udp server start 4242 Success: started UDP server on port 4242
-
Send packets to the echo server in the Zephyr node, they should be echoed and printed on the RIOT side. Zephyr node will inform of the received packet as well on the shell.
# On iotlab-m3:riot node > udp send fe80::d419:100:7ae4:9b3b 4242 "RIOT Testing!" udp send fe80::9c1a:100:42e5:9b3b 4242 "RIOT Testing!" Success: sent 13 byte(s) to [fe80::9c1a:100:42e5:9b3b]:4242 PKTDUMP: data received: ~~ SNIP 0 - size: 13 byte, type: NETTYPE_UNDEF (0) 00000000 52 49 4F 54 20 54 65 73 74 69 6E 67 21 ~~ SNIP 1 - size: 8 byte, type: NETTYPE_UDP (4) src-port: 4242 dst-port: 4242 length: 21 cksum: 0xee9e ~~ SNIP 2 - size: 40 byte, type: NETTYPE_IPV6 (2) traffic class: 0x00 (ECN: 0x0, DSCP: 0x00) flow label: 0x00000 length: 21 next header: 17 hop limit: 64 source address: fe80::9c1a:100:42e5:9b3b destination address: fe80::30a9:fa65:106b:1114 ~~ SNIP 3 - size: 24 byte, type: NETTYPE_NETIF (-1) if_pid: 7 rssi: -43 lqi: 255 flags: 0x0 src_l2addr: 9E:1A:01:00:42:E5:9B:3B dst_l2addr: 32:A9:FA:65:10:6B:11:14 ~~ PKT - 4 snips, total size: 85 byte
This test will ensure RIOT can connect to a real IPv6 enabled WiFi network and share the uplink connection with constrained nodes.
An esp* board with the gnrc_border_router
connects to your WiFi.
The module sock_dns
is used to resolve domain names.
The module gnrc_ipv6_nib_dns
is used to distribute DNS information through router advertisements.
Two network interfaces are configured:
- a 802.11 WiFi interface used as uplink
- a proprietary
esp_now
interface as 6LoWPAN downlink
You'll need:
- a pair of esp8266/esp32 boards
- 2.4 GHz WiFi network with an IPv6 uplink
- to make sure prefix delegation (IA_PD) is enabled in your router's DHCPv6 server (On the popular Fritz!Box line of routers this can be enabled in the Network -> Network Settings -> IPv6 Addresses menu. On OpenWRT it should be enabled by default)
Flash the gnrc_border_router
example onto one of the esp* boards.
Use the sock_dns
and gnrc_ipv6_nib_dns
modules to enable name resolution.
The credentials for the WiFi network will be passed on the command line.
Replace esp8266-esp-12x
with the esp* board of your choice, adjust PORT
if needed.
USEMODULE="sock_dns gnrc_ipv6_nib_dns" make -C examples/gnrc_border_router BOARD=esp<...> UPLINK=wifi WIFI_SSID=<your_ssd> WIFI_PASS=<your_password> PORT=<port> flash term
RIOT should be able to connect to your WiFi network and configure a global address on both interfaces
2020-08-02 20:38:20,346 # Iface 11 HWaddr: EC:FA:BC:5F:82:91 Channel: 6 Link: up
2020-08-02 20:38:20,349 # L2-PDU:1500 MTU:1492 HL:255 RTR
2020-08-02 20:38:20,352 # Source address length: 6
2020-08-02 20:38:20,355 # Link type: wireless
2020-08-02 20:38:20,360 # inet6 addr: fe80::eefa:bcff:fe5f:8291 scope: link VAL
2020-08-02 20:38:20,368 # inet6 addr: 2001:16b8:453f:1f00:eefa:bcff:fe5f:8291 scope: global VAL
2020-08-02 20:38:20,371 # inet6 group: ff02::2
2020-08-02 20:38:20,374 # inet6 group: ff02::1
2020-08-02 20:38:20,377 # inet6 group: ff02::1:ff5f:8291
2020-08-02 20:38:20,377 #
2020-08-02 20:38:20,382 # Iface 10 HWaddr: EE:FA:BC:5F:82:91 Channel: 6
2020-08-02 20:38:20,385 # L2-PDU:249 MTU:1280 HL:64 RTR
2020-08-02 20:38:20,390 # RTR_ADV 6LO Source address length: 6
2020-08-02 20:38:20,393 # Link type: wireless
2020-08-02 20:38:20,399 # inet6 addr: fe80::ecfa:bcff:fe5f:8291 scope: link VAL
2020-08-02 20:38:20,404 # inet6 addr: 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291 scope: global VAL
2020-08-02 20:38:20,407 # inet6 group: ff02::2
2020-08-02 20:38:20,410 # inet6 group: ff02::1
2020-08-02 20:38:20,416 # inet6 group: ff02::1:ff5f:8291
You should be able to ping global addresses (requires a working IPv6 uplink on your network)
2020-08-02 20:35:27,462 # ping6 2600::
2020-08-02 20:35:27,672 # 12 bytes from 2600::: icmp_seq=0 ttl=50 time=203.340 ms
2020-08-02 20:35:28,607 # 12 bytes from 2600::: icmp_seq=1 ttl=50 time=139.033 ms
2020-08-02 20:35:29,608 # 12 bytes from 2600::: icmp_seq=2 ttl=50 time=140.839 ms
2020-08-02 20:35:29,609 #
2020-08-02 20:35:29,611 # --- 2600:: PING statistics ---
2020-08-02 20:35:29,616 # 3 packets transmitted, 3 packets received, 0% packet loss
2020-08-02 20:35:29,621 # round-trip min/avg/max = 139.033/161.070/203.340 ms
Valid DNS names should get resolved too
2020-08-02 20:35:37,927 # ping6 riot-os.org
2020-08-02 20:35:38,075 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=0 ttl=56 time=33.071 ms
2020-08-02 20:35:39,076 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=1 ttl=56 time=34.129 ms
2020-08-02 20:35:40,076 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=2 ttl=56 time=33.182 ms
2020-08-02 20:35:40,076 #
2020-08-02 20:35:40,078 # --- riot-os.org PING statistics ---
2020-08-02 20:35:40,084 # 3 packets transmitted, 3 packets received, 0% packet loss
2020-08-02 20:35:40,088 # round-trip min/avg/max = 33.071/33.460/34.129 ms
A second esp* board will connect to the border router from Task #12 using 6LoWPAN/esp_now
.
It should be able to access hosts on the internet.
Flash the gnrc_networking
example onto the second esp* board.
Use the sock_dns
and gnrc_ipv6_nib_dns
modules to enable name resolution.
Replace esp8266-esp-12x
with the esp* board of your choice, adjust PORT
if needed.
USEMODULE="sock_dns gnrc_ipv6_nib_dns" make -C examples/gnrc_networking BOARD=esp<…> PORT=<port> flash term
RIOT should connect to the border router and obtain a global address.
Make sure both boards operate on the same esp_now
channel.
2020-08-02 20:45:02,898 # Iface 9 HWaddr: 3C:71:BF:9E:13:FD Channel: 6
2020-08-02 20:45:02,902 # L2-PDU:249 MTU:1280 HL:64 RTR
2020-08-02 20:45:02,906 # RTR_ADV 6LO Source address length: 6
2020-08-02 20:45:02,909 # Link type: wireless
2020-08-02 20:45:02,914 # inet6 addr: fe80::3e71:bfff:fe9e:13fd scope: link VAL
2020-08-02 20:45:02,921 # inet6 addr: 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd scope: global VAL
2020-08-02 20:45:02,924 # inet6 group: ff02::2
2020-08-02 20:45:02,927 # inet6 group: ff02::1
2020-08-02 20:45:02,930 # inet6 group: ff02::1:ff9e:13fd
2020-08-02 20:45:02,931 #
2020-08-02 20:45:02,934 # Statistics for Layer 2
2020-08-02 20:45:02,937 # RX packets 0 bytes 0
2020-08-02 20:45:02,942 # TX packets 0 (Multicast: 0) bytes 214
2020-08-02 20:45:02,945 # TX succeeded 3 errors 0
2020-08-02 20:45:02,947 # Statistics for IPv6
2020-08-02 20:45:02,950 # RX packets 3 bytes 312
2020-08-02 20:45:02,955 # TX packets 4 (Multicast: 2) bytes 264
2020-08-02 20:45:02,958 # TX succeeded 4 errors 0
You should be able to reach the border router using it's global address
2020-08-02 20:45:41,423 # ping6 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291
2020-08-02 20:45:41,439 # 12 bytes from 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291: icmp_seq=0 ttl=64 time=8.020 ms
2020-08-02 20:45:42,438 # 12 bytes from 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291: icmp_seq=1 ttl=64 time=7.252 ms
2020-08-02 20:45:43,438 # 12 bytes from 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291: icmp_seq=2 ttl=64 time=6.779 ms
2020-08-02 20:45:43,438 #
2020-08-02 20:45:43,443 # --- 2001:16b8:453f:1ff0:ecfa:bcff:fe5f:8291 PING statistics ---
2020-08-02 20:45:43,449 # 3 packets transmitted, 3 packets received, 0% packet loss
2020-08-02 20:45:43,453 # round-trip min/avg/max = 6.779/7.350/8.020 ms
You should be able to reach a global address on the internet
2020-08-02 20:45:49,052 # ping6 2600::
2020-08-02 20:45:49,200 # 12 bytes from 2600::: icmp_seq=0 ttl=49 time=143.513 ms
2020-08-02 20:45:50,200 # 12 bytes from 2600::: icmp_seq=1 ttl=49 time=143.223 ms
2020-08-02 20:45:51,199 # 12 bytes from 2600::: icmp_seq=2 ttl=49 time=142.450 ms
2020-08-02 20:45:51,200 #
2020-08-02 20:45:51,202 # --- 2600:: PING statistics ---
2020-08-02 20:45:51,207 # 3 packets transmitted, 3 packets received, 0% packet loss
2020-08-02 20:45:51,212 # round-trip min/avg/max = 142.450/143.062/143.513 ms
DNS names should also get resolved
2020-08-02 20:45:57,277 # ping6 riot-os.org
2020-08-02 20:45:57,330 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=0 ttl=55 time=35.999 ms
2020-08-02 20:45:58,335 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=1 ttl=55 time=40.993 ms
2020-08-02 20:45:59,328 # 12 bytes from 2a01:4f8:151:64::11: icmp_seq=2 ttl=55 time=34.089 ms
2020-08-02 20:45:59,329 #
2020-08-02 20:45:59,331 # --- riot-os.org PING statistics ---
2020-08-02 20:45:59,336 # 3 packets transmitted, 3 packets received, 0% packet loss
2020-08-02 20:45:59,340 # round-trip min/avg/max = 34.089/37.027/40.993 ms
And finally, you should be able to reach the 6LoWPAN node from any IPv6 host from your local network.
% ping -c3 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd
PING 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd(2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd) 56 data bytes
64 bytes from 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd: icmp_seq=1 ttl=63 time=11.0 ms
64 bytes from 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd: icmp_seq=2 ttl=63 time=9.08 ms
64 bytes from 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd: icmp_seq=3 ttl=63 time=10.5 ms
--- 2001:16b8:453f:1ff0:3e71:bfff:fe9e:13fd ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 9.077/10.192/10.997/0.814 ms