23 #include "ns3/string.h" 24 #include "ns3/queue.h" 27 #include "ns3/net-device-queue-interface.h" 39 .SetGroupName (
"TrafficControl")
113 .SetGroupName (
"TrafficControl")
115 .AddAttribute (
"UseEcn",
116 "True to use ECN (packets are marked instead of being dropped)",
120 .AddAttribute (
"Interval",
121 "The CoDel algorithm interval for each FQCoDel queue",
125 .AddAttribute (
"Target",
126 "The CoDel algorithm target queue delay for each FQCoDel queue",
130 .AddAttribute (
"MaxSize",
131 "The maximum number of packets accepted by this queue disc",
136 .AddAttribute (
"Flows",
137 "The number of queues into which the incoming packets are classified",
140 MakeUintegerChecker<uint32_t> ())
141 .AddAttribute (
"DropBatchSize",
142 "The maximum number of packets dropped from the fat flow",
145 MakeUintegerChecker<uint32_t> ())
146 .AddAttribute (
"Perturbation",
147 "The salt used as an additional input to the hash function used to classify packets",
150 MakeUintegerChecker<uint32_t> ())
151 .AddAttribute (
"CeThreshold",
152 "The FqCoDel CE threshold for marking packets",
156 .AddAttribute (
"EnableSetAssociativeHash",
157 "Enable/Disable Set Associative Hash",
161 .AddAttribute (
"SetWays",
162 "The size of a set of queues (used by set associative hash)",
165 MakeUintegerChecker<uint32_t> ())
200 uint32_t h = (flowHash %
m_flows);
202 uint32_t outerHash = h - innerHash;
204 for (uint32_t i = outerHash; i < outerHash +
m_setWays; i++)
220 m_tags[outerHash] = flowHash;
229 uint32_t flowHash, h;
241 flowHash =
static_cast<uint32_t
> (ret);
245 NS_LOG_ERROR (
"No filter has been able to classify this packet, drop it.");
263 NS_LOG_DEBUG (
"Creating a new flow queue with index " << h);
274 flow->SetQueueDisc (qd);
292 flow->GetQueueDisc ()->Enqueue (item);
321 if (flow->GetDeficit () <= 0)
323 NS_LOG_DEBUG (
"Increase deficit for new flow index " << flow->GetIndex ());
331 NS_LOG_DEBUG (
"Found a new flow " << flow->GetIndex () <<
" with positive deficit");
340 if (flow->GetDeficit () <= 0)
342 NS_LOG_DEBUG (
"Increase deficit for old flow index " << flow->GetIndex ());
349 NS_LOG_DEBUG (
"Found an old flow " << flow->GetIndex () <<
" with positive deficit");
360 item = flow->GetQueueDisc ()->Dequeue ();
364 NS_LOG_DEBUG (
"Could not get a packet from the selected flow queue");
379 NS_LOG_DEBUG (
"Dequeued packet " << item->GetPacket ());
383 flow->IncreaseDeficit (item->GetSize () * -1);
400 NS_LOG_ERROR (
"FqCoDelQueueDisc cannot have internal queues");
412 if (ndqi && (dev = ndqi->GetObject<
NetDevice> ()))
427 NS_LOG_ERROR (
"The number of queues must be an integer multiple of the size " 428 "of the set of queues used by set associative hash");
453 uint32_t maxBacklog = 0, index = 0;
461 if (bytes > maxBacklog)
469 uint32_t len = 0, count = 0, threshold = maxBacklog >> 1;
475 NS_LOG_DEBUG (
"Drop packet (overflow); count: " << count <<
" len: " << len <<
" threshold: " << threshold);
478 len += item->GetSize ();
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
A FqCoDel packet queue disc.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
Class for representing queue sizes.
FlowStatus
Used to determine the status of this flow queue.
uint32_t m_quantum
Deficit assigned to flows at each round.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of 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...
static const int PF_NO_MATCH
Standard value used by packet filters to indicate that no match was possible.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
QueueSizeUnit
Enumeration of the operating modes of queues.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
uint32_t FqCoDelDrop(void)
Drop a packet from the head of the queue with the largest current byte count.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
int32_t GetDeficit(void) const
Get the deficit for this flow.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
uint32_t m_setWays
size of a set of queues (used by set associative hash)
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
FqCoDelFlow()
FqCoDelFlow constructor.
void SetStatus(FlowStatus status)
Set the status for this flow.
A flow queue used by the FqCoDel queue disc.
static Time Max()
Maximum representable Time.
Ptr< const AttributeChecker > MakeStringChecker(void)
int32_t m_deficit
the deficit for this flow
uint32_t m_flows
Number of flow queues.
bool m_enableSetAssociativeHash
whether to enable set associative hash
AttributeValue implementation for Time.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Hold an unsigned integer type.
Use number of packets for queue size.
uint32_t GetQuantum(void) const
Get the quantum value.
uint32_t m_perturbation
hash perturbation value
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
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 GetIndex(void) const
Get the index of this flow.
uint32_t m_index
the index for this flow
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Time m_ceThreshold
Threshold above which to CE mark.
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
QueueDiscClass is the base class for classes that are included in a queue disc.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
std::list< Ptr< FqCoDelFlow > > m_newFlows
The list of new flows.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
std::string m_interval
CoDel interval attribute.
void SetQuantum(uint32_t quantum)
Set the quantum value.
std::string m_target
CoDel target attribute.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
virtual ~FqCoDelQueueDisc()
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
static TypeId GetTypeId(void)
Get the type ID.
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
void SetIndex(uint32_t index)
Set the index for this flow.
FqCoDelQueueDisc()
FqCoDelQueueDisc constructor.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
A CoDel packet queue disc.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
Used by queue discs with multiple internal queues/child queue discs.
Network layer to device interface.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
FlowStatus GetStatus(void) const
Get the status of this flow.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
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::list< Ptr< FqCoDelFlow > > m_oldFlows
The list of old flows.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
FlowStatus m_status
the status of this flow
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Inactive Period or unslotted CSMA-CA.
ObjectFactory m_flowFactory
Factory to create a new flow.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.