Change in osmo-bts[master]: measurement: fix SACCH interval remapping in test_is_meas_overdue()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Tue Sep 4 13:44:50 UTC 2018


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10760


Change subject: measurement: fix SACCH interval remapping in test_is_meas_overdue()
......................................................................

measurement: fix SACCH interval remapping in test_is_meas_overdue()

The function test_is_meas_overdue() checks if a SACCH block was lost in
order to be able to conclude the measurement interval even when the
SAACH block gets lost.

Unfortunately, the measurements for the SACCH do not arrive in order with
the normal voice measurements. The measurement for the SACCH is shifted
by -26 frames but arrives with the correct frame number. The detection
logic that checks for dropped out SACCH frames does not take this
correctly into account. It calculates the frame number shift, but it
still expects the measurements to arrive in order. This needs to be
fixed.

- Add logic to work around the frame number shift
- Adapt unit tests

Change-Id: Idf6db73f67b7273c3d5965616c9e78f66b74a406
Related: OS#3502
---
M include/osmo-bts/measurement.h
M src/common/measurement.c
M tests/meas/meas_test.c
M tests/meas/meas_test.ok
4 files changed, 246 insertions(+), 184 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/60/10760/1

diff --git a/include/osmo-bts/measurement.h b/include/osmo-bts/measurement.h
index b4fc35b..a071fdb 100644
--- a/include/osmo-bts/measurement.h
+++ b/include/osmo-bts/measurement.h
@@ -8,7 +8,7 @@
 
 int lchan_meas_check_compute(struct gsm_lchan *lchan, uint32_t fn);
 
-void lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn);
+int lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn);
 
 void lchan_meas_reset(struct gsm_lchan *lchan);
 
diff --git a/src/common/measurement.c b/src/common/measurement.c
index 59f5d83..bfba11f 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -240,32 +240,6 @@
 	return 0;
 }
 
-/* Same as above, but the inverse function */
-static uint8_t translate_tch_meas_rep_fn104_inv(uint8_t fn_mod)
-{
-	switch (fn_mod) {
-	case 103:
-		return 25;
-	case 12:
-		return 38;
-	case 25:
-		return 51;
-	case 38:
-		return 64;
-	case 51:
-		return 77;
-	case 64:
-		return 90;
-	case 77:
-		return 103;
-	case 90:
-		return 12;
-	}
-
-	/* Invalid / not of interest */
-	return 0;
-}
-
 /* determine if a measurement period ends at the given frame number
  * (this function is only used internally, it is public to call it from
  * unit-tests) */
@@ -322,6 +296,41 @@
 	return rc;
 }
 
