lwmac_internal.h File Reference

Interface definition for internal functions of LWMAC protocol. More...

Detailed Description

Interface definition for internal functions of LWMAC protocol.

Author
Daniel Krebs githu.nosp@m.b@da.nosp@m.niel-.nosp@m.kreb.nosp@m.s.net
Shuguo Zhuo shugu.nosp@m.o.zh.nosp@m.uo@in.nosp@m.ria..nosp@m.fr

Definition in file lwmac_internal.h.

#include <stdint.h>
#include "periph/rtt.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/mac/types.h"
#include "net/gnrc/lwmac/types.h"
+ Include dependency graph for lwmac_internal.h:

Go to the source code of this file.

Data Structures

struct  gnrc_lwmac_packet_info_t
 Type to pass information about parsing. More...
 
#define GNRC_LWMAC_TX_CONTINUE   (0x0008U)
 Flag to track if the sender can continue to transmit packet to the receiver in its TX procedure. More...
 
#define GNRC_LWMAC_QUIT_TX   (0x0010U)
 Flag to track if the sender should quit Tx in current cycle. More...
 
#define GNRC_LWMAC_PHASE_BACKOFF   (0x0020U)
 Flag to track if the device need to reselect a new wake-up phase. More...
 
#define GNRC_LWMAC_QUIT_RX   (0x0040U)
 Flag to track if the device needs to quit the wake-up (listening) procedure. More...
 
#define GNRC_LWMAC_RTT_EVENT_MARGIN_TICKS   (RTT_MS_TO_TICKS(2))
 Next RTT event must be at least this far in the future. More...
 
static void gnrc_lwmac_set_tx_continue (gnrc_netif_t *netif, bool tx_continue)
 set the GNRC_LWMAC_TX_CONTINUE flag of the device More...
 
static bool gnrc_lwmac_get_tx_continue (gnrc_netif_t *netif)
 get the GNRC_LWMAC_TX_CONTINUE flag of the device More...
 
static void gnrc_lwmac_set_quit_tx (gnrc_netif_t *netif, bool quit_tx)
 set the GNRC_LWMAC_QUIT_TX flag of the device More...
 
static bool gnrc_lwmac_get_quit_tx (gnrc_netif_t *netif)
 get the GNRC_LWMAC_QUIT_TX flag of the device More...
 
static void gnrc_lwmac_set_phase_backoff (gnrc_netif_t *netif, bool backoff)
 set the GNRC_LWMAC_PHASE_BACKOFF flag of the device More...
 
static bool gnrc_lwmac_get_phase_backoff (gnrc_netif_t *netif)
 get the GNRC_LWMAC_PHASE_BACKOFF flag of the device More...
 
static void gnrc_lwmac_set_quit_rx (gnrc_netif_t *netif, bool quit_rx)
 set the GNRC_LWMAC_QUIT_RX flag of the device More...
 
static bool gnrc_lwmac_get_quit_rx (gnrc_netif_t *netif)
 get the GNRC_LWMAC_QUIT_RX flag of the device More...
 
static void gnrc_lwmac_set_dutycycle_active (gnrc_netif_t *netif, bool active)
 set the GNRC_LWMAC_DUTYCYCLE_ACTIVE flag of LWMAC More...
 
static bool gnrc_lwmac_get_dutycycle_active (gnrc_netif_t *netif)
 get the GNRC_LWMAC_DUTYCYCLE_ACTIVE flag of LWMAC More...
 
static void gnrc_lwmac_set_reschedule (gnrc_netif_t *netif, bool reschedule)
 set the GNRC_LWMAC_NEEDS_RESCHEDULE flag of LWMAC More...
 
static bool gnrc_lwmac_get_reschedule (gnrc_netif_t *netif)
 get the GNRC_LWMAC_NEEDS_RESCHEDULE flag of LWMAC More...
 
