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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Pasquale Imputato <p.imputato@gmail.com>
18 * Stefano Avallone <stefano.avallone@unina.it>
19 *
20 * This code is a port of the dynamic queue limits library implemented
21 * in the Linux kernel by
22 * Author: Tom Herbert <therbert@google.com>
23 */
24
25#ifndef DYNAMIC_QUEUE_LIMITS_H
26#define DYNAMIC_QUEUE_LIMITS_H
27
28#include "queue-limits.h"
29
30#include "ns3/nstime.h"
31#include "ns3/traced-value.h"
32
33#include <limits.h>
34
35namespace ns3
36{
37
38/**
39 * \ingroup network
40 *
41 * DynamicQueueLimits would be used in conjunction with a producer/consumer
42 * type queue (possibly a netdevice queue).
43 * Such a queue would have these general properties:
44 *
45 * 1) Objects are queued up to some limit specified as number of objects.
46 * 2) Periodically a completion process executes which retires consumed
47 * objects.
48 * 3) Starvation occurs when limit has been reached, all queued data has
49 * actually been consumed, but completion processing has not yet run
50 * so queuing new data is blocked.
51 * 4) Minimizing the amount of queued data is desirable.
52 *
53 * The goal of DynamicQueueLimits is to calculate the limit as the minimum
54 * number of objects needed to prevent starvation.
55 *
56 * The primary functions of DynamicQueueLimits are:
57 * Completed - called at completion time to indicate how many objects
58 * were retired from the queue
59 * Available - returns how many objects are available to be queued based
60 * on the object limit and how many objects are already enqueued
61 * Queued - called when objects are enqueued to record number of objects
62 *
63 */
64
66{
67 public:
68 /**
69 * \brief Get the type ID.
70 * \return the object TypeId
71 */
72 static TypeId GetTypeId();
73
75 ~DynamicQueueLimits() override;
76
77 void Reset() override;
78 void Completed(uint32_t count) override;
79 int32_t Available() const override;
80 void Queued(uint32_t count) override;
81
82 private:
83 /**
84 * Calculates the difference between the two operators and
85 * returns the number if positive, zero otherwise.
86 * \param a First operator.
87 * \param b Second operator.
88 * \returns the difference between a and b if positive, zero otherwise.
89 */
91
92 // Fields accessed in enqueue path
93 uint32_t m_numQueued{0}; //!< Total ever queued
94 uint32_t m_adjLimit{0}; //!< limit + num_completed
95 uint32_t m_lastObjCnt{0}; //!< Count at last queuing
96
97 // Fields accessed only by completion path
98 TracedValue<uint32_t> m_limit; //!< Current limit
99 uint32_t m_numCompleted{0}; //!< Total ever completed
100
101 uint32_t m_prevOvlimit{0}; //!< Previous over limit
102 uint32_t m_prevNumQueued{0}; //!< Previous queue total
103 uint32_t m_prevLastObjCnt{0}; //!< Previous queuing cnt
104
105 uint32_t m_lowestSlack{std::numeric_limits<uint32_t>::max()}; //!< Lowest slack found
106 Time m_slackStartTime{Seconds(0)}; //!< Time slacks seen
107
108 // Configuration
109 uint32_t m_maxLimit; //!< Max limit
110 uint32_t m_minLimit; //!< Minimum limit
111 Time m_slackHoldTime; //!< Time to measure slack
112};
113
114} // namespace ns3
115
116#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.
Definition: queue-limits.h:44
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.