+/* The measurement indications of voice blocks are not received in order with
+ * the measurement indications of the SACCH blocks. In relation to the normal
+ * voice blocks the The SACCH block that concludes the measurement interval is
+ * received 26 frames earlier than its frame number would indicate. In order
+ * to simplify the computation that detects if a SACCH frame was missed or not
+ * we subtract 26 from all SACCH frame numbers. This function MUST only be used
+ * with TCH/H and TCH/F channels. */
+static uint32_t fn_demangle(uint32_t fn)
+{
+	uint8_t rc;
+
+	/* Since a similar problem exists in is_meas_complete(), we can borrow
+	 * from there. translate_tch_meas_rep_fn104() returns 0 if the frame
+	 * number does not belong to a SACCH frame */
+	rc = translate_tch_meas_rep_fn104(fn % 104);
+
+	if (rc > 0 && fn >= 26)
+		return fn - 26;
+	else if (rc > 0)
+		return GSM_MAX_FN - (26 - fn);
+
+	return fn;
+}
+
+/* Inverse function of fn_demangle to convert the resulting fn back, this
+ * function must only be used with frame numbers that fall onto a SACCH
+ * interval end. It also must be a frame number from a TCH/H or a TCH/F. */
+static uint32_t fn_mangle(uint32_t fn)
+{
+	if (fn <= GSM_MAX_FN - 26)
+		return fn + 26;
+	else
+		return fn - (GSM_MAX_FN - 26);
+}
+
 /* Check if a measurement period is overdue. This situation may occur when the
  * SACCH frame that closes the measurement interval was not received. Then the
  * end of the measurement will not be detected. Using this function we can
@@ -332,6 +341,7 @@
 {
 	uint32_t fn_mod;
 	uint32_t last_fn_mod;
+	uint32_t last_fn;
 	uint32_t fn_rounded;
 	uint8_t interval_end;
 	uint8_t modulus;
@@ -349,7 +359,8 @@
 	case GSM_PCHAN_TCH_F:
 		modulus = 104;
 		interval_end = tchf_meas_rep_fn104_by_ts[lchan->ts->nr];
-		interval_end = translate_tch_meas_rep_fn104_inv(interval_end);
+		fn = fn_demangle(fn);
+		last_fn = fn_demangle(lchan->meas.last_fn);
 		break;
 	case GSM_PCHAN_TCH_H:
 		modulus = 104;
@@ -358,17 +369,20 @@
 		else
 			tbl = tchh1_meas_rep_fn104_by_ts;
 		interval_end = tbl[lchan->ts->nr];
-		interval_end = translate_tch_meas_rep_fn104_inv(interval_end);
+		fn = fn_demangle(fn);
+		last_fn = fn_demangle(lchan->meas.last_fn);
 		break;
 	case GSM_PCHAN_SDCCH8_SACCH8C:
 	case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
 		modulus = 102;
 		interval_end = sdcch8_meas_rep_fn102_by_ss[lchan->nr];
+		last_fn = lchan->meas.last_fn;
 		break;
 	case GSM_PCHAN_CCCH_SDCCH4:
 	case GSM_PCHAN_CCCH_SDCCH4_CBCH:
 		modulus = 102;
 		interval_end = sdcch4_meas_rep_fn102_by_ss[lchan->nr];
+		last_fn = lchan->meas.last_fn;
 		break;
 	default:
 		return false;
@@ -376,7 +390,7 @@
 	}
 
 	fn_mod = fn % modulus;
-	last_fn_mod = lchan->meas.last_fn % modulus;
+	last_fn_mod = last_fn % modulus;
 	fn_rounded = fn - fn_mod;
 
 	if (fn_mod > last_fn_mod) {
@@ -386,6 +400,8 @@
 		 * position on which the interval should have ended. */
 		if (interval_end > last_fn_mod && interval_end < fn_mod) {
 			*fn_missed_end = interval_end + fn_rounded;
+			if(modulus == 104)
+				*fn_missed_end = fn_mangle(*fn_missed_end);
 			return true;
 		}
 	} else {
@@ -395,19 +411,23 @@
 		 * that starts at the current frame number and ends at the
 		 * interval end. */
 		if (interval_end > last_fn_mod) {
-			if (fn < lchan->meas.last_fn)
+			if (fn < last_fn)
 				*fn_missed_end = interval_end + GSM_MAX_FN - modulus;
 			else
 				*fn_missed_end = interval_end + fn_rounded - modulus;
+			if(modulus == 104)
+				*fn_missed_end = fn_mangle(*fn_missed_end);
 			return true;
 		}
 		/* We also check the section that starts from the beginning of
 		 * the interval and ends at the current frame number. */
 		if (interval_end < fn_mod) {
-			if (fn < lchan->meas.last_fn)
+			if (fn < last_fn)
 				*fn_missed_end = interval_end;
 			else
 				*fn_missed_end = interval_end + fn_rounded;
+			if(modulus == 104)
+				*fn_missed_end = fn_mangle(*fn_missed_end);
 			return true;
 		}
 	}
@@ -800,10 +820,11 @@
  * l1sap.c every time a measurement indication is received. It collects the
  * measurement samples and automatically detects the end oft the measurement
  * interval. */