int _gnrc_lwmac_transmit (gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
 send a packet over the network interface in LWMAC
 
int _gnrc_lwmac_parse_packet (gnrc_pktsnip_t *pkt, gnrc_lwmac_packet_info_t *info)
 Parse an incoming packet and extract important information. More...
 
netopt_state_t _gnrc_lwmac_get_netdev_state (gnrc_netif_t *netif)
 Shortcut to get the state of netdev. More...
 
void _gnrc_lwmac_set_netdev_state (gnrc_netif_t *netif, netopt_state_t devstate)
 Shortcut to set the state of netdev. More...
 
static uint32_t _gnrc_lwmac_ticks_to_phase (uint32_t ticks)
 Convert RTT ticks to device phase. More...
 
static uint32_t _gnrc_lwmac_phase_now (void)
 Get device's current phase. More...
 
static uint32_t _gnrc_lwmac_ticks_until_phase (uint32_t phase)
 Calculate how many ticks remaining to the targeted phase in the future. More...
 
int _gnrc_lwmac_dispatch_defer (gnrc_pktsnip_t *buffer[], gnrc_pktsnip_t *pkt)
 Store the received packet to the dispatch buffer and remove possible duplicate packets. More...
 

Macro Definition Documentation

◆ GNRC_LWMAC_PHASE_BACKOFF

#define GNRC_LWMAC_PHASE_BACKOFF   (0x0020U)

Flag to track if the device need to reselect a new wake-up phase.

This flag is mainly for potential collision avoidance. In multi-hop scenario, it could be dangerous that a sender's wake-up phase is close to its receiver's, which may lead to collisions when the sender is sending to the receiver while the sender's son nodes are also sending to the sender. To avoid this, in case a sender finds its phase close to its receiver's, it sets up this flag and then randomly reselects a new wake-up phase.

Definition at line 68 of file lwmac_internal.h.

◆ GNRC_LWMAC_QUIT_RX

#define GNRC_LWMAC_QUIT_RX   (0x0040U)

Flag to track if the device needs to quit the wake-up (listening) procedure.

LWMAC adopts an auto wake-up extension scheme. That is, normally, after each data reception in the wake-up period, it extends the wake-up period to another basic duration, thus to receive more potential incoming packets, which is also correlated to the pending-bit transmission scheme to support burst transmissions to boost throughput. However, in some situations, like receiving broadcast (stream) packet, the receiver should immediately goto sleep (by setting up this flag) after one reception, thus not to receive duplicate broadcast packets.

Definition at line 81 of file lwmac_internal.h.

◆ GNRC_LWMAC_QUIT_TX

#define GNRC_LWMAC_QUIT_TX   (0x0010U)

Flag to track if the sender should quit Tx in current cycle.

This flag is mainly for collision avoidance. In case a node overhears ongoing broadcast packets stream or other ongoing transmissions of other communication pairs during its wake-up period, it sets up this flag, which quits all its potential transmission attempts in this current cycle (started by the wake-up period), thus not to collide with other (neighbor) nodes' transmissions.

Definition at line 56 of file lwmac_internal.h.

◆ GNRC_LWMAC_RTT_EVENT_MARGIN_TICKS

#define GNRC_LWMAC_RTT_EVENT_MARGIN_TICKS   (RTT_MS_TO_TICKS(2))

Next RTT event must be at least this far in the future.

When setting an RTT alarm to short in the future it could be possible that the counter already passed the calculated alarm before it could be set.

Definition at line 98 of file lwmac_internal.h.

◆ GNRC_LWMAC_TX_CONTINUE

#define GNRC_LWMAC_TX_CONTINUE   (0x0008U)

Flag to track if the sender can continue to transmit packet to the receiver in its TX procedure.

LWMAC supports burst transmission based on the pending-bit technique. Namely, if the sender has multi packets for the same receiver, it can successively transmit its packets back to back with this flag set up, with the awareness that the receiver will also keep awake for receptions.

Definition at line 44 of file lwmac_internal.h.

Function Documentation

◆ _gnrc_lwmac_dispatch_defer()

int _gnrc_lwmac_dispatch_defer ( gnrc_pktsnip_t buffer[],
gnrc_pktsnip_t pkt 
)

Store the received packet to the dispatch buffer and remove possible duplicate packets.

Parameters
[in,out]bufferRX dispatch packet buffer
[in]pktreceived packet
Returns
0 if correctly stored
<0 on error

◆ _gnrc_lwmac_get_netdev_state()

netopt_state_t _gnrc_lwmac_get_netdev_state ( gnrc_netif_t netif)

Shortcut to get the state of netdev.

Parameters
[in]netifptr to the network interface
Returns
state of netdev

◆ _gnrc_lwmac_parse_packet()

int _gnrc_lwmac_parse_packet ( gnrc_pktsnip_t pkt,
gnrc_lwmac_packet_info_t info 
)

Parse an incoming packet and extract important information.

   Copies addresses into @p info, but header points inside @p pkt.
Parameters
[in]pktpacket that will be parsed
[out]infostructure that will hold parsed information
Returns
0 if correctly parsed
<0 on error

◆ _gnrc_lwmac_phase_now()

static uint32_t _gnrc_lwmac_phase_now ( void  )
inlinestatic

Get device's current phase.

Returns
device phase

Definition at line 353 of file lwmac_internal.h.

◆ _gnrc_lwmac_set_netdev_state()

void _gnrc_lwmac_set_netdev_state ( gnrc_netif_t netif,
netopt_state_t  devstate 
)

Shortcut to set the state of netdev.

Parameters
[in]netifptr to the network interface
[in]devstatenew state for netdev

◆ _gnrc_lwmac_ticks_to_phase()

static uint32_t _gnrc_lwmac_ticks_to_phase ( uint32_t  ticks)
inlinestatic

Convert RTT ticks to device phase.

Parameters
[in]ticksRTT ticks
Returns
device phase

Definition at line 341 of file lwmac_internal.h.

◆ _gnrc_lwmac_ticks_until_phase()

static uint32_t _gnrc_lwmac_ticks_until_phase ( uint32_t  phase)
inlinestatic

Calculate how many ticks remaining to the targeted phase in the future.

Parameters
[in]phasedevice phase
Returns
RTT ticks

Definition at line 365 of file lwmac_internal.h.

◆ gnrc_lwmac_get_dutycycle_active()

static bool gnrc_lwmac_get_dutycycle_active ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_DUTYCYCLE_ACTIVE flag of LWMAC

Parameters
[in]netifptr to the network interface
Returns
true if active
false if not active

Definition at line 245 of file lwmac_internal.h.

◆ gnrc_lwmac_get_phase_backoff()

static bool gnrc_lwmac_get_phase_backoff ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_PHASE_BACKOFF flag of the device

Parameters
[in]netifptr to the network interface
Returns
true if will run phase-backoff
false if will not run phase-backoff

Definition at line 185 of file lwmac_internal.h.

◆ gnrc_lwmac_get_quit_rx()

static bool gnrc_lwmac_get_quit_rx ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_QUIT_RX flag of the device

Parameters
[in]netifptr to the network interface
Returns
true if will quit rx
false if will not quit rx

Definition at line 215 of file lwmac_internal.h.

◆ gnrc_lwmac_get_quit_tx()

static bool gnrc_lwmac_get_quit_tx ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_QUIT_TX flag of the device

Parameters
[in]netifptr to the network interface
Returns
true if quit tx
false if will not quit tx

Definition at line 155 of file lwmac_internal.h.

◆ gnrc_lwmac_get_reschedule()

static bool gnrc_lwmac_get_reschedule ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_NEEDS_RESCHEDULE flag of LWMAC

Parameters
[in]netifptr to the network interface
Returns
true if needs rescheduling
false if no need for rescheduling

Definition at line 275 of file lwmac_internal.h.

◆ gnrc_lwmac_get_tx_continue()

static bool gnrc_lwmac_get_tx_continue ( gnrc_netif_t netif)
inlinestatic

get the GNRC_LWMAC_TX_CONTINUE flag of the device

Parameters
[in]netifptr to the network interface
Returns
true if tx continue
false if tx will not continue

Definition at line 125 of file lwmac_internal.h.

◆ gnrc_lwmac_set_dutycycle_active()

static void gnrc_lwmac_set_dutycycle_active ( gnrc_netif_t netif,
bool  active 
)
inlinestatic

set the GNRC_LWMAC_DUTYCYCLE_ACTIVE flag of LWMAC

Parameters
[in]netifptr to the network interface
[in]activevalue for LWMAC GNRC_LWMAC_DUTYCYCLE_ACTIVE flag

Definition at line 227 of file lwmac_internal.h.

◆ gnrc_lwmac_set_phase_backoff()

static void gnrc_lwmac_set_phase_backoff ( gnrc_netif_t netif,
bool  backoff 
)
inlinestatic

set the GNRC_LWMAC_PHASE_BACKOFF flag of the device

Parameters
[in]netifptr to the network interface
[in]backoffvalue for LWMAC GNRC_LWMAC_PHASE_BACKOFF flag

Definition at line 167 of file lwmac_internal.h.

◆ gnrc_lwmac_set_quit_rx()

static void gnrc_lwmac_set_quit_rx ( gnrc_netif_t netif,
bool  quit_rx 
)
inlinestatic

set the GNRC_LWMAC_QUIT_RX flag of the device

Parameters
[in]netifptr to the network interface
[in]quit_rxvalue for LWMAC GNRC_LWMAC_QUIT_RX flag

Definition at line 197 of file lwmac_internal.h.

◆ gnrc_lwmac_set_quit_tx()

static void gnrc_lwmac_set_quit_tx ( gnrc_netif_t netif,
bool  quit_tx 
)
inlinestatic

set the GNRC_LWMAC_QUIT_TX flag of the device

Parameters
[in]netifptr to the network interface
[in]quit_txvalue for GNRC_LWMAC_QUIT_TX flag

Definition at line 137 of file lwmac_internal.h.

◆ gnrc_lwmac_set_reschedule()

static void gnrc_lwmac_set_reschedule ( gnrc_netif_t netif,
bool  reschedule 
)
inlinestatic

set the GNRC_LWMAC_NEEDS_RESCHEDULE flag of LWMAC

Parameters
[in]netifptr to the network interface
[in]reschedulevalue for GNRC_LWMAC_NEEDS_RESCHEDULE flag

Definition at line 257 of file lwmac_internal.h.

◆ gnrc_lwmac_set_tx_continue()

static void gnrc_lwmac_set_tx_continue ( gnrc_netif_t netif,
bool  tx_continue 
)
inlinestatic

set the GNRC_LWMAC_TX_CONTINUE flag of the device

Parameters
[in]netifptr to the network interface
[in]tx_continuevalue for LWMAC tx-continue flag

Definition at line 107 of file lwmac_internal.h.