nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ICMP

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.


tftp_link_local.svg
Figure 1: Setup of the ICMPv6 application for link-local addresses.



ICMPv6_remote.svg
Figure 2: Setup of the ICMPv6 application for remote addresses.


Overview

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.

ICMPv6 Data Exchange MSC

The MSC below provides an overview of the data exchange in the application between the node (nRF5x) and the router.

msc_nrf_icmp
Figure 3: ICMPv6 Data Exchange.

Note
No response is indicated by turning the LEDs off.

Common Modules Dependency and Usage

This section summarizes the usage of nRF5x 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 PCA10040 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 enabledTracing is included but not enabled by default.

Setup

The source code and project file of the example can be found at: <InstallFolder>/examples/iot/icmp

See the short state diagram below that describes the application states.

Nordic_ICMP_Diagram.png
Figure 4: Application State Diagram.

LED assignments

Application State LED 1 State LED 2 State LED 3 State LED 4 State
Idle OFF OFF OFF OFF
Advertising BLINKING OFF OFF OFF
IPv6 Interface Up OFF ON OFF OFF
IPv6 Interface Down ON OFF OFF OFF
Operation success OFF ON BLINK (approx. 1 s) BLINK (approx. 1 s)
ASSERT ON ON ON ON
Note
If commissioning is enabled, additional LED and Button assignments are made.
If the application asserts, it is halted.
This application is not power optimized!

Requests and Responses

The formats below present a simplified version of the ICMPv6 packets used in this example.

Neighbor Solicitation (NS) Packet Format

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)

Neighbor Advertisement (NA) Packet Format

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)

Router Solicitation (RS) Packet Format

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)

Router Advertisement (RA) Packet Format

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)
Note
Peer node has to be configured to play the router role, in order to get this response

Echo Request Packet Format

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'

Echo Response Packet Format

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'

Testing

See Connecting devices to the router for a list of relevant Linux commands.

  1. Compile and program the application. Observe that the advertising LED is lit.
  2. Prepare the Linux router device by initializing the 6LoWPAN module.
  3. Discover the advertising device by using the hcitool lescan command.
  4. Connect to the discovered device from the Linux console using the Bluetooth 6LoWPAN connect command.
  5. Observe that only the connected LED (LED 2) is lit.
  6. Push Button 1 on the kit.
  7. Observe if the LEDs are blinking for approx. 1 second - indicating that the Neighbor Advertisement was received.
  8. Prepare the Router role on the peer device (e.g. by turning on RADVD daemon).
  9. Push Button 2 on the kit.
  10. Observe if the LEDs are blinking for approx. 1 second - indicating that the Router Advertisement was received.
  11. Push Button 3 on the kit.
  12. Observe if the LEDs are blinking for approx. 1 second - indicating that the Echo Response was received.
  13. Push Button 4 on the kit.
  14. Observe if the LEDs are blinking for approx. 1 second - indicating that the Echo Response was received.
  15. Disconnect from the device by using the Bluetooth 6LoWPAN disconnect command.
  16. Observe that only the advertising LED is lit.