gnrc_sixlowpan_frag_stats: add average fragments per datagram statistic

This commit is contained in:
Martine S. Lenders 2020-02-05 16:14:46 +01:00
parent 81d348cafd
commit ed9f43ab3a
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
3 changed files with 22 additions and 0 deletions

View File

@ -35,6 +35,8 @@ typedef struct {
* reassembly buffer is full */ * reassembly buffer is full */
unsigned frag_full; /**< counts the number of events that there where unsigned frag_full; /**< counts the number of events that there where
* no @ref gnrc_sixlowpan_frag_fb_t available */ * no @ref gnrc_sixlowpan_frag_fb_t available */
unsigned datagrams; /**< reassembled datagrams */
unsigned fragments; /**< total fragments of reassembled fragments */
#if defined(MODULE_GNRC_SIXLOWPAN_FRAG_VRB) || DOXYGEN #if defined(MODULE_GNRC_SIXLOWPAN_FRAG_VRB) || DOXYGEN
unsigned vrb_full; /**< counts the number of events where the virtual unsigned vrb_full; /**< counts the number of events where the virtual
* reassembly buffer is full */ * reassembly buffer is full */

View File

@ -580,6 +580,20 @@ static void _tmp_rm(gnrc_sixlowpan_frag_rb_t *rbuf)
#endif /* CONFIG_GNRC_SIXLOWPAN_FRAG_RBUF_DEL_TIMER */ #endif /* CONFIG_GNRC_SIXLOWPAN_FRAG_RBUF_DEL_TIMER */
} }
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_STATS)
static inline unsigned _count_frags(gnrc_sixlowpan_frag_rb_t *rbuf)
{
unsigned frags = 0;
gnrc_sixlowpan_frag_rb_int_t *frag = rbuf->super.ints;
while (frag) {
frag = frag->next;
frags++;
}
return frags;
}
#endif
int gnrc_sixlowpan_frag_rb_dispatch_when_complete(gnrc_sixlowpan_frag_rb_t *rbuf, int gnrc_sixlowpan_frag_rb_dispatch_when_complete(gnrc_sixlowpan_frag_rb_t *rbuf,
gnrc_netif_hdr_t *netif_hdr) gnrc_netif_hdr_t *netif_hdr)
{ {
@ -610,6 +624,10 @@ int gnrc_sixlowpan_frag_rb_dispatch_when_complete(gnrc_sixlowpan_frag_rb_t *rbuf
new_netif_hdr->lqi = netif_hdr->lqi; new_netif_hdr->lqi = netif_hdr->lqi;
new_netif_hdr->rssi = netif_hdr->rssi; new_netif_hdr->rssi = netif_hdr->rssi;
LL_APPEND(rbuf->pkt, netif); LL_APPEND(rbuf->pkt, netif);
#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_STATS)
gnrc_sixlowpan_frag_stats_get()->fragments += _count_frags(rbuf);
gnrc_sixlowpan_frag_stats_get()->datagrams++;
#endif
gnrc_sixlowpan_dispatch_recv(rbuf->pkt, NULL, 0); gnrc_sixlowpan_dispatch_recv(rbuf->pkt, NULL, 0);
_tmp_rm(rbuf); _tmp_rm(rbuf);
} }

View File

@ -28,6 +28,8 @@ int _gnrc_6lo_frag_stats(int argc, char **argv)
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_VRB #ifdef MODULE_GNRC_SIXLOWPAN_FRAG_VRB
printf("VRB full: %u\n", stats->vrb_full); printf("VRB full: %u\n", stats->vrb_full);
#endif #endif
printf("frags complete: %u\n", stats->fragments);
printf("dgs complete: %u\n", stats->datagrams);
return 0; return 0;
} }