Skip to content

Commit

Permalink
Merge pull request RIOT-OS#12648 from miri64/gnrc_sixlowpan_frag_sfr/…
Browse files Browse the repository at this point in the history
…feat/initial

gnrc_sixlowpan_frag: initial import of Selective Fragment Recovery
  • Loading branch information
miri64 authored Dec 14, 2020
2 parents dae714c + e980405 commit 41a844f
Show file tree
Hide file tree
Showing 31 changed files with 5,699 additions and 95 deletions.
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ PSEUDOMODULES += gnrc_sixloenc
PSEUDOMODULES += gnrc_sixlowpan_border_router_default
PSEUDOMODULES += gnrc_sixlowpan_default
PSEUDOMODULES += gnrc_sixlowpan_frag_hint
PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_stats
PSEUDOMODULES += gnrc_sixlowpan_iphc_nhc
PSEUDOMODULES += gnrc_sixlowpan_nd_border_router
PSEUDOMODULES += gnrc_sixlowpan_router_default
Expand Down
25 changes: 22 additions & 3 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,26 @@ endif
ifneq (,$(filter gnrc_sixlowpan_default,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib_6ln
USEMODULE += gnrc_sixlowpan
USEMODULE += gnrc_sixlowpan_frag
ifeq (,$(filter gnrc_sixlowpan_frag_sfr,$(USEMODULE)))
USEMODULE += gnrc_sixlowpan_frag
endif
USEMODULE += gnrc_sixlowpan_iphc
endif

ifneq (,$(filter gnrc_sixlowpan_router_default,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib_6lr
USEMODULE += gnrc_sixlowpan_frag
ifeq (,$(filter gnrc_sixlowpan_frag_sfr,$(USEMODULE)))
USEMODULE += gnrc_sixlowpan_frag
endif
USEMODULE += gnrc_sixlowpan_iphc
endif

ifneq (,$(filter gnrc_sixlowpan_border_router_default,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib_6lbr
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_sixlowpan_frag
ifeq (,$(filter gnrc_sixlowpan_frag_sfr,$(USEMODULE)))
USEMODULE += gnrc_sixlowpan_frag
endif
USEMODULE += gnrc_sixlowpan_iphc
endif

Expand All @@ -318,6 +324,19 @@ ifneq (,$(filter gnrc_sixlowpan_frag_rb,$(USEMODULE)))
USEMODULE += xtimer
endif

ifneq (,$(filter gnrc_sixlowpan_frag_sfr,$(USEMODULE)))
USEMODULE += gnrc_sixlowpan
USEMODULE += gnrc_sixlowpan_frag_fb
USEMODULE += gnrc_sixlowpan_frag_vrb
USEMODULE += gnrc_sixlowpan_frag_rb
USEMODULE += evtimer
USEMODULE += xtimer
endif

ifneq (,$(filter gnrc_sixlowpan_frag_sfr_stats,$(USEMODULE)))
USEMODULE += gnrc_sixlowpan_frag_sfr
endif

ifneq (,$(filter gnrc_sixlowpan_frag_vrb,$(USEMODULE)))
USEMODULE += xtimer
USEMODULE += gnrc_sixlowpan_frag_fb
Expand Down
31 changes: 31 additions & 0 deletions sys/include/net/gnrc/netif/6lo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,34 @@
#ifndef NET_GNRC_NETIF_6LO_H
#define NET_GNRC_NETIF_6LO_H

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Local 6LoWPAN capability flags
* @anchor net_gnrc_netif_6lo_local_flags
* @see gnrc_netif_6lo_t::local_flags
*
* Like the the capability flags in the [6LoWPAN Capability Indication Option
* (6CIO)](https://tools.ietf.org/html/rfc7400#section-3.3) are less about
* hardware capabilities than about the implementation status within the
* network. For the flags in this group it is currently undefined how to
* exchange the capabilities between nodes, but they might be added to the 6CIO
* at a later point. Once the 6CIO is implemented in GNRC and the flag is
* supported by it, the corresponding flag in these local flags can be removed.
* @{
*/
/**
* @brief Selective Fragment Recovery enabled
* @see [RFC 8931](https://tools.ietf.org/html/rfc8931)
*/
#define GNRC_NETIF_6LO_LOCAL_FLAGS_SFR (0x01)
/** @} */

/**
* @brief 6Lo component of @ref gnrc_netif_t
*/
Expand All @@ -35,6 +57,15 @@ typedef struct {
* @ref net_gnrc_sixlowpan_frag "gnrc_sixlowpan_frag".
*/
uint16_t max_frag_size;
/**
* @brief 6LoWPAN capability flags beyond the ones advertised in
* [6LoWPAN Capability Indication Option
* (6CIO)](https://tools.ietf.org/html/rfc7400#section-3.3)
*
* @see [Local 6LoWPAN capability flags](@ref
* net_gnrc_netif_6lo_local_flags)
*/
uint8_t local_flags;
} gnrc_netif_6lo_t;

#ifdef __cplusplus
Expand Down
87 changes: 51 additions & 36 deletions sys/include/net/gnrc/sixlowpan/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ extern "C" {
* [gnrc_sixlowpan_frag_fb](@ref net_gnrc_sixlowpan_frag_fb) module
*/
#ifndef CONFIG_GNRC_SIXLOWPAN_FRAG_FB_SIZE
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR)
#define CONFIG_GNRC_SIXLOWPAN_FRAG_FB_SIZE (4U)
#else /* defined(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) */
#define CONFIG_GNRC_SIXLOWPAN_FRAG_FB_SIZE (1U)
#endif /* defined(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) */
#endif

/**
Expand Down Expand Up @@ -163,16 +167,16 @@ extern "C" {

/**
* @name Selective fragment recovery configuration
* @see [draft-ietf-6lo-fragment-recovery-07, section 7.1]
* (https://tools.ietf.org/html/draft-ietf-6lo-fragment-recovery-07#section-7.1)
* @see [RFC 8931, section 7.1]
* (https://tools.ietf.org/html/rfc8931#section-7.1)
* @note Only applicable with gnrc_sixlowpan_frag_sfr module
* @{
*/
/**
* @brief Default minimum value for fragment size (MinFragmentSize)
*/
#ifndef GNRC_SIXLOWPAN_SFR_MIN_FRAG_SIZE
#define GNRC_SIXLOWPAN_SFR_MIN_FRAG_SIZE (96U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MIN_FRAG_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_MIN_FRAG_SIZE 96U
#endif

/**
Expand All @@ -182,32 +186,37 @@ extern "C" {
* the chances of buffer bloat and transmission loss. The value must be less
* than 512 if the unit is defined for the PHY layer is the octet.
*/
#ifndef GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE
#define GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE (112U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE 112U
#endif

/**
* @brief Default value for fragment size that the sender should use to start
* with (OptFragmentSize)
*
* @pre Must be inclusively between
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MIN_FRAG_SIZE and
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE
*/
#ifndef GNRC_SIXLOWPAN_SFR_OPT_FRAG_SIZE
#define GNRC_SIXLOWPAN_SFR_OPT_FRAG_SIZE (GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_OPT_FRAG_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_OPT_FRAG_SIZE CONFIG_GNRC_SIXLOWPAN_SFR_MAX_FRAG_SIZE
#endif

/**
* @brief Indicates whether the sender should react to ECN (UseECN)
*
* When the sender reacts to ECN its window size will vary between @ref
* GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE and @ref GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE.
* When the sender reacts to Explicit Congestion Notification (ECN) its window
* size will vary between @ref CONFIG_GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE and @ref
* CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE.
*/
#define GNRC_SIXLOWPAN_SFR_USE_ECN (0U)
#define CONFIG_GNRC_SIXLOWPAN_SFR_USE_ECN 0U

/**
* @brief Default minimum value of window size that the sender can use
* (MinWindowSize)
*/
#ifndef GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE
#define GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE (1U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE 1U
#endif

/**
Expand All @@ -216,16 +225,20 @@ extern "C" {
*
* @warning **Must** be lesser than 32.
*/
#ifndef GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE
#define GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE (16U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE 16U
#endif

/**
* @brief Default value of window size that the sender should start with
* (OptWindowSize)
*
* @pre Must be inclusively between
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MIN_WIN_SIZE and
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE
*/
#ifndef GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE
#define GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE (16U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE
#define CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE 16U
#endif

/**
Expand All @@ -240,51 +253,53 @@ extern "C" {
* ratio of air and memory in intermediate nodes that a particular datagram will
* use.
*/
#ifndef GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US
#define GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US (100U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US
#define CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US 100U
#endif

/**
* @brief Default minimum amount of time in milliseconds a node should wait
* for an RFRAG Acknowledgment before it takes a next action
* @brief Minimum RFRAG-ACK timeout in msec before a node takes a next action
* (MinARQTimeOut)
*/
#ifndef GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS
#define GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS (350U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS
#define CONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS 350U
#endif

/**
* @brief Default maximum amount of time in milliseconds a node should wait
* for an RFRAG Acknowledgment before it takes a next action
* @brief Maximum RFRAG-ACK timeout in msec before a node takes a next action
* (MaxARQTimeOut)
*/
#ifndef GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS
#define GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS (700U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS
#define CONFIG_GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS 700U
#endif

/**
* @brief Default starting point of the value of the amount of time in
* milliseconds that a sender should wait for an RFRAG Acknowledgment
* before it takes a next action (OptARQTimeOut)
* @brief Default RFRAG-ACK timeout in msec before a node takes a next action
* (OptARQTimeOut)
*
* @pre Must be inclusively between
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS and
* @ref CONFIG_GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS
*/
#ifndef GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS
#define GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS (GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS
#define CONFIG_GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS \
CONFIG_GNRC_SIXLOWPAN_SFR_MAX_ARQ_TIMEOUT_MS
#endif

/**
* @brief The maximum number of retries for a particular fragment
* (MaxFragRetries)
*/
#ifndef GNRC_SIXLOWPAN_SFR_FRAG_RETRIES
#define GNRC_SIXLOWPAN_SFR_FRAG_RETRIES (2U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_FRAG_RETRIES
#define CONFIG_GNRC_SIXLOWPAN_SFR_FRAG_RETRIES 2U
#endif

/**
* @brief The maximum number of retries from scratch for a particular
* datagram (MaxDatagramRetries)
*/
#ifndef GNRC_SIXLOWPAN_SFR_DG_RETRIES
#define GNRC_SIXLOWPAN_SFR_DG_RETRIES (0U)
#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES
#define CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES 0U
#endif
/** @} */

Expand Down
15 changes: 14 additions & 1 deletion sys/include/net/gnrc/sixlowpan/frag/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_HINT
#include "net/gnrc/sixlowpan/frag/hint.h"
#endif /* MODULE_GNRC_SIXLOWPAN_FRAG_HINT */
#include "net/gnrc/sixlowpan/frag/sfr_types.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -43,10 +44,22 @@ extern "C" {
*/
typedef struct {
gnrc_pktsnip_t *pkt; /**< Pointer to the IPv6 packet to be fragmented */
uint16_t datagram_size; /**< Length of just the (uncompressed) IPv6 packet to be fragmented */
/**
* @brief Length of just the (uncompressed) IPv6 packet to be fragmented
*
* @note With @ref net_gnrc_sixlowpan_frag_sfr this denotes the
* _compressed form_ of the datagram
*/
uint16_t datagram_size;
uint16_t tag; /**< Tag used for the fragment */
uint16_t offset; /**< Offset of the Nth fragment from the beginning of the
* payload datagram */
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR)
/**
* @brief Extension for selective fragment recovery.
*/
gnrc_sixlowpan_frag_sfr_fb_t sfr;
#endif /* IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR) */
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_HINT
/**
* @brief Hint for the size (smaller than link-layer PDU) for the next
Expand Down
Loading

0 comments on commit 41a844f

Please sign in to comment.