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 (nRF5x) and the router.
This section summarizes the usage of nRF5 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 LED assignments |
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. |
You can find the source code and the project file of the example in the following folder: <InstallFolder>\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 | 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 |
The formats below present a simplified version of the ICMPv6 packets used in this example.
Press 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 respond 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) |
Press 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 respond 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, press 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 the 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.