Commit 2ff243bd authored by 123's avatar 123 Committed by Your Name

add speed info

parent 6f77ee85
......@@ -83,25 +83,41 @@ void clear_mac_stats(gNB_MAC_INST *gNB) {
}
}
#define DUMP_MAC_STATUS_MAX_UE_NUM 5
#define DUMP_MAC_STATUS_MAX_LC_NUM 64
uint64_t dlsch_total_last[DUMP_MAC_STATUS_MAX_UE_NUM]={0};
uint64_t ulsch_total_last[DUMP_MAC_STATUS_MAX_UE_NUM]={0};
uint64_t mac_lc_dl_last[DUMP_MAC_STATUS_MAX_UE_NUM][DUMP_MAC_STATUS_MAX_LC_NUM]={0};
uint64_t mac_lc_ul_last[DUMP_MAC_STATUS_MAX_UE_NUM][DUMP_MAC_STATUS_MAX_LC_NUM]={0};
size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset_rsrp)
{
int num = 1;
const char *begin = output;
const char *end = output + strlen;
/* this function is called from gNB_dlsch_ulsch_scheduler(), so assumes the
* scheduler to be locked*/
NR_SCHED_ENSURE_LOCKED(&gNB->sched_lock);
NR_SCHED_LOCK(&gNB->UE_info.mutex);
int ue_index = 0;
pthread_mutex_lock(&gNB->UE_info.mutex);
UE_iterator(gNB->UE_info.list, UE) {
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
NR_mac_stats_t *stats = &UE->mac_stats;
const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0;
u_int64_t test_u64 = stats->dl.total_bytes-dlsch_total_last[ue_index];
double test_double = stats->dl.total_bytes-dlsch_total_last[ue_index];
output += snprintf(output,
end - output,
"UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n",
"SPEED: PHY DL %.3f Mbps, UL %.3f Mbps \n",
(double)(stats->dl.total_bytes-dlsch_total_last[ue_index])*8/1280/1000,// bit/per msec/per sec
(double)(stats->ul.total_bytes-ulsch_total_last[ue_index])*8/1280/1000);
output += snprintf(output,
end - output,
"SPEED: MAC DL %.3f Mbps, UL %.3f Mbps \n",
(double)(stats->dl.lc_bytes[4]-mac_lc_dl_last[ue_index][4])*8/1280/1000,
(double)(stats->ul.lc_bytes[4]-mac_lc_ul_last[ue_index][4])*8/1280/1000);
output += snprintf(output,
end - output,
"UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas), UL-SNR %d dB\n",
UE->rnti,
num++,
sched_ctrl->ph,
......@@ -131,11 +147,13 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset
output += snprintf(output,
end - output,
", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n",
", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.3f% MCS %d, RB %d, TBsize %d Byte.\n",
stats->dl.errors,
stats->pucch0_DTX,
sched_ctrl->dl_bler_stats.bler,
sched_ctrl->dl_bler_stats.mcs);
sched_ctrl->dl_bler_stats.bler*100,
sched_ctrl->dl_bler_stats.mcs,
stats->dl.current_rbs,
stats->dl.current_bytes);
if (reset_rsrp) {
stats->num_rsrp_meas = 0;
stats->cumul_rsrp = 0;
......@@ -153,11 +171,13 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset
output += snprintf(output,
end - output,
", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n",
", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.3f% MCS %d, RB %d, TBsize %d Byte.\n",
stats->ulsch_DTX,
stats->ul.errors,
sched_ctrl->ul_bler_stats.bler,
sched_ctrl->ul_bler_stats.mcs);
sched_ctrl->ul_bler_stats.bler*100,
sched_ctrl->ul_bler_stats.mcs,
stats->ul.current_rbs,
stats->ul.current_bytes);
output += snprintf(output,
end - output,
"UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n",
......@@ -179,7 +199,17 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset
UE->rnti,
lc_id,
stats->ul.lc_bytes[lc_id]);
if (reset_rsrp) {
// only count when called by gNB_dlsch_ulsch_scheduler
mac_lc_dl_last[ue_index][lc_id]=stats->dl.lc_bytes[lc_id];
mac_lc_ul_last[ue_index][lc_id]=stats->ul.lc_bytes[lc_id];}
}
if (reset_rsrp) {
// only count when called by gNB_dlsch_ulsch_scheduler
dlsch_total_last[ue_index]=stats->dl.total_bytes;
ulsch_total_last[ue_index]=stats->ul.total_bytes;}
ue_index++;
}
NR_SCHED_UNLOCK(&gNB->UE_info.mutex);
return output - begin;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment