32 #include "ns3/simulator.h"
33 #include "ns3/uinteger.h"
34 #include "ns3/attribute.h"
35 #include "ns3/object-factory.h"
36 #include "ns3/drop-tail-queue.h"
37 #include "ns3/net-device-queue-interface.h"
50 .SetGroupName (
"TrafficControl")
52 .AddAttribute (
"MaxSize",
58 .AddAttribute (
"Burst",
59 "Size of the first bucket in bytes",
62 MakeUintegerChecker<uint32_t> ())
64 "Size of the second bucket in bytes. If null, it is initialized"
65 " to the MTU of the attached NetDevice (if any)",
68 MakeUintegerChecker<uint32_t> ())
69 .AddAttribute (
"Rate",
70 "Rate at which tokens enter the first bucket in bps or Bps.",
74 .AddAttribute (
"PeakRate",
75 "Rate at which tokens enter the second bucket in bps or Bps."
76 "If null, there is no second bucket",
80 .AddTraceSource (
"TokensInFirstBucket",
81 "Number of First Bucket Tokens in bytes",
83 "ns3::TracedValueCallback::Uint32")
84 .AddTraceSource (
"TokensInSecondBucket",
85 "Number of Second Bucket Tokens in bytes",
87 "ns3::TracedValueCallback::Uint32")
222 uint32_t pktSize = itemPeek->GetSize ();
239 NS_LOG_LOGIC (
"Number of ptokens we can consume " << ptoks);
240 NS_LOG_LOGIC (
"Required to dequeue next packet " << pktSize);
251 NS_LOG_LOGIC (
"Number of btokens we can consume " << btoks);
252 NS_LOG_LOGIC (
"Required to dequeue next packet " << pktSize);
255 if ((btoks|ptoks) >= 0)
260 NS_LOG_DEBUG (
"That's odd! Expecting the peeked packet, we got no packet.");
284 NS_LOG_LOGIC(
"Waking Event Scheduled in " << requiredDelayTime);
296 NS_LOG_ERROR (
"TbfQueueDisc cannot have internal queues");
302 NS_LOG_ERROR (
"TbfQueueDisc cannot have packet filters");
310 factory.
SetTypeId (
"ns3::FifoQueueDisc");
315 NS_LOG_ERROR (
"Cannot set the max size of the child queue disc to that of TbfQueueDisc");
321 c->SetQueueDisc (qd);
338 NS_LOG_ERROR (
"A non-null peak rate has been set, but the mtu is null. No packet will be dequeued");
345 <<
"greater than the size of the second bucket (" <<
m_mtu <<
").");
351 <<
"greater than the rate for the first bucket (" <<
m_rate <<
").");
virtual void DoDispose(void)
Dispose of the object.
Simulation virtual time values and global simulation resolution.
DataRate m_peakRate
Rate at which tokens enter the second bucket.
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
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 "...
Class for representing queue sizes.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
TracedValue< uint32_t > m_btokens
Current number of tokens in first bucket.
uint32_t GetMtu(void) const
Get the size of the second bucket in bytes.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
DataRate m_rate
Rate at which tokens enter the first bucket.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSecondBucketTokens(void) const
Get the current number of tokens inside the second bucket in bytes.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void SetPeakRate(DataRate peakRate)
Set the rate of the tokens entering the second bucket.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes.
Used by queue discs with single child queue disc.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
Class for representing data rates.
TbfQueueDisc()
TbfQueueDisc Constructor.
uint32_t m_mtu
Size of second bucket in bytes.
uint32_t GetNInternalQueues(void) const
Get the number of internal queues.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
EventId m_id
EventId of the scheduled queue waking event when enough tokens are available.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Hold an unsigned integer type.
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
virtual void DoDispose(void)
Dispose of the object.
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual Ptr< const QueueDiscItem > DoPeek(void)
This function returns a copy of the next packet the queue disc will extract.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_timeCheckPoint
Time check-point.
DataRate GetRate(void) const
Get the rate of the tokens entering the first bucket.
uint64_t GetBitRate() const
Get the underlying bitrate.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
void SetMtu(uint32_t mtu)
Set the size of the second bucket in bytes.
void SetBurst(uint32_t burst)
Set the size of the first bucket in bytes.
static Time Now(void)
Return the current simulation virtual time.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_burst
Size of first bucket in bytes.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
Instantiate subclasses of ns3::Object.
Ptr< const QueueDiscItem > PeekDequeued(void)
Dequeue a packet and retain it in the queue disc as a requeued packet.
An identifier for simulation events.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
AttributeValue implementation for DataRate.
TracedValue< uint32_t > m_ptokens
Current number of tokens in second bucket.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
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.
DataRate GetPeakRate(void) const
Get the rate of the tokens entering the second bucket.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
virtual ~TbfQueueDisc()
Destructor.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Ptr< QueueDiscClass > GetQueueDiscClass(uint32_t i) const
Get the i-th queue disc class.
uint32_t GetBurst(void) const
Get the size of the first bucket in bytes.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
void SetRate(DataRate rate)
Set the rate of the tokens entering the first bucket.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.