31 #include "ns3/attribute.h"
32 #include "ns3/drop-tail-queue.h"
35 #include "ns3/net-device-queue-interface.h"
36 #include "ns3/object-factory.h"
37 #include "ns3/simulator.h"
38 #include "ns3/uinteger.h"
51 TypeId(
"ns3::TbfQueueDisc")
53 .SetGroupName(
"TrafficControl")
55 .AddAttribute(
"MaxSize",
59 MakeQueueSizeChecker())
60 .AddAttribute(
"Burst",
61 "Size of the first bucket in bytes",
64 MakeUintegerChecker<uint32_t>())
66 "Size of the second bucket in bytes. If null, it is initialized"
67 " to the MTU of the receiving NetDevice (if any)",
70 MakeUintegerChecker<uint32_t>())
72 "Rate at which tokens enter the first bucket in bps or Bps.",
75 MakeDataRateChecker())
76 .AddAttribute(
"PeakRate",
77 "Rate at which tokens enter the second bucket in bps or Bps."
78 "If null, there is no second bucket",
81 MakeDataRateChecker())
82 .AddTraceSource(
"TokensInFirstBucket",
83 "Number of First Bucket Tokens in bytes",
85 "ns3::TracedValueCallback::Uint32")
86 .AddTraceSource(
"TokensInSecondBucket",
87 "Number of Second Bucket Tokens in bytes",
89 "ns3::TracedValueCallback::Uint32");
206 uint32_t
pktSize = itemPeek->GetSize();
223 NS_LOG_LOGIC(
"Number of ptokens we can consume " << ptoks);
235 NS_LOG_LOGIC(
"Number of btokens we can consume " << btoks);
239 if ((btoks | ptoks) >= 0)
244 NS_LOG_DEBUG(
"That's odd! Expecting the peeked packet, we got no packet.");
253 <<
" ptokens after packet dequeue");
267 Time requiredDelayTime;
270 NS_ASSERT_MSG(btoks < 0,
"Logic error; btoks must be < 0 here");
275 if (btoks < 0 && ptoks >= 0)
279 else if (btoks >= 0 && ptoks < 0)
303 NS_LOG_ERROR(
"TbfQueueDisc cannot have internal queues");
309 NS_LOG_ERROR(
"TbfQueueDisc cannot have packet filters");
322 NS_LOG_ERROR(
"Cannot set the max size of the child queue disc to that of TbfQueueDisc");
347 if (ndqi && (dev = ndqi->GetObject<
NetDevice>()))
349 m_mtu = dev->GetMtu();
356 "A non-null peak rate has been set, but the mtu is null. No packet will be dequeued");
364 <<
"greater than the size of the second bucket (" <<
m_mtu <<
").");
371 <<
"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.
An identifier for simulation events.
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Network layer to device interface.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() 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()
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 GetNPackets() const
Get the number of packets stored by the queue disc.
uint32_t GetNBytes() const
Get the amount of bytes stored by the queue disc.
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface() const
void Run()
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets,...
std::size_t GetNQueueDiscClasses() const
Get the number of queue disc classes.
QueueSize GetMaxSize() const
Get the maximum size of the queue disc.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
std::size_t GetNPacketFilters() const
Get the number of packet filters.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
std::size_t GetNInternalQueues() const
Get the number of internal queues.
void DoDispose() override
Dispose of the object.
Class for representing queue sizes.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
DataRate GetRate() const
Get the rate of the tokens entering the first bucket.
TbfQueueDisc()
TbfQueueDisc Constructor.
void SetBurst(uint32_t burst)
Set the size of the first bucket in bytes.
TracedValue< uint32_t > m_ptokens
Current number of tokens in second bucket.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
Time m_timeCheckPoint
Time check-point.
uint32_t m_mtu
Size of second bucket in bytes.
~TbfQueueDisc() override
Destructor.
void DoDispose() override
Dispose of the object.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
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.
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
DataRate GetPeakRate() const
Get the rate of the tokens entering the second bucket.
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.
uint32_t GetBurst() const
Get the size of the first bucket in bytes.
uint32_t GetFirstBucketTokens() const
Get the current number of tokens inside the first bucket in bytes.
static TypeId GetTypeId()
Get the type ID.
bool CheckConfig() override
Check whether the current configuration is correct.
uint32_t GetSecondBucketTokens() const
Get the current number of tokens inside the second bucket in bytes.
uint32_t GetMtu() const
Get the size of the second bucket in bytes.
TracedValue< uint32_t > m_btokens
Current number of tokens in first bucket.
DataRate m_peakRate
Rate at which tokens enter the second bucket.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated 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...
#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.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#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.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
uint32_t pktSize
packet size used for the simulation (in bytes)