mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_ipv6_ext_frag: initial import of statistics module
This commit is contained in:
parent
81d348cafd
commit
cf69e61289
@ -18,6 +18,7 @@ PSEUDOMODULES += event_%
|
||||
PSEUDOMODULES += fmt_%
|
||||
PSEUDOMODULES += gnrc_dhcpv6_%
|
||||
PSEUDOMODULES += gnrc_ipv6_default
|
||||
PSEUDOMODULES += gnrc_ipv6_ext_frag_stats
|
||||
PSEUDOMODULES += gnrc_ipv6_router
|
||||
PSEUDOMODULES += gnrc_ipv6_router_default
|
||||
PSEUDOMODULES += gnrc_ipv6_nib_6lbr
|
||||
|
@ -93,6 +93,18 @@ typedef struct {
|
||||
uint8_t last; /**< received last fragment */
|
||||
} gnrc_ipv6_ext_frag_rbuf_t;
|
||||
|
||||
/**
|
||||
* @brief Statistics on reassembly and reassembly
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned rbuf_full; /**< counts the number of events where the
|
||||
* reassembly buffer is full */
|
||||
unsigned frag_full; /**< counts the number of events that there where
|
||||
* no @ref gnrc_sixlowpan_frag_fb_t available */
|
||||
unsigned datagrams; /**< reassembled datagrams */
|
||||
unsigned fragments; /**< total fragments of reassembled fragments */
|
||||
} gnrc_ipv6_ext_frag_stats_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes IPv6 fragmentation and reassembly
|
||||
* @internal
|
||||
@ -187,6 +199,14 @@ static inline void gnrc_ipv6_ext_frag_rbuf_del(gnrc_ipv6_ext_frag_rbuf_t *rbuf)
|
||||
void gnrc_ipv6_ext_frag_rbuf_gc(void);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Get the current statistics on reassembly and fragmentation
|
||||
*
|
||||
* @return The current statistics on reassembly and fragmentation.
|
||||
* @return NULL, if module `gnrc_ipv6_ext_frag_stats` is not compiled in.
|
||||
*/
|
||||
gnrc_ipv6_ext_frag_stats_t *gnrc_ipv6_ext_frag_stats(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -40,6 +40,7 @@ static gnrc_ipv6_ext_frag_limits_t _limits_pool[CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS
|
||||
static clist_node_t _free_limits;
|
||||
static xtimer_t _gc_xtimer;
|
||||
static msg_t _gc_msg = { .type = GNRC_IPV6_EXT_FRAG_RBUF_GC };
|
||||
static gnrc_ipv6_ext_frag_stats_t _stats;
|
||||
|
||||
/**
|
||||
* @todo Implement better mechanism as described in
|
||||
@ -278,6 +279,9 @@ static gnrc_ipv6_ext_frag_send_t *_snd_buf_alloc(void)
|
||||
return snd_buf;
|
||||
}
|
||||
}
|
||||
if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) {
|
||||
_stats.frag_full++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -495,6 +499,10 @@ gnrc_pktsnip_t *gnrc_ipv6_ext_frag_reass(gnrc_pktsnip_t *pkt)
|
||||
gnrc_ipv6_ext_frag_rbuf_del(rbuf);
|
||||
ipv6->len = byteorder_htons(byteorder_ntohs(ipv6->len) -
|
||||
sizeof(ipv6_ext_frag_t));
|
||||
if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) {
|
||||
_stats.fragments++;
|
||||
_stats.datagrams++;
|
||||
}
|
||||
return pkt;
|
||||
}
|
||||
else {
|
||||
@ -562,10 +570,16 @@ gnrc_ipv6_ext_frag_rbuf_t *gnrc_ipv6_ext_frag_rbuf_get(ipv6_hdr_t *ipv6,
|
||||
assert(oldest != NULL); /* reassembly buffer is full, so there needs
|
||||
* to be an oldest entry */
|
||||
DEBUG("ipv6_ext_frag: dropping oldest entry\n");
|
||||
if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) {
|
||||
_stats.rbuf_full++;
|
||||
}
|
||||
gnrc_ipv6_ext_frag_rbuf_del(oldest);
|
||||
res = oldest;
|
||||
_init_rbuf(res, ipv6, id);
|
||||
}
|
||||
else if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS) && (res == NULL)) {
|
||||
_stats.rbuf_full++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -589,6 +603,11 @@ void gnrc_ipv6_ext_frag_rbuf_gc(void)
|
||||
}
|
||||
}
|
||||
|
||||
gnrc_ipv6_ext_frag_stats_t *gnrc_ipv6_ext_frag_stats(void)
|
||||
{
|
||||
return (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) ? &_stats : NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint16_t start;
|
||||
uint16_t end;
|
||||
@ -698,6 +717,10 @@ static gnrc_pktsnip_t *_completed(gnrc_ipv6_ext_frag_rbuf_t *rbuf)
|
||||
/* rewrite length */
|
||||
rbuf->ipv6->len = byteorder_htons(rbuf->pkt_len);
|
||||
rbuf->pkt = NULL;
|
||||
if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) {
|
||||
_stats.fragments += clist_count(&rbuf->limits);
|
||||
_stats.datagrams++;
|
||||
}
|
||||
gnrc_ipv6_ext_frag_rbuf_free(rbuf);
|
||||
return res;
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ endif
|
||||
ifneq (,$(filter fib,$(USEMODULE)))
|
||||
SRC += sc_fib.c
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_ext_frag_stats,$(USEMODULE)))
|
||||
SRC += sc_gnrc_ipv6_frag_stats.c
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE)))
|
||||
SRC += sc_gnrc_ipv6_nib.c
|
||||
endif
|
||||
|
35
sys/shell/commands/sc_gnrc_ipv6_frag_stats.c
Normal file
35
sys/shell/commands/sc_gnrc_ipv6_frag_stats.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Martine Lenders <m.lenders@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "net/gnrc/ipv6/ext/frag.h"
|
||||
|
||||
int _gnrc_ipv6_frag_stats(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
if (IS_USED(MODULE_GNRC_IPV6_EXT_FRAG_STATS)) {
|
||||
gnrc_ipv6_ext_frag_stats_t *stats = gnrc_ipv6_ext_frag_stats();
|
||||
|
||||
printf("rbuf full: %u\n", stats->rbuf_full);
|
||||
printf("frag full: %u\n", stats->frag_full);
|
||||
printf("frags complete: %u\n", stats->fragments);
|
||||
printf("dgs complete: %u\n", stats->datagrams);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** @} */
|
@ -90,6 +90,10 @@ extern int _gnrc_netif_send(int argc, char **argv);
|
||||
extern int _fib_route_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_GNRC_IPV6_EXT_FRAG_STATS
|
||||
extern int _gnrc_ipv6_frag_stats(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_GNRC_IPV6_WHITELIST
|
||||
extern int _whitelist(int argc, char **argv);
|
||||
#endif
|
||||
@ -214,6 +218,9 @@ const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_FIB
|
||||
{"fibroute", "Manipulate the FIB (info: 'fibroute [add|del]')", _fib_route_handler},
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_IPV6_EXT_FRAG_STATS
|
||||
{"ip6_frag", "IPv6 fragmentation statistics", _gnrc_ipv6_frag_stats },
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_IPV6_WHITELIST
|
||||
{"whitelist", "whitelists an address for receival ('whitelist [add|del|help]')", _whitelist },
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user