[PATCH] osmo-pcu[master]: Fix issues in URBB generation in EGPRS PUAN

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

prasadkg gerrit-no-reply at lists.osmocom.org
Fri Jun 24 12:15:57 UTC 2016


Review at  https://gerrit.osmocom.org/412

Fix issues in URBB generation in EGPRS PUAN

Below issue in number of bits of uncompresed bitmap
1. Corrected the calculation of number of bits that is included in URBB
2. If length is not present, 0s are coded as remaining bits
Along with this, code is restructured to enable addition of
compression support

Change-Id: Ie5c25b6ee30f2f1b613e923c234b03a6ffe12ae2
---
M src/encoding.cpp
1 file changed, 46 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/12/412/1

diff --git a/src/encoding.cpp b/src/encoding.cpp
index e174c80..ff91309 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -25,6 +25,11 @@
 #include <tbf.h>
 #include <gprs_debug.h>
 
+extern "C" {
+#include <osmocom/core/utils.h>
+#include <osmocom/core/bitcomp.h>
+}
+
 #include <errno.h>
 #include <string.h>
 
@@ -537,7 +542,6 @@
 	gprs_rlc_ul_window *window, bool is_final)
 {
 	int urbb_len = 0;
-	int crbb_len = 0;
 	int len;
 	bool bow = true;
 	bool eow = true;
@@ -545,6 +549,9 @@
 	int num_blocks = window->mod_sns(window->v_r() - window->v_q());
 	int esn_crbb = window->mod_sns(ssn - 1);
 	int rest_bits = dest->data_len * 8 - wp;
+	int is_compressed = 0;
+	bool len_coded = true;
+	uint8_t i;
 
 	if (num_blocks > 0)
 		/* V(Q) is NACK and omitted -> SSN = V(Q) + 1 */
@@ -553,31 +560,30 @@
 	if (num_blocks > window->ws())
 		num_blocks = window->ws();
 
-	if (num_blocks > rest_bits) {
-		eow = false;
-		urbb_len = rest_bits;
-		/* TODO: use compression, start encoding bits and stop when the
-		 * space is exhausted. Use the first combination that encodes
-		 * all bits. If there is none, use the combination that encodes
-		 * the largest number of bits (e.g. by setting num_blocks to the
-		 * max and repeating the construction).
-		 */
-	} else if (num_blocks > rest_bits - 9) {
-		/* union bit and length field take 9 bits */
-		eow = false;
-		urbb_len = rest_bits - 9;
-		/* TODO: use compression (see above) */
+	if (is_compressed == 0) {
+		/* Union bit takes 1 bit */
+		/* Other fields in descr for uncompresed bitmap takes 23 bits*/
+
+		if (num_blocks > rest_bits - 15 - 1) {
+			eow = false;
+			urbb_len = rest_bits - 15 - 1;
+			len_coded = false;
+		} else if (num_blocks == rest_bits - 15 - 1) {
+			urbb_len = rest_bits - 15 - 1;
+			len_coded = false;
+		/* Union bit takes 1 bit length field takes 8 bits*/
+		} else if (num_blocks > rest_bits - 15 - 9) {
+			eow = false;
+			urbb_len = rest_bits - 15 - 9;
+		} else
+			urbb_len = num_blocks;
+		len = urbb_len + 15;
+	} else {
+		/* TODO Compressed bitmap */
 	}
 
-	if (urbb_len + crbb_len == rest_bits)
-		len = -1;
-	else if (crbb_len == 0)
-		len = urbb_len + 15;
-	else
-		len = urbb_len + crbb_len + 23;
-
 	/* EGPRS Ack/Nack Description IE */
-	if (len < 0) {
+	if (len_coded == false) {
 		bitvec_write_field(dest, wp, 0, 1); // 0: don't have length
 	} else {
 		bitvec_write_field(dest, wp, 1, 1); // 1: have length
@@ -588,21 +594,30 @@
 	bitvec_write_field(dest, wp, bow, 1); // BEGINNING_OF_WINDOW
 	bitvec_write_field(dest, wp, eow, 1); // END_OF_WINDOW
 	bitvec_write_field(dest, wp, ssn, 11); // STARTING_SEQUENCE_NUMBER
-	bitvec_write_field(dest, wp, 0, 1); // 0: don't have CRBB
-
-	/* TODO: Add CRBB support */
-
+	if (is_compressed) {
+		/* TODO Add CRBB support */
+	}
+	else {
+		bitvec_write_field(dest, wp, 0, 1); // CRBB_Exist
+	}
 	LOGP(DRLCMACUL, LOGL_DEBUG,
-		" - EGPRS URBB, len = %d, SSN = %d, ESN_CRBB = %d, "
+		"EGPRS URBB, urbb len = %d, SSN = %d, ESN_CRBB = %d, "
+		"len present = %s,desc len = %d, "
 		"SNS = %d, WS = %d, V(Q) = %d, V(R) = %d%s%s\n",
-		urbb_len, ssn, esn_crbb,
+		urbb_len, ssn, esn_crbb, len_coded ? "yes" : "No" ,len,
 		window->sns(), window->ws(), window->v_q(), window->v_r(),
 		bow ? ", BOW" : "", eow ? ", EOW" : "");
-	for (int i = urbb_len; i > 0; i--) {
-		/* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */
+
+	for (i = urbb_len; i > 0; i--) {
+	/* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */
 		bool is_ack = window->m_v_n.is_received(esn_crbb + i);
 		bitvec_write_field(dest, wp, is_ack, 1);
 	}
+	/* If len is not coded, set remaining bits as 0 */
+	if (len_coded == false) {
+		for (i = wp; i < dest->data_len*8; i++)
+			bitvec_write_field(dest, wp, 0, 1);
+	}
 }
 
 static void write_packet_uplink_ack_egprs(

-- 
To view, visit https://gerrit.osmocom.org/412
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5c25b6ee30f2f1b613e923c234b03a6ffe12ae2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: prasadkg <Prasad.Kaup at radisys.com>



More information about the gerrit-log mailing list