31 #include "ns3/net-device-queue-interface.h"
32 #include "ns3/queue.h"
33 #include "ns3/string.h"
47 .SetGroupName(
"TrafficControl")
119 TypeId(
"ns3::FqPieQueueDisc")
121 .SetGroupName(
"TrafficControl")
123 .AddAttribute(
"UseEcn",
124 "True to use ECN (packets are marked instead of being dropped)",
128 .AddAttribute(
"MarkEcnThreshold",
129 "ECN marking threshold (RFC 8033 suggests 0.1 (i.e., 10%) default)",
132 MakeDoubleChecker<double>(0, 1))
133 .AddAttribute(
"CeThreshold",
134 "The FqPie CE threshold for marking packets",
138 .AddAttribute(
"UseL4s",
139 "True to use L4S (only ECT1 packets are marked at CE threshold)",
143 .AddAttribute(
"MeanPktSize",
144 "Average of packet size",
147 MakeUintegerChecker<uint32_t>())
152 MakeDoubleChecker<double>())
157 MakeDoubleChecker<double>())
158 .AddAttribute(
"Tupdate",
159 "Time period to calculate drop probability",
163 .AddAttribute(
"Supdate",
164 "Start time of the update timer",
168 .AddAttribute(
"MaxSize",
169 "The maximum number of packets accepted by this queue disc",
172 MakeQueueSizeChecker())
173 .AddAttribute(
"DequeueThreshold",
174 "Minimum queue size in bytes before dequeue rate is measured",
177 MakeUintegerChecker<uint32_t>())
178 .AddAttribute(
"QueueDelayReference",
179 "Desired queue delay",
183 .AddAttribute(
"MaxBurstAllowance",
184 "Current max burst allowance before random drop",
188 .AddAttribute(
"UseDequeueRateEstimator",
189 "Enable/Disable usage of Dequeue Rate Estimator",
193 .AddAttribute(
"UseCapDropAdjustment",
194 "Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033",
198 .AddAttribute(
"UseDerandomization",
199 "Enable/Disable Derandomization feature mentioned in RFC 8033",
203 .AddAttribute(
"Flows",
204 "The number of queues into which the incoming packets are classified",
207 MakeUintegerChecker<uint32_t>())
208 .AddAttribute(
"DropBatchSize",
209 "The maximum number of packets dropped from the fat flow",
212 MakeUintegerChecker<uint32_t>())
213 .AddAttribute(
"Perturbation",
214 "The salt used as an additional input to the hash function used to "
218 MakeUintegerChecker<uint32_t>())
219 .AddAttribute(
"EnableSetAssociativeHash",
220 "Enable/Disable Set Associative Hash",
224 .AddAttribute(
"SetWays",
225 "The size of a set of queues (used by set associative hash)",
228 MakeUintegerChecker<uint32_t>());
262 uint32_t h = (flowHash %
m_flows);
264 uint32_t outerHash = h - innerHash;
266 for (uint32_t i = outerHash; i < outerHash +
m_setWays; i++)
283 m_tags[outerHash] = flowHash;
305 flowHash =
static_cast<uint32_t
>(ret);
309 NS_LOG_ERROR(
"No filter has been able to classify this packet, drop it.");
327 NS_LOG_DEBUG(
"Creating a new flow queue with index " << h);
339 flow->SetQueueDisc(qd);
357 flow->GetQueueDisc()->Enqueue(item);
386 if (flow->GetDeficit() <= 0)
388 NS_LOG_DEBUG(
"Increase deficit for new flow index " << flow->GetIndex());
396 NS_LOG_DEBUG(
"Found a new flow " << flow->GetIndex() <<
" with positive deficit");
405 if (flow->GetDeficit() <= 0)
407 NS_LOG_DEBUG(
"Increase deficit for old flow index " << flow->GetIndex());
414 NS_LOG_DEBUG(
"Found an old flow " << flow->GetIndex() <<
" with positive deficit");
425 item = flow->GetQueueDisc()->Dequeue();
429 NS_LOG_DEBUG(
"Could not get a packet from the selected flow queue");
448 flow->IncreaseDeficit(item->GetSize() * -1);
465 NS_LOG_ERROR(
"FqPieQueueDisc cannot have internal queues");
476 if (ndqi && (dev = ndqi->GetObject<
NetDevice>()))
491 NS_LOG_ERROR(
"The number of queues must be an integer multiple of the size "
492 "of the set of queues used by set associative hash");
502 NS_LOG_WARN(
"Enabling ECN as L4S mode is enabled");
535 uint32_t maxBacklog = 0;
544 if (bytes > maxBacklog)
554 uint32_t threshold = maxBacklog >> 1;
560 NS_LOG_DEBUG(
"Drop packet (overflow); count: " << count <<
" len: " << len
561 <<
" threshold: " << threshold);
564 len += item->GetSize();
This class can be used to hold variables of floating point type such as 'double' or 'float'.
A flow queue used by the FqPie queue disc.
void SetIndex(uint32_t index)
Set the index for this flow.
FlowStatus
Used to determine the status of this flow queue.
int32_t m_deficit
the deficit for this flow
void SetStatus(FlowStatus status)
Set the status for this flow.
static TypeId GetTypeId()
Get the type ID.
FlowStatus GetStatus() const
Get the status of this flow.
FlowStatus m_status
the status of this flow
uint32_t m_index
the index for this flow
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
uint32_t GetIndex() const
Get the index of this flow.
FqPieFlow()
FqPieFlow constructor.
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
int32_t GetDeficit() const
Get the deficit for this flow.
A FqPie packet queue disc.
Time m_qDelayRef
Desired queue delay.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
bool m_enableSetAssociativeHash
whether to enable set associative hash
uint32_t m_meanPktSize
Average packet size in bytes.
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
uint32_t GetQuantum() const
Get the quantum value.
uint32_t m_perturbation
hash perturbation value
FqPieQueueDisc()
FqPieQueueDisc constructor.
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
double m_a
Parameter to pie controller.
Time m_sUpdate
Start time of the update timer.
bool m_useDqRateEstimator
Enable/Disable usage of dequeue rate estimator for queue delay calculation.
Time m_ceThreshold
Threshold above which to CE mark.
uint32_t m_dqThreshold
Minimum queue size in bytes before dequeue rate is measured.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
bool CheckConfig() override
Check whether the current configuration is correct.
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
uint32_t m_quantum
Deficit assigned to flows at each round.
Time m_tUpdate
Time period after which CalculateP () is called.
uint32_t FqPieDrop()
Drop a packet from the head of the queue with the largest current byte count.
bool m_isCapDropAdjustment
Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033.
std::list< Ptr< FqPieFlow > > m_newFlows
The list of new flows.
Time m_maxBurst
Maximum burst allowed before random early dropping kicks in.
bool m_useDerandomization
Enable Derandomization feature mentioned in RFC 8033.
uint32_t m_setWays
size of a set of queues (used by set associative hash)
uint32_t m_flows
Number of flow queues.
~FqPieQueueDisc() override
static TypeId GetTypeId()
Get the type ID.
double m_markEcnTh
ECN marking threshold (default 10% as suggested in RFC 8033)
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
void SetQuantum(uint32_t quantum)
Set the quantum value.
double m_b
Parameter to pie controller.
ObjectFactory m_flowFactory
Factory to create a new flow.
std::list< Ptr< FqPieFlow > > m_oldFlows
The list of old flows.
Network layer to device interface.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
static const int PF_NO_MATCH
Standard value used by packet filters to indicate that no match was possible.
Implements PIE Active Queue Management discipline.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscClass is the base class for classes that are included in a queue disc.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
uint32_t GetNBytes() const
Get the amount of bytes stored by the queue disc.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
QueueSize GetCurrentSize() const
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
int32_t Classify(Ptr< QueueDiscItem > item)
Classify a packet by calling the packet filters, one at a time, until either a filter able to classif...
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface() const
void DropAfterDequeue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped after dequeue.
std::size_t GetNQueueDiscClasses() const
Get the number of queue disc classes.
QueueSize GetMaxSize() const
Get the maximum size of the queue disc.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
std::size_t GetNPacketFilters() const
Get the number of packet filters.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
std::size_t GetNInternalQueues() const
Get the number of internal queues.
void DropBeforeEnqueue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped before enqueue.
Class for representing queue sizes.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
QueueSizeUnit
Enumeration of the operating modes of queues.
@ PACKETS
Use number of packets for queue size.
Time Seconds(double value)
Construct a Time in the indicated unit.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
@ MULTIPLE_QUEUES
Used by queue discs with multiple internal queues/child queue discs.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)