Module riot_coap_handler_demos::ping

source ·
Expand description

An implementation of Ping, with focus on using little RAM and producing output suitable to a (possibly polling, especially for lack of implemented observations) data retreival method.

This works on a static list of potential pingings (always 4, to be configurable when const generic defaults are usable in RIOT’s used nightly).

This is losely based on the sc_gnrc_icmpv6_echo implementation in RIOT.


When registered under /ping (see ping_tree help for why this is essential right now unfortunately), send POST requests with an address to /ping/, fetch from the indicated location with GET, and remove the obtained data with DELETE to free up resources again:

$ aiocoap-client 'coap://[2001:db8::1]/ping/' -m POST --content-format 0 --payload 2001:db8::2
Location options indicate new resource: /ping/47
$ aiocoap-client 'coap://[2001:db8::1]/ping/47'
CBOR message shown in naïve Python decoding
{'address': b'\x20\x01\x0d\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02',
 'identifier': 47,
 'stop_after': 20,
 'stats': {'sent': 10, 'seen_in_time': 9, 'repeats_in_time': 0, 'late': 0}}
$ aiocoap-client 'coap://[2001:db8::1]/ping/47' -m DELETE

Currently, only a custom (and not thought-through – essentially, what serde happens to produce) CBOR format is returned, and addresses are only accepted in text format.

Pings do not measure time (apart from marking a packet as “late” if it’s more than 16 seconds behind), and are not configurable in terms of ping interval (which is currently 1 second independent of the arrival of any packets).

Rough plans for extensibility include logging of delay as minimum, average and maximum (all of which can be done in constant space), finer granularity of time reporting (the current API only measures times in numbers packets sent between then and now), reporting in user-defined bins, and retention of responding addresses (useful in multicast pings). Possibly, those would be mutually exclusive to keep space small (eg. you can get a list of address-count pairs or a fine-grained histogram).


  • Container for a number of ping jobs


  • A resource tree representing a set of launchable pings.