Change in libosmocore[master]: tests/coding: Test decoding of DL EGPRS data packet

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/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Apr 7 14:34:08 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/17750 )


Change subject: tests/coding: Test decoding of DL EGPRS data packet
......................................................................

tests/coding: Test decoding of DL EGPRS data packet

Change-Id: Ide23a484b980995f24092d1cfbf062aed58fdf61
---
M tests/coding/coding_test.c
M tests/coding/coding_test.ok
2 files changed, 106 insertions(+), 28 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/17750/1

diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index 17ddfaa..5ae464f 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -316,7 +316,76 @@
 	printf("\n");
 }
 
-static void test_pdtch(uint8_t *l2, int len)
+struct test_macblock {
+	bool is_egprs;
+	uint16_t exp_burst_bits;
+	uint16_t l2_len;
+	uint8_t l2[54];
+};
+
+struct test_macblock test_macblock[] = {
+	/* Random frame */
+	{	false,
+		GSM0503_GPRS_BURSTS_NBITS,
+		54,
+		{ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+		  0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+		  0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,
+		  0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+		  0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+		  0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+		  0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 }
+	},
+	/* jolly frame */
+	{	false,
+		GSM0503_GPRS_BURSTS_NBITS,
+		23,
+		{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+		  0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+		  0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }
+	},
+/*
+GSM RLC/MAC: EGPRS DL HEADER
+    0... .... .... 0000 = DL TFI: 0
+    0... .... crumb 1 of DL TFI (decoded above)
+    .00. .... = RRBP: Reserved Block: (N+13) mod 2715648 (0)
+    ...0 0... = ES/P: RRBP field is not valid (no Polling) (0)
+    .... .111 = USF: 7
+    01.. .... 0000 0000 .... ...0 = BSN: 1
+    01.. .... crumb 2 of BSN (decoded above)
+    ..00 .... = PR: 0 dB (included) to 3 dB (excluded) less than BCCH level - P0 (0)
+    .... 0000 crumb 0 of DL TFI (decoded above)
+    0000 0000 crumb 1 of BSN (decoded above)
+    .00. .... = SPB (DL): No retransmission (0)
+    ...1 011. = CPS: MCS-1/P1 (0x0b)
+    .... ...0 crumb 0 of BSN (decoded above)
+GSM RLC/MAC: EGPRS DL DATA BLOCK 1 (BSN 1)
+    .... ..0. = FBI: Current Block is not last RLC data block in TBF
+    .... ...0 = Extension: Extension octet follows immediately
+    0000 100. = Length Indicator: 4
+    .... ...0 = Extension: Extension octet follows immediately
+    0010 000. = Length Indicator: 16
+    .... ...1 = Extension: No extension octet follows
+    data segment: LI[0]=4 indicates: (Last segment of) LLC frame (4 octets)
+        Data (4 bytes)
+            Data: 012b2b2b
+            [Length: 4]
+    data segment: LI[1]=16 indicates: (Last segment of) LLC frame (16 octets)
+        Data (16 bytes)
+            Data: 43c0012b2b2b2b2b2b2b2b2b2b2b2b2b
+            [Length: 16]
+*/
+	{	true,
+		GSM0503_GPRS_BURSTS_NBITS,
+		27,
+		{ 0x07, 0x40, 0x00, 0x16, 0x10, 0x42, 0x02, 0x56,
+		  0x56, 0x56, 0x86, 0x80, 0x03, 0x56, 0x56, 0x56,
+		  0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
+		  0x56, 0x56, 0x00 }
+	},
+};
+
+static void test_pdtch(struct test_macblock *tmb, int len)
 {
 	uint8_t result[len];
 	ubit_t bursts_u[116 * 4];
@@ -328,19 +397,22 @@
 	switch (len) {
 	case 34:
 	case 54:
-		l2[len - 1] &= 0x7f;
+		tmb->l2[len - 1] &= 0x7f;
 		result[len - 1] &= 0x7f;
 		break;
 	case 40:
-		l2[len - 1] &= 0x07;
+		tmb->l2[len - 1] &= 0x07;
 		result[len - 1] &= 0x07;
 		break;
 	}
 
 	/* Encode L2 message */
-	printf("Encoding: %s\n", osmo_hexdump(l2, len));
-	rc = gsm0503_pdtch_encode(bursts_u, l2, len);
-	CHECK_RC_OR_RET(rc == GSM0503_GPRS_BURSTS_NBITS, "encoding");
+	printf("Encoding: %s\n", osmo_hexdump(tmb->l2, len));
+	if (tmb->is_egprs)
+		rc = gsm0503_pdtch_egprs_encode(bursts_u, tmb->l2, len);
+	else
+		rc = gsm0503_pdtch_encode(bursts_u, tmb->l2, len);
+	CHECK_RC_OR_RET(rc == (int)tmb->exp_burst_bits, "encoding");
 
 	/* Prepare soft-bits */
 	osmo_ubit2sbit(bursts_s, bursts_u, 116 * 4);
@@ -349,15 +421,21 @@
 	dump_sbits((uint8_t *)bursts_s, 348);
 
 	/* Decode */
-	rc = gsm0503_pdtch_decode(result, bursts_s, NULL,
-		&n_errors, &n_bits_total);
+	if (tmb->is_egprs) {
+		/* gsm0503_pdtch_egprs_decode() is meant to decode EGPRS UL frames, so we cannot use it here */
+		rc = gsm0503_pdtch_egprs_decode(result, bursts_s, rc, NULL, &n_errors, &n_bits_total);
+		OSMO_ASSERT(rc == -EIO);
+		return;
+	} else {
+		rc = gsm0503_pdtch_decode(result, bursts_s, NULL, &n_errors, &n_bits_total);
+	}
 	CHECK_RC_OR_RET(rc == len, "decoding");
 
 	printf("Decoded: %s\n", osmo_hexdump(result, len));
 	printf("pdtch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
 		n_errors, n_bits_total, (float)n_errors/n_bits_total);
 
-	OSMO_ASSERT(!memcmp(l2, result, len));
+	OSMO_ASSERT(!memcmp(tmb->l2, result, len));
 
 	printf("\n");
 }
