Skip to content

Commit 93c7c9c

Browse files
committed
rlc: adding latency metric to RLC AM in the uplink
1 parent 770fae7 commit 93c7c9c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/rlc/rlc_rx_am_entity.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ void rlc_rx_am_entity::handle_data_pdu(byte_buffer_slice buf)
208208
} else {
209209
logger.log_info("RX SDU. sn={} sdu_len={}", header.sn, sdu.value().length());
210210
metrics.metrics_add_sdus(1, sdu.value().length());
211+
auto latency = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() -
212+
sdu_info.time_of_arrival);
213+
metrics.metrics_add_sdu_latency(latency.count() / 1000);
211214
upper_dn.on_new_sdu(std::move(sdu.value()));
212215
}
213216
// Release all buffers of sdu_data; keep "fully_received == true" for correct construction of status report
@@ -328,7 +331,11 @@ bool rlc_rx_am_entity::handle_full_data_sdu(const rlc_am_pdu_header& header, byt
328331
logger.log_debug("RX SDU. payload_len={} {}", payload.length(), header);
329332

330333
// Add new SN to RX window if no segments have been received yet
331-
rlc_rx_am_sdu_info& rx_sdu = rx_window->has_sn(header.sn) ? (*rx_window)[header.sn] : rx_window->add_sn(header.sn);
334+
rlc_rx_am_sdu_info& rx_sdu = rx_window->has_sn(header.sn) ? (*rx_window)[header.sn] : ([&]() -> rlc_rx_am_sdu_info& {
335+
rlc_rx_am_sdu_info& sdu = rx_window->add_sn(header.sn);
336+
sdu.time_of_arrival = std::chrono::high_resolution_clock::now();
337+
return sdu;
338+
})();
332339

333340
// Store the full SDU and flag it as complete.
334341
rx_sdu.sdu_data = std::move(payload);
@@ -348,7 +355,11 @@ bool rlc_rx_am_entity::handle_segment_data_sdu(const rlc_am_pdu_header& header,
348355
logger.log_debug("RX SDU segment. payload_len={} {}", payload.length(), header);
349356

350357
// Add new SN to RX window if no segments have been received yet
351-
rlc_rx_am_sdu_info& rx_sdu = rx_window->has_sn(header.sn) ? (*rx_window)[header.sn] : rx_window->add_sn(header.sn);
358+
rlc_rx_am_sdu_info& rx_sdu = rx_window->has_sn(header.sn) ? (*rx_window)[header.sn] : ([&]() -> rlc_rx_am_sdu_info& {
359+
rlc_rx_am_sdu_info& sdu = rx_window->add_sn(header.sn);
360+
sdu.time_of_arrival = std::chrono::high_resolution_clock::now();
361+
return sdu;
362+
})();
352363

353364
// Create SDU segment, to be stored later
354365
rlc_rx_am_sdu_segment segment = {};

lib/rlc/rlc_rx_am_entity.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct rlc_rx_am_sdu_info {
4444
bool has_gap = false;
4545
/// Buffer for either a full SDU or a set of SDU segments.
4646
std::variant<byte_buffer_slice, segment_set_t> sdu_data;
47+
/// Time of arrival of the first segment of the SDU.
48+
std::chrono::system_clock::time_point time_of_arrival;
4749
};
4850

4951
/// \brief Rx state variables

0 commit comments

Comments
 (0)