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 receiving 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);
233 NS_LOG_LOGIC (
"Number of btokens we can consume " << btoks);
237 if ((btoks|ptoks) >= 0)
242 NS_LOG_DEBUG (
"That's odd! Expecting the peeked packet, we got no packet.");
263 Time requiredDelayTime;
266 NS_ASSERT_MSG (btoks < 0,
"Logic error; btoks must be < 0 here");
271 if (btoks < 0 && ptoks >= 0)
275 else if (btoks >= 0 && ptoks < 0)
300 NS_LOG_ERROR (
"TbfQueueDisc cannot have internal queues");
306 NS_LOG_ERROR (
"TbfQueueDisc cannot have packet filters");
314 factory.
SetTypeId (
"ns3::FifoQueueDisc");
319 NS_LOG_ERROR (
"Cannot set the max size of the child queue disc to that of TbfQueueDisc");
325 c->SetQueueDisc (qd);
344 if (ndqi && (dev = ndqi->GetObject<
NetDevice> ()))
352 NS_LOG_ERROR (
"A non-null peak rate has been set, but the mtu is null. No packet will be dequeued");
359 <<
"greater than the size of the second bucket (" <<
m_mtu <<
").");
365 <<
"greater than the rate for the first bucket (" <<
m_rate <<
").");
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
AttributeValue implementation for DataRate.
An identifier for simulation events.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Network layer to device interface.
virtual uint16_t GetMtu(void) const =0
Instantiate subclasses of ns3::Object.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Smart pointer class similar to boost::intrusive_ptr.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets,...
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
virtual void DoDispose(void)
Dispose of the object.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
DataRate GetPeakRate(void) const
Get the rate of the tokens entering the second bucket.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
TbfQueueDisc()
TbfQueueDisc Constructor.
void SetBurst(uint32_t burst)
Set the size of the first bucket in bytes.
virtual ~TbfQueueDisc()
Destructor.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
TracedValue< uint32_t > m_ptokens
Current number of tokens in second bucket.
Time m_timeCheckPoint
Time check-point.
uint32_t m_mtu
Size of second bucket in bytes.
void SetPeakRate(DataRate peakRate)
Set the rate of the tokens entering the second bucket.
uint32_t m_burst
Size of first bucket in bytes.
DataRate m_rate
Rate at which tokens enter the first bucket.
EventId m_id
EventId of the scheduled queue waking event when enough tokens are available.
static TypeId GetTypeId(void)
Get the type ID.
DataRate GetRate(void) const
Get the rate of the tokens entering the first bucket.
uint32_t GetSecondBucketTokens(void) const
Get the current number of tokens inside the second bucket in bytes.
void SetRate(DataRate rate)
Set the rate of the tokens entering the first bucket.
void SetMtu(uint32_t mtu)
Set the size of the second bucket in bytes.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
virtual void DoDispose(void)
Dispose of the object.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
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.
uint32_t GetBurst(void) const
Get the size of the first bucket in bytes.
DataRate m_peakRate
Rate at which tokens enter the second bucket.
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
@ SINGLE_CHILD_QUEUE_DISC
Used by queue discs with single child queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t pktSize
packet size used for the simulation (in bytes)