A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
24
namespace
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
54
class
DynamicQueueLimits
:
public
QueueLimits
55
{
56
public
:
57
/**
58
* \brief Get the type ID.
59
* \return the object TypeId
60
*/
61
static
TypeId
GetTypeId
();
62
63
DynamicQueueLimits
();
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
*/
79
int32_t
Posdiff
(
int32_t
a,
int32_t
b);
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 */
int32_t
ns3::DynamicQueueLimits
DynamicQueueLimits would be used in conjunction with a producer/consumer type queue (possibly a netde...
Definition
dynamic-queue-limits.h:55
ns3::DynamicQueueLimits::m_adjLimit
uint32_t m_adjLimit
limit + num_completed
Definition
dynamic-queue-limits.h:83
ns3::DynamicQueueLimits::~DynamicQueueLimits
~DynamicQueueLimits() override
Definition
dynamic-queue-limits.cc:69
ns3::DynamicQueueLimits::DynamicQueueLimits
DynamicQueueLimits()
Definition
dynamic-queue-limits.cc:63
ns3::DynamicQueueLimits::Reset
void Reset() override
Reset queue limits state.
Definition
dynamic-queue-limits.cc:75
ns3::DynamicQueueLimits::m_numCompleted
uint32_t m_numCompleted
Total ever completed.
Definition
dynamic-queue-limits.h:88
ns3::DynamicQueueLimits::m_slackStartTime
Time m_slackStartTime
Time slacks seen.
Definition
dynamic-queue-limits.h:95
ns3::DynamicQueueLimits::m_numQueued
uint32_t m_numQueued
Total ever queued.
Definition
dynamic-queue-limits.h:82
ns3::DynamicQueueLimits::m_prevOvlimit
uint32_t m_prevOvlimit
Previous over limit.
Definition
dynamic-queue-limits.h:90
ns3::DynamicQueueLimits::m_minLimit
uint32_t m_minLimit
Minimum limit.
Definition
dynamic-queue-limits.h:99
ns3::DynamicQueueLimits::m_slackHoldTime
Time m_slackHoldTime
Time to measure slack.
Definition
dynamic-queue-limits.h:100
ns3::DynamicQueueLimits::m_prevNumQueued
uint32_t m_prevNumQueued
Previous queue total.
Definition
dynamic-queue-limits.h:91
ns3::DynamicQueueLimits::m_lastObjCnt
uint32_t m_lastObjCnt
Count at last queuing.
Definition
dynamic-queue-limits.h:84
ns3::DynamicQueueLimits::m_prevLastObjCnt
uint32_t m_prevLastObjCnt
Previous queuing cnt.
Definition
dynamic-queue-limits.h:92
ns3::DynamicQueueLimits::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
dynamic-queue-limits.cc:34
ns3::DynamicQueueLimits::Completed
void Completed(uint32_t count) override
Record number of completed bytes and recalculate the limit.
Definition
dynamic-queue-limits.cc:91
ns3::DynamicQueueLimits::Posdiff
int32_t Posdiff(int32_t a, int32_t b)
Calculates the difference between the two operators and returns the number if positive,...
Definition
dynamic-queue-limits.cc:217
ns3::DynamicQueueLimits::m_lowestSlack
uint32_t m_lowestSlack
Lowest slack found.
Definition
dynamic-queue-limits.h:94
ns3::DynamicQueueLimits::Available
int32_t Available() const override
Available is called from NotifyTransmittedBytes to calculate the number of bytes that can be passed a...
Definition
dynamic-queue-limits.cc:200
ns3::DynamicQueueLimits::m_limit
TracedValue< uint32_t > m_limit
Current limit.
Definition
dynamic-queue-limits.h:87
ns3::DynamicQueueLimits::Queued
void Queued(uint32_t count) override
Record the number of bytes queued.
Definition
dynamic-queue-limits.cc:207
ns3::DynamicQueueLimits::m_maxLimit
uint32_t m_maxLimit
Max limit.
Definition
dynamic-queue-limits.h:98
ns3::QueueLimits
Abstract base class for NetDevice queue length controller.
Definition
queue-limits.h:33
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TracedValue
Trace classes with value semantics.
Definition
traced-value.h:105
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
queue-limits.h
src
network
utils
dynamic-queue-limits.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0