|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include "ns3/tbf-queue-disc.h"
25 #include "ns3/packet.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/string.h"
28 #include "ns3/double.h"
30 #include "ns3/simulator.h"
31 #include "ns3/node-container.h"
32 #include "ns3/simple-net-device.h"
33 #include "ns3/simple-channel.h"
34 #include "ns3/traffic-control-layer.h"
35 #include "ns3/config.h"
55 virtual void AddHeader (
void);
56 virtual bool Mark (
void);
103 virtual void DoRun (
void);
127 :
TestCase (
"Sanity check on the TBF queue implementation")
136 uint32_t modeSize = 1;
138 uint32_t burst = 6000;
158 qSize = qSize * modeSize;
162 true,
"Verify that we can actually set the attribute MaxSize");
164 "Verify that we can actually set the attribute Burst");
166 "Verify that we can actually set the attribute Mtu");
168 "Verify that we can actually set the attribute Rate");
170 "Verify that we can actually set the attribute PeakRate");
183 queue->
Enqueue (Create<TbfQueueDiscTestItem> (p1, dest));
185 queue->
Enqueue (Create<TbfQueueDiscTestItem> (p2, dest));
187 queue->
Enqueue (Create<TbfQueueDiscTestItem> (p3, dest));
189 queue->
Enqueue (Create<TbfQueueDiscTestItem> (p4, dest));
191 queue->
Enqueue (Create<TbfQueueDiscTestItem> (p5, dest));
193 "There should still be four packets in there as this enqueue cannot happen since QueueLimit will be exceeded");
202 "The number of tokens in the first bucket should be one pktSize lesser");
209 "The number of tokens in the first bucket should be two pktSizes lesser");
216 "The number of tokens in the first bucket should be three pktSizes lesser");
223 "The number of tokens in the first bucket should be four pktSizes lesser");
226 queue = CreateObject<TbfQueueDisc> ();
233 uint32_t nPkt = qSize;
238 qSize = qSize * modeSize;
242 true,
"Verify that we can actually set the attribute MaxSize");
244 "Verify that we can actually set the attribute Burst");
246 "Verify that we can actually set the attribute Mtu");
248 "Verify that we can actually set the attribute Rate");
250 "Verify that we can actually set the attribute PeakRate");
254 for (uint32_t i = 1; i <= nPkt; i++)
259 for (uint32_t i = 1; i <= nPkt; i++)
262 queue,
true,
"No packet should be blocked");
271 queue = CreateObject<TbfQueueDisc> ();
301 qSize = qSize * modeSize;
305 true,
"Verify that we can actually set the attribute MaxSize");
307 "Verify that we can actually set the attribute Burst");
309 "Verify that we can actually set the attribute Mtu");
311 "Verify that we can actually set the attribute Rate");
313 "Verify that we can actually set the attribute PeakRate");
316 for (uint32_t i = 1; i <= nPkt; i++)
321 for (uint32_t i = 1; i <= nPkt; i++)
326 queue,
false,
"10th packet should be blocked");
331 queue,
true,
"This packet should not be blocked");
334 Simulator::Stop (
Seconds (1.3));
344 queue = CreateObject<TbfQueueDisc> ();
375 qSize = qSize * modeSize;
379 true,
"Verify that we can actually set the attribute MaxSize");
381 "Verify that we can actually set the attribute Burst");
383 "Verify that we can actually set the attribute Mtu");
385 "Verify that we can actually set the attribute Rate");
387 "Verify that we can actually set the attribute PeakRate");
391 for (uint32_t i = 1; i <= nPkt; i++)
403 double nextDelay = (2 * delay) + 0.02;
404 for (uint32_t i = 1; i <= nPkt; i++)
409 queue,
true,
"1st packet should not be blocked");
415 queue,
false,
"This packet should be blocked");
419 Simulator::Stop (
Seconds (0.55));
427 queue->
Enqueue (Create<TbfQueueDiscTestItem> (Create<Packet> (size), dest));
442 Simulator::Destroy ();
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
AttributeValue implementation for DataRate.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
Tbf Queue Disc Test Item.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~TbfQueueDiscTestItem()
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
TbfQueueDiscTestSuite g_tbfQueueTestSuite
the test suite
@ PACKETS
Use number of packets for queue size.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Tbf Queue Disc Test Case.
Class for representing data rates.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
virtual Address GetAddress(void) const
void RunTbfTest(QueueSizeUnit mode)
Run TBF test function.
a polymophic address class
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void Enqueue(Ptr< TbfQueueDisc > queue, Address dest, uint32_t size)
Enqueue function.
void DequeueAndCheck(Ptr< TbfQueueDisc > queue, bool flag, std::string printStatement)
DequeueAndCheck function to check if a packet is blocked or not after dequeuing and verify against ex...
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes.
virtual void AddHeader(void)
Add the header to the packet.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any,...
virtual void SetNode(Ptr< Node > node)
Ptr< Packet > GetPacket(void) const
Tbf Queue Disc Test Suite.
@ UNIT
This test suite implements a Unit Test.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
TbfQueueDiscTestItem(const TbfQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
uint32_t pktSize
packet size used for the simulation (in bytes)
@ BYTES
Use number of bytes for queue size.
keep track of a set of node pointers.
QueueSizeUnit
Enumeration of the operating modes of queues.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
uint32_t GetValue() const
Get the underlying value.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Class for representing queue sizes.
uint64_t GetUid(void) const
Returns the packet's Uid.