-void lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn)
+int lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn)
 {
 	uint32_t fn_missed_end;
 	bool missed_end;
+	int rc;
 
 	/* The measurement processing detects the end of a measurement period
 	 * by checking if the received measurement sample is from a SACCH
@@ -821,12 +842,22 @@
 		 * of a new interval */
 		lchan_meas_check_compute(lchan, fn_missed_end);
 		lchan_new_ul_meas(lchan, ulm, fn);
+
+		/* Report to the caller that we missed an inverval end
+		 * (unit-test) */
+		rc = 1;
 	} else {
 		/* This is the normal case, we first add the measurement sample
 		 * to the current interva and run the check+computation */
 		lchan_new_ul_meas(lchan, ulm, fn);
 		lchan_meas_check_compute(lchan, fn);
+
+		/* Report to the caller that the measurement was processed
+		 * normally (unit-test) */
+		rc = 0;
 	}
+
+	return rc;
 }
 
 /* Reset all measurement related struct members to their initial values. This
diff --git a/tests/meas/meas_test.c b/tests/meas/meas_test.c
index a33a808..ca08ba8 100644
--- a/tests/meas/meas_test.c
+++ b/tests/meas/meas_test.c
@@ -68,8 +68,8 @@
 
 static void reset_lchan_meas(struct gsm_lchan *lchan)
 {
+	lchan_meas_reset(lchan);
 	lchan->state = LCHAN_S_ACTIVE;
-	memset(&lchan->meas, 0, sizeof(lchan->meas));
 }
 
 static void test_meas_compute(const struct meas_testcase *mtc)
@@ -136,236 +136,236 @@
 	printf("===========================================================\n");
 	printf("Testing is_meas_overdue()\n");
 
-	/* Missing period-end-trigger at fn=12, TCH/F, TS0 */
+	/* Missing period-end-trigger at fn=12(90), TCH/F, TS0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[0].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 95;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	lchan->meas.last_fn = 86;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 12 + 104);
 
-	/* Missing period-end-trigger at fn=12, TCH/H, TS0 */
+	/* Missing period-end-trigger at fn=12(90), TCH/H, TS0.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[0].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 95;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	lchan->meas.last_fn = 86;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 12 + 104);
 
-	/* Missing period-end-trigger at fn=12, TCH/H, TS1 */
+	/* Missing period-end-trigger at fn=12(90), TCH/H, TS1.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[1].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 95;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	lchan->meas.last_fn = 86;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 12 + 104);
 
-	/* Missing period-end-trigger at fn=25, TCH/F, TS1 */
+	/* Missing period-end-trigger at fn=25(103), TCH/F, TS1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[1].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 21;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 30);
+	lchan->meas.last_fn = 99;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 25);
+	OSMO_ASSERT(fn_missed_end == 25 + 104);
 
-	/* Missing period-end-trigger at fn=25, TCH/H, TS0 */
+	/* Missing period-end-trigger at fn=25(103), TCH/H, TS0.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[0].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 21;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 30);
+	lchan->meas.last_fn = 99;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 25);
+	OSMO_ASSERT(fn_missed_end == 25 + 104);
 
-	/* Missing period-end-trigger at fn=25, TCH/H, TS1 */
+	/* Missing period-end-trigger at fn=25(103), TCH/H, TS1.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[1].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
+	lchan->meas.last_fn = 99;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
+	OSMO_ASSERT(rc);
+	OSMO_ASSERT(fn_missed_end == 25 + 104);
+
+	/* Missing period-end-trigger at fn=38(12), TCH/F, TS2 */
+	fn_missed_end = LCHAN_FN_DUMMY;
+	lchan = &trx->ts[2].lchan[0];
+	lchan->ts->pchan = GSM_PCHAN_TCH_F;
+	lchan->meas.last_fn = 95;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	OSMO_ASSERT(rc);
+	OSMO_ASSERT(fn_missed_end == 38 + 104);
+
+	/* Missing period-end-trigger at fn=38(12), TCH/H, TS2.0 */
+	fn_missed_end = LCHAN_FN_DUMMY;
+	lchan = &trx->ts[2].lchan[0];
+	lchan->ts->pchan = GSM_PCHAN_TCH_H;
+	lchan->meas.last_fn = 95;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	OSMO_ASSERT(rc);
+	OSMO_ASSERT(fn_missed_end == 38 + 104);
+
+	/* Missing period-end-trigger at fn=38(12), TCH/H, TS3.0 */
+	fn_missed_end = LCHAN_FN_DUMMY;
+	lchan = &trx->ts[3].lchan[0];
+	lchan->ts->pchan = GSM_PCHAN_TCH_H;
+	lchan->meas.last_fn = 95;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 17 + 104);
+	OSMO_ASSERT(rc);
+	OSMO_ASSERT(fn_missed_end == 38 + 104);
+
+	/* Missing period-end-trigger at fn=51(25), TCH/F, TS3 */
+	fn_missed_end = LCHAN_FN_DUMMY;
+	lchan = &trx->ts[3].lchan[0];
+	lchan->ts->pchan = GSM_PCHAN_TCH_F;
 	lchan->meas.last_fn = 21;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 30);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 25);
