nRF51 IoT SDK
|
The Internet Control Message Protocol (ICMP) is the control protocol of the IP stack that enables establishment of reachability, routes, and so on. This protocol is an integral part of any IP, but is unique as it is not a transport protocol to exchange data between hosts.
This application aims at demonstrating some of the ICMP functionality like reaching link local and global scopes as shown in Figure 1 and Figure 2 respectively.
This example demonstrates how Nordic's IPv6 stack can be used for sending and receiving ICMPv6 packets. Request and response formats used for this example are described in the section Requests and Responses.
Sending ICMP packets is triggered by the buttons on the kit. LEDs blinking indicates that response has been received.
The MSC below provides an overview of the data exchange in the application between the node (nRF51) and the router.
This section summarizes the usage of nRF51 resources and common modules in the examples apart from the IoT 6lowpan and IPv6 stack library.
Module | Inclusion/Usage | Description |
---|---|---|
Timer | 1 | One timer is used to make the LEDs blink on success. |
Button | 4 | All four buttons of PCA10028 are used in this example. |
LEDs | 4 | LEDs are used to indicate the application states. See the LED assignment section. |
Adv Data Encoder | Yes | Device name used is 'IPv6ICMP', IPSP Service UUID is included in the UUID list. |
Scheduler | Yes | Scheduler is used for processing stack events. |
UART Trace | Included not enabled | Tracing is included but not enabled by default. |
The name of this example is iot_ipv6_icmp. The source code and project file of the example can be found at: <InstallFolder>/Nordic/nrf51/examples/iot/icmp
See the short state diagram below that describes the application states.
Application State | LED 1 State | LED 2 State | LED 3 State | LED 4 State |
---|---|---|---|---|
Idle | OFF | OFF | OFF | OFF |
Advertising | ON | OFF | OFF | OFF |
IPv6 Interface Up | OFF | ON | OFF | OFF |
IPv6 Interface Down | ON | OFF | OFF | OFF |
Operation success | BLINK (approx. 1 s) | BLINK (approx. 1 s) | BLINK (approx. 1 s) | BLINK (approx. 1 s) |
ASSERT | ON | ON | ON | ON |
The formats below present a simplified version of the ICMPv6 packets used in this example.
Push Button 1 to send the Neighbor Solicitation message of the following format:
IPv6 Header | ICMP Header | ICMP Option | ICMP Option |
---|---|---|---|
Source and Destination address are link-local addresses (e.g. FE80::2AA:BBFF:FECC:DDEE) | Type: 135 (NS) | Source Link-Layer (SLLAO) | Address Registration (ARO) |
In response to a Neighbor Solicitation message, the router should response with a Neighbor Advertisement packet. With optional (if supported) ARO option.
IPv6 Header | ICMP Header | ICMP Option |
---|---|---|
Source and Destination address are link-local addresses (e.g. FE80::2AA:BBFF:FECC:DDEE) | Type: 136 (NA) | Address Registration (ARO) |
Push Button 2 to send a Router Solicitation message of the following format:
IPv6 Header | ICMP Header | ICMP Option |
---|---|---|
Source address is link-local address (e.g. FE80::2AA:BBFF:FECC:DDEE) Destination is all router multicast address (FF02::2) | Type: 133 (RS) | Source Link-Layer (SLLAO) |
In response to a Router Solicitation message, the router should response with a Router Advertisement packet. With optional prefix option (for creating IPv6 global address).
IPv6 Header | ICMP Header | ICMP Option |
---|---|---|
Source and Destination address are link-local addresses (e.g. FE80::2AA:BBFF:FECC:DDEE) | Type: 134 (RA) | Prefix Option (PIO) |
In order to send a Echo Request to all the nodes in the network or on the Xively server, push Button 3 or 4 respectively. ICMP message has the following format:
IPv6 Header | ICMP Header | Payload |
---|---|---|
Source and Destination address are link-local addresses (e.g. FE80::2AA:BBFF:FECC:DDEE) | Type: 128 (Echo Request) | 10x 'A' |
In response to an Echo Request message, you should receive an Echo Response with following format:
IPv6 Header | ICMP Header | Payload |
---|---|---|
Source and Destination address are link-local addresses (e.g. FE80::2AA:BBFF:FECC:DDEE) | Type: 129 (Echo Response) | 10x 'A' |
See Connecting devices to the router for a list of relevant Linux commands.