diff --git a/srsue/hdr/stack/upper/gw.h b/srsue/hdr/stack/upper/gw.h index 510b27a92..83d0139cd 100644 --- a/srsue/hdr/stack/upper/gw.h +++ b/srsue/hdr/stack/upper/gw.h @@ -43,7 +43,7 @@ public: int init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack); void stop(); - void get_metrics(gw_metrics_t& m); + void get_metrics(gw_metrics_t& m, const uint32_t nof_tti); // PDCP interface void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); @@ -82,8 +82,8 @@ private: uint32_t current_ip_addr = 0; uint8_t current_if_id[8]; - long ul_tput_bytes = 0; - long dl_tput_bytes = 0; + uint32_t ul_tput_bytes = 0; + uint32_t dl_tput_bytes = 0; struct timeval metrics_time[3]; void run_thread(); diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 510277b74..fe306d809 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -84,15 +84,24 @@ void gw::stop() } } -void gw::get_metrics(gw_metrics_t& m) +void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti) { gettimeofday(&metrics_time[2], NULL); get_time_interval(metrics_time); - double secs = (double)metrics_time[0].tv_sec + metrics_time[0].tv_usec * 1e-6; - m.dl_tput_mbps = (dl_tput_bytes * 8 / (double)1e6) / secs; - m.ul_tput_mbps = (ul_tput_bytes * 8 / (double)1e6) / secs; - log.info("RX throughput: %4.6f Mbps. TX throughput: %4.6f Mbps.\n", m.dl_tput_mbps, m.ul_tput_mbps); + double secs = (double)metrics_time[0].tv_sec + metrics_time[0].tv_usec * 1e-6; + double dl_tput_mbps_real_time = (dl_tput_bytes * 8 / (double)1e6) / secs; + double ul_tput_mbps_real_time = (ul_tput_bytes * 8 / (double)1e6) / secs; + + // Use the provided TTI counter to compute rate for metrics interface + m.dl_tput_mbps = (dl_tput_bytes * 8 / (double)1e6) / (nof_tti / 1000.0); + m.ul_tput_mbps = (ul_tput_bytes * 8 / (double)1e6) / (nof_tti / 1000.0); + + log.info("gw_rx_rate_mbps=%4.2f (real=%4.2f), gw_tx_rate_mbps=%4.2f (real=%4.2f)\n", + m.dl_tput_mbps, + dl_tput_mbps_real_time, + m.ul_tput_mbps, + ul_tput_mbps_real_time); memcpy(&metrics_time[1], &metrics_time[2], sizeof(struct timeval)); dl_tput_bytes = 0; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index bab1a0a23..2c463c6a7 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -298,7 +298,7 @@ bool ue::get_metrics(ue_metrics_t* m) phy->get_metrics(&m->phy); radio->get_metrics(&m->rf); stack->get_metrics(&m->stack); - gw_inst->get_metrics(m->gw); + gw_inst->get_metrics(m->gw, m->stack.mac[0].nof_tti); return true; }