-
-	/* Missing period-end-trigger at fn=38, TCH/F, TS2 */
-	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
-	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 34;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
-	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 38);
-
-	/* Missing period-end-trigger at fn=38, TCH/H, TS2 */
-	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
-	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 34;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
-	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 38);
-
-	/* Missing period-end-trigger at fn=38, TCH/H, TS3 */
-	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[3].lchan[0];
-	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 34;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
-	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 38);
-
-	/* Missing period-end-trigger at fn=51, TCH/F, TS3 */
-	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[3].lchan[0];
-	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 47;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
-	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 51);
 
-	/* Missing period-end-trigger at fn=51, TCH/H, TS2 */
+	/* Missing period-end-trigger at fn=51(25), TCH/H, TS2 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[2].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 47;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
+	lchan->meas.last_fn = 21;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 30);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 51);
 
-	/* Missing period-end-trigger at fn=51, TCH/H, TS3 */
+	/* Missing period-end-trigger at fn=51(25), TCH/H, TS3.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[3].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 47;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
+	lchan->meas.last_fn = 21;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 30);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 51);
 
-	/* Missing period-end-trigger at fn=64, TCH/F, TS4 */
+	/* Missing period-end-trigger at fn=64(38), TCH/F, TS4 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 60;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
+	lchan->meas.last_fn = 34;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 64);
 
-	/* Missing period-end-trigger at fn=64, TCH/H, TS4 */
+	/* Missing period-end-trigger at fn=64(38)38, TCH/H, TS4.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 60;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
+	lchan->meas.last_fn = 34;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 64);
 
-	/* Missing period-end-trigger at fn=64, TCH/H, TS4 */
+	/* Missing period-end-trigger at fn=64(38)38, TCH/H, TS5.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[5].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 60;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
+	lchan->meas.last_fn = 34;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 43);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 64);
 
-	/* Missing period-end-trigger at fn=77, TCH/F, TS5 */
+	/* Missing period-end-trigger at fn=77(51), TCH/F, TS5 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[5].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 73;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
+	lchan->meas.last_fn = 47;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 77);
 
-	/* Missing period-end-trigger at fn=77, TCH/H, TS4 */
+	/* Missing period-end-trigger at fn=77(51), TCH/H, TS5.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[4].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 73;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
+	lchan->meas.last_fn = 47;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 77);
 
-	/* Missing period-end-trigger at fn=77, TCH/H, TS5 */
+	/* Missing period-end-trigger at fn=77(51), TCH/H, TS6.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[5].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 73;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
+	lchan->meas.last_fn = 47;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 52);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 77);
 
-	/* Missing period-end-trigger at fn=90, TCH/F, TS6 */
+	/* Missing period-end-trigger at fn=90(64), TCH/F, TS6 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[6].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 86;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
+	lchan->meas.last_fn = 60;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 90);
 
-	/* Missing period-end-trigger at fn=90, TCH/H, TS6 */
+	/* Missing period-end-trigger at fn=90(64), TCH/H, TS6.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[6].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 86;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
+	lchan->meas.last_fn = 60;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 90);
 
-	/* Missing period-end-trigger at fn=90, TCH/H, TS7 */
+	/* Missing period-end-trigger at fn=90(64), TCH/H, TS7.0 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[7].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 86;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 91);
+	lchan->meas.last_fn = 60;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 90);
 
-	/* Missing period-end-trigger at fn=103, TCH/F, TS7 */
+	/* Missing period-end-trigger at fn=103(77), TCH/F, TS7 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[7].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
-	lchan->meas.last_fn = 99;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
+	lchan->meas.last_fn = 73;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 103);
 
-	/* Missing period-end-trigger at fn=103, TCH/H, TS6 */
+	/* Missing period-end-trigger at fn=103(77), TCH/H, TS6.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[6].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 99;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
+	lchan->meas.last_fn = 73;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 103);
 
-	/* Missing period-end-trigger at fn=103, TCH/H, TS7 */
+	/* Missing period-end-trigger at fn=103(77), TCH/H, TS7.1 */
 	fn_missed_end = LCHAN_FN_DUMMY;
 	lchan = &trx->ts[7].lchan[1];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 99;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 0 + 104);
