summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-09-23 17:55:32 +0200
committerNélio Laranjeiro2011-11-02 17:44:27 +0100
commit8804641f9610b1a11e792225e7b7016a34a64198 (patch)
treee2b6a6ead0c1008916052ba8e782b6f43398c4d7 /cesar
parent2f14bb627691abe01f6e09beef5643d3cd1921a8 (diff)
cesar/mac/sar: improve SAR statistics test by simulating a hole, refs #2722
This commit will test the case of a hole reception, by receiving PBs before and after the SSN min with the OPSF flag set. This test computes the missing PBs when this case occurs and compare it with the missing PBs computed by the SAR. Missing PBs are only computed when the new PB is greater than the ssn_max, in the other case the PB is dropped and not counted as missing.
Diffstat (limited to 'cesar')
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/stats.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/cesar/mac/sar/test/unit_test/ecos/src/stats.c b/cesar/mac/sar/test/unit_test/ecos/src/stats.c
index f9a3bc5391..561ac6315a 100644
--- a/cesar/mac/sar/test/unit_test/ecos/src/stats.c
+++ b/cesar/mac/sar/test/unit_test/ecos/src/stats.c
@@ -44,7 +44,6 @@ test_case_sar_stats_tx (test_t test)
uint i;
uint nb_msdus = 10;
pbproc_t pbproc;
-
memset (&pbproc, 0, sizeof (pbproc));
sar_test_init (&t, INVALID_PTR, &pbproc);
/* Create the MFS to verify the test. */
@@ -476,12 +475,108 @@ test_sar_stats_rx_do (test_t test, bool bcast)
}
}
+/**
+ * Initialise an empty PB.
+ * \param pb the PB to initialise.
+ * \param ssn the SSN to store in the PB header.
+ */
+static void
+test_sar_stats_rx_hole_init_pb_header (pb_t *pb, u16 ssn)
+{
+ pb->header.ssn = ssn;
+ pb->header.mfbo = 0;
+ pb->header.vpbf = true;
+ pb->header.mmqf = false;
+ pb->header.mfbf = true;
+ pb->header.opsf = false;
+ pb->header.spc_encrypted = true;
+ pb->next = NULL;
+ pb->data[0] = 0;
+ pb->phy_pb.pb_rx.pb_measurement.crc_error = false;
+}
+
+/**
+ * Initialise a test to compute the missing PBs for a single oldest PB.
+ * \param test the test context.
+ * \param ssn the first SSN to initialise the single PB.
+ *
+ * This test set the ssn min of the MFS to a defined value (65534), An
+ * MPDU is created with a single PB whose ssn is provided in parameter.
+ * This should compute the number of missing PBs when this MPDU with the
+ * single PB is received by the SAR.
+ * Two cases are possible:
+ * 1. The PB has an ssn under the mfs->ssn_min, in this case the PB is
+ * dropped because it is considered as already received.
+ * 2. The Pb has an ssn greater than the mfs->ssn_min, in this case, the
+ * mfs->ssn_min is updated to match to the PB's ssn and the difference
+ * between the PB's ssn and the previous mfs->ssn_min corresponds to the
+ * number of missing PBs.
+ */
+void
+test_sar_stats_rx_hole_do (test_t test, u16 ssn)
+{
+ test_within (test);
+ sar_test_t t;
+ mfs_rx_t *mfs;
+ bool added;
+ sar_test_init (&t, INVALID_PTR, INVALID_PTR);
+ sar_activate (t.sar, true);
+ mfs = mac_store_mfs_add_rx (t.mac_store, false, false, 1, 1,
+ &added);
+ sar_mfs_add (t.sar, PARENT_OF (mfs_t, rx, mfs));
+ mfs->ssn_min = 65534;
+ mfs->window_size = 3;
+ /* Add the first PB directly into the MFS. */
+ mfs->head = (pb_t *) blk_alloc_desc ();
+ test_sar_stats_rx_hole_init_pb_header (mfs->head, mfs->ssn_min - 1);
+ /* Prepare the MPDU to receive. */
+ pbproc_rx_desc_t *desc = (pbproc_rx_desc_t *) blk_alloc_desc ();
+ sar_mpdu_t *mpdu = PARENT_OF (sar_mpdu_t, rx, desc->rx);
+ sar_test_mpdu_default_fill (mpdu, 1, 1);
+ mpdu->rx.pb_nb = 1;
+ mpdu->rx.params.bcast = false;
+ mpdu->rx.pb_first = (pb_t *) blk_alloc_desc ();
+ test_sar_stats_rx_hole_init_pb_header (mpdu->rx.pb_first, ssn);
+ mpdu->rx.pb_last = mpdu->rx.pb_first;
+ mpdu->rx.pb_first->header.opsf = true;
+ /* Test it. */
+ uint ssn_max = mfs->ssn_min + mfs->window_size - 1;
+ uint missing_pbs = (u16) (ssn - mfs->head->header.ssn - 1);
+ sar_mpdu_add (t.sar, desc);
+ if (lesseq_mod2p16 (ssn_max, ssn))
+ test_fail_unless (mfs->stats.num_segs_missed == missing_pbs);
+ else
+ test_fail_unless (!mfs->stats.num_segs_missed);
+ blk_release (mfs);
+ sar_activate (t.sar, false);
+ sar_cleanup (t.sar);
+ sar_test_uninit (&t);
+}
+
+/**
+ * Initialise a test to compute the missing PBs for a single oldest PB.
+ * \param test the test context.
+ */
+void
+test_sar_stats_rx_hole (test_t test)
+{
+ uint i;
+ test_case_begin (test, "Test an hole");
+ test_begin (test, "Small and big hole")
+ {
+ for (i = 0; i < BITS_ONES (16); i++)
+ test_sar_stats_rx_hole_do (test, i);
+ }
+ test_end;
+}
+
void
test_case_sar_stats_rx (test_t test)
{
test_case_begin (test, "Stats SAR RX - Unicast/broadcast");
test_sar_stats_rx_do (test, false);
test_sar_stats_rx_do (test, true);
+ test_sar_stats_rx_hole (test);
}
void