Skip to content

Commit

Permalink
improved Wi-SUN stack statistics added
Browse files Browse the repository at this point in the history
Added join state information to statistics
Added neighbor remove and add statistics
added Child add remove statistics
Added improved Async message statistics
  • Loading branch information
Mika Tervonen authored and Mika Tervonen committed Mar 9, 2021
1 parent e656190 commit 56b7735
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Features
* Added support for Anonymous address generation in DHCPv6 server for Wi-SUN Border router
* Improved Wi-SUN Async messaging statics. Time spent in different states and neighbor management changes.

### Changes
* Added throttling of number of simultaneous EAPOL authentications based on Border Router TX queue size
Expand Down
41 changes: 41 additions & 0 deletions nanostack/ws_management_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,47 @@ typedef struct ws_statistics {
uint32_t asynch_tx_count;
/** Asynch RX counter */
uint32_t asynch_rx_count;


/** Time spent in individual Wi-SUN join state 1 Discovery*/
uint32_t join_state_1;
/** Time spent in individual Wi-SUN join state 2 Authentication*/
uint32_t join_state_2;
/** Time spent in individual Wi-SUN join state 3 Configuration learn*/
uint32_t join_state_3;
/** Time spent in individual Wi-SUN join state 4 RPL parent discovery*/
uint32_t join_state_4;
/** Time spent in individual Wi-SUN join state 5 Active state*/
uint32_t join_state_5;


/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
uint32_t sent_PAS;
/** Amount of Wi-SUN Pan Advertisement Message sent*/
uint32_t sent_PA;
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
uint32_t sent_PCS;
/** Amount of Wi-SUN Pan Configuration Message sent*/
uint32_t sent_PC;

/** Amount of Wi-SUN Pan Advertisement Solicit Message sent*/
uint32_t recv_PAS;
/** Amount of Wi-SUN Pan Advertisement Message sent*/
uint32_t recv_PA;
/** Amount of Wi-SUN Pan Configuration Solicit Message sent*/
uint32_t recv_PCS;
/** Amount of Wi-SUN Pan Configuration Message sent*/
uint32_t recv_PC;

/** New Neighbours found */
uint32_t Neighbour_add;
/** New Neighbours Removed */
uint32_t Neighbour_remove;
/** New Child added */
uint32_t Child_add;
/** Child lost */
uint32_t child_remove;

} ws_statistics_t;

/**
Expand Down
35 changes: 32 additions & 3 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,7 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
// Not from long address
return;
}
ws_stats_update(cur, STATS_WS_ASYNCH_RX, 1);
//Validate network name
switch (message_type) {
case WS_FT_PAN_ADVERT:
Expand All @@ -1926,7 +1927,6 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
default:
return;
}
ws_stats_update(cur, STATS_WS_ASYNCH_RX, 1);
//UTT-IE and US-IE are mandatory for all Asynch Messages
ws_utt_ie_t ws_utt;
if (!ws_wh_utt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_utt)) {
Expand All @@ -1949,20 +1949,26 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
switch (message_type) {
case WS_FT_PAN_ADVERT:
// Analyse Advertisement
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PA, 1);
tr_info("received ADVERT Src:%s panid:%x rssi:%d", trace_array(data->SrcAddr, 8), data->SrcPANId, data->signal_dbm);
ws_bootstrap_pan_advertisement_analyse(cur, data, ie_ext, &ws_utt, &ws_us);
break;
case WS_FT_PAN_ADVERT_SOL:
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PAS, 1);
tr_info("received ADVERT SOL Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm);
ws_bootstrap_pan_advertisement_solicit_analyse(cur, data, &ws_utt, &ws_us);
break;
case WS_FT_PAN_CONF:
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PC, 1);
tr_info("received CONFIG Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm);
ws_bootstrap_pan_config_analyse(cur, data, ie_ext, &ws_utt, &ws_us);
break;
default:
case WS_FT_PAN_CONF_SOL:
ws_stats_update(cur, STATS_WS_ASYNCH_RX_PCS, 1);
tr_info("received CONFIG SOL Src:%s rssi:%d", trace_array(data->SrcAddr, 8), data->signal_dbm);
ws_bootstrap_pan_config_solicit_analyse(cur, data, &ws_utt, &ws_us);
default:
// Unknown message do not process
break;
}
}
Expand Down Expand Up @@ -2104,6 +2110,7 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor_buffer->neighbor);
return false;
}
ws_stats_update(interface, STATS_WS_NEIGHBOUR_ADD, 1);
return true;
}

Expand All @@ -2119,6 +2126,11 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt

//TODO State machine check here

if (ipv6_neighbour_has_registered_by_eui64(&cur->ipv6_neighbour_cache, entry_ptr->mac64)) {
// Child entry deleted
ws_stats_update(cur, STATS_WS_CHILD_REMOVE, 1);
}

if (entry_ptr->ffd_device) {
protocol_6lowpan_release_short_link_address_from_neighcache(cur, entry_ptr->mac16);
protocol_6lowpan_release_long_link_address_from_neighcache(cur, entry_ptr->mac64);
Expand All @@ -2128,6 +2140,8 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
ws_nud_entry_remove(cur, entry_ptr);

ws_bootstrap_neighbor_delete(cur, entry_ptr);
ws_stats_update(cur, STATS_WS_NEIGHBOUR_REMOVE, 1);

}

static uint32_t ws_probe_init_time_get(protocol_interface_info_entry_t *cur)
Expand Down Expand Up @@ -3428,6 +3442,7 @@ static void ws_bootstrap_pan_advert_solicit(protocol_interface_info_entry_t *cur

async_req.security.SecurityLevel = 0;

ws_stats_update(cur, STATS_WS_ASYNCH_TX_PAS, 1);
ws_llc_asynch_request(cur, &async_req);
}

Expand All @@ -3444,6 +3459,7 @@ static void ws_bootstrap_pan_config_solicit(protocol_interface_info_entry_t *cur
ws_set_asynch_channel_list(cur, &async_req);
async_req.security.SecurityLevel = 0;

ws_stats_update(cur, STATS_WS_ASYNCH_TX_PCS, 1);
ws_llc_asynch_request(cur, &async_req);
}

Expand Down Expand Up @@ -3533,7 +3549,7 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
cur->ws_info->pan_information.routing_cost = ws_bootstrap_routing_cost_calculate(cur);
}


ws_stats_update(cur, STATS_WS_ASYNCH_TX_PA, 1);
ws_llc_asynch_request(cur, &async_req);
}

Expand Down Expand Up @@ -3562,6 +3578,7 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
async_req.security.KeyIndex = mac_helper_default_key_index_get(cur);
}

ws_stats_update(cur, STATS_WS_ASYNCH_TX_PC, 1);
ws_llc_asynch_request(cur, &async_req);
}

Expand Down Expand Up @@ -4050,6 +4067,18 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
cur->ws_info->ws_bsi_block.old_bsi = 0;
}
}
/*Update join state statistics*/
if (ws_bootstrap_state_discovery(cur)) {
ws_stats_update(cur, STATS_WS_STATE_1, 1);
} else if (ws_bootstrap_state_authenticate(cur)) {
ws_stats_update(cur, STATS_WS_STATE_2, 1);
} else if (ws_bootstrap_state_configure(cur)) {
ws_stats_update(cur, STATS_WS_STATE_3, 1);
} else if (ws_bootstrap_state_wait_rpl(cur)) {
ws_stats_update(cur, STATS_WS_STATE_4, 1);
} else if (ws_bootstrap_state_active(cur)) {
ws_stats_update(cur, STATS_WS_STATE_5, 1);
}

ws_llc_timer_seconds(cur, seconds);

Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
#include "6LoWPAN/ws/ws_pae_controller.h"
#include "6LoWPAN/ws/ws_cfg_settings.h"
#include "6LoWPAN/ws/ws_stats.h"
#include "Service_Libs/etx/etx.h"
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
#include "Service_Libs/blacklist/blacklist.h"
Expand Down Expand Up @@ -629,6 +630,7 @@ uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *inte
ws_common_neighbour_address_reg_link_update(interface, eui64, link_lifetime);
tr_info("Child registration allowed %d/%d, max:%d", child_count, max_child_count, mac_neighbor_info(interface)->list_total_size);

ws_stats_update(interface, STATS_WS_CHILD_ADD, 1);
return ARO_SUCCESS;
}

Expand Down
69 changes: 59 additions & 10 deletions source/6LoWPAN/ws/ws_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,69 @@ int ws_statistics_stop(int8_t interface_id)

void ws_stats_update(protocol_interface_info_entry_t *cur, ws_stats_type_t type, uint32_t update_val)
{
if (!cur || !ws_info(cur)) {
if (!cur || !ws_info(cur) || !cur->ws_info->stored_stats_ptr) {
return;
}
ws_statistics_t *stored_stats = cur->ws_info->stored_stats_ptr;

if (stored_stats) {
switch (type) {
case STATS_WS_ASYNCH_TX:
stored_stats->asynch_tx_count += update_val;
break;
case STATS_WS_ASYNCH_RX:
stored_stats->asynch_rx_count += update_val;
break;
}
switch (type) {
case STATS_WS_ASYNCH_TX:
stored_stats->asynch_tx_count += update_val;
break;
case STATS_WS_ASYNCH_RX:
stored_stats->asynch_rx_count += update_val;
break;
case STATS_WS_ASYNCH_TX_PAS:
stored_stats->sent_PAS += update_val;
break;
case STATS_WS_ASYNCH_TX_PA:
stored_stats->sent_PA += update_val;
break;
case STATS_WS_ASYNCH_TX_PCS:
stored_stats->sent_PCS += update_val;
break;
case STATS_WS_ASYNCH_TX_PC:
stored_stats->sent_PC += update_val;
break;
case STATS_WS_ASYNCH_RX_PAS:
stored_stats->recv_PAS += update_val;
break;
case STATS_WS_ASYNCH_RX_PA:
stored_stats->recv_PA += update_val;
break;
case STATS_WS_ASYNCH_RX_PCS:
stored_stats->recv_PCS += update_val;
break;
case STATS_WS_ASYNCH_RX_PC:
stored_stats->recv_PC += update_val;
break;
case STATS_WS_STATE_1:
stored_stats->join_state_1 += update_val;
break;
case STATS_WS_STATE_2:
stored_stats->join_state_2 += update_val;
break;
case STATS_WS_STATE_3:
stored_stats->join_state_3 += update_val;
break;
case STATS_WS_STATE_4:
stored_stats->join_state_4 += update_val;
break;
case STATS_WS_STATE_5:
stored_stats->join_state_5 += update_val;
break;
case STATS_WS_NEIGHBOUR_ADD:
stored_stats->Neighbour_add += update_val;
break;
case STATS_WS_NEIGHBOUR_REMOVE:
stored_stats->Neighbour_remove += update_val;
break;
case STATS_WS_CHILD_ADD:
stored_stats->Child_add += update_val;
break;
case STATS_WS_CHILD_REMOVE:
stored_stats->child_remove += update_val;
break;
}
}
#endif // HAVE_WS
19 changes: 18 additions & 1 deletion source/6LoWPAN/ws/ws_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@

typedef enum {
STATS_WS_ASYNCH_TX,
STATS_WS_ASYNCH_RX
STATS_WS_ASYNCH_RX,
STATS_WS_ASYNCH_RX_PAS,
STATS_WS_ASYNCH_RX_PA,
STATS_WS_ASYNCH_RX_PCS,
STATS_WS_ASYNCH_RX_PC,
STATS_WS_ASYNCH_TX_PAS,
STATS_WS_ASYNCH_TX_PA,
STATS_WS_ASYNCH_TX_PCS,
STATS_WS_ASYNCH_TX_PC,
STATS_WS_STATE_1,
STATS_WS_STATE_2,
STATS_WS_STATE_3,
STATS_WS_STATE_4,
STATS_WS_STATE_5,
STATS_WS_NEIGHBOUR_ADD,
STATS_WS_NEIGHBOUR_REMOVE,
STATS_WS_CHILD_ADD,
STATS_WS_CHILD_REMOVE,
} ws_stats_type_t;

void ws_stats_update(protocol_interface_info_entry_t *cur, ws_stats_type_t type, uint32_t update_val);
Expand Down

0 comments on commit 56b7735

Please sign in to comment.