Trickle Timer Library

Overview

The Trickle timer library implements IETF RFC6206 (Trickle Algorithm).

The Trickle algorithm allows nodes in a lossy shared medium (e.g., low-power and lossy networks) to exchange information in a highly robust, energy efficient, simple, and scalable manner.

API Reference

group trickle

Trickle algorithm library.

Typedefs

typedef void (*net_trickle_cb_t)(struct net_trickle *trickle, bool do_suppress, void *user_data)

Trickle timer callback.

The callback is called after Trickle timeout expires.

Param trickle

The trickle context to use.

Param do_suppress

Is TX allowed (true) or not (false).

Param user_data

The user data given in net_trickle_start() call.

Functions

int net_trickle_create(struct net_trickle *trickle, uint32_t Imin, uint8_t Imax, uint8_t k)

Create a Trickle timer.

Parameters
  • trickle – Pointer to Trickle struct.

  • Imin – Imin configuration parameter in ms.

  • Imax – Max number of doublings.

  • k – Redundancy constant parameter. See RFC 6206 for details.

Returns

Return 0 if ok and <0 if error.

int net_trickle_start(struct net_trickle *trickle, net_trickle_cb_t cb, void *user_data)

Start a Trickle timer.

Parameters
  • trickle – Pointer to Trickle struct.

  • cb – User callback to call at time T within the current trickle interval

  • user_data – User pointer that is passed to callback.

Returns

Return 0 if ok and <0 if error.

int net_trickle_stop(struct net_trickle *trickle)

Stop a Trickle timer.

Parameters
  • trickle – Pointer to Trickle struct.

Returns

Return 0 if ok and <0 if error.

void net_trickle_consistency(struct net_trickle *trickle)

To be called by the protocol handler when it hears a consistent network transmission.

Parameters
  • trickle – Pointer to Trickle struct.

void net_trickle_inconsistency(struct net_trickle *trickle)

To be called by the protocol handler when it hears an inconsistent network transmission.

Parameters
  • trickle – Pointer to Trickle struct.

static inline bool net_trickle_is_running(struct net_trickle *trickle)

Check if the Trickle timer is running or not.

Parameters
  • trickle – Pointer to Trickle struct.

Returns

Return True if timer is running and False if not.

struct net_trickle
#include <trickle.h>

The variable names are taken directly from RFC 6206 when applicable. Note that the struct members should not be accessed directly but only via the Trickle API.

Public Members

uint32_t Imin

Min interval size in ms

uint8_t Imax

Max number of doublings

uint8_t k

Redundancy constant

uint32_t I

Current interval size

uint32_t Istart

Start of the interval in ms

uint8_t c

Consistency counter

uint32_t Imax_abs

Max interval size in ms (not doublings)

net_trickle_cb_t cb

Callback to be called when timer expires