summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/bsu/inc/context.h4
-rw-r--r--cesar/bsu/src/bsu.c20
-rw-r--r--cesar/bsu/test/utest/src/bsut.c10
3 files changed, 30 insertions, 4 deletions
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 02f64e30a2..54c165d9c6 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -42,6 +42,10 @@ struct bsu_stats_t
u32 ntb_offset_tck;
/** Current frequency error in q30. */
uint frequency_error_q30;
+ /** Number of beacon received from a neighbor network. */
+ uint neighbor_beacon_nb;
+ /** Last MAC received from a neighbor network. */
+ mac_t neighbor_beacon_last_mac;
};
typedef struct bsu_stats_t bsu_stats_t;
#endif
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 7656a57970..c28c503e01 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -146,6 +146,8 @@ bsu_track_avln_identify (bsu_t *ctx, bsu_avln_t *avln)
ctx->track_new = true;
BSU_TRACE (TRACK, ctx->nid_track, ctx->snid_track,
ctx->tei_track, TRACE_U64 (ctx->cco_mac_address_track));
+ ctx->stats.neighbor_beacon_nb = 0;
+ ctx->stats.neighbor_beacon_last_mac = 0;
}
/**
@@ -897,6 +899,14 @@ bsu_stats_init (bsu_t *ctx)
&ctx->stats.frequency_error_q30,
LIB_STATS_ACCESS_READ_ONLY,
LIB_STATS_USER);
+ lib_stats_set_stat_value_notype ("bsu_neighbor_beacon_nb",
+ &ctx->stats.neighbor_beacon_nb,
+ LIB_STATS_ACCESS_READ_ONLY,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("bsu_neighbor_beacon_last_mac",
+ &ctx->stats.neighbor_beacon_last_mac,
+ LIB_STATS_ACCESS_READ_ONLY,
+ LIB_STATS_DEBUG);
lib_stats_set_stat_value_notype ("CLK_SYNC_WEIGHT_K",
&ctx->ntb_clk_sync_weight_k,
LIB_STATS_ACCESS_WRITE_ONLY,
@@ -1050,11 +1060,10 @@ bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
pbproc_rx_beacon_params_t *params)
{
bool added;
+ mac_t mac = beacon->bmis.mac_address.present
+ ? beacon->bmis.mac_address.mac_address: MAC_ZERO;
bsu_avln_t *avln = bsu_avln_add (
- ctx, beacon->vf.nid, params->snid,
- beacon->bmis.mac_address.present ?
- beacon->bmis.mac_address.mac_address : MAC_ZERO,
- &added);
+ ctx, beacon->vf.nid, params->snid, mac, &added);
u32 bpsd, i;
bsu_aclf_beacon_period_start_date (ctx->aclf, &bpsd, 1);
/* Other AVLN. */
@@ -1076,6 +1085,9 @@ bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
avln ? FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT): 0);
BSU_TRACE (BEACON_DATA, params->bts, params->bto[0],
params->bto[1], params->bto[2]);
+ /* Record neighbor network for stats. */
+ ctx->stats.neighbor_beacon_nb++;
+ ctx->stats.neighbor_beacon_last_mac = mac;
}
return avln;
}
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index fc05b69615..43dad99371 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -74,6 +74,8 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid == 0);
test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_CENTRAL]
== 0);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_nb == 0);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_last_mac == 0);
/* NTB called? */
test_fail_unless (t.bsu->avlns[0].sync.init == false);
test_fail_unless (t.bsu->avlns[0].sync.sync_nb == 0);
@@ -92,6 +94,8 @@ test_case_bsu_process (test_t test)
central_beacon_nb_recv++;
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== central_beacon_nb_recv);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_nb == 1);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_last_mac == 0x123456789abcull);
/* NTB called? */
test_fail_unless (t.bsu->avlns[0].sync.init == true);
test_fail_unless (t.bsu->avlns[0].sync.sync_nb == 0);
@@ -121,12 +125,16 @@ test_case_bsu_process (test_t test)
/* Cleanup. */
blk_release (bprocessed);
}
+ test_fail_unless (t.bsu->stats.neighbor_beacon_nb
+ == 1 + BSU_NTB_CLK_SYNC_NB_STABLE_DEFAULT);
/* Cleanup. */
blk_release_desc ((blk_t*) bneighbour);
/* => Our AVLN. */
bsu_track_avln (t.bsu,
beacon_neighbour.vf.nid, 0x4, beacon_neighbour.vf.stei,
beacon_neighbour.bmis.mac_address.mac_address);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_nb == 0);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_last_mac == 0);
/* Reset synchronisation. */
bsu_ntb_init (&t.bsu->sta_avln->sync);
/* => Beacon with bad CRC. */
@@ -158,6 +166,8 @@ test_case_bsu_process (test_t test)
central_beacon_nb_recv++;
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== central_beacon_nb_recv);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_nb == 0);
+ test_fail_unless (t.bsu->stats.neighbor_beacon_last_mac == 0);
/* NTB called? */
test_fail_unless (t.bsu->sta_avln->sync.init == true);
test_fail_unless (t.bsu->sta_avln->sync.sync_nb == 0);