[PATCH] osmo-pcu[master]: Add compression support 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/413

Add compression support in EGPRS PUAN

This adds compression of bitmap in PUAN. The compressed bitmap
is used only if the number of bits in the bitmap does not fit in
the message and there is a gain after compression.
The algorithm is part of libosmocore and so there is dependency
on the libosmocore for compilation.
The algorithm is tested on integration setup by forcing compression.

Change-Id: I89683e82eda6c80b7328ddb4ec2c2f55d4a687aa
---
M src/encoding.cpp
M src/rlc.cpp
M src/rlc.h
3 files changed, 98 insertions(+), 5 deletions(-)


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

diff --git a/src/encoding.cpp b/src/encoding.cpp
index ff91309..6720975 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -542,15 +542,23 @@
 	gprs_rlc_ul_window *window, bool is_final)
 {
 	int urbb_len = 0;
-	int len;
+	uint8_t crbb_len = 0;
+	uint8_t len;
 	bool bow = true;
 	bool eow = true;
 	int ssn = window->mod_sns(window->v_q() + 1);
 	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;
+	uint8_t rbb[128] = {'\0'};
+	uint8_t iter = 0;
 	int is_compressed = 0;
+	uint16_t ucmp_bmplen;
+	uint8_t crbb_bitmap[127] = {'\0'};
+	bitvec out;
+	uint16_t uclen_crbb = 0;
 	bool len_coded = true;
+	uint8_t crbb_start_clr_code;
 	uint8_t i;
 
 	if (num_blocks > 0)
@@ -559,6 +567,33 @@
 
 	if (num_blocks > window->ws())
 		num_blocks = window->ws();
+
+	if (num_blocks > rest_bits - 23 - 9) {
+	/* Try Compression  as number of blocks does not fit */
+		is_compressed = 1;
+	}
+	if (is_compressed == 1) {
+		ucmp_bmplen = window->update_egprs_rbb(rbb);
+		out.data = rbb;
+		out.cur_bit = 0;
+		out.data_len = ucmp_bmplen;
+		LOGP(DRLCMACUL, LOGL_DEBUG,
+		"rest_bits=%d uncompressed len %d and uncompressed bitmap = %s\n",
+		 rest_bits, ucmp_bmplen,
+		osmo_hexdump(out.data, (out.data_len+7)/8));
+
+		is_compressed = osmo_bitmap_compress(&out, /* Uncompressed bitmap*/
+			&ucmp_bmplen, /*Uncompressed bitmap len*/
+			&crbb_len, /*Compressed bitmap len */
+			crbb_bitmap,
+			&uclen_crbb,
+			(rest_bits - 23 - 9));/* 9 bits for union + length */
+		LOGP(DRLCMACUL, LOGL_DEBUG,
+		"the ucmp len=%d uclen_crbb=%d num_blocks=%d crbb length %d, "
+		"and the CRBB bitmap  = %s\n",
+		ucmp_bmplen, uclen_crbb, num_blocks, crbb_len,
+		osmo_hexdump(crbb_bitmap, (crbb_len+7)/8));
+	}
 
 	if (is_compressed == 0) {
 		/* Union bit takes 1 bit */
@@ -579,7 +614,22 @@
 			urbb_len = num_blocks;
 		len = urbb_len + 15;
 	} else {
-		/* TODO Compressed bitmap */
+		if (num_blocks > uclen_crbb) {
+			eow = false;
+			urbb_len = num_blocks - uclen_crbb;
+		}
+		/* Union bit takes 1 bit */
+		/* Other fields in descr of compresed bitmap takes 23 bits*/
+		if (urbb_len > (rest_bits - crbb_len - 23 - 1)) {
+			eow = false;
+			len_coded = false;
+			urbb_len = rest_bits - crbb_len - 23 - 1;
+		} else if (urbb_len > (rest_bits - crbb_len - 23 - 9)) {
+			eow = false;
+			len_coded = false;
+			urbb_len = rest_bits - crbb_len - 23 - 9;
+		}
+		len = urbb_len + crbb_len + 23;
 	}
 
 	/* EGPRS Ack/Nack Description IE */
@@ -595,9 +645,25 @@
 	bitvec_write_field(dest, wp, eow, 1); // END_OF_WINDOW
 	bitvec_write_field(dest, wp, ssn, 11); // STARTING_SEQUENCE_NUMBER
 	if (is_compressed) {
-		/* TODO Add CRBB support */
-	}
-	else {
+		bitvec_write_field(dest, wp, 1, 1); // CRBB_Exist
+		bitvec_write_field(dest, wp, crbb_len, 7); // CRBB_LENGTH
+		crbb_start_clr_code = (0x80 & crbb_bitmap[0])>>7;
+		bitvec_write_field(dest, wp, crbb_start_clr_code, 1); // CRBB_clr_code
+		LOGP(DRLCMACUL, LOGL_DEBUG,
+			"EGPRS CRBB, crbb_len = %d, crbb_start_clr_code = %d\n",
+			crbb_len, crbb_start_clr_code);
+		while (crbb_len != 0) {
+			if (crbb_len > 8) {
+				bitvec_write_field(dest, wp, crbb_bitmap[iter], 8);
+				crbb_len = crbb_len - 8;
+				iter++;
+			} else {
+				bitvec_write_field(dest, wp, crbb_bitmap[iter], crbb_len);
+				crbb_len = 0;
+			}
+		}
+		esn_crbb = window->mod_sns(esn_crbb + uclen_crbb);
+	} else {
 		bitvec_write_field(dest, wp, 0, 1); // CRBB_Exist
 	}
 	LOGP(DRLCMACUL, LOGL_DEBUG,
diff --git a/src/rlc.cpp b/src/rlc.cpp
index 6770043..1b178a1 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -83,6 +83,32 @@
 	return resend;
 }
 
+/* Update the receive block bitmap */
+uint16_t gprs_rlc_ul_window::update_egprs_rbb(uint8_t *rbb)
+{
+	int i;
+	uint16_t bsn;
+	uint16_t bitmask = 0x80;
+	int8_t pos = 0;
+	int8_t bit_pos = 0;
+	for (i = 0, bsn = (v_q()+1); ((bsn < (v_r())) && (i < ws())); i++,
+					bsn = this->mod_sns(bsn + 1)) {
+		if (m_v_n.is_received(bsn)) {
+			rbb[pos] = rbb[pos] | bitmask;
+		} else {
+			rbb[pos] = rbb[pos] & (~bitmask);
+		}
+		bitmask = bitmask >> 1;
+		bit_pos++;
+		bit_pos = bit_pos % 8;
+		if(bit_pos == 0) {
+			pos++;
+			bitmask = 0x80;
+		}
+	}
+	return i;
+}
+
 int gprs_rlc_dl_window::count_unacked()
 {
 	uint16_t unacked = 0;
diff --git a/src/rlc.h b/src/rlc.h
index ad10b3a..086f66e 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -259,6 +259,7 @@
 	bool is_received(uint16_t bsn) const;
 
 	void update_rbb(char *rbb);
+	uint16_t update_egprs_rbb(uint8_t *rbb);
 	void raise_v_r_to(int moves);
 	void raise_v_r(const uint16_t bsn);
 	uint16_t raise_v_q();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I89683e82eda6c80b7328ddb4ec2c2f55d4a687aa
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