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")
204 uint32_t pktSize = itemPeek->GetSize ();
221 NS_LOG_LOGIC (
"Number of ptokens we can consume " << ptoks);
222 NS_LOG_LOGIC (
"Required to dequeue next packet " << pktSize);
233 NS_LOG_LOGIC (
"Number of btokens we can consume " << btoks);
234 NS_LOG_LOGIC (
"Required to dequeue next packet " << pktSize);
237 if ((btoks|ptoks) >= 0)
242 NS_LOG_DEBUG (
"That's odd! Expecting the peeked packet, we got no packet.");
266 NS_LOG_LOGIC(
"Waking Event Scheduled in " << requiredDelayTime);
278 NS_LOG_ERROR (
"TbfQueueDisc cannot have internal queues");
284 NS_LOG_ERROR (
"TbfQueueDisc cannot have packet filters");
292 factory.
SetTypeId (
"ns3::FifoQueueDisc");
297 NS_LOG_ERROR (
"Cannot set the max size of the child queue disc to that of TbfQueueDisc");
303 c->SetQueueDisc (qd);
320 NS_LOG_ERROR (
"A non-null peak rate has been set, but the mtu is null. No packet will be dequeued");
327 <<
"greater than the size of the second bucket (" <<
m_mtu <<
").");
333 <<
"greater than the rate for the first bucket (" <<
m_rate <<
").");
virtual void DoDispose(void)
Dispose of the object.
uint32_t GetSecondBucketTokens(void) const
Get the current number of tokens inside the second bucket in bytes.
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
Simulation virtual time values and global simulation resolution.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
DataRate m_peakRate
Rate at which tokens enter the second bucket.
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 "...
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes.
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.
DataRate GetPeakRate(void) const
Get the rate of the tokens entering the second bucket.
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.
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.
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...
Used by queue discs with single child queue disc.
uint64_t GetBitRate() const
Get the underlying bitrate.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
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.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
EventId m_id
EventId of the scheduled queue waking event when enough tokens are available.
Hold an unsigned integer type.
DataRate GetRate(void) const
Get the rate of the tokens entering the first bucket.
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.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_timeCheckPoint
Time check-point.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
uint32_t GetBurst(void) const
Get the size of the first bucket in bytes.
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.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
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.
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.
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.
uint32_t GetMtu(void) const
Get the size of the second bucket in bytes.
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.
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.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual ~TbfQueueDisc()
Destructor.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
void SetRate(DataRate rate)
Set the rate of the tokens entering the first bucket.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.