aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpravin <pravin.manoharan@radisys.com>2016-06-23 15:40:41 +0530
committerpravin <pravin.manoharan@radisys.com>2016-06-23 15:40:41 +0530
commitbd1e4bcc4cb4207675fe62b4374b7671f25a3e15 (patch)
treef06b1e39ea600649232ee98144223aa9cf9f323a
parent0a918983f384c5326f7c4d1ac33d3d84e6a9635e (diff)
Fix computation of max value in decompression profiling testusers/pravin/epdan_profiling
Bug in calculating max value is fixed. Along with this, new test vectors are identified where in existing algorithm fails whereas tree based algorithm succeeds. Abnormally high timings are counted and counter is logged.
-rw-r--r--tests/tbf/TbfTest.cpp197
1 files changed, 134 insertions, 63 deletions
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 4838f0f..a9d2e8b 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -40,27 +40,41 @@ extern "C" {
#include <errno.h>
#define NUMBER_OF_TEST_CASE 4
#define NEW 1
+#define DELTA 1000
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
- struct test_data {
- int8_t crbb_len;
- uint8_t cc ;
- uint8_t data[23];
- uint8_t exp_data[40];
- int exp_len;
- }test[4] = { { (int8_t)67, (uint8_t)1,{0x02, 0x0c, 0xa0, 0x30, 0xcb, 0x1a, 0x0c, 0xe3, 0x6c},
- {0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff,
- 0xdb}, (int)194},
- { (int8_t)40, (uint8_t)1,{0x53, 0x06, 0xc5, 0x40, 0x6d}, { 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03}, (int)182},
- { (int8_t)6, (uint8_t)1, {0x1c}, {0x80}, (int)1},
- { (int8_t)103,(uint8_t)1, {0x02, 0x0c, 0xe0, 0x41, 0xa0, 0x0c, 0x36, 0x0d, 0x03,
- 0x71, 0xb0, 0x6e, 0x24}, {0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff,
- 0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff} ,
- (int)288} };
+struct test_data {
+ int8_t crbb_len;
+ uint8_t cc ;
+ uint8_t data[23];
+ uint8_t exp_data[40];
+ int exp_len;
+}test[4] = { { (int8_t)67, (uint8_t)1,{0x02, 0x0c, 0xa0, 0x30, 0xcb, 0x1a, 0x0c, 0xe3, 0x6c},
+ {0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff,
+ 0xdb}, (int)194},
+ {(int8_t)40, (uint8_t)1, {0x53,0x06,0xc5,0x40,0x6d}, {0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
+ 0x00, 0x00, 0x00, 0x03}, (int)182},
+ { (int8_t)8, (uint8_t)1, {0x02}, {0xff, 0xff, 0xff, 0xf8}, (int)29},
+ { (int8_t)103,(uint8_t)1, {0x02, 0x0c, 0xe0, 0x41, 0xa0, 0x0c, 0x36, 0x0d, 0x03,
+ 0x71, 0xb0, 0x6e, 0x24}, {0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff,
+ 0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff} ,
+ (int)288} };
+struct test_data1 {
+ int8_t crbb_len;
+ uint8_t cc;
+ uint8_t data[23];
+ uint8_t exp_data[42];
+ int exp_len;
+} test1[3] = { {(int8_t)41, (uint8_t)1, {0xac,0x22,0x70,0xa3,0x03,0x80}, {0xff, 0xff, 0x80, 0x1f, 0xff,
+ 0xf8, 0x00, 0xff, 0xff, 0xe0, 0x00}, (int)87},
+ {(int8_t)12, (uint8_t)1, {0x38, 0x40}, {0xff, 0xc0, 0x00}, (int)20},
+ {(int8_t)16, (uint8_t)0, {0x0c, 0x93}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00}, (int)197} };
+
static void check_tbf(gprs_rlcmac_tbf *tbf)
{
OSMO_ASSERT(tbf);
@@ -69,6 +83,7 @@ static void check_tbf(gprs_rlcmac_tbf *tbf)
if (tbf->state_is(GPRS_RLCMAC_RELEASING))
OSMO_ASSERT(tbf->T != 0);
}
+
static void send_ul_mac_block(BTS *the_bts, unsigned trx_no, unsigned ts_no,
RlcMacUplink_t *ulreq, unsigned fn)
{
@@ -87,6 +102,7 @@ static void send_ul_mac_block(BTS *the_bts, unsigned trx_no, unsigned ts_no,
pdch = &the_bts->bts_data()->trx[trx_no].pdch[ts_no];
pdch->rcv_block(&buf[0], num_bytes, fn, &meas);
}
+
static void send_control_ack(gprs_rlcmac_tbf *tbf)
{
RlcMacUplink_t ulreq = {0};
@@ -100,10 +116,12 @@ static void send_control_ack(gprs_rlcmac_tbf *tbf)
send_ul_mac_block(tbf->bts, tbf->trx->trx_no, tbf->poll_ts,
&ulreq, tbf->poll_fn);
}
+
static unsigned fn2bn(unsigned fn)
{
return (fn % 52) / 4;
}
+
static unsigned fn_add_blocks(unsigned fn, unsigned blocks)
{
unsigned bn = fn2bn(fn) + blocks;
@@ -111,6 +129,7 @@ static unsigned fn_add_blocks(unsigned fn, unsigned blocks)
fn += bn * 4 + bn / 3;
return fn % 2715648;
}
+
static void setup_bts(BTS *the_bts, uint8_t ts_no, uint8_t cs = 1)
{
gprs_rlcmac_bts *bts;
@@ -122,6 +141,7 @@ static void setup_bts(BTS *the_bts, uint8_t ts_no, uint8_t cs = 1)
trx = &bts->trx[0];
trx->pdch[ts_no].enable();
}
+
static void request_dl_rlc_block(struct gprs_rlcmac_bts *bts,
uint8_t trx_no, uint8_t ts_no, uint16_t arfcn,
uint32_t *fn, uint8_t *block_nr = NULL)
@@ -133,6 +153,7 @@ static void request_dl_rlc_block(struct gprs_rlcmac_bts *bts,
if (block_nr)
*block_nr = bn;
}
+
static void request_dl_rlc_block(struct gprs_rlcmac_tbf *tbf,
uint32_t *fn, uint8_t *block_nr = NULL)
{
@@ -143,6 +164,7 @@ enum test_tbf_final_ack_mode {
TEST_MODE_STANDARD,
TEST_MODE_REVERSE_FREE
};
+
static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_spb_pdan(BTS *the_bts,
uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta,
uint8_t ms_class, uint8_t egprs_ms_class)
@@ -167,6 +189,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_spb_pdan(BTS *the_bts,
pdch = &the_bts->bts_data()->trx[trx_no].pdch[ts_no];
pdch->rcv_block(&data_msg[0], 23, *fn, &meas);
}
+
static gprs_rlcmac_dl_tbf *create_dl_tbf(BTS *the_bts, uint8_t ms_class,
uint8_t egprs_ms_class, uint8_t *trx_no_)
{
@@ -186,6 +209,7 @@ static gprs_rlcmac_dl_tbf *create_dl_tbf(BTS *the_bts, uint8_t ms_class,
*trx_no_ = trx_no;
return dl_tbf;
}
+
static gprs_rlcmac_dl_tbf *tbf_init(BTS *the_bts,
int mcs)
{
@@ -214,6 +238,7 @@ static gprs_rlcmac_dl_tbf *tbf_init(BTS *the_bts,
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
return dl_tbf;
}
+
static void establish_and_use_egprs_dl_tbf_pdan(BTS *the_bts,
int mcs, int demanded_mcs)
{
@@ -290,20 +315,19 @@ void test_EPDAN_time_osmot4(int test_run, int verify)
{
LOGP(DRLCMACDL, LOGL_DEBUG, "\nMaster decoding osmo_t4");
int itr = 0;
- long long int min_master = 0, max_master = 0, avg_master = 0 ;
+ long long int min_master = 0, max_master = 0, sum = 0, avg = 0;
+ float avg_master = 0;
bitvec bits;
struct bitvec data1;
struct timeval t0, t1;
- data1.data = test[itr].data;
uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
-
- for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
- int loop = 0, init_flag = 1;
- avg_master = 0 ;
+ for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
+ int loop = 0, init_flag = 1, count = 0, first = 0, last = 0;
+ avg_master = 0 , min_master = 0 ,max_master = 0;
while (loop++ < test_run) {
data1.data_len = ((test[itr].crbb_len + 7)/8);
data1.cur_bit = test[itr].crbb_len;
-
+ data1.data = test[itr].data;
bits.data = bits_data;
bits.data_len = sizeof(bits_data);
bits.cur_bit = 0;
@@ -314,27 +338,39 @@ void test_EPDAN_time_osmot4(int test_run, int verify)
gettimeofday(&t1, 0);
long long elapsed = (t1.tv_sec-t0.tv_sec)*1000000LL + t1.tv_usec-t0.tv_usec;
if (init_flag) {
- min_master = elapsed;
- max_master = elapsed;
init_flag = 0 ;
}
if (verify) {
if (check_result (bits, test[itr].exp_data, test[itr].exp_len) == 0) {
LOGP(DRLCMACDL, LOGL_DEBUG, "Master decoding :Error\n");
- OSMO_ASSERT(0);
+ OSMO_ASSERT(0) ;
}
}
- if (min_master >= elapsed) {
+ if (loop == 1) {
+ first = elapsed;
+ sum = elapsed;
+ avg = elapsed;
min_master = elapsed;
- } else {
max_master = elapsed;
+ avg_master = elapsed;
+ } else {
+ if (loop == test_run-1)
+ last = elapsed;
+ if (elapsed > (avg+DELTA))
+ count++;/*Count of abnormal values*/
+ sum = sum + elapsed;
+ avg = sum / loop;
+ if (min_master > elapsed)
+ min_master = elapsed;
+ if (max_master < elapsed)
+ max_master = elapsed;
+ avg_master = avg_master + elapsed;
}
- avg_master = avg_master + elapsed;
}
avg_master = (avg_master / test_run);
LOGP(DRLCMACDL, LOGL_DEBUG,
- "\nTest case number :%d \nTime elapsed:\nmin = %Ld\n"
- "max = %Ld\navg = %Ld\n", itr+1, min_master, max_master, avg_master) ;
+ "\nTest case number :%d \nTime elapsed:\nFirst = %d\tLast = %d\nmin = %Ld\n"
+ "max = %Ld\navg = %f\nabnormal value occurred %d\n", itr+1, first, last, min_master, max_master, avg_master,count) ;
}
}
/* To check time taken to decode crbb by Tree based method
@@ -343,55 +379,93 @@ void test_EPDAN_time_tree(int test_run, int verify)
{
LOGP (DRLCMACDL, LOGL_DEBUG, "Tree based decoding");
int itr = 0;
- long long int min_tree = 0, max_tree = 0, avg_tree = 0;
+ long long int min_tree = 0, max_tree = 0, sum = 0, avg = 0;
+ float avg_tree = 0;
bitvec bits;
struct bitvec data1;
-
- for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
- int loop = 0, init_flag = 1;
- avg_tree = 0;
-
+ for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
+ int loop = 0, init_flag = 1, first = 0, last = 0, count = 0;
+ avg_tree = 0 , min_tree = 0 , max_tree = 0;
while (loop++ < test_run) {
data1.data_len = ((test[itr].crbb_len + 7)/8);
data1.cur_bit = test[itr].crbb_len;
-
struct timeval t0, t1;
-
data1.data = test[itr].data;
uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
-
bits.data = bits_data;
bits.data_len = sizeof(bits_data);
bits.cur_bit = 0;
gettimeofday(&t0, 0);
Decoding::decompress_crbb(test[itr].crbb_len, test[itr].cc, test[itr].data, &bits);
gettimeofday(&t1, 0);
-
long long elapsed = (t1.tv_sec-t0.tv_sec)*1000000LL + t1.tv_usec-t0.tv_usec;
-
- if (init_flag) {
- min_tree = elapsed;
- max_tree = elapsed;
+ if (init_flag)
init_flag = 0;
- }
if (verify) {
if (check_result(bits, test[itr].exp_data, test[itr].exp_len) == 0) {
LOGP (DRLCMACDL, LOGL_DEBUG, "Tree based decoding :Error\n");
OSMO_ASSERT(0) ;
}
}
- if (min_tree >= elapsed) {
+ if (loop == 1) {
+ first = elapsed;
min_tree = elapsed;
- }else {
max_tree = elapsed;
+ sum = elapsed;
+ avg = elapsed;
+ avg_tree = elapsed;
+ } else {
+ if (loop == test_run-1)
+ last = elapsed;
+ if (elapsed > (avg+DELTA))
+ count++;
+ sum = sum + elapsed;
+ avg = sum / loop;
+ if (min_tree > elapsed)
+ min_tree = elapsed;
+ if (max_tree < elapsed)
+ max_tree = elapsed;
+ avg_tree = avg_tree + elapsed;
}
- avg_tree = avg_tree + elapsed;
- }
+ }
avg_tree = (avg_tree / test_run);
- LOGP(DRLCMACDL, LOGL_DEBUG, "\nTest case number :%d\nTime elapsed:\n"
- "min = %Ld\nmax = %Ld\navg = %Ld\n", itr+1, min_tree, max_tree, avg_tree);
+ LOGP(DRLCMACDL, LOGL_DEBUG, "\nTest case number :%d\nTime elapsed:\nFirst = %d\tLast = %d\n"
+ "min = %Ld\nmax = %Ld\navg = %f\nabnormal value occurred %d\n", itr+1, first, last, min_tree, max_tree, avg_tree,count);
}
}
+/*Functoin to check the test vectors*/
+void test_EPDAN_test_vector()
+{
+
+ LOGP(DRLCMACDL, LOGL_DEBUG, "\nCompressed bitmap test vectors check\n");
+ struct bitvec data1;
+ bitvec bits, bits1;
+ uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
+ int itr = 0;
+ for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
+ data1.data_len = ((test1[itr].crbb_len+7)/8);
+ data1.cur_bit = test1[itr].crbb_len;
+ data1.data = test1[itr].data;
+ bits.data = bits_data;
+ bits.data_len = sizeof(bits_data);
+ bits.cur_bit = 0;
+
+ Decoding::decompress_crbb(test[itr].crbb_len, test[itr].cc, test[itr].data, &bits);
+ if (check_result(bits, test[itr].exp_data, test[itr].exp_len) == 0)
+ LOGP (DRLCMACDL, LOGL_DEBUG, "Tree based decoding :Error\n");
+ else
+ LOGP (DRLCMACDL, LOGL_DEBUG, "Tree based decoding :Success\n");
+ bits1.data = bits_data;
+ bits1.data_len = sizeof(bits_data);
+ bits1.cur_bit = 0;
+ osmo_t4_decode(&data1, test[itr].cc, &bits1);
+ if (check_result(bits1, test[itr].exp_data, test[itr].exp_len) == 0)
+ LOGP (DRLCMACDL, LOGL_DEBUG, "Exsiting decoding :Error\n");
+ else
+ LOGP (DRLCMACDL, LOGL_DEBUG, "Existing decoding :Success\n");
+ }
+}
+
static void test_tbf_base()
{
printf("=== start %s ===\n", __func__);
@@ -399,6 +473,7 @@ static void test_tbf_base()
OSMO_ASSERT(GPRS_RLCMAC_UL_TBF == reverse(GPRS_RLCMAC_DL_TBF));
printf("=== end %s ===\n", __func__);
}
+
static void test_tbf_tlli_update()
{
BTS the_bts;
@@ -467,6 +542,7 @@ int pcu_sock_send(struct msgb *msg)
{
return 0;
}
+
static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
{
BTS the_bts;
@@ -1999,15 +2075,10 @@ static void test_tbf_egprs_dl()
setup_bts(&the_bts, ts_no);
bts->dl_tbf_idle_msec = 200;
bts->egprs_enabled = 1;
-
for (i = 1; i <= 9; i++)
establish_and_use_egprs_dl_tbf(&the_bts, i);
-
printf("=== end %s ===\n", __func__);
}
-
-
-
static const struct log_info_cat default_categories[] = {
{"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0},
{"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1},
@@ -2021,7 +2092,6 @@ static const struct log_info_cat default_categories[] = {
{"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1},
{"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1},
};
-
static int filter_fn(const struct log_context *ctx,
struct log_target *tar)
{
@@ -2069,8 +2139,9 @@ int main(int argc, char **argv)
test_tbf_ws();
test_tbf_egprs_two_phase();
test_tbf_egprs_dl();
- test_EPDAN_time_tree(10000, 0);
- test_EPDAN_time_osmot4(10000, 0);
+ test_EPDAN_time_tree(10000, 1);
+ test_EPDAN_time_osmot4(10000, 1);
+ test_EPDAN_test_vector();
if (getenv("TALLOC_REPORT_FULL"))
talloc_report_full(tall_pcu_ctx, stderr);
return EXIT_SUCCESS;