A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dynamic-queue-limits.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Pasquale Imputato <p.imputato@gmail.com>
7 * Stefano Avallone <stefano.avallone@unina.it>
8 *
9 * This code is a port of the dynamic queue limits library implemented
10 * in the Linux kernel by
11 * Author: Tom Herbert <therbert@google.com>
12 */
13
14#ifndef DYNAMIC_QUEUE_LIMITS_H
15#define DYNAMIC_QUEUE_LIMITS_H
16
17#include "queue-limits.h"
18
19#include "ns3/nstime.h"
20#include "ns3/traced-value.h"
21
22#include <limits.h>
23
24namespace ns3
25{
26
27/**
28 * \ingroup network
29 *
30 * DynamicQueueLimits would be used in conjunction with a producer/consumer
31 * type queue (possibly a netdevice queue).
32 * Such a queue would have these general properties:
33 *
34 * 1) Objects are queued up to some limit specified as number of objects.
35 * 2) Periodically a completion process executes which retires consumed
36 * objects.
37 * 3) Starvation occurs when limit has been reached, all queued data has
38 * actually been consumed, but completion processing has not yet run
39 * so queuing new data is blocked.
40 * 4) Minimizing the amount of queued data is desirable.
41 *
42 * The goal of DynamicQueueLimits is to calculate the limit as the minimum
43 * number of objects needed to prevent starvation.
44 *
45 * The primary functions of DynamicQueueLimits are:
46 * Completed - called at completion time to indicate how many objects
47 * were retired from the queue
48 * Available - returns how many objects are available to be queued based
49 * on the object limit and how many objects are already enqueued
50 * Queued - called when objects are enqueued to record number of objects
51 *
52 */
53
55{
56 public:
57 /**
58 * \brief Get the type ID.
59 * \return the object TypeId
60 */
61 static TypeId GetTypeId();
62
64 ~DynamicQueueLimits() override;
65
66 void Reset() override;
67 void Completed(uint32_t count) override;
68 int32_t Available() const override;
69 void Queued(uint32_t count) override;
70
71 private:
72 /**
73 * Calculates the difference between the two operators and
74 * returns the number if positive, zero otherwise.
75 * \param a First operator.
76 * \param b Second operator.
77 * \returns the difference between a and b if positive, zero otherwise.
78 */
80
81 // Fields accessed in enqueue path
82 uint32_t m_numQueued{0}; //!< Total ever queued
83 uint32_t m_adjLimit{0}; //!< limit + num_completed
84 uint32_t m_lastObjCnt{0}; //!< Count at last queuing
85
86 // Fields accessed only by completion path
87 TracedValue<uint32_t> m_limit; //!< Current limit
88 uint32_t m_numCompleted{0}; //!< Total ever completed
89
90 uint32_t m_prevOvlimit{0}; //!< Previous over limit
91 uint32_t m_prevNumQueued{0}; //!< Previous queue total
92 uint32_t m_prevLastObjCnt{0}; //!< Previous queuing cnt
93
94 uint32_t m_lowestSlack{std::numeric_limits<uint32_t>::max()}; //!< Lowest slack found
95 Time m_slackStartTime{Seconds(0)}; //!< Time slacks seen
96
97 // Configuration
98 uint32_t m_maxLimit; //!< Max limit
99 uint32_t m_minLimit; //!< Minimum limit
100 Time m_slackHoldTime; //!< Time to measure slack
101};
102
103} // namespace ns3
104
105#endif /* DYNAMIC_QUEUE_LIMITS_H */
DynamicQueueLimits would be used in conjunction with a producer/consumer type queue (possibly a netde...
uint32_t m_adjLimit
limit + num_completed
void Reset() override
Reset queue limits state.
uint32_t m_numCompleted
Total ever completed.
Time m_slackStartTime
Time slacks seen.
uint32_t m_numQueued
Total ever queued.
uint32_t m_prevOvlimit
Previous over limit.
uint32_t m_minLimit
Minimum limit.
Time m_slackHoldTime
Time to measure slack.
uint32_t m_prevNumQueued
Previous queue total.
uint32_t m_lastObjCnt
Count at last queuing.
uint32_t m_prevLastObjCnt
Previous queuing cnt.
static TypeId GetTypeId()
Get the type ID.
void Completed(uint32_t count) override
Record number of completed bytes and recalculate the limit.
int32_t Posdiff(int32_t a, int32_t b)
Calculates the difference between the two operators and returns the number if positive,...
uint32_t m_lowestSlack
Lowest slack found.
int32_t Available() const override
Available is called from NotifyTransmittedBytes to calculate the number of bytes that can be passed a...
TracedValue< uint32_t > m_limit
Current limit.
void Queued(uint32_t count) override
Record the number of bytes queued.
uint32_t m_maxLimit
Max limit.
Abstract base class for NetDevice queue length controller.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.