From 9c623892f5bb2bcc058a43c4d18aa2ce3bff2383 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Wed, 4 Dec 2013 18:11:47 +0100 Subject: llc: Calculate the average queuing delay of the LLC queues Use a formula like it is used with TCP. This can help to make decisions about if frames should be dropped or not at the time we enqueue them. This code will store two timeval structs in fron the of the actual data and compute the average at the time of the dequeue. --- src/tbf.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/tbf.cpp') diff --git a/src/tbf.cpp b/src/tbf.cpp index 4c0e845a..5d7e4efb 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -100,12 +100,14 @@ int gprs_rlcmac_tbf::append_data(const uint8_t ms_class, /* the TBF exists, so we must write it in the queue * we prepend lifetime in front of PDU */ struct timeval *tv; - struct msgb *llc_msg = msgb_alloc(len + sizeof(*tv), + struct msgb *llc_msg = msgb_alloc(len + sizeof(*tv) * 2, "llc_pdu_queue"); if (!llc_msg) return -ENOMEM; tv = (struct timeval *)msgb_put(llc_msg, sizeof(*tv)); gprs_llc::calc_pdu_lifetime(bts, pdu_delay_csec, tv); + tv = (struct timeval *)msgb_put(llc_msg, sizeof(*tv)); + gettimeofday(tv, NULL); memcpy(msgb_put(llc_msg, len), data, len); m_llc.enqueue(llc_msg); tbf_update_ms_class(this, ms_class); @@ -633,6 +635,7 @@ struct msgb *gprs_rlcmac_tbf::llc_dequeue(bssgp_bvc_ctx *bctx) while ((msg = m_llc.dequeue())) { tv = (struct timeval *)msg->data; msgb_pull(msg, sizeof(*tv)); + msgb_pull(msg, sizeof(*tv)); if (gprs_llc::is_frame_expired(&tv_now, tv)) { LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU " -- cgit v1.2.3