summaryrefslogtreecommitdiff
path: root/cesar/mac
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-09-14 15:24:52 +0200
committerNélio Laranjeiro2011-11-02 17:44:27 +0100
commit2f14bb627691abe01f6e09beef5643d3cd1921a8 (patch)
tree7772f59ee8b724f2113e0cd6925fc974f4cd9bc6 /cesar/mac
parentc6fa3a6fdf24501e16f824da0ae5cd439093ba02 (diff)
cesar/mac/sar: fix missing PBs calculation, closes #2722
Diffstat (limited to 'cesar/mac')
-rw-r--r--cesar/mac/sar/src/sar.c22
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/stats.c22
2 files changed, 30 insertions, 14 deletions
diff --git a/cesar/mac/sar/src/sar.c b/cesar/mac/sar/src/sar.c
index 6a2b451b74..2a1ffbbaef 100644
--- a/cesar/mac/sar/src/sar.c
+++ b/cesar/mac/sar/src/sar.c
@@ -314,20 +314,18 @@ sar_rx_mfs_resize_ssn (mfs_rx_t *mfs, pb_t *pb, uint pb_nb)
{
ssn_min_last = mfs->ssn_min;
mfs->ssn_min = pb->header.ssn;
- if (mfs->head)
+ uint nb_pb_released = 0;
+ /* Now we can release each PB under the SSN min and increase the
+ * pb_released counter. */
+ while (mfs->head
+ && less_mod2p16 (mfs->head->header.ssn, mfs->ssn_min))
{
- while (mfs->head
- && less_mod2p16 (mfs->head->header.ssn, mfs->ssn_min))
- {
- pb_missing += sar_stats_rx_gap_between_pb_ssn_min (
- mfs, mfs->head);
- mfs->head = sar_pb_release (mfs->head);
- }
+ if (less_mod2p16 (ssn_min_last, mfs->head->header.ssn))
+ nb_pb_released ++;
+ mfs->head = sar_pb_release (mfs->head);
}
- else
- /* SSN last is a missing PB too, this function compute the gap
- * between two SSN, it consider ssn_min_last has been received. */
- pb_missing = sar_ssn_gap (mfs->ssn_min, ssn_min_last) + 1;
+ pb_missing +=
+ (u16) (mfs->ssn_min - ssn_min_last - nb_pb_released);
sar_mfs_stats_missing_pbs (mfs, pb_missing);
}
}
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 63a0a56d50..f9a3bc5391 100644
--- a/cesar/mac/sar/test/unit_test/ecos/src/stats.c
+++ b/cesar/mac/sar/test/unit_test/ecos/src/stats.c
@@ -231,11 +231,16 @@ test_sar_stats_rx_compute (link_stats_rx_t *stats, pb_t *pb, u16 ssn,
if (pb_dropped_nb == 0
|| (pb_dropped_nb != 0
&& pb_dropped_table[pb_dropped_index] != pb->header.ssn))
+ {
stats->num_pbs++;
+ }
/* Some PBs are drop. */
else if (less_mod2p16 (pb->header.ssn, ssn))
{
stats->num_segs_missed++;
+ }
+ if (pb_dropped_table[pb_dropped_index] == pb->header.ssn)
+ {
pb_dropped_index++;
}
}
@@ -267,8 +272,20 @@ u16
test_sar_stats_rx_ssn_min_compute (pbproc_rx_desc_t *mpdu, bool bcast, u16 ssn,
uint ws)
{
- pb_t *pb;
- for (pb = mpdu->rx->pb_first; pb; pb = pb->next)
+ pb_t *pb = mpdu->rx->pb_first;
+ /* If a single PB with an OPSF is received, the SSN MIN must
+ * be equal to its SSN + 1. */
+ if (pb->next == NULL
+ && pb->header.opsf
+ && pb->header.vpbf
+ && !pb->phy_pb.pb_rx.pb_measurement.crc_error
+ && (pb->header.mmqf
+ || mpdu->rx->params.eks == MAC_EKS_CLEAR)
+ )
+ {
+ ssn = pb->header.ssn + 1;
+ }
+ for (; pb; pb = pb->next)
{
if (ssn == pb->header.ssn
&& !pb->phy_pb.pb_rx.pb_measurement.crc_error)
@@ -404,6 +421,7 @@ test_sar_stats_rx_do (test_t test, bool bcast)
&pb_nb, bcast,
mfs->window_size,
lib_rnd32 (&rnd));
+ dbg_assert (mpdu->rx->pb_nb);
/* Compute which PB is dropped because it is outside the MFS
* window. */
test_sar_stats_rx_pb_dropped (mpdu, bcast, ssn_min_computed,