+	lchan->meas.last_fn = 73;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 78);
 	OSMO_ASSERT(rc);
 	OSMO_ASSERT(fn_missed_end == 103);
 
 	/* Dropout inside the interval, no period-end-trigger missed */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[0].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
 	lchan->meas.last_fn = 56;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 69);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
-	/* No dropout, but right after period-end-trigger */
+	/* No dropout, but right after period-end-trigger (64=>38) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 38;
+	lchan->meas.last_fn = 64;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 39);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
@@ -373,92 +373,92 @@
 	/* No dropout, two neigbouring frames at random position
 	 * (should not happen in the real world) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[0].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
 	lchan->meas.last_fn = 43;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 44);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
-	/* No dropout, Two neigbouring frames (period end, right side) */
+	/* No dropout, Two neigbouring frames (period end, right side, 64=>38) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 38;
+	lchan->meas.last_fn = 64;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 39);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
 	/* No dropout, Two neigbouring frames (period end, left side,
-	 * should not happen in the real world) */
+	 * should not happen in the real world, 64=>38) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
 	lchan->meas.last_fn = 37;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 38);
+	rc = is_meas_overdue(lchan, &fn_missed_end, 64);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
-	/* No dropout, test directly on a the trigger frame */
+	/* No dropout, test directly on a the trigger frame (64=>38) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 34;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 38);
+	lchan->meas.last_fn = 38;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 64);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
 	/* No dropout, previous frame is trigger frame
-	 * (should not happen in the real world) */
+	 * (should not happen in the real world, 64=>38) */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[2].lchan[0];
+	lchan = &trx->ts[4].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_H;
-	lchan->meas.last_fn = 38;
-	rc = is_meas_overdue(lchan, &fn_missed_end, 38);
+	lchan->meas.last_fn = 64;
+	rc = is_meas_overdue(lchan, &fn_missed_end, 39);
 	OSMO_ASSERT(!rc);
 	OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
 
 	/* Missing period-end-trigger at fn=38+i*104, TCH/F, TS2 to
-	 * see the modulus is correct. */
+	 * see the modulus is correct. (64=>38) */
 	for (i = 0; i < 100; i++) {
 		fn_missed_end = LCHAN_FN_DUMMY;
-		lchan = &trx->ts[2].lchan[0];
+		lchan = &trx->ts[4].lchan[0];
 		lchan->ts->pchan = GSM_PCHAN_TCH_F;
 		lchan->meas.last_fn = 34 + 104 * 1;
 		rc = is_meas_overdue(lchan, &fn_missed_end, 43 + 104 * 1);
 		OSMO_ASSERT(rc);
-		OSMO_ASSERT(fn_missed_end == 38 + 104 * 1);
+		OSMO_ASSERT(fn_missed_end == 64 + 104 * 1);
 	}
 
 	/* See whats happening if we miss a period-end-triggerend at the
-	 * hyperframe beginning. */
+	 * hyperframe beginning (12=>38). */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[0].lchan[0];
+	lchan = &trx->ts[2].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
 	lchan->meas.last_fn = GSM_MAX_FN - 104 + 95;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 17);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == 12);
