llc: Keep track of the number of stored LLC octets
To get the number of LLC octets that are stored in the queue, this commit adds a m_queue_octets member along with a octets() method. This value is updated similarly to m_queue_size on each modifying method call. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
1eae96ca2f
commit
07eb655244
|
@ -100,12 +100,14 @@ void gprs_llc_queue::init()
|
||||||
{
|
{
|
||||||
INIT_LLIST_HEAD(&m_queue);
|
INIT_LLIST_HEAD(&m_queue);
|
||||||
m_queue_size = 0;
|
m_queue_size = 0;
|
||||||
|
m_queue_octets = 0;
|
||||||
m_avg_queue_delay = 0;
|
m_avg_queue_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc_queue::enqueue(struct msgb *llc_msg)
|
void gprs_llc_queue::enqueue(struct msgb *llc_msg)
|
||||||
{
|
{
|
||||||
m_queue_size += 1;
|
m_queue_size += 1;
|
||||||
|
m_queue_octets += msgb_length(llc_msg) - 2*sizeof(struct timeval);
|
||||||
msgb_enqueue(&m_queue, llc_msg);
|
msgb_enqueue(&m_queue, llc_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +122,7 @@ void gprs_llc_queue::clear(BTS *bts)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queue_size = 0;
|
m_queue_size = 0;
|
||||||
|
m_queue_octets = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ALPHA 0.5f
|
#define ALPHA 0.5f
|
||||||
|
@ -136,6 +139,7 @@ struct msgb *gprs_llc_queue::dequeue()
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
m_queue_size -= 1;
|
m_queue_size -= 1;
|
||||||
|
m_queue_octets -= msgb_length(msg) - 2*sizeof(struct timeval);
|
||||||
|
|
||||||
/* take the second time */
|
/* take the second time */
|
||||||
gettimeofday(&tv_now, NULL);
|
gettimeofday(&tv_now, NULL);
|
||||||
|
|
|
@ -73,10 +73,12 @@ struct gprs_llc_queue {
|
||||||
struct msgb *dequeue();
|
struct msgb *dequeue();
|
||||||
void clear(BTS *bts);
|
void clear(BTS *bts);
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
size_t octets() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_avg_queue_delay; /* Average delay of data going through the queue */
|
uint32_t m_avg_queue_delay; /* Average delay of data going through the queue */
|
||||||
size_t m_queue_size;
|
size_t m_queue_size;
|
||||||
|
size_t m_queue_octets;
|
||||||
struct llist_head m_queue; /* queued LLC DL data */
|
struct llist_head m_queue; /* queued LLC DL data */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -118,3 +120,8 @@ inline size_t gprs_llc_queue::size() const
|
||||||
{
|
{
|
||||||
return this ? m_queue_size : 0;
|
return this ? m_queue_size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline size_t gprs_llc_queue::octets() const
|
||||||
|
{
|
||||||
|
return this ? m_queue_octets : 0;
|
||||||
|
}
|
||||||
|
|
|
@ -102,24 +102,31 @@ static void test_llc_queue()
|
||||||
|
|
||||||
queue.init();
|
queue.init();
|
||||||
OSMO_ASSERT(queue.size() == 0);
|
OSMO_ASSERT(queue.size() == 0);
|
||||||
|
OSMO_ASSERT(queue.octets() == 0);
|
||||||
|
|
||||||
enqueue_data(&queue, "LLC message");
|
enqueue_data(&queue, "LLC message");
|
||||||
OSMO_ASSERT(queue.size() == 1);
|
OSMO_ASSERT(queue.size() == 1);
|
||||||
|
OSMO_ASSERT(queue.octets() == 11);
|
||||||
|
|
||||||
enqueue_data(&queue, "other LLC message");
|
enqueue_data(&queue, "other LLC message");
|
||||||
OSMO_ASSERT(queue.size() == 2);
|
OSMO_ASSERT(queue.size() == 2);
|
||||||
|
OSMO_ASSERT(queue.octets() == 28);
|
||||||
|
|
||||||
dequeue_and_check(&queue, "LLC message");
|
dequeue_and_check(&queue, "LLC message");
|
||||||
OSMO_ASSERT(queue.size() == 1);
|
OSMO_ASSERT(queue.size() == 1);
|
||||||
|
OSMO_ASSERT(queue.octets() == 17);
|
||||||
|
|
||||||
dequeue_and_check(&queue, "other LLC message");
|
dequeue_and_check(&queue, "other LLC message");
|
||||||
OSMO_ASSERT(queue.size() == 0);
|
OSMO_ASSERT(queue.size() == 0);
|
||||||
|
OSMO_ASSERT(queue.octets() == 0);
|
||||||
|
|
||||||
enqueue_data(&queue, "LLC");
|
enqueue_data(&queue, "LLC");
|
||||||
OSMO_ASSERT(queue.size() == 1);
|
OSMO_ASSERT(queue.size() == 1);
|
||||||
|
OSMO_ASSERT(queue.octets() == 3);
|
||||||
|
|
||||||
queue.clear(NULL);
|
queue.clear(NULL);
|
||||||
OSMO_ASSERT(queue.size() == 0);
|
OSMO_ASSERT(queue.size() == 0);
|
||||||
|
OSMO_ASSERT(queue.octets() == 0);
|
||||||
|
|
||||||
printf("=== end %s ===\n", __func__);
|
printf("=== end %s ===\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue