Skip to content

Commit

Permalink
gnrc_sixlowpan_frag_stats: initial import of frag statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Apr 9, 2019
1 parent 61cad70 commit 08b4686
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PSEUDOMODULES += gnrc_sixloenc
PSEUDOMODULES += gnrc_sixlowpan_border_router_default
PSEUDOMODULES += gnrc_sixlowpan_default
PSEUDOMODULES += gnrc_sixlowpan_frag_hint
PSEUDOMODULES += gnrc_sixlowpan_frag_stats
PSEUDOMODULES += gnrc_sixlowpan_iphc_nhc
PSEUDOMODULES += gnrc_sixlowpan_nd_border_router
PSEUDOMODULES += gnrc_sixlowpan_router
Expand Down
23 changes: 23 additions & 0 deletions sys/include/net/gnrc/sixlowpan/frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ typedef struct {
#endif /* MODULE_GNRC_SIXLOWPAN_FRAG_HINT */
} gnrc_sixlowpan_msg_frag_t;

#if defined(MODULE_GNRC_SIXLOWPAN_FRAG_STATS) || DOXYGEN
/**
* @brief Statistics on fragmentation and reassembly
*
* @note Only available with the `gnrc_sixlowpan_frag_stats` module
*/
typedef struct {
unsigned rbuf_full; /**< counts the number of events were the
* reassembly buffer is full */
#if defined(MODULE_GNRC_SIXLOWPAN_FRAG_VRB) || DOXYGEN
unsigned vrb_full; /**< counts the number of events were the virtual
* reassembly buffer is full */
#endif
} gnrc_sixlowpan_frag_stats_t;

/**
* @brief Get the current statistics on fragmentation and reassembly
*
* @return The current statistics on fragmentation and reassembly
*/
gnrc_sixlowpan_frag_stats_t *gnrc_sixlowpan_frag_stats_get(void);
#endif

/**
* @brief Allocates a @ref gnrc_sixlowpan_msg_frag_t object
*
Expand Down
12 changes: 12 additions & 0 deletions sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ enum {
RBUF_ADD_DUPLICATE,
};

#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_STATS
static gnrc_sixlowpan_frag_stats_t _stats;

gnrc_sixlowpan_frag_stats_t *gnrc_sixlowpan_frag_stats_get(void)
{
return &_stats;
}
#endif

static int _check_fragments(gnrc_sixlowpan_rbuf_base_t *entry,
size_t frag_size, size_t offset)
{
Expand Down Expand Up @@ -190,6 +199,9 @@ static int _rbuf_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *pkt,
dst, netif_hdr->dst_l2addr_len,
datagram_size, tag, page)) == NULL) {
DEBUG("6lo rbuf: reassembly buffer full.\n");
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_STATS
_stats.rbuf_full++;
#endif
gnrc_pktbuf_release(pkt);
return RBUF_ADD_ERROR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_add(
break;
}
}
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_STATS
if (vrbe == NULL) {
gnrc_sixlowpan_frag_stats_get()->vrb_full++;
}
#endif
return vrbe;
}

Expand Down

0 comments on commit 08b4686

Please sign in to comment.