gnrc_rpl: netstats_rpl: introduce statistics
parent
25e18dad88
commit
ad6677b33f
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2016 HAW Hamburg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_netstats_rpl Packet statistics for RPL
|
||||
* @ingroup net_netstats
|
||||
* @brief Packet statistics for RPL
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definition of RPL related packet statistics
|
||||
*
|
||||
* @author Cenk Gündoğan <mail@cgundogan.de>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef NETSTATS_RPL_H
|
||||
#define NETSTATS_RPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief RPL statistics struct
|
||||
*/
|
||||
typedef struct {
|
||||
/* DIO */
|
||||
uint32_t dio_rx_ucast_count; /**< unicast dio received in packets */
|
||||
uint32_t dio_rx_ucast_bytes; /**< unicast dio received in bytes */
|
||||
uint32_t dio_rx_mcast_count; /**< multicast dio received in packets */
|
||||
uint32_t dio_rx_mcast_bytes; /**< multicast dio received in bytes */
|
||||
uint32_t dio_tx_ucast_count; /**< unicast dio sent in packets */
|
||||
uint32_t dio_tx_ucast_bytes; /**< unicast dio sent in bytes */
|
||||
uint32_t dio_tx_mcast_count; /**< multicast dio sent in packets */
|
||||
uint32_t dio_tx_mcast_bytes; /**< multicast dio sent in bytes*/
|
||||
/* DIS */
|
||||
uint32_t dis_rx_ucast_count; /**< unicast dis received in packets */
|
||||
uint32_t dis_rx_ucast_bytes; /**< unicast dis received in bytes */
|
||||
uint32_t dis_rx_mcast_count; /**< multicast dis received in packets */
|
||||
uint32_t dis_rx_mcast_bytes; /**< multicast dis received in bytes */
|
||||
uint32_t dis_tx_ucast_count; /**< unicast dis sent in packets */
|
||||
uint32_t dis_tx_ucast_bytes; /**< unicast dis sent in bytes */
|
||||
uint32_t dis_tx_mcast_count; /**< multicast dis sent in packets */
|
||||
uint32_t dis_tx_mcast_bytes; /**< multicast dis sent in bytes*/
|
||||
/* DAO */
|
||||
uint32_t dao_rx_ucast_count; /**< unicast dao received in packets */
|
||||
uint32_t dao_rx_ucast_bytes; /**< unicast dao received in bytes */
|
||||
uint32_t dao_rx_mcast_count; /**< multicast dao received in packets */
|
||||
uint32_t dao_rx_mcast_bytes; /**< multicast dao received in bytes */
|
||||
uint32_t dao_tx_ucast_count; /**< unicast dao sent in packets */
|
||||
uint32_t dao_tx_ucast_bytes; /**< unicast dao sent in bytes */
|
||||
uint32_t dao_tx_mcast_count; /**< multicast dao sent in packets */
|
||||
uint32_t dao_tx_mcast_bytes; /**< multicast dao sent in bytes*/
|
||||
/* DAO-ACK */
|
||||
uint32_t dao_ack_rx_ucast_count; /**< unicast dao_ack received in packets */
|
||||
uint32_t dao_ack_rx_ucast_bytes; /**< unicast dao_ack received in bytes */
|
||||
uint32_t dao_ack_rx_mcast_count; /**< multicast dao_ack received in packets */
|
||||
uint32_t dao_ack_rx_mcast_bytes; /**< multicast dao_ack received in bytes */
|
||||
uint32_t dao_ack_tx_ucast_count; /**< unicast dao_ack sent in packets */
|
||||
uint32_t dao_ack_tx_ucast_bytes; /**< unicast dao_ack sent in bytes */
|
||||
uint32_t dao_ack_tx_mcast_count; /**< multicast dao_ack sent in packets */
|
||||
uint32_t dao_ack_tx_mcast_bytes; /**< multicast dao_ack sent in bytes*/
|
||||
} netstats_rpl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NETSTATS_RPL_H */
|
||||
/** @} */
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Cenk Gündoğan <mail@cgundogan.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_gnrc_rpl
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief RPL control message statistics functions
|
||||
*
|
||||
* @author Cenk Gündoğan <mail@cgundogan.de>
|
||||
*/
|
||||
|
||||
#ifndef RPL_NETSTATS_H_
|
||||
#define RPL_NETSTATS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "net/rpl/rpl_netstats.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
#define GNRC_RPL_NETSTATS_MULTICAST (0)
|
||||
#define GNRC_RPL_NETSTATS_UNICAST (1)
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for received DIO
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_rx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dio_rx_mcast_count++;
|
||||
netstats->dio_rx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dio_rx_ucast_count++;
|
||||
netstats->dio_rx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for sent DIO
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_tx_DIO(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dio_tx_mcast_count++;
|
||||
netstats->dio_tx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dio_tx_ucast_count++;
|
||||
netstats->dio_tx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for received DIS
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_rx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dis_rx_mcast_count++;
|
||||
netstats->dis_rx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dis_rx_ucast_count++;
|
||||
netstats->dis_rx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for sent DIS
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_tx_DIS(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dis_tx_mcast_count++;
|
||||
netstats->dis_tx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dis_tx_ucast_count++;
|
||||
netstats->dis_tx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for received DAO
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_rx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dao_rx_mcast_count++;
|
||||
netstats->dao_rx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dao_rx_ucast_count++;
|
||||
netstats->dao_rx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for sent DIO
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_tx_DAO(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dao_tx_mcast_count++;
|
||||
netstats->dao_tx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dao_tx_ucast_count++;
|
||||
netstats->dao_tx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for received DAO-ACK
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_rx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dao_ack_rx_mcast_count++;
|
||||
netstats->dao_ack_rx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dao_ack_rx_ucast_count++;
|
||||
netstats->dao_ack_rx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase statistics for sent DAO-ACK
|
||||
*
|
||||
* @param[in] netstats Pointer to netstats_rpl_t
|
||||
* @param[in] len Length in bytes of an ICMPv6 packet to add to statistics
|
||||
* @param[in] cast GNRC_RPL_NETSTATS_MULTICAST or GNRC_RPL_NETSTATS_UNICAST
|
||||
*/
|
||||
static inline void gnrc_rpl_netstats_tx_DAO_ACK(netstats_rpl_t *netstats, size_t len, int cast)
|
||||
{
|
||||
if (cast == GNRC_RPL_NETSTATS_MULTICAST) {
|
||||
netstats->dao_ack_tx_mcast_count++;
|
||||
netstats->dao_ack_tx_mcast_bytes += len;
|
||||
}
|
||||
else if (cast == GNRC_RPL_NETSTATS_UNICAST) {
|
||||
netstats->dao_ack_tx_ucast_count++;
|
||||
netstats->dao_ack_tx_ucast_bytes += len;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RPL_NETSTATS_H_ */
|
||||
/** @} */
|
Loading…
Reference in New Issue