CoAP Communication Between the Linux Border Router and the Network Performance Application#

The Network Measurement Application supports a CoAP server to allow the Wi-SUN Border Router to get data from the node using the linux libcoap client. Follow the steps below to get CoAP network performance data on your Border Router, without the need to directly access the CLI on the Wi-SUN node.

Install the libcoap library on the Border Router#

$ sudo apt-get install libcoap-1-0
$ sudo apt-get install libcoap-1-0-bin

Get your node’s global address#

From the node cli, make sure that you are connected to the network.

> wisun get wisun.connection_state
wisun.connection_state = Operational (5)

Then, get your global IPv6 address:

> wisun get wisun.ip_address_global
wisun.ip_address_global = fd12:3456::20d:6fff:fe20:be0a

Discover the Available Resources#

The CoAP protocol supports an interoperable discovery feature. A CoAP client can request the attributes hosted by a CoAP server. In the case of the Network Performance application, the available resources can be retrieved using the libcoap GET method with the standard discovery entry-point.

$ coap-client -m get -N coap://[fd12:3456::20d:6fff:fe20:be0a]:5683/.well-known/core
v:1 t:NON c:GET i:32bf {} [ ]
</cli>;ct=40,</cli/nbrinfo>;rt="nbrinfo";if="cli",</cli/iperf>;rt="iperf";if="cli",</cli/ping>;rt="ping";if="cli"

The above shows that we have access to the following commands:

</cli>;ct=40,

</cli/nbrinfo>;rt="nbrinfo";if="cli",

</cli/iperf>;rt="iperf";if="cli",

</cli/ping>;rt="ping";if="cli"

Check the node and Border Router info using:

**$ coap-client -m get -N  coap://[fd00:6172:6d00:0:b6e3:f9ff:fea6:3aa]:5683/cli/nbrinfo**

v:1 t:NON c:GET i:ff62 {} [ ]
{
"Border Router":
{"addr":"fd00:6172:6d00:0:92fd:9fff:fe6d:5a15","lt":0,"txc":0,"txf":0,"txmsc":0,"txmsf":0,"rplr":0,"etx":0,"rslo":0,"rsli":0},
"Primary Parent":
{"addr":"fd00:6172:6d00:0:92fd:9fff:fe6d:5a15","lt":2037,"txc":2096,"txf":9,"txmsc":0,"txmsf":0,"rplr":128,"etx":150,"rslo":142,"rsli":138},
"Child0":
{"addr":"fd00:6172:6d00:0:5e02:72ff:fe96:c97f","lt":2159,"txc":162,"txf":0,"txmsc":0,"txmsf":0,"rplr":65535,"etx":276,"rslo":152,"rsli":151}
}

Calling iperf using CoAP#

It is possible to get the available iperf options using the -e text payload coap-client parameter:

$ coap-client -m get -N -e "iperf help" coap://[fd00:6172:6d00:0:b6e3:f9ff:fea6:3aa]:5683/cli/iperf

v:1 t:NON c:GET i:4807 {} [ ]

iPerf Remote Control CLI Help.

  Writable options:
    -options.remote_addr
    -options.bandwidth
    -options.duration
    -options.interval
  Example: iperf set options.bandwidth 10000

  Start iPerf command: iperf <client|server>

Set the iperf options using:

$ coap-client -m get -N -e "iperf set options.bandwidth 10000" coap://[fd00:6172:6d00:0:b6e3:f9ff:fea6:3aa]:5683/cli/iperf

v:1 t:NON c:GET i:d665 {} [ ]
10000

$ coap-client -m get -N -e "iperf set options.remote_addr fd00:6172:6d00:0:92fd:9fff:fe6d:5a15" coap://[fd00:6172:6d00:0:b6e3:f9ff:fea6:3aa]:5683/cli/iperf

v:1 t:NON c:GET i:4c8a {} [ ]
fd00:6172:6d00:0:92fd:9fff:fe6d:5a15

Launch the iperf test using:

$ coap-client -m get -N -e "iperf client" coap://[fd00:6172:6d00:0:b6e3:f9ff:fea6:3aa]:5683/cli/iperf

v:1 t:NON c:GET i:10d8 {} [ ]
{
  "Test-3": {
    "id":     3,
    "status": "DONE",
    "error":  "NONE",
    "options": {
      "mode":        "CLIENT",
      "protocol":    "IPV6_UDP",
      "port":        5001,
      "remote_addr": "fd00:6172:6d00::192fd:9fff:fe6d:5a15",
      "bandwidth":   10000,
      "packet_nbr":  10,
      "buf_len":     1234,
      "duration_ms": 10000,
      "win_size":    0,
      "persistent":  false,
      "interval_ms": 1000,
      "bw_format": "bits/s"
    },
    "statistic": {
      "nbr_calls":             10,
      "bytes":                 12340,
      "tot_packets":           10,
      "nbr_rcv_snt_packets":   10,
      "errs":                  0,
      "transitory_error_cnts": 0,
      "last_recv_pkt_cnt":     0,
      "ts_curr_recv_ms":       0,
      "ts_prev_recv_ms":       0,
      "ts_curr_sent_ms":       19794004,
      "ts_prev_sent_ms":       0,
      "udp_jitter":            0,
      "udp_rx_last_pkt":       0,
      "udp_lost_pkt":          0,
      "udp_out_of_order":      0,
      "udp_dup_pkt":           0,
      "udp_async_error":       false,
      "end_err":               false,
      "ts_start_ms":           19783880,
      "ts_end_ms":             19794012,
      "bandwidth":             9743,
      "finack_tot_len":        0,
      "finack_duration_ms":    0,
      "finack_pkt":            0
    }
  }
}