@@ -377,21 +455,6 @@
 	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
 };
 
-uint8_t test_macblock[][54] = {
-	/* Random frame */
-	{ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
-	0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
-	0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,
-	0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
-	0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
-	0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
-	0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 },
-	/* jolly frame */
-	{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
-	0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
-	0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
-};
-
 /* 11-bit Access Burst soft-bits (payload only) from an EGPRS capable phone (BSIC 63) */
 static const sbit_t test_rach_11bit[6][36] = {
 	{  103,  109, -108, -110,  107,  108, -106, -120, -121,
@@ -480,10 +543,14 @@
 		test_hr(test_l2[i], sizeof(test_l2[0]));
 
 	for (i = 0; i < len_mb; i++) {
-		test_pdtch(test_macblock[i], 23);
-		test_pdtch(test_macblock[i], 34);
-		test_pdtch(test_macblock[i], 40);
-		test_pdtch(test_macblock[i], 54);
+		if (test_macblock[i].is_egprs) {
+			test_pdtch(&test_macblock[i], test_macblock[i].l2_len);
+		} else {
+			test_pdtch(&test_macblock[i], 23);
+			test_pdtch(&test_macblock[i], 34);
+			test_pdtch(&test_macblock[i], 40);
+			test_pdtch(&test_macblock[i], 54);
+		}
 	}
 
 	printf("Success\n");
diff --git a/tests/coding/coding_test.ok b/tests/coding/coding_test.ok
index 3a4fbf2..91083e4 100644
--- a/tests/coding/coding_test.ok
+++ b/tests/coding/coding_test.ok
@@ -356,4 +356,15 @@
 Decoded: 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00
 
+Encoding: 07 40 00 16 10 42 02 56 56 56 86 80 03 56 56 56 56 56 56 56 56 56 56 56 56 56 00 
+U-Bits:
+100111000001011111111010101010011100010011111010000110110 00  00  000110110000010000000011000000000110011001100110010000000
+100010010000000000001101001111110010100100001000100111010 00  01  001001010101100010111000000000010111100011100011010001001
+111100001101001011010000110111100001001001000001000100110 00  01  000000110110110100011111011110011001101100000111100010001
+001000110011010110011011001011100100010001101101011100000 01  00  000010000010010110001111111001011101011000000011101100010
+S-Bits:
+81 7f 7f 81 81 81 7f 7f 7f 7f 7f 81 7f 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 7f 81 7f 7f 81 81 81 7f 7f 7f 81 7f 7f 81 81 81 81 81 7f 81 7f 7f 7f 7f 81 81 7f 81 81 7f  7f  7f  7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 
+81 7f 7f 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 81 7f 81 7f  7f  81  7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 81 81 7f 7f 7f 81 81 81 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 7f 7f 81 
+81 81 81 81 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 81 81 7f 81 7f 7f 7f 7f 81 81 7f 81 81 81 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 7f  7f  81  7f 7f 7f 7f 7f 7f 81 81 7f 81 81 7f 81 81 7f 81 7f 7f 7f 81 81 81 81 81 7f 81 81 81 81 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 7f 7f 7f 81 
+7f 7f 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 7f 7f 7f 81 7f 7f 7f 81 81 7f 81 81 7f 81 7f 81 81 81 7f 7f 7f 7f 7f  81  7f  7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 7f 81 7f 81 81 7f 7f 7f 81 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 7f 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 81 81 7f 81 81 7f 7f 7f 81 7f 
 Success

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ide23a484b980995f24092d1cfbf062aed58fdf61
Gerrit-Change-Number: 17750
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200407/a0cde213/attachment.htm>


More information about the gerrit-log mailing list