From 419b03497555eec53bc5759f6838d6a464987b99 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 14 Jan 2016 13:40:01 +0100 Subject: tbf: Use bitvec based window methods for GPRS Currently the old fixed 64 bit RBB based implementation is used for GPRS. Use the new bitvec based methods instead. Sponsored-by: On-Waves ehf --- src/bts.cpp | 23 +++++++++++++++++-- tests/tbf/TbfTest.err | 1 + tests/types/TypesTest.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++-- tests/types/TypesTest.ok | 3 ++- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index 16961454..d95dd869 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -892,6 +892,11 @@ void gprs_rlcmac_pdch::rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *ack_n struct gprs_rlcmac_dl_tbf *tbf; int rc; struct pcu_l1_meas meas; + int num_blocks; + uint8_t bits_data[RLC_GPRS_WS/8]; + bitvec bits; + int bsn_begin, bsn_end; + char show_bits[RLC_GPRS_WS + 1]; tfi = ack_nack->DOWNLINK_TFI; tbf = bts()->dl_tbf_by_poll_fn(fn, trx_no(), ts_no); @@ -918,10 +923,24 @@ void gprs_rlcmac_pdch::rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *ack_n LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] %s Packet Downlink Ack/Nack\n", tbf_name(tbf)); tbf->poll_state = GPRS_RLCMAC_POLL_NONE; + bits.data = bits_data; + bits.data_len = sizeof(bits_data); + bits.cur_bit = 0; + + num_blocks = Decoding::decode_gprs_acknack_bits( + &ack_nack->Ack_Nack_Description, &bits, + &bsn_begin, &bsn_end, &tbf->m_window); + + LOGP(DRLCMAC, LOGL_DEBUG, + "Got GPRS DL ACK bitmap: SSN: %d, BSN %d to %d - 1 (%d blocks), " + "\"%s\"\n", + ack_nack->Ack_Nack_Description.STARTING_SEQUENCE_NUMBER, + bsn_begin, bsn_end, num_blocks, + (Decoding::extract_rbb(&bits, show_bits), show_bits)); + rc = tbf->rcvd_dl_ack( ack_nack->Ack_Nack_Description.FINAL_ACK_INDICATION, - ack_nack->Ack_Nack_Description.STARTING_SEQUENCE_NUMBER, - ack_nack->Ack_Nack_Description.RECEIVED_BLOCK_BITMAP); + bsn_begin, &bits); if (rc == 1) { tbf_free(tbf); return; diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index ad0b69bb..5f493954 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -2764,6 +2764,7 @@ Got RLC block, coding scheme: CS-1, length: 23 (23)) +++++++++++++++++++++++++ RX : Uplink Control Block +++++++++++++++++++++++++ ------------------------- RX : Uplink Control Block ------------------------- RX: [PCU <- BTS] TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=FINISHED) Packet Downlink Ack/Nack +Got GPRS DL ACK bitmap: SSN: 0, BSN 0 to 28 - 1 (28 blocks), "RRRRRRRRRRRRRRRRRRRRRRRRRRRR" TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=FINISHED) downlink acknowledge - Final ACK received. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=FINISHED) changes state from FINISHED to WAIT RELEASE diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index 3447f695..c56b125a 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -327,8 +327,12 @@ static void test_rlc_dl_ul_basic() { uint16_t lost = 0, recv = 0; char show_rbb[65]; + uint8_t bits_data[8]; BTS dummy_bts; gprs_rlc_dl_window dl_win; + bitvec bits; + int bsn_begin, bsn_end, num_blocks; + Ack_Nack_Description_t desc; dl_win.m_v_b.reset(); @@ -348,13 +352,61 @@ static void test_rlc_dl_ul_basic() } uint8_t rbb_cmp[8] = { 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff }; - Decoding::extract_rbb(rbb_cmp, show_rbb); + bits.data = bits_data; + bits.data_len = sizeof(bits_data); + bits.cur_bit = 0; + + memcpy(desc.RECEIVED_BLOCK_BITMAP, rbb_cmp, + sizeof(desc.RECEIVED_BLOCK_BITMAP)); + desc.FINAL_ACK_INDICATION = 0; + desc.STARTING_SEQUENCE_NUMBER = 35; + + num_blocks = Decoding::decode_gprs_acknack_bits( + &desc, &bits, + &bsn_begin, &bsn_end, &dl_win); + Decoding::extract_rbb(&bits, show_rbb); printf("show_rbb: %s\n", show_rbb); - dl_win.update(&dummy_bts, show_rbb, 35, &lost, &recv); + dl_win.update(&dummy_bts, &bits, 0, &lost, &recv); OSMO_ASSERT(lost == 0); OSMO_ASSERT(recv == 35); + OSMO_ASSERT(bsn_begin == 0); + OSMO_ASSERT(bsn_end == 35); + OSMO_ASSERT(num_blocks == 35); + dl_win.raise(dl_win.move_window()); + + for (int i = 0; i < 8; ++i) { + dl_win.increment_send(); + OSMO_ASSERT(!dl_win.window_empty()); + OSMO_ASSERT(dl_win.distance() == 2 + i); + } + + uint8_t rbb_cmp2[8] = { 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x31 }; + bits.data = bits_data; + bits.data_len = sizeof(bits_data); + bits.cur_bit = 0; + + memcpy(desc.RECEIVED_BLOCK_BITMAP, rbb_cmp2, + sizeof(desc.RECEIVED_BLOCK_BITMAP)); + desc.FINAL_ACK_INDICATION = 0; + desc.STARTING_SEQUENCE_NUMBER = 35 + 8; + + num_blocks = Decoding::decode_gprs_acknack_bits( + &desc, &bits, + &bsn_begin, &bsn_end, &dl_win); + Decoding::extract_rbb(&bits, show_rbb); + printf("show_rbb: %s\n", show_rbb); + + lost = recv = 0; + dl_win.update(&dummy_bts, &bits, 0, &lost, &recv); + OSMO_ASSERT(lost == 5); + OSMO_ASSERT(recv == 3); + OSMO_ASSERT(bitvec_get_bit_pos(&bits, 0) == 0); + OSMO_ASSERT(bitvec_get_bit_pos(&bits, 7) == 1); + OSMO_ASSERT(bsn_begin == 35); + OSMO_ASSERT(bsn_end == 43); + OSMO_ASSERT(num_blocks == 8); } } diff --git a/tests/types/TypesTest.ok b/tests/types/TypesTest.ok index 6ca2717c..cb40d398 100644 --- a/tests/types/TypesTest.ok +++ b/tests/types/TypesTest.ok @@ -4,4 +4,5 @@ rbb: 00 00 00 00 00 00 00 01 rbb: 00 00 00 00 00 00 00 03 rbb: 00 00 00 00 00 00 00 31 rbb: 10 00 00 00 00 00 00 01 -show_rbb: IIIIIIIIIIIIIIIIIIIIIIIIIIIIIRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR +show_rbb: RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR +show_rbb: IIRRIIIR -- cgit v1.2.3