:::warning
# <center><i class="fa fa-edit"></i>read rlc</center>
:::
[TOC]
Here is a source code of read_rlc_sm function
```c
void read_rlc_sm(rlc_ind_msg_t* data)
{
assert(data != NULL);
const NR_UE_info_t* UE_info = &RC.nrmac[mod_id]->UE_info;
uint32_t const act_rb = num_act_rb(UE_info);
//assert(0!=0 && "Read RLC called");
data->len = act_rb;
if(data->len > 0){
data->rb = calloc(data->len, sizeof(rlc_radio_bearer_stats_t));
assert(data->rb != NULL && "Memory exhausted");
}
data->tstamp = time_now_us();
const NR_list_t* ue_list = &UE_info->list;
uint32_t i = 0;
for (int ue_id = ue_list->head; ue_id >= 0; ue_id = ue_list->next[ue_id]) {
uint16_t const rnti = UE_info->rnti[ue_id];
//for every LC ID
for(int rb_id = 1; rb_id < 6; ++rb_id ){
nr_rlc_statistics_t rb_rlc = {0};
const int srb_flag = 0;
const int rc = nr_rlc_get_statistics(rnti, srb_flag, rb_id, &rb_rlc);
if(rc == 0) continue;
rlc_radio_bearer_stats_t* sm_rb = &data->rb[i];
sm_rb->txpdu_pkts = rb_rlc.txpdu_pkts;
sm_rb->txpdu_bytes = rb_rlc.txpdu_bytes; /* aggregated amount of transmitted bytes in RLC PDUs */
sm_rb->txpdu_wt_ms = rb_rlc.txpdu_wt_ms; /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */
sm_rb->txpdu_dd_pkts = rb_rlc.txpdu_dd_pkts; /* aggregated number of dropped or discarded tx packets by RLC */
sm_rb->txpdu_dd_bytes = rb_rlc.txpdu_dd_bytes; /* aggregated amount of bytes dropped or discarded tx packets by RLC */
sm_rb->txpdu_retx_pkts = rb_rlc.txpdu_retx_pkts; /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */
sm_rb->txpdu_retx_bytes = rb_rlc.txpdu_retx_bytes ; /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */
sm_rb->txpdu_segmented = rb_rlc.txpdu_segmented ; /* aggregated number of segmentations */
sm_rb->txpdu_status_pkts = rb_rlc.txpdu_status_pkts ; /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */
sm_rb->txpdu_status_bytes = rb_rlc.txpdu_status_bytes ; /* aggregated amount of tx status bytes (only applicable to RLC AM) */
sm_rb->txbuf_occ_bytes = rb_rlc.txbuf_occ_bytes ; /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
sm_rb->txbuf_occ_pkts = rb_rlc.txbuf_occ_pkts ; /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* RX */
sm_rb->rxpdu_pkts = rb_rlc.rxpdu_pkts ; /* aggregated number of received RLC PDUs */
sm_rb->rxpdu_bytes = rb_rlc.rxpdu_bytes ; /* amount of bytes received by the RLC */
sm_rb->rxpdu_dup_pkts = rb_rlc.rxpdu_dup_pkts ; /* aggregated number of duplicate packets */
sm_rb->rxpdu_dup_bytes = rb_rlc.rxpdu_dup_bytes ; /* aggregated amount of duplicated bytes */
sm_rb->rxpdu_dd_pkts = rb_rlc.rxpdu_dd_pkts ; /* aggregated number of rx packets dropped or discarded by RLC */
sm_rb->rxpdu_dd_bytes = rb_rlc.rxpdu_dd_bytes ; /* aggregated amount of rx bytes dropped or discarded by RLC */
sm_rb->rxpdu_ow_pkts = rb_rlc.rxpdu_ow_pkts ; /* aggregated number of out of window received RLC pdu */
sm_rb->rxpdu_ow_bytes = rb_rlc.rxpdu_ow_bytes ; /* aggregated number of out of window bytes received RLC pdu */
sm_rb->rxpdu_status_pkts = rb_rlc.rxpdu_status_pkts ; /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */
sm_rb->rxpdu_status_bytes = rb_rlc.rxpdu_status_bytes ; /* aggregated amount of rx status bytes (only applicable to RLC AM) */
sm_rb->rxbuf_occ_bytes = rb_rlc.rxbuf_occ_bytes ; /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
sm_rb->rxbuf_occ_pkts = rb_rlc.rxbuf_occ_pkts ; /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* TX */
sm_rb->txsdu_pkts = rb_rlc.txsdu_pkts ; /* number of SDUs delivered */
sm_rb->txsdu_bytes = rb_rlc.txsdu_bytes ; /* number of bytes of SDUs delivered */
/* RX */
sm_rb->rxsdu_pkts = rb_rlc.rxsdu_pkts ; /* number of SDUs received */
sm_rb->rxsdu_bytes = rb_rlc.rxsdu_bytes ; /* number of bytes of SDUs received */
sm_rb->rxsdu_dd_pkts = rb_rlc.rxsdu_dd_pkts ; /* number of dropped or discarded SDUs */
sm_rb->rxsdu_dd_bytes = rb_rlc.rxsdu_dd_bytes ; /* number of bytes of SDUs dropped or discarded */
sm_rb->mode = rb_rlc.mode; /* 0: RLC AM, 1: RLC UM, 2: RLC TM */
sm_rb->rnti = rnti;
sm_rb->rbid = rb_id;
++i;
}
}
}
```
- [***num_act_rb***](https://hackmd.io/3dFtD0nxTW6lWU-qJLWHEA) - function for using MAC structure to get RNTIs
- [***rlc_radio_bearer_stats_t***](https://hackmd.io/BsxK4vgASJiyen1LBHd9tA) - function with all RLC radio bearer options
- [***NR_list_t***](https://hackmd.io/2624JYfuRhSmZgkESFRQJg) - NR_list_t is a "list" (of users, HARQ processes, slices). Especially useful in the scheduler and to keep "classes" of users.
- [***nr_rlc_statistics_t***](https://hackmd.io/rDeEqEbSQ-OOp4qyeI2y-g) - function with all PDU/SDU stats