+	OSMO_ASSERT(fn_missed_end == 38);
 
 	/* See whats happening if we miss a period-end-triggerend at the
 	 * hyperframe ending. */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[6].lchan[0];
+	lchan = &trx->ts[0].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
 	lchan->meas.last_fn = GSM_MAX_FN - 104 + 86;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 8);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == GSM_MAX_FN - 104 + 90);
+	OSMO_ASSERT(fn_missed_end == 12);
 
 	/* See whats happening if we miss a period-end-triggerend exactly at the
 	 * hyperframe ending. */
 	fn_missed_end = LCHAN_FN_DUMMY;
-	lchan = &trx->ts[7].lchan[0];
+	lchan = &trx->ts[1].lchan[0];
 	lchan->ts->pchan = GSM_PCHAN_TCH_F;
 	lchan->meas.last_fn = GSM_MAX_FN - 104 + 99;
 	rc = is_meas_overdue(lchan, &fn_missed_end, 0);
 	OSMO_ASSERT(rc);
-	OSMO_ASSERT(fn_missed_end == GSM_MAX_FN - 1);
+	OSMO_ASSERT(fn_missed_end == 25);
 
 	/* Test a wrap around at the hyperframe ending, while no measurements
 	 * are lost */
@@ -897,6 +897,7 @@
 	unsigned int fn = 0;
 	unsigned int fn104;
 	struct bts_ul_meas ulm;
+	int rc = 0;
 
 	printf("\n\n");
 	printf("===========================================================\n");
@@ -928,12 +929,18 @@
 
 		if (dropouts == false || i % 4) {
 			if (ulm.is_sub == 1)
-				printf("(now adding SUB measurement sample %u)\n", fn);
-			lchan_meas_process_measurement(lchan, &ulm, fn);
+				printf
+				    ("(now adding SUB measurement sample %u)\n",
+				     fn);
+			rc += lchan_meas_process_measurement(lchan, &ulm, fn);
 		} else if (ulm.is_sub == 1)
-			printf("(leaving out SUB measurement sample for frame number %u)\n", fn);
+			printf
+			    ("(leaving out SUB measurement sample for frame number %u)\n",
+			     fn);
 		else
-			printf("(leaving out measurement sample for frame number %u)\n", fn);
+			printf
+			    ("(leaving out measurement sample for frame number %u)\n",
+			     fn);
 
 		fn += 4;
 		if (k == 2) {
@@ -942,13 +949,33 @@
 		} else
 			k++;
 
-		if (fn % 104 == 39 && no_sacch == false) {
-			printf("(now adding SUB measurement sample for SACCH block at frame number %u)\n", fn);
+		/* Note: The SACCH frame that concludes the measurement interval is
+		 * expected to be received at pos 13 with the frame number 38. This
+		 * is exactly one 26 multiframe later. */
+		if (fn % 104 == 13 && no_sacch == false) {
+			printf
+			    ("(now adding SUB measurement sample for SACCH block at frame number %u)\n",
+			     fn - 1 + 26);
 			ulm.is_sub = 1;
-			lchan_meas_process_measurement(lchan, &ulm, fn - 1);
-		} else if (fn % 104 == 39 && no_sacch == true)
-			printf("(leaving out SUB measurement sample for SACCH block at frame number %u)\n", fn);
+			rc +=
+			    lchan_meas_process_measurement(lchan, &ulm,
+							   fn - 1 + 26);
+		} else if (fn % 104 == 13 && no_sacch == true)
+			printf
+			    ("(leaving out SUB measurement sample for SACCH block at frame number %u)\n",
+			     fn - 1 + 26);
 	}
+
+	if (no_sacch == false && rc > 0) {
+		printf
+		    ("lchan_meas_process_measurement() is falsely indicating missed interval ends!\n");
+		OSMO_ASSERT(false);
+	} else if (no_sacch == true && rc == 0) {
+		printf
+		    ("lchan_meas_process_measurement() is falsely does not detect missed interval ends!\n");
+		OSMO_ASSERT(false);
+	}
+
 }
 
 static bool test_ts45008_83_is_sub_is_sacch(uint32_t fn)
diff --git a/tests/meas/meas_test.ok b/tests/meas/meas_test.ok
index 3d4f430..d7f85e9 100644
--- a/tests/meas/meas_test.ok
+++ b/tests/meas/meas_test.ok
@@ -723,73 +723,76 @@
 
 ===========================================================
 Testing lchan_meas_process_measurement()
-(now adding SUB measurement sample for SACCH block at frame number 39)
+(now adding SUB measurement sample for SACCH block at frame number 38)
 (now adding SUB measurement sample 52)
 (now adding SUB measurement sample 56)
-(now adding SUB measurement sample for SACCH block at frame number 143)
+(now adding SUB measurement sample for SACCH block at frame number 142)
 (now adding SUB measurement sample 156)
 (now adding SUB measurement sample 160)
-(now adding SUB measurement sample for SACCH block at frame number 247)
+(now adding SUB measurement sample for SACCH block at frame number 246)
 (now adding SUB measurement sample 260)
 (now adding SUB measurement sample 264)
-(now adding SUB measurement sample for SACCH block at frame number 351)
+(now adding SUB measurement sample for SACCH block at frame number 350)
 (now adding SUB measurement sample 364)
 (now adding SUB measurement sample 368)
+(now adding SUB measurement sample for SACCH block at frame number 454)
 
 
 ===========================================================
 Testing lchan_meas_process_measurement()
  * SACCH blocks not generated.
-(leaving out SUB measurement sample for SACCH block at frame number 39)
+(leaving out SUB measurement sample for SACCH block at frame number 38)
 (now adding SUB measurement sample 52)
 (now adding SUB measurement sample 56)
-(leaving out SUB measurement sample for SACCH block at frame number 143)
+(leaving out SUB measurement sample for SACCH block at frame number 142)
 (now adding SUB measurement sample 156)
 (now adding SUB measurement sample 160)
-(leaving out SUB measurement sample for SACCH block at frame number 247)
+(leaving out SUB measurement sample for SACCH block at frame number 246)
 (now adding SUB measurement sample 260)
 (now adding SUB measurement sample 264)
-(leaving out SUB measurement sample for SACCH block at frame number 351)
+(leaving out SUB measurement sample for SACCH block at frame number 350)
 (now adding SUB measurement sample 364)
 (now adding SUB measurement sample 368)
+(leaving out SUB measurement sample for SACCH block at frame number 454)
 
 
 ===========================================================
 Testing lchan_meas_process_measurement()
  * Simulate dropouts by leaving out every 4th measurement
 (leaving out measurement sample for frame number 0)
+(now adding SUB measurement sample for SACCH block at frame number 38)
 (leaving out measurement sample for frame number 17)
 (leaving out measurement sample for frame number 34)
-(now adding SUB measurement sample for SACCH block at frame number 39)
 (leaving out SUB measurement sample for frame number 52)
 (now adding SUB measurement sample 56)
 (leaving out measurement sample for frame number 69)
 (leaving out measurement sample for frame number 86)
 (leaving out measurement sample for frame number 104)
