Tools and Scripts

OpenThread Border Router (OTBR) includes a variety of tools and scripts that can be used for testing purposes.

PSKc generator

pskc generates a Pre-Shared Key for the Commissioner (PSKc). The PSKc is used to authenticate an external Thread Commissioner to a Thread network. Build and install OTBR to use this tool.

After building, pskc is located at /borderrouter/tools.

Parameters

The PSKc is generated from the following parameters:

  • Commissioner Credential
  • Thread Network Extended PAN ID
  • Thread Network Name

Usage

Syntax:

pskc <commissioner-credential> <extpanid> <network-name>

Example:

./pskc J01NME 1234AAAA1234BBBB MyOTBRNetwork
ee4fb64e9341e13846bbe7e1c52b6785

See External Thread Commissioning for how to use this tool with wpanctl.

OTBR commissioner

Use otbr-commissioner to commission a Thread device from the command line. This tool is used in MeshCop (Mesh Commissioning Protocol) tests during continuous integration. Build and install OTBR to use this tool.

After building, otbr-commissioner is located at /src/commissioner.

Parameters

To successfully commissioner a Thread device with otbr-commissioner, we suggest using the following parameters at a minimum:

Parameters
Network details
--network-name
Thread network name.
--xpanid
Thread extended PAN ID.
--agent-passphrase
Commissioner credential.
Joiner details
--joiner-eui64
Factory-assigned IEEE EUI-64 of the joiner device.
--joiner-passphrase
Joiner credential.
Agent details
--agent-addr
Agent IP address from mDNS broadcasts.
--agent-port
Agent port from mDNS broadcasts.
Timeout envelope
--comm-envelope-timeout
Timeout period for the end-to-end commissioning process, in seconds.
Commissioning
--commission-device
Commission the device.

Use --help for a full list of parameters.

Usage

./otbr-commissioner --network-name MyOTBRNetwork --xpanid 1234AAAA1234BBBB \
      --agent-passphrase J01NME --joiner-eui64 000b57fffe15d68 \
      --joiner-passphrase J01NU5 --agent-addr 192.168.1.2 --agent-port 49191 \
      --comm-envelope-timeout 200 --commission-device

For a shell script example, see the meshcop test script.

otbr-commissioner can also be used to generate a PSKc:

./otbr-commissioner --network-name MyOTBRNetwork --xpanid 1234AAAA1234BBBB \
      --agent-passphrase J01NME --compute-pskc
PSKc: EE4FB64E9341E13846BBE7E1C52B6785

libcoap examples

libcoap is an open-source C implementation of CoAP. By default, OTBR builds libcoap with examples and documentation disabled.

To build the examples:

  1. Remove the --disable-examples flag from the root configure.ac file.
  2. Rebuild OTBR:
    cd <path-to-borderrouter>
    ./script/setup

After building, libcoap examples are located at /borderrouter/third_party/libcoap/repo/examples.

coap-client

Use the coap-client example to test the IPv6 connectivity of your Thread network featuring OTBR. coap-client can send non-secure CoAP requests to Thread devices on the Thread network.

When sending CoAP requests to a Thread network, use the device's Global IPv6 address. This address uses the On-Mesh Prefix specified during formation of the Thread network.

For example, if a resource of /some/path has been setup on a Thread node with a Global IPv6 address of fd11:22::287f:87ca:f4b3:498a, use coap-client to send a non-secure GET request to that node:

coap-client -m get coap://[fd11:22::287f:87ca:f4b3:498a]/some/path

Other examples

The libcoap library also includes the following examples:

  • coap-server—Server-side CoAP features
  • coap-rd—Implements a CoAP Resource Directory

For more information on the libcoap library, see libcoap.net.

standalone_ipv6 script

Use the standalone_ipv6 script to test IPv6 functionality if your test or development environment does not have a full IPv6 infrastructure available (for example, if your network is not connected to an upstream IPv6 provider).

This script installs extra features on the platform running OTBR to enable the device to serve IPv6 addresses.

This script is located at /borderrouter/script/standalone_ipv6.