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 (
"Interval",
127 "The CoDel algorithm interval for each FqCobalt queue",
131 .AddAttribute (
"Target",
132 "The CoDel algorithm target queue delay for each FqCobalt queue",
136 .AddAttribute (
"MaxSize",
137 "The maximum number of packets accepted by this queue disc",
142 .AddAttribute (
"Flows",
143 "The number of queues into which the incoming packets are classified",
146 MakeUintegerChecker<uint32_t> ())
147 .AddAttribute (
"DropBatchSize",
148 "The maximum number of packets dropped from the fat flow",
151 MakeUintegerChecker<uint32_t> ())
152 .AddAttribute (
"Perturbation",
153 "The salt used as an additional input to the hash function used to classify packets",
156 MakeUintegerChecker<uint32_t> ())
157 .AddAttribute (
"CeThreshold",
158 "The FqCobalt CE threshold for marking packets",
162 .AddAttribute (
"EnableSetAssociativeHash",
163 "Enable/Disable Set Associative Hash",
167 .AddAttribute (
"SetWays",
168 "The size of a set of queues (used by set associative hash)",
171 MakeUintegerChecker<uint32_t> ())
172 .AddAttribute (
"UseL4s",
173 "True to use L4S (only ECT1 packets are marked at CE threshold)",
177 .AddAttribute (
"Pdrop",
178 "Marking Probability",
181 MakeDoubleChecker<double> ())
182 .AddAttribute (
"Increment",
183 "Pdrop increment value",
186 MakeDoubleChecker<double> ())
187 .AddAttribute (
"Decrement",
188 "Pdrop decrement Value",
191 MakeDoubleChecker<double> ())
192 .AddAttribute (
"BlueThreshold",
193 "The Threshold after which Blue is enabled",
231 uint32_t h = (flowHash %
m_flows);
233 uint32_t outerHash = h - innerHash;
235 for (uint32_t i = outerHash; i < outerHash +
m_setWays; i++)
251 m_tags[outerHash] = flowHash;
260 uint32_t flowHash, h;
272 flowHash =
static_cast<uint32_t
> (ret);
276 NS_LOG_ERROR (
"No filter has been able to classify this packet, drop it.");
294 NS_LOG_DEBUG (
"Creating a new flow queue with index " << h);
307 flow->SetQueueDisc (qd);
325 flow->GetQueueDisc ()->Enqueue (item);
354 if (flow->GetDeficit () <= 0)
356 NS_LOG_DEBUG (
"Increase deficit for new flow index " << flow->GetIndex ());
364 NS_LOG_DEBUG (
"Found a new flow " << flow->GetIndex () <<
" with positive deficit");
373 if (flow->GetDeficit () <= 0)
375 NS_LOG_DEBUG (
"Increase deficit for old flow index " << flow->GetIndex ());
382 NS_LOG_DEBUG (
"Found an old flow " << flow->GetIndex () <<
" with positive deficit");
393 item = flow->GetQueueDisc ()->Dequeue ();
397 NS_LOG_DEBUG (
"Could not get a packet from the selected flow queue");
412 NS_LOG_DEBUG (
"Dequeued packet " << item->GetPacket ());
417 flow->IncreaseDeficit (item->GetSize () * -1);
434 NS_LOG_ERROR (
"FqCobaltQueueDisc cannot have internal queues");
445 if (ndqi && (dev = ndqi->GetObject<
NetDevice> ()))
460 NS_LOG_ERROR (
"The number of queues must be an integer multiple of the size " 461 "of the set of queues used by set associative hash");
471 NS_LOG_WARN (
"Enabling ECN as L4S mode is enabled");
498 uint32_t maxBacklog = 0, index = 0;
506 if (bytes > maxBacklog)
514 uint32_t len = 0, count = 0, threshold = maxBacklog >> 1;
520 NS_LOG_DEBUG (
"Drop packet (overflow); count: " << count <<
" len: " << len <<
" threshold: " << threshold);
523 len += item->GetSize ();
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.
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.
std::string m_target
CoDel target attribute.
uint32_t GetIndex(void) const
Get the index of this flow.
std::string m_interval
CoDel interval attribute.
Hold variables of type string.
QueueSizeUnit
Enumeration of the operating modes of queues.
std::list< Ptr< FqCobaltFlow > > m_oldFlows
The list of old flows.
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::list< Ptr< FqCobaltFlow > > m_newFlows
The list of new flows.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
void SetQuantum(uint32_t quantum)
Set the quantum value.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
double m_increment
increment value for marking probability
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
FqCobaltFlow()
FqCobaltFlow constructor.
double m_Pdrop
Drop Probability.
double m_decrement
decrement value for marking probability
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
uint32_t m_quantum
Deficit assigned to flows at each round.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Ptr< const AttributeChecker > MakeStringChecker(void)
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
static TypeId GetTypeId(void)
Get the type ID.
A FqCobalt packet queue disc.
AttributeValue implementation for Time.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
FlowStatus m_status
the status of this flow
static TypeId GetTypeId(void)
Get the type ID.
bool m_enableSetAssociativeHash
whether to enable set associative hash
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Hold an unsigned integer type.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
Use number of packets for queue size.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
FlowStatus
Used to determine the status of this flow queue.
Cobalt packet queue disc.
Time m_ceThreshold
Threshold above which to CE mark.
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
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...
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
uint32_t m_index
the index for this flow
QueueDiscClass is the base class for classes that are included in a queue disc.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
A flow queue used by the FqCobalt queue disc.
virtual ~FqCobaltQueueDisc()
void SetIndex(uint32_t index)
Set the index for this flow.
ObjectFactory m_flowFactory
Factory to create a new flow.
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
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.
int32_t GetDeficit(void) const
Get the deficit for this flow.
uint32_t m_flows
Number of flow queues.
FqCobaltQueueDisc()
FqCobaltQueueDisc constructor.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
uint32_t GetQuantum(void) const
Get the quantum value.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Used by queue discs with multiple internal queues/child queue discs.
Network layer to device interface.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
int32_t m_deficit
the deficit for this flow
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)
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
uint32_t m_perturbation
hash perturbation value
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
void SetStatus(FlowStatus status)
Set the status for this flow.
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...
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.
FlowStatus GetStatus(void) const
Get the status of this flow.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Time m_blueThreshold
Threshold to enable blue enhancement.
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
uint32_t FqCobaltDrop(void)
Drop a packet from the head of the queue with the largest current byte count.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Inactive Period or unslotted CSMA-CA.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
uint32_t m_setWays
size of a set of queues (used by set associative hash)
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)