+(now adding SUB measurement sample for SACCH block at frame number 142)
 (leaving out measurement sample for frame number 121)
 (leaving out measurement sample for frame number 138)
-(now adding SUB measurement sample for SACCH block at frame number 143)
 (leaving out SUB measurement sample for frame number 156)
 (now adding SUB measurement sample 160)
 (leaving out measurement sample for frame number 173)
 (leaving out measurement sample for frame number 190)
 (leaving out measurement sample for frame number 208)
+(now adding SUB measurement sample for SACCH block at frame number 246)
 (leaving out measurement sample for frame number 225)
 (leaving out measurement sample for frame number 242)
-(now adding SUB measurement sample for SACCH block at frame number 247)
 (leaving out SUB measurement sample for frame number 260)
 (now adding SUB measurement sample 264)
 (leaving out measurement sample for frame number 277)
 (leaving out measurement sample for frame number 294)
 (leaving out measurement sample for frame number 312)
+(now adding SUB measurement sample for SACCH block at frame number 350)
 (leaving out measurement sample for frame number 329)
 (leaving out measurement sample for frame number 346)
-(now adding SUB measurement sample for SACCH block at frame number 351)
 (leaving out SUB measurement sample for frame number 364)
 (now adding SUB measurement sample 368)
 (leaving out measurement sample for frame number 381)
 (leaving out measurement sample for frame number 398)
 (leaving out measurement sample for frame number 416)
+(now adding SUB measurement sample for SACCH block at frame number 454)
 
 
 ===========================================================
@@ -797,38 +800,39 @@
  * SACCH blocks not generated.
  * Simulate dropouts by leaving out every 4th measurement
 (leaving out measurement sample for frame number 0)
+(leaving out SUB measurement sample for SACCH block at frame number 38)
 (leaving out measurement sample for frame number 17)
 (leaving out measurement sample for frame number 34)
-(leaving out SUB measurement sample for SACCH block at frame number 39)
 (leaving out SUB measurement sample for frame number 52)
 (now adding SUB measurement sample 56)
 (leaving out measurement sample for frame number 69)
 (leaving out measurement sample for frame number 86)
 (leaving out measurement sample for frame number 104)
+(leaving out SUB measurement sample for SACCH block at frame number 142)
 (leaving out measurement sample for frame number 121)
 (leaving out measurement sample for frame number 138)
-(leaving out SUB measurement sample for SACCH block at frame number 143)
 (leaving out SUB measurement sample for frame number 156)
 (now adding SUB measurement sample 160)
 (leaving out measurement sample for frame number 173)
 (leaving out measurement sample for frame number 190)
 (leaving out measurement sample for frame number 208)
+(leaving out SUB measurement sample for SACCH block at frame number 246)
 (leaving out measurement sample for frame number 225)
 (leaving out measurement sample for frame number 242)
-(leaving out SUB measurement sample for SACCH block at frame number 247)
 (leaving out SUB measurement sample for frame number 260)
 (now adding SUB measurement sample 264)
 (leaving out measurement sample for frame number 277)
 (leaving out measurement sample for frame number 294)
 (leaving out measurement sample for frame number 312)
+(leaving out SUB measurement sample for SACCH block at frame number 350)
 (leaving out measurement sample for frame number 329)
 (leaving out measurement sample for frame number 346)
-(leaving out SUB measurement sample for SACCH block at frame number 351)
 (leaving out SUB measurement sample for frame number 364)
 (now adding SUB measurement sample 368)
 (leaving out measurement sample for frame number 381)
 (leaving out measurement sample for frame number 398)
 (leaving out measurement sample for frame number 416)
+(leaving out SUB measurement sample for SACCH block at frame number 454)
 
 
 ===========================================================

-- 
To view, visit https://gerrit.osmocom.org/10760
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf6db73f67b7273c3d5965616c9e78f66b74a406
Gerrit-Change-Number: 10760
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180904/2d7d2e68/attachment.htm>


More information about the gerrit-log mailing list