|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
29 #include "ns3/string.h"
30 #include "ns3/queue.h"
33 #include "ns3/net-device-queue-interface.h"
45 .SetGroupName (
"TrafficControl")
119 .SetGroupName (
"TrafficControl")
121 .AddAttribute (
"UseEcn",
122 "True to use ECN (packets are marked instead of being dropped)",
126 .AddAttribute (
"MarkEcnThreshold",
127 "ECN marking threshold (RFC 8033 suggests 0.1 (i.e., 10%) default)",
130 MakeDoubleChecker<double> (0, 1))
131 .AddAttribute (
"CeThreshold",
132 "The FqPie CE threshold for marking packets",
136 .AddAttribute (
"UseL4s",
137 "True to use L4S (only ECT1 packets are marked at CE threshold)",
141 .AddAttribute (
"MeanPktSize",
142 "Average of packet size",
145 MakeUintegerChecker<uint32_t> ())
150 MakeDoubleChecker<double> ())
155 MakeDoubleChecker<double> ())
156 .AddAttribute (
"Tupdate",
157 "Time period to calculate drop probability",
161 .AddAttribute (
"Supdate",
162 "Start time of the update timer",
166 .AddAttribute (
"MaxSize",
167 "The maximum number of packets accepted by this queue disc",
172 .AddAttribute (
"DequeueThreshold",
173 "Minimum queue size in bytes before dequeue rate is measured",
176 MakeUintegerChecker<uint32_t> ())
177 .AddAttribute (
"QueueDelayReference",
178 "Desired queue delay",
182 .AddAttribute (
"MaxBurstAllowance",
183 "Current max burst allowance before random drop",
187 .AddAttribute (
"UseDequeueRateEstimator",
188 "Enable/Disable usage of Dequeue Rate Estimator",
192 .AddAttribute (
"UseCapDropAdjustment",
193 "Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033",
197 .AddAttribute (
"UseDerandomization",
198 "Enable/Disable Derandomization feature mentioned in RFC 8033",
202 .AddAttribute (
"Flows",
203 "The number of queues into which the incoming packets are classified",
206 MakeUintegerChecker<uint32_t> ())
207 .AddAttribute (
"DropBatchSize",
208 "The maximum number of packets dropped from the fat flow",
211 MakeUintegerChecker<uint32_t> ())
212 .AddAttribute (
"Perturbation",
213 "The salt used as an additional input to the hash function used to classify packets",
216 MakeUintegerChecker<uint32_t> ())
217 .AddAttribute (
"EnableSetAssociativeHash",
218 "Enable/Disable Set Associative Hash",
222 .AddAttribute (
"SetWays",
223 "The size of a set of queues (used by set associative hash)",
226 MakeUintegerChecker<uint32_t> ())
261 uint32_t h = (flowHash %
m_flows);
263 uint32_t outerHash = h - innerHash;
265 for (uint32_t i = outerHash; i < outerHash +
m_setWays; i++)
281 m_tags[outerHash] = flowHash;
290 uint32_t flowHash, h;
302 flowHash =
static_cast<uint32_t
> (ret);
306 NS_LOG_ERROR (
"No filter has been able to classify this packet, drop it.");
324 NS_LOG_DEBUG (
"Creating a new flow queue with index " << h);
336 flow->SetQueueDisc (qd);
354 flow->GetQueueDisc ()->Enqueue (item);
383 if (flow->GetDeficit () <= 0)
385 NS_LOG_DEBUG (
"Increase deficit for new flow index " << flow->GetIndex ());
393 NS_LOG_DEBUG (
"Found a new flow " << flow->GetIndex () <<
" with positive deficit");
402 if (flow->GetDeficit () <= 0)
404 NS_LOG_DEBUG (
"Increase deficit for old flow index " << flow->GetIndex ());
411 NS_LOG_DEBUG (
"Found an old flow " << flow->GetIndex () <<
" with positive deficit");
422 item = flow->GetQueueDisc ()->Dequeue ();
426 NS_LOG_DEBUG (
"Could not get a packet from the selected flow queue");
441 NS_LOG_DEBUG (
"Dequeued packet " << item->GetPacket ());
446 flow->IncreaseDeficit (item->GetSize () * -1);
463 NS_LOG_ERROR (
"FqPieQueueDisc cannot have internal queues");
474 if (ndqi && (dev = ndqi->GetObject<
NetDevice> ()))
489 NS_LOG_ERROR (
"The number of queues must be an integer multiple of the size "
490 "of the set of queues used by set associative hash");
500 NS_LOG_WARN (
"Enabling ECN as L4S mode is enabled");
533 uint32_t maxBacklog = 0, index = 0;
541 if (bytes > maxBacklog)
549 uint32_t len = 0, count = 0, threshold = maxBacklog >> 1;
555 NS_LOG_DEBUG (
"Drop packet (overflow); count: " << count <<
" len: " << len <<
" threshold: " << threshold);
558 len += item->GetSize ();
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_useDqRateEstimator
Enable/Disable usage of dequeue rate estimator for queue delay calculation.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
@ MULTIPLE_QUEUES
Used by queue discs with multiple internal queues/child queue discs.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t m_perturbation
hash perturbation value
int32_t m_deficit
the deficit for this flow
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
ObjectFactory m_flowFactory
Factory to create a new flow.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Time m_ceThreshold
Threshold above which to CE mark.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Implements PIE Active Queue Management discipline.
FqPieFlow()
FqPieFlow constructor.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
@ PACKETS
Use number of packets for queue size.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
virtual uint16_t GetMtu(void) const =0
bool m_useDerandomization
Enable Derandomization feature mentioned in RFC 8033.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
A flow queue used by the FqPie queue disc.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Time m_tUpdate
Time period after which CalculateP () is called.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
FqPieQueueDisc()
FqPieQueueDisc constructor.
uint32_t m_setWays
size of a set of queues (used by set associative hash)
QueueDiscClass is the base class for classes that are included in a queue disc.
std::list< Ptr< FqPieFlow > > m_newFlows
The list of new flows.
double m_markEcnTh
ECN marking threshold (default 10% as suggested in RFC 8033)
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
double m_a
Parameter to pie controller.
Smart pointer class similar to boost::intrusive_ptr.
FlowStatus m_status
the status of this flow
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
uint32_t m_dqThreshold
Minimum queue size in bytes before dequeue rate is measured.
uint32_t m_meanPktSize
Average packet size in bytes.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
virtual ~FqPieQueueDisc()
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Time m_maxBurst
Maximum burst allowed before random early dropping kicks in.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
int32_t GetDeficit(void) const
Get the deficit for this flow.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
FlowStatus GetStatus(void) const
Get the status of this flow.
uint32_t GetQuantum(void) const
Get the quantum value.
bool m_enableSetAssociativeHash
whether to enable set associative hash
double m_b
Parameter to pie controller.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
FlowStatus
Used to determine the status of this flow queue.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t m_flows
Number of flow queues.
static const int PF_NO_MATCH
Standard value used by packet filters to indicate that no match was possible.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetStatus(FlowStatus status)
Set the status for this flow.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
uint32_t FqPieDrop(void)
Drop a packet from the head of the queue with the largest current byte count.
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
void SetQuantum(uint32_t quantum)
Set the quantum value.
AttributeValue implementation for Time.
bool m_isCapDropAdjustment
Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
QueueSizeUnit
Enumeration of the operating modes of queues.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Hold an unsigned integer type.
Time m_sUpdate
Start time of the update timer.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
uint32_t GetIndex(void) const
Get the index of this flow.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetIndex(uint32_t index)
Set the index for this flow.
A FqPie packet queue disc.
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...
uint32_t m_index
the index for this flow
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
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.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Class for representing queue sizes.
Time m_qDelayRef
Desired queue delay.
std::list< Ptr< FqPieFlow > > m_oldFlows
The list of old flows.
static TypeId GetTypeId(void)
Get the type ID.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
uint32_t m_quantum
Deficit assigned to flows at each round.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Network layer to device interface.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
static TypeId GetTypeId(void)
Get the type ID.
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.