From da0476d8817b8dbb378460e2ac7e45c3d75c42aa Mon Sep 17 00:00:00 2001 From: skarg Date: Wed, 14 Oct 2015 19:15:21 +0000 Subject: [PATCH] Added Self/TT to statistics (was just Self for Tokens to Self) to track Tardy Tokens. Tardy Tokens (TT) are Token Frames that are send out of order, from a MAC to was not the previous Token Frame MAC destination. --- bacnet-stack/demo/mstpcap/main.c | 15 +++++++++++++-- bacnet-stack/demo/mstpcap/mstpcap.txt | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index f7539507..6fa04605 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -113,6 +113,8 @@ struct mstp_statistics { /* Addendum 2008v - sending tokens to myself */ /* counts how many times the node passes the token */ uint32_t self_token_count; + /* counts how many times the node sends the token out-of-order (ooo) */ + uint32_t ooo_token_count; /* if we see an I-Am message from this node, store the Device ID */ uint32_t device_id; }; @@ -185,6 +187,7 @@ static void packet_statistics( static uint8_t old_frame = 255; static uint8_t old_src = 255; static uint8_t old_dst = 255; + static uint8_t old_token_dst = 255; uint8_t frame, src, dst; uint32_t delta; uint32_t npoll; @@ -223,6 +226,11 @@ static void packet_statistics( MSTP_Statistics[src].tusage_timeout = delta; } } + if (old_token_dst != src) { + /* out-of-order Token sender */ + MSTP_Statistics[src].ooo_token_count++; + } + old_token_dst = dst; break; case FRAME_TYPE_POLL_FOR_MASTER: if (MSTP_Statistics[src].last_pfm_tokens) { @@ -312,6 +320,7 @@ static void packet_statistics_print( { unsigned i; /* loop counter */ unsigned node_count = 0; + long unsigned int self_or_ooo_count; fprintf(stdout, "\n"); fprintf(stdout, "==== MS/TP Frame Counts ====\n"); @@ -349,7 +358,7 @@ static void packet_statistics_print( fprintf(stdout, "\n"); fprintf(stdout, "==== MS/TP Usage and Timing Maximums ====\n"); fprintf(stdout, "%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-7s", "MAC", - "MaxMstr", "Retries", "Npoll", "Self", "Treply", "Tusage", "Trpfm", + "MaxMstr", "Retries", "Npoll", "Self/TT", "Treply", "Tusage", "Trpfm", "Tder", "Tpostpd"); fprintf(stdout, "\n"); for (i = 0; i < MAX_MSTP_DEVICES; i++) { @@ -357,12 +366,14 @@ static void packet_statistics_print( if ((MSTP_Statistics[i].token_count) || (MSTP_Statistics[i].der_reply) || (MSTP_Statistics[i].pfm_count)) { node_count++; + self_or_ooo_count = MSTP_Statistics[i].self_token_count + + MSTP_Statistics[i].ooo_token_count; fprintf(stdout, "%-8u", i); fprintf(stdout, "%-8lu%-8lu%-8lu%-8lu%-8lu", (long unsigned int) MSTP_Statistics[i].max_master, (long unsigned int) MSTP_Statistics[i].token_retries, (long unsigned int) MSTP_Statistics[i].npoll, - (long unsigned int) MSTP_Statistics[i].self_token_count, + self_or_ooo_count, (long unsigned int) MSTP_Statistics[i].token_reply); fprintf(stdout, "%-8lu%-8lu%-8lu%-7lu", (long unsigned int) MSTP_Statistics[i].tusage_timeout, diff --git a/bacnet-stack/demo/mstpcap/mstpcap.txt b/bacnet-stack/demo/mstpcap/mstpcap.txt index 31034661..df29428d 100644 --- a/bacnet-stack/demo/mstpcap/mstpcap.txt +++ b/bacnet-stack/demo/mstpcap/mstpcap.txt @@ -92,7 +92,8 @@ Retries = number of second tokens sent to this MAC address. Npoll = number of Tokens between Poll-For-Master -Self = number of Tokens sent to self (Addendum 135-2008v) +Self/TT = number of Tokens sent to self (Addendum 135-2008v) and + number of tardy tokens sent late. Treply = maximum number of milliseconds it took to reply with a token after receiving a token. Treply is required to be less