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");
   207   NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), 
"Was this the second packet ?");
   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");
   221   NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (), 
"Was this the fourth packet ?");
   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> ();
   374       qSize = qSize * modeSize;
   378                          true, 
"Verify that we can actually set the attribute MaxSize");
   380                          "Verify that we can actually set the attribute Burst");
   382                          "Verify that we can actually set the attribute Mtu");
   384                          "Verify that we can actually set the attribute Rate");
   386                          "Verify that we can actually set the attribute PeakRate");
   390   for (uint32_t i = 1; i <= nPkt; i++)
   395   for (uint32_t i = 1; i <= nPkt; i++)
   400                                queue, 
true, 
"1st packet should not be blocked");
   405                                queue, 
false, 
"This packet should be blocked");
   408   Simulator::Stop (
Seconds (0.55));
   416   queue->
Enqueue (Create<TbfQueueDiscTestItem> (Create<Packet> (size), dest));
   431   Simulator::Destroy ();
 Tbf Queue Disc Test Item. 
Tbf Queue Disc Test Case. 
uint64_t GetUid(void) const
Returns the packet's Uid. 
Simulation virtual time values and global simulation resolution. 
virtual ~TbfQueueDiscTestItem()
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes. 
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device. 
Class for representing queue sizes. 
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline. 
uint32_t GetValue() const
Get the underlying value. 
QueueSizeUnit
Enumeration of the operating modes of queues. 
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise. 
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together. 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not. 
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors. 
QueueDiscItem is the abstract base class for items that are stored in a queue disc. 
TbfQueueDiscTestSuite g_tbfQueueTestSuite
the test suite 
Tbf Queue Disc Test Suite. 
a polymophic address class 
Class for representing data rates. 
virtual void SetNode(Ptr< Node > node)
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
Hold an unsigned integer type. 
Use number of packets for queue size. 
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...
virtual Address GetAddress(void) const
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
keep track of a set of node pointers. 
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node. 
  AttributeValue implementation for DataRate. 
Time Seconds(double value)
Construct a Time in the indicated unit. 
void SetDefault(std::string name, const AttributeValue &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index. 
virtual void AddHeader(void)
Add the header to the packet. 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
This test suite implements a Unit Test. 
uint32_t pktSize
packet size used for the simulation (in bytes) 
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device. 
Use number of bytes for queue size. 
void RunTbfTest(QueueSizeUnit mode)
Run TBF test function. 
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate. 
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.