Add RLC stats: avg time to tx for an RLC SDU
This commit is contained in:
committed by
Chieh-Chun Chen
parent
6a23bcfb42
commit
fad3f23164
@@ -29,12 +29,16 @@
|
||||
|
||||
#include "LOG/log.h"
|
||||
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
static void nr_rlc_entity_get_stats(
|
||||
nr_rlc_entity_t *entity,
|
||||
nr_rlc_statistics_t *out)
|
||||
{
|
||||
// printf("Stats from the RLC entity asked\n");
|
||||
*out = entity->stats;
|
||||
out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx,
|
||||
time_average_now());
|
||||
}
|
||||
|
||||
nr_rlc_entity_t *new_nr_rlc_entity_am(
|
||||
@@ -105,6 +109,11 @@ nr_rlc_entity_t *new_nr_rlc_entity_am(
|
||||
|
||||
ret->common.stats.mode = 0; /* 0 for AM */
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -155,6 +164,11 @@ nr_rlc_entity_t *new_nr_rlc_entity_um(
|
||||
|
||||
ret->common.stats.mode = 1; /* 1 for UM */
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -190,5 +204,10 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm(
|
||||
|
||||
ret->common.stats.mode = 2; /* 2 for TM */
|
||||
|
||||
/* let's take average over the last 100 milliseconds
|
||||
* initial_size of 1024 is arbitrary
|
||||
*/
|
||||
ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024);
|
||||
|
||||
return (nr_rlc_entity_t *)ret;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
#define NR_SDU_MAX 16000 /* max NR PDCP SDU size is 9000, let's take more */
|
||||
|
||||
typedef struct {
|
||||
@@ -77,6 +79,16 @@ typedef struct {
|
||||
uint32_t rxsdu_bytes; /* number of bytes of SDUs received */
|
||||
uint32_t rxsdu_dd_pkts; /* number of dropped or discarded SDUs */
|
||||
uint32_t rxsdu_dd_bytes; /* number of bytes of SDUs dropped or discarded */
|
||||
|
||||
/* Average time for an SDU to be passed to MAC.
|
||||
* Actually measures the time it takes for any part of an SDU to be
|
||||
* passed to MAC for the first time, that is: the first TX of (part of) the
|
||||
* SDU.
|
||||
* Since the MAC schedules in advance, it does not measure the time of
|
||||
* transmission over the air, just the time to reach the MAC layer.
|
||||
*/
|
||||
double txsdu_avg_time_to_tx;
|
||||
|
||||
} nr_rlc_statistics_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -124,6 +136,7 @@ typedef struct nr_rlc_entity_t {
|
||||
nr_rlc_entity_buffer_status_t bstatus;
|
||||
|
||||
nr_rlc_statistics_t stats;
|
||||
time_average_t *txsdu_avg_time_to_tx;
|
||||
} nr_rlc_entity_t;
|
||||
|
||||
nr_rlc_entity_t *new_nr_rlc_entity_am(
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "nr_rlc_pdu.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
/* for a given SDU/SDU segment, computes the corresponding PDU header size */
|
||||
static int compute_pdu_header_size(nr_rlc_entity_am_t *entity,
|
||||
@@ -1620,6 +1621,14 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size)
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += ret_size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
return ret_size;
|
||||
// return serialize_sdu(entity, sdu, buffer, size, p);
|
||||
}
|
||||
@@ -1708,6 +1717,8 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity,
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu)
|
||||
+ sdu->size;
|
||||
|
||||
sdu->sdu->time_of_arrival = time_average_now();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -1949,6 +1960,7 @@ void nr_rlc_entity_am_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "nr_rlc_pdu.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
|
||||
@@ -78,6 +79,13 @@ static int generate_tx_pdu(nr_rlc_entity_tm_t *entity, char *buffer, int size)
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
/* update buffer status */
|
||||
entity->common.bstatus.tx_size -= sdu->size;
|
||||
@@ -189,6 +197,7 @@ void nr_rlc_entity_tm_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "nr_rlc_pdu.h"
|
||||
|
||||
#include "LOG/log.h"
|
||||
#include "common/utils/time_stat.h"
|
||||
|
||||
/* for a given SDU/SDU segment, computes the corresponding PDU header size */
|
||||
static int compute_pdu_header_size(nr_rlc_entity_um_t *entity,
|
||||
@@ -516,12 +517,19 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size)
|
||||
ret = serialize_sdu(entity, sdu, buffer, size);
|
||||
|
||||
entity->tx_size -= sdu->size;
|
||||
nr_rlc_free_sdu_segment(sdu);
|
||||
|
||||
entity->common.stats.txpdu_pkts++;
|
||||
entity->common.stats.txpdu_bytes += size;
|
||||
|
||||
if (sdu->sdu->time_of_arrival) {
|
||||
uint64_t time_now = time_average_now();
|
||||
uint64_t waited_time = time_now - sdu->sdu->time_of_arrival;
|
||||
/* set time_of_arrival to 0 so as to update stats only once */
|
||||
sdu->sdu->time_of_arrival = 0;
|
||||
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
|
||||
}
|
||||
|
||||
nr_rlc_free_sdu_segment(sdu);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -736,6 +744,7 @@ void nr_rlc_entity_um_delete(nr_rlc_entity_t *_entity)
|
||||
{
|
||||
nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity;
|
||||
clear_entity(entity);
|
||||
time_average_free(entity->common.txsdu_avg_time_to_tx);
|
||||
free(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef _NR_RLC_SDU_H_
|
||||
#define _NR_RLC_SDU_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct nr_rlc_sdu_t {
|
||||
int sn;
|
||||
int upper_layer_id;
|
||||
@@ -34,6 +36,12 @@ typedef struct nr_rlc_sdu_t {
|
||||
* when it equals ref_count we can free the SDU
|
||||
* completely
|
||||
*/
|
||||
|
||||
/* for statistics, will be set to 0 after SDU (or first part of it) has
|
||||
* been serialized for MAC for the first time so that only the first
|
||||
* transmission is used for statistics
|
||||
*/
|
||||
uint64_t time_of_arrival; /* unit microsecond */
|
||||
} nr_rlc_sdu_t;
|
||||
|
||||
typedef struct nr_rlc_sdu_segment_t {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -g --coverage -I.
|
||||
CFLAGS=-Wall -g --coverage -I. -I../../../..
|
||||
|
||||
LIB=nr_rlc_entity.o nr_rlc_entity_am.o nr_rlc_entity_um.o nr_rlc_entity_tm.o \
|
||||
nr_rlc_pdu.o nr_rlc_sdu.o
|
||||
nr_rlc_pdu.o nr_rlc_sdu.o time_stat.o
|
||||
|
||||
tests:
|
||||
@./run_tests.sh
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "../../../../common/utils/time_stat.h"
|
||||
|
||||
time_average_t *time_average_new(int duration, int initial_size)
|
||||
{
|
||||
return (void *)0;
|
||||
}
|
||||
|
||||
void time_average_free(time_average_t *t)
|
||||
{
|
||||
}
|
||||
|
||||
void time_average_add(time_average_t *t, uint64_t time, uint64_t value)
|
||||
{
|
||||
}
|
||||
|
||||
double time_average_get_average(time_average_t *t, uint64_t time)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t time_average_now(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user