nRF5 SDK for Thread v0.11.0
Thread PER Measurement Example

The Thread PER measurement example enables to measure Packet Error Rate (PER) between two nodes. One of the nodes serves as a receiver, the other one as a transmitter. The transmitter node sends UDP packets to the receiver node and, at the end of the test, it collects RX statistics from the receiver node.

Description

Both the transmitter and the receiver indicate their Thread network state on BSP_LED_0. When the device is not connected to the network, the LED blinks at a 100 ms period. Once the device connects to a network, either as a Child or as a Leader, the LED stops blinking and remains turned on. On startup, nodes automatically enter the network with default parameters. The first device that is turned on becomes a Leader of the network, while the other one becomes a Child or a Router.

Once connected to the Thread network, the nodes establish peer IPv6 addresses via a CoAP resource. Having done that, the transmitter node sends a number of UDP packets to the receiver node. The number of test packets and the interval at which they are sent can be configured in per_measure_tranmitter/main.c by changing the NUMBER_OF_TEST_PACKETS and TEST_PACKET_SEND_PERIOD macros.

#define IPV6_ADDR_BYTE_LENGTH 16 /**< Length of IPv6 address in bytes. */
#define PAYLOAD_BYTE_LENGTH 4 /**< Length of test packet payload in bytes. */
#define UDP_PORT 40001 /**< Default UDP port of the transmitter. */
#define NUMBER_OF_TEST_PACKETS 1000 /**< Number of test UDP packets to send. */
#define TEST_PACKET_SEND_PERIOD 10 /**< Period between UDP test packets [ms]. */
#define COAP_TOKEN_LENGTH 2 /**< Length of CoAP token. */

By default, these numbers are set to 10000 test packets and 5 ms.

Note
Sending a packet may take up to 5 ms (depending on the payload length). Setting the TEST_PACKET_SEND_PERIOD macro to a value smaller than 5 ms results in problems with buffer availability - the application tries to allocate a buffer for a message before the previously used buffer is freed. It is, therefore, not recommended to set interval times lower than 5 ms.

At the end of the test, the transmitter node collects test results through a CoAP resource. Four numbers are sent in response:

  1. the total number of received UDP packets on the application layer,
  2. the total number of lost UDP packets on the application layer,
  3. the packet error rate calculating from above parameters,
  4. the total number of received MAC frames,
  5. the number of incorrectly received frames on the MAC layer due to incorrect FCS, security errors, and other errors.

Transmitter

The test is triggered by pressing BSP_BUTTON_3 on the transmitter node. When the test is finished, its results (listed above) are logged.

Receiver

The receiver does not require any action to perform the test.

Setup

You can find the source code and the makefiles in the following folders:

Testing

To test this example, you need two nRF52840 Development Kits.

  1. Build the example according to the instructions in Building examples.
  2. Program a development kit with the PER Measurement Receiver application.
  3. Program another development kit with the PER Measurement Transmitter application.
  4. Press BSP_BUTTON_3 on the transmitter node to start the test.
  5. Results of the test are available in the log console (for example, Segger RTT Viewer).

Documentation feedback | Developer Zone | Subscribe | Updated