|
|
|
@ -22,7 +22,14 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include "srslte/common/log_filter.h"
|
|
|
|
|
#include "srslte/upper/rlc_um.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
#define TESTASSERT(cond) \
|
|
|
|
|
{ \
|
|
|
|
|
if (!(cond)) { \
|
|
|
|
|
std::cout << "[" << __FUNCTION__ << "][Line " << __LINE__ << "]: FAIL at " << (#cond) << std::endl; \
|
|
|
|
|
return -1; \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MAX_NBUFS 100
|
|
|
|
|
#define NBUFS 5
|
|
|
|
@ -71,8 +78,7 @@ public:
|
|
|
|
|
// PDCP interface
|
|
|
|
|
void write_pdu(uint32_t lcid, byte_buffer_t *sdu)
|
|
|
|
|
{
|
|
|
|
|
assert(lcid == 3);
|
|
|
|
|
if (sdu->N_bytes != expected_sdu_len) {
|
|
|
|
|
if (lcid != 3 && sdu->N_bytes != expected_sdu_len) {
|
|
|
|
|
printf("Received PDU with size %d, expected %d. Exiting.\n", sdu->N_bytes, expected_sdu_len);
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
@ -83,7 +89,6 @@ public:
|
|
|
|
|
void write_pdu_pcch(byte_buffer_t *sdu) {}
|
|
|
|
|
void write_pdu_mch(uint32_t lcid, srslte::byte_buffer_t *sdu)
|
|
|
|
|
{
|
|
|
|
|
assert(lcid == 3);
|
|
|
|
|
sdus[n_sdus++] = sdu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -92,13 +97,12 @@ public:
|
|
|
|
|
std::string get_rb_name(uint32_t lcid) { return std::string(""); }
|
|
|
|
|
void set_expected_sdu_len(uint32_t len) { expected_sdu_len = len; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte_buffer_t *sdus[MAX_NBUFS];
|
|
|
|
|
int n_sdus;
|
|
|
|
|
uint32_t expected_sdu_len;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void basic_test()
|
|
|
|
|
int basic_test()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("RLC_UM_1");
|
|
|
|
|
srslte::log_filter log2("RLC_UM_2");
|
|
|
|
@ -126,8 +130,8 @@ void basic_test()
|
|
|
|
|
cnfg.um_bi_dir().dl_um_rlc.sn_field_len = sn_field_len_e::size10;
|
|
|
|
|
cnfg.um_bi_dir().ul_um_rlc.sn_field_len = sn_field_len_e::size10;
|
|
|
|
|
|
|
|
|
|
assert(rlc1.configure(&cnfg) == true);
|
|
|
|
|
assert(rlc2.configure(&cnfg) == true);
|
|
|
|
|
TESTASSERT(rlc1.configure(&cnfg) == true);
|
|
|
|
|
TESTASSERT(rlc2.configure(&cnfg) == true);
|
|
|
|
|
|
|
|
|
|
tester.set_expected_sdu_len(1);
|
|
|
|
|
|
|
|
|
@ -140,7 +144,7 @@ void basic_test()
|
|
|
|
|
rlc1.write_sdu(&sdu_bufs[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(14 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(14 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Read 5 PDUs from RLC1 (1 byte each)
|
|
|
|
|
byte_buffer_t pdu_bufs[NBUFS];
|
|
|
|
@ -150,7 +154,7 @@ void basic_test()
|
|
|
|
|
pdu_bufs[i].N_bytes = len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(0 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Write 5 PDUs into RLC2
|
|
|
|
|
for(int i=0;i<NBUFS;i++)
|
|
|
|
@ -158,17 +162,19 @@ void basic_test()
|
|
|
|
|
rlc2.write_pdu(pdu_bufs[i].msg, pdu_bufs[i].N_bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(0 == rlc2.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc2.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
assert(NBUFS == tester.n_sdus);
|
|
|
|
|
TESTASSERT(NBUFS == tester.n_sdus);
|
|
|
|
|
for(int i=0; i<tester.n_sdus; i++)
|
|
|
|
|
{
|
|
|
|
|
assert(tester.sdus[i]->N_bytes == 1);
|
|
|
|
|
assert(*(tester.sdus[i]->msg) == i);
|
|
|
|
|
TESTASSERT(tester.sdus[i]->N_bytes == 1);
|
|
|
|
|
TESTASSERT(*(tester.sdus[i]->msg) == i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loss_test()
|
|
|
|
|
int loss_test()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("RLC_UM_1");
|
|
|
|
|
srslte::log_filter log2("RLC_UM_2");
|
|
|
|
@ -210,7 +216,7 @@ void loss_test()
|
|
|
|
|
rlc1.write_sdu(&sdu_bufs[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(14 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(14 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Read 5 PDUs from RLC1 (1 byte each)
|
|
|
|
|
byte_buffer_t pdu_bufs[NBUFS];
|
|
|
|
@ -220,7 +226,7 @@ void loss_test()
|
|
|
|
|
pdu_bufs[i].N_bytes = len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(0 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Write 5 PDUs into RLC2 (skip SN 1)
|
|
|
|
|
for(int i=0;i<NBUFS;i++)
|
|
|
|
@ -233,11 +239,12 @@ void loss_test()
|
|
|
|
|
while(!timers.timer_get(1)->is_expired())
|
|
|
|
|
timers.timer_get(1)->step();
|
|
|
|
|
|
|
|
|
|
assert(NBUFS-1 == tester.n_sdus);
|
|
|
|
|
}
|
|
|
|
|
TESTASSERT(NBUFS - 1 == tester.n_sdus);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void basic_mbsfn_test()
|
|
|
|
|
int basic_mbsfn_test()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("RLC_UM_1");
|
|
|
|
|
srslte::log_filter log2("RLC_UM_2");
|
|
|
|
@ -273,7 +280,7 @@ void basic_mbsfn_test()
|
|
|
|
|
rlc1.write_sdu(&sdu_bufs[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(13 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(13 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Read 5 PDUs from RLC1 (1 byte each)
|
|
|
|
|
byte_buffer_t pdu_bufs[NBUFS*2];
|
|
|
|
@ -283,7 +290,7 @@ void basic_mbsfn_test()
|
|
|
|
|
pdu_bufs[i].N_bytes = len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(0 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Write 5 PDUs into RLC2
|
|
|
|
|
for(int i=0;i<NBUFS;i++)
|
|
|
|
@ -291,14 +298,16 @@ void basic_mbsfn_test()
|
|
|
|
|
rlc2.write_pdu(pdu_bufs[i].msg, pdu_bufs[i].N_bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(0 == rlc2.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc2.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
assert(NBUFS == tester.n_sdus);
|
|
|
|
|
TESTASSERT(NBUFS == tester.n_sdus);
|
|
|
|
|
for(int i=0; i<tester.n_sdus; i++)
|
|
|
|
|
{
|
|
|
|
|
assert(tester.sdus[i]->N_bytes == 1);
|
|
|
|
|
assert(*(tester.sdus[i]->msg) == i);
|
|
|
|
|
TESTASSERT(tester.sdus[i]->N_bytes == 1);
|
|
|
|
|
TESTASSERT(*(tester.sdus[i]->msg) == i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -312,7 +321,7 @@ void basic_mbsfn_test()
|
|
|
|
|
// This test sends PDU in two batches so it's not the reordering
|
|
|
|
|
// timeout that detects the missing PDU but the fact more
|
|
|
|
|
// PDUs than rx_mod are received.
|
|
|
|
|
void reassmble_test()
|
|
|
|
|
int reassmble_test()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("RLC_UM_1");
|
|
|
|
|
srslte::log_filter log2("RLC_UM_2");
|
|
|
|
@ -378,7 +387,7 @@ void reassmble_test()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Generated %d PDUs in first batch\n", n_pdus);
|
|
|
|
|
assert(0 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// push second batch of SDUs
|
|
|
|
|
for (int i = n_sdu_first_batch; i < n_sdus; ++i) {
|
|
|
|
@ -414,10 +423,12 @@ void reassmble_test()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We should have received one SDU less than we tx'ed
|
|
|
|
|
assert(tester.n_sdus == n_sdus - 1);
|
|
|
|
|
TESTASSERT(tester.n_sdus == n_sdus - 1);
|
|
|
|
|
for (int i = 0; i < tester.n_sdus; ++i) {
|
|
|
|
|
assert(tester.sdus[i]->N_bytes == sdu_len);
|
|
|
|
|
TESTASSERT(tester.sdus[i]->N_bytes == sdu_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This reassmble test checks the reassembly routines when a PDU
|
|
|
|
@ -427,7 +438,7 @@ void reassmble_test()
|
|
|
|
|
// On reassembly of the SDUs, the missing start segment
|
|
|
|
|
// should be detected and the complete SDU be discarded
|
|
|
|
|
// Therefore, one SDU less should be received than was tx'ed.
|
|
|
|
|
void reassmble_test2()
|
|
|
|
|
int reassmble_test2()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("RLC_UM_1");
|
|
|
|
|
srslte::log_filter log2("RLC_UM_2");
|
|
|
|
@ -491,7 +502,7 @@ void reassmble_test2()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Generated %d PDUs in first batch\n", n_pdus);
|
|
|
|
|
assert(0 == rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// push second batch of SDUs
|
|
|
|
|
for (int i = n_sdu_first_batch; i < n_sdus; ++i) {
|
|
|
|
@ -525,25 +536,39 @@ void reassmble_test2()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We should have received one SDU less than we tx'ed
|
|
|
|
|
assert(tester.n_sdus == n_sdus - 1);
|
|
|
|
|
TESTASSERT(tester.n_sdus == n_sdus - 1);
|
|
|
|
|
for (int i = 0; i < tester.n_sdus; ++i) {
|
|
|
|
|
assert(tester.sdus[i]->N_bytes == sdu_len);
|
|
|
|
|
TESTASSERT(tester.sdus[i]->N_bytes == sdu_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
basic_test();
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
if (basic_test()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
byte_buffer_pool::get_instance()->cleanup();
|
|
|
|
|
|
|
|
|
|
loss_test();
|
|
|
|
|
if (loss_test()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
byte_buffer_pool::get_instance()->cleanup();
|
|
|
|
|
basic_mbsfn_test();
|
|
|
|
|
|
|
|
|
|
if (basic_mbsfn_test()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
byte_buffer_pool::get_instance()->cleanup();
|
|
|
|
|
|
|
|
|
|
reassmble_test();
|
|
|
|
|
if (reassmble_test()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
byte_buffer_pool::get_instance()->cleanup();
|
|
|
|
|
|
|
|
|
|
reassmble_test2();
|
|
|
|
|
if (reassmble_test2()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
byte_buffer_pool::get_instance()->cleanup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|