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")
 
  134   uint32_t pktSize = 1500;
 
  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");
 
  175   p1 = Create<Packet> (pktSize);
 
  176   p2 = Create<Packet> (pktSize);
 
  177   p3 = Create<Packet> (pktSize);
 
  178   p4 = Create<Packet> (pktSize);
 
  179   p5 = Create<Packet> (pktSize);
 
  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> ();
 
  302       qSize = qSize * modeSize;
 
  306                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  308                          "Verify that we can actually set the attribute Burst");
 
  310                          "Verify that we can actually set the attribute Mtu");
 
  312                          "Verify that we can actually set the attribute Rate");
 
  314                          "Verify that we can actually set the attribute PeakRate");
 
  317   for (uint32_t i = 1; i <= nPkt; i++)
 
  322   for (uint32_t i = 1; i <= nPkt; i++)
 
  327                                queue, 
false, 
"10th packet should be blocked");
 
  332                                queue, 
true, 
"This packet should not be blocked");
 
  335   Simulator::Stop (
Seconds (1.3));
 
  345   queue = CreateObject<TbfQueueDisc> ();
 
  376       qSize = qSize * modeSize;
 
  380                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  382                          "Verify that we can actually set the attribute Burst");
 
  384                          "Verify that we can actually set the attribute Mtu");
 
  386                          "Verify that we can actually set the attribute Rate");
 
  388                          "Verify that we can actually set the attribute PeakRate");
 
  392   for (uint32_t i = 1; i <= nPkt; i++)
 
  397   for (uint32_t i = 1; i <= nPkt; i++)
 
  402                                queue, 
true, 
"1st packet should not be blocked");
 
  407                                queue, 
false, 
"This packet should be blocked");
 
  410   Simulator::Stop (
Seconds (0.55));
 
  418   queue->
Enqueue (Create<TbfQueueDiscTestItem> (Create<Packet> (size), dest));
 
  433   Simulator::Destroy ();
 
virtual Address GetAddress(void) const 
 
Tbf Queue Disc Test Item. 
 
Tbf Queue Disc Test Case. 
 
Simulation virtual time values and global simulation resolution. 
 
virtual ~TbfQueueDiscTestItem()
 
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. 
 
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. 
 
uint64_t GetUid(void) const 
Returns the packet's Uid. 
 
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. 
 
This test suite implements a Unit Test. 
 
TbfQueueDiscTestSuite g_tbfQueueTestSuite
the test suite 
 
uint32_t GetFirstBucketTokens(void) const 
Get the current number of tokens inside the first bucket in bytes. 
 
uint32_t GetValue() const 
Get the underlying value. 
 
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 bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
 
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet. 
 
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. 
 
Ptr< Node > Get(uint32_t i) const 
Get the Ptr stored in this container at a given index. 
 
Time Seconds(double value)
Construct a Time in the indicated unit. 
 
void SetDefault(std::string name, const AttributeValue &value)
 
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. 
 
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 Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one. 
 
void SetNetDevice(Ptr< NetDevice > device)
Set the NetDevice on which this queue discipline is installed.