summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-09-16 16:58:48 +0200
committerNélio Laranjeiro2011-11-02 17:44:28 +0100
commitef031031a71624eb1e61e6ff1c2f634600346dca (patch)
tree57380109755333c5051b8215c46e9951389543f0 /cesar
parentfb24d4bb935e2cb322e262582931f1be2eaa253c (diff)
cesar/mac/sar: resend a previous PB with an OPSF, refs #2722
Objective is to test that nothing is done by the SAR when an oldest PB with an OPSF flag set is resent by the emitter. SAR should just drop the segment, but it must count it as a received segment in statistics even if the PB will be dropped.
Diffstat (limited to 'cesar')
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/stats.c36
1 files changed, 28 insertions, 8 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 d993f6f7e0..3938331f41 100644
--- a/cesar/mac/sar/test/unit_test/ecos/src/stats.c
+++ b/cesar/mac/sar/test/unit_test/ecos/src/stats.c
@@ -207,7 +207,8 @@ test_sar_stats_rx_create_mpdu (pb_t **pb_first, pb_t **pb_last, uint *pb_nb,
* the MPDU was already processed to compute those statistics.
*/
void
-test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb, u16 ssn,
+test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb,
+ u16 ssn_init, u16 new_ssn_min,
uint ws, uint nb, pbproc_rx_desc_t *mpdu,
u32 *pb_dropped_table, uint pb_dropped_nb)
{
@@ -221,9 +222,13 @@ test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb, u16 ssn,
if (pb->phy_pb.pb_rx.pb_measurement.crc_error)
{
stats->num_bad_pbs_crc++;
- if (less_mod2p16 (pb->header.ssn, ssn))
+ if (less_mod2p16 (pb->header.ssn, new_ssn_min))
stats->num_segs_missed++;
}
+ else if (less_mod2p16 (pb->header.ssn, ssn_init))
+ {
+ stats->num_pbs++;
+ }
else
{
stats->num_segs_suc++;
@@ -234,7 +239,7 @@ test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb, u16 ssn,
stats->num_pbs++;
}
/* Some PBs are drop. */
- else if (less_mod2p16 (pb->header.ssn, ssn))
+ else if (less_mod2p16 (pb->header.ssn, new_ssn_min))
{
stats->num_segs_missed++;
}
@@ -243,7 +248,6 @@ test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb, u16 ssn,
pb_dropped_index++;
}
}
-
}
for (pb = mpdu->rx->pb_first; pb; pb = pb->next)
{
@@ -290,7 +294,8 @@ test_sar_stats_rx_ssn_min_compute (pbproc_rx_desc_t *mpdu, bool bcast, u16 ssn,
&& !pb->phy_pb.pb_rx.pb_measurement.crc_error)
ssn++;
else if (pb->header.opsf
- && !pb->phy_pb.pb_rx.pb_measurement.crc_error)
+ && !pb->phy_pb.pb_rx.pb_measurement.crc_error
+ && less_mod2p16 (ssn, pb->header.ssn))
ssn = pb->header.ssn + 1;
else if (bcast
&& !pb->phy_pb.pb_rx.pb_measurement.crc_error
@@ -373,7 +378,7 @@ test_sar_stats_rx_do (test_t test, bool bcast)
mfs_rx_t *mfs;
char text_test[50];
bool added;
- u16 ssn_min_computed;
+ u16 ssn_min_computed, ssn_init = 65534;
pbproc_rx_desc_t *mpdu;
lib_rnd_init (&rnd, 0x43d);
for (i = 0; i < 10000; i++)
@@ -398,15 +403,29 @@ test_sar_stats_rx_do (test_t test, bool bcast)
/* Add an MFS to the store and the SAR, change the window size to be
* smaller, useful to cause missing PBs in the link stats. */
sar_mfs_add (t.sar, PARENT_OF (mfs_t, rx, mfs));
- ssn_min_computed = mfs->ssn_min = 65534;
+ ssn_min_computed = mfs->ssn_min = ssn_init;
mfs->window_size = 3;
/* Create PBs containing the 5 Ethernet frames, the PB list start with
* the SSN == 64534. */
test_sar_stats_rx_prepare (&t, bcast, lib_rnd32 (&rnd),
&pb_first, &pb_last,
- &pb_nb, 65534, 5);
+ &pb_nb, ssn_init, 5);
/* Set the CRC error flag in the PB list randomly. */
test_sar_stats_rx_set_crc_error (pb_first, lib_rnd32 (&rnd));
+ if (!bcast)
+ {
+ /* Duplicate the first PB and just change the SSN to be the oldest. */
+ pb_t *pb_old;
+ pb_old = (pb_t *) blk_alloc_desc ();
+ pb_old->header = pb_first->header;
+ pb_old->header.ssn = 65000;
+ pb_old->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ memcpy (pb_old->data, pb_first->data, BLK_SIZE);
+ /* Chain the duplicated PB to the list. */
+ pb_old->next = pb_first;
+ pb_first = pb_old;
+ pb_nb++;
+ }
/* Duplicate the PB list to check the test. */
sar_test_duplicate_pb (&pb_final_first, &pb_final_last,
pb_first, pb_last, pb_nb);
@@ -442,6 +461,7 @@ test_sar_stats_rx_do (test_t test, bool bcast)
/* Compute the stats RX before providing the MPDU to the SAR.
* */
test_sar_stats_rx_compute (&stats, pb_final_first,
+ ssn_init,
ssn_min_computed,
mfs->window_size, mpdu_pb_num,
mpdu, pb_dropped_ssn,