summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2010-06-04 07:46:43 +0000
committerlaranjeiro2010-06-04 07:46:43 +0000
commit0eff7f0897bed5bd1f8b4b82848ce660248fa5b0 (patch)
tree0ca45dc81f8b1edd87c0188a7491954228299491
parent7a52ac1f2a819e8372b1d549fdc8385eb495f65a (diff)
cesar/bsu: beacons statistics
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7165 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/bsu/inc/context.h6
-rw-r--r--cesar/bsu/src/bsu.c5
-rw-r--r--cesar/bsu/src/interface.c1
-rw-r--r--cesar/bsu/test/utest/src/bsut.c18
4 files changed, 29 insertions, 1 deletions
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 5cdce36f7a..4095819b8f 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -87,7 +87,11 @@ struct bsu_t
/** Activated status. */
bool activate;
/** Beacons MFS. */
- mfs_tx_t *mfs_beacons[3];
+ mfs_tx_t *mfs_beacons[BSU_BEACON_TYPE_NB];
+ /** Statistics sent beacons. */
+ u32 beacon_nb_sent[BSU_BEACON_TYPE_NB];
+ /** Statistics received beacons. */
+ u32 beacon_nb_recv[BSU_BEACON_TYPE_NB];
#if CONFIG_TRACE
/** Trace system. */
trace_buffer_t trace;
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index d8ddb5718c..83957086a6 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -442,6 +442,10 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
ctx->is_sta = BSU_UPDATE_STA_TYPE_STA;
for (i = 0; i < COUNT (ctx->mfs_beacons); i++)
ctx->mfs_beacons[i] = NULL;
+ for (i = 0; i < COUNT (ctx->beacon_nb_recv); i++)
+ ctx->beacon_nb_recv[i] = 0;
+ for (i = 0; i < COUNT (ctx->beacon_nb_sent); i++)
+ ctx->beacon_nb_sent[i] = 0;
ctx->ca_index = 0;
/* Trace. */
bsu_trace_init (ctx);
@@ -488,6 +492,7 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
bsu_beacon_bmi_discover_t discover;
bsu_beacon_track_info_t tinfo;
bsu_beacon_read_track_info (beacon, &tinfo);
+ ctx->beacon_nb_recv[tinfo.bt]++;
/* It the beacon from our AVLN ? */
if (ctx->is_sta == BSU_UPDATE_STA_TYPE_STA
&& tinfo.nid == ctx->nid_track
diff --git a/cesar/bsu/src/interface.c b/cesar/bsu/src/interface.c
index d4540f36aa..e3f215e188 100644
--- a/cesar/bsu/src/interface.c
+++ b/cesar/bsu/src/interface.c
@@ -100,6 +100,7 @@ bsu_beacon_send (bsu_t *ctx, bsu_beacon_type_t beacon_type,
/* Hold the segment until the next beacon period. Only for central
* beacons. To be done each time, the CA only held until the next beacon
* period it is not forever. */
+ ctx->beacon_nb_sent[beacon_type]++;
if (beacon_type == BSU_BEACON_TYPE_CENTRAL)
ca_mfs_hold (ctx->ca, mfs);
blk_addref_desc ((blk_t*) beacon);
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 616c9618e8..974c6e89f6 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -59,6 +59,8 @@ test_case_bsu_process (test_t test)
/* Central beacon processed ? */
test_fail_unless (t.bsu->avlns[0].bs.snid == 0);
test_fail_unless (t.bsu->avlns[0].bs.nid == 0);
+ test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_CENTRAL]
+ == 0);
/* NTB called ? */
test_fail_unless (t.bsu->avlns[0].sync.init == false);
bneighbour = bsu_beacon_write (&beacon_neighbour,
@@ -70,6 +72,8 @@ test_case_bsu_process (test_t test)
/* Central beacon processed ? */
test_fail_unless (t.bsu->avlns[0].bs.snid == bpneighbour_rx.snid);
test_fail_unless (t.bsu->avlns[0].bs.nid == beacon_neighbour.vf.nid);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 1);
/* NTB called ? */
test_fail_unless (t.bsu->avlns[0].sync.init == true);
/* Second shoot... */
@@ -81,6 +85,8 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.bsu->avlns[0].sync.init == true);
test_fail_unless (t.bsu->avlns[0].sync.beacon_nb == 2);
blk_release_desc ((blk_t*) bneighbour);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 2);
/* Our AVLN. */
t.mac_config.tei = 1;
bsu_track_avln (0x2, 0x5, t.mac_config.tei,
@@ -94,6 +100,8 @@ test_case_bsu_process (test_t test)
/* Central beacon processed ? */
test_fail_unless (t.bsu->sta_avln->bs.snid == t.bsu->snid_track);
test_fail_unless (t.bsu->sta_avln->bs.nid == t.bsu->nid_track);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 2);
/* NTB called ? */
test_fail_unless (t.bsu->sta_avln->sync.init == false);
bp_rx.snid = 0x5;
@@ -106,6 +114,8 @@ test_case_bsu_process (test_t test)
/* Central beacon processed ? */
test_fail_unless (t.bsu->sta_avln->bs.snid == bp_rx.snid);
test_fail_unless (t.bsu->sta_avln->bs.nid == beacon.vf.nid);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 3);
/* NTB called ? */
test_fail_unless (t.bsu->sta_avln->sync.init == true);
blk_release_desc ((blk_t*) b);
@@ -133,6 +143,10 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.sar.beacon != NULL);
test_fail_unless (t.sar.mfs != NULL);
test_fail_unless (t.sar.mfs->common.lid == MAC_LID_DISCOVER);
+ test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_DISCOVER]
+ == 1);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 4);
/* Upper layer receives it ? */
test_fail_unless (t.ul.beacon == t.sar.beacon);
test_fail_unless (t.ul.beacon->next);
@@ -161,12 +175,16 @@ test_case_bsu_process_sta_is_cco (test_t test)
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config,
&btx);
bool ok = bsu_beacon_process (t.bsu, b, &brx);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == 1);
test_fail_unless (ok == true);
test_fail_unless (t.bsu->sta_avln->sync.init == false);
blk_release_desc ((blk_t*) b);
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_DISCOVER,
&t.mac_config, &btx);
ok = bsu_beacon_process (t.bsu, b, &brx);
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_DISCOVER]
+ == 1);
test_fail_unless (ok == true);
test_fail_unless (t.bsu->sta_avln->sync.init == false);
blk_release_desc ((blk_t*) b);