22#include "ns3/double.h" 
   24#include "ns3/packet.h" 
   25#include "ns3/red-queue-disc.h" 
   26#include "ns3/simulator.h" 
   27#include "ns3/string.h" 
   29#include "ns3/uinteger.h" 
   65      m_ecnCapablePacket(ecnCapable)
 
   94    void DoRun() 
override;
 
  113    : 
TestCase(
"Sanity check on the red queue implementation")
 
  131                          "Verify that we can actually set the attribute MinTh");
 
  134                          "Verify that we can actually set the attribute MaxTh");
 
  138        "Verify that we can actually set the attribute MaxSize");
 
  141                          "Verify that we can actually set the attribute QW");
 
  151        queue->SetTh(minTh * modeSize, maxTh * modeSize);
 
  152        queue->SetMaxSize(
QueueSize(mode, qSize * modeSize));
 
  175                          "There should be no packets in there");
 
  176    queue->Enqueue(Create<RedQueueDiscTestItem>(p1, dest, 
false));
 
  179                          "There should be one packet in there");
 
  180    queue->Enqueue(Create<RedQueueDiscTestItem>(p2, dest, 
false));
 
  183                          "There should be two packets in there");
 
  184    queue->Enqueue(Create<RedQueueDiscTestItem>(p3, dest, 
false));
 
  185    queue->Enqueue(Create<RedQueueDiscTestItem>(p4, dest, 
false));
 
  186    queue->Enqueue(Create<RedQueueDiscTestItem>(p5, dest, 
false));
 
  187    queue->Enqueue(Create<RedQueueDiscTestItem>(p6, dest, 
false));
 
  188    queue->Enqueue(Create<RedQueueDiscTestItem>(p7, dest, 
false));
 
  189    queue->Enqueue(Create<RedQueueDiscTestItem>(p8, dest, 
false));
 
  192                          "There should be eight packets in there");
 
  196    item = queue->Dequeue();
 
  200                          "There should be seven packets in there");
 
  203    item = queue->Dequeue();
 
  207                          "There should be six packet in there");
 
  210                          "Was this the second packet ?");
 
  212    item = queue->Dequeue();
 
  216                          "There should be five packets in there");
 
  219    item = queue->Dequeue();
 
  220    item = queue->Dequeue();
 
  221    item = queue->Dequeue();
 
  222    item = queue->Dequeue();
 
  223    item = queue->Dequeue();
 
  225    item = queue->Dequeue();
 
  229    queue = CreateObject<RedQueueDisc>();
 
  230    minTh = 70 * modeSize;
 
  231    maxTh = 150 * modeSize;
 
  232    qSize = 300 * modeSize;
 
  235                          "Verify that we can actually set the attribute MinTh");
 
  238                          "Verify that we can actually set the attribute MaxTh");
 
  242        "Verify that we can actually set the attribute MaxSize");
 
  248                          "There should be zero unforced drops");
 
  251                          "There should be zero forced dropps");
 
  254                          "There should be zero drops due to queue limit");
 
  270    queue = CreateObject<RedQueueDisc>();
 
  273                          "Verify that we can actually set the attribute MinTh");
 
  276                          "Verify that we can actually set the attribute MaxTh");
 
  280        "Verify that we can actually set the attribute MaxSize");
 
  283                          "Verify that we can actually set the attribute QW");
 
  286    st = queue->GetStats();
 
  293    maxTh = 100 * modeSize;
 
  294    queue = CreateObject<RedQueueDisc>();
 
  297                          "Verify that we can actually set the attribute MinTh");
 
  300                          "Verify that we can actually set the attribute MaxTh");
 
  304        "Verify that we can actually set the attribute MaxSize");
 
  307                          "Verify that we can actually set the attribute QW");
 
  310    st = queue->GetStats();
 
  317    maxTh = 150 * modeSize;
 
  318    queue = CreateObject<RedQueueDisc>();
 
  321                          "Verify that we can actually set the attribute MinTh");
 
  324                          "Verify that we can actually set the attribute MaxTh");
 
  328        "Verify that we can actually set the attribute MaxSize");
 
  331                          "Verify that we can actually set the attribute QW");
 
  334                          "Verify that we can actually set the attribute LInterm");
 
  337    st = queue->GetStats();
 
  344    queue = CreateObject<RedQueueDisc>();
 
  347                          "Verify that we can actually set the attribute MinTh");
 
  350                          "Verify that we can actually set the attribute MaxTh");
 
  354        "Verify that we can actually set the attribute MaxSize");
 
  357                          "Verify that we can actually set the attribute QW");
 
  360                          "Verify that we can actually set the attribute Gentle");
 
  363    st = queue->GetStats();
 
  370    queue = CreateObject<RedQueueDisc>();
 
  373                          "Verify that we can actually set the attribute MinTh");
 
  376                          "Verify that we can actually set the attribute MaxTh");
 
  380        "Verify that we can actually set the attribute MaxSize");
 
  383                          "Verify that we can actually set the attribute QW");
 
  386                          "Verify that we can actually set the attribute Wait");
 
  389    st = queue->GetStats();
 
  396    queue = CreateObject<RedQueueDisc>();
 
  397    minTh = 30 * modeSize;
 
  398    maxTh = 90 * modeSize;
 
  401                          "Verify that we can actually set the attribute MinTh");
 
  404                          "Verify that we can actually set the attribute MaxTh");
 
  408        "Verify that we can actually set the attribute MaxSize");
 
  411                          "Verify that we can actually set the attribute QW");
 
  414                          "Verify that we can actually set the attribute LInterm");
 
  417                          "Verify that we can actually set the attribute Gentle");
 
  420                          "Verify that we can actually set the attribute UseECN");
 
  423    st = queue->GetStats();
 
  427                          "There should be some unforced drops");
 
  430                          "There should be no unforced marks");
 
  433    queue = CreateObject<RedQueueDisc>();
 
  436                          "Verify that we can actually set the attribute MinTh");
 
  439                          "Verify that we can actually set the attribute MaxTh");
 
  443        "Verify that we can actually set the attribute MaxSize");
 
  446                          "Verify that we can actually set the attribute QW");
 
  449                          "Verify that we can actually set the attribute LInterm");
 
  452                          "Verify that we can actually set the attribute Gentle");
 
  455                          "Verify that we can actually set the attribute UseECN");
 
  458    st = queue->GetStats();
 
  462                          "There should be some unforced drops");
 
  465                          "There should be no unforced marks");
 
  468    queue = CreateObject<RedQueueDisc>();
 
  471                          "Verify that we can actually set the attribute MinTh");
 
  474                          "Verify that we can actually set the attribute MaxTh");
 
  478        "Verify that we can actually set the attribute MaxSize");
 
  481                          "Verify that we can actually set the attribute QW");
 
  484                          "Verify that we can actually set the attribute LInterm");
 
  487                          "Verify that we can actually set the attribute Gentle");
 
  490                          "Verify that we can actually set the attribute UseECN");
 
  493    st = queue->GetStats();
 
  498                          "There should be no unforced drops");
 
  501                          "There should be some unforced marks");
 
  504    queue = CreateObject<RedQueueDisc>();
 
  505    minTh = 30 * modeSize;
 
  506    maxTh = 90 * modeSize;
 
  509                          "Verify that we can actually set the attribute MinTh");
 
  512                          "Verify that we can actually set the attribute MaxTh");
 
  516        "Verify that we can actually set the attribute MaxSize");
 
  519                          "Verify that we can actually set the attribute QW");
 
  522                          "Verify that we can actually set the attribute LInterm");
 
  525                          "Verify that we can actually set the attribute Gentle");
 
  528    st = queue->GetStats();
 
  532                          "There should some dropped packets due to probability mark");
 
  535    queue = CreateObject<RedQueueDisc>();
 
  538                          "Verify that we can actually set the attribute MinTh");
 
  541                          "Verify that we can actually set the attribute MaxTh");
 
  545        "Verify that we can actually set the attribute MaxSize");
 
  548                          "Verify that we can actually set the attribute QW");
 
  551                          "Verify that we can actually set the attribute LInterm");
 
  554                          "Verify that we can actually set the attribute Gentle");
 
  557                          "Verify that we can actually set the attribute FengAdaptive");
 
  560    st = queue->GetStats();
 
  564                          "Test 12 should have less drops due to probability mark than test 11");
 
  567    queue = CreateObject<RedQueueDisc>();
 
  568    minTh = 30 * modeSize;
 
  569    maxTh = 90 * modeSize;
 
  572                          "Verify that we can actually set the attribute MinTh");
 
  575                          "Verify that we can actually set the attribute MaxTh");
 
  579        "Verify that we can actually set the attribute MaxSize");
 
  582                          "Verify that we can actually set the attribute QW");
 
  585                          "Verify that we can actually set the attribute LInterm");
 
  588                          "Verify that we can actually set the attribute Gentle");
 
  591                          "Verify that we can actually set the attribute NLRED");
 
  594    st = queue->GetStats();
 
  598                          "Test 13 should have less drops due to probability mark than test 11");
 
  610        queue->Enqueue(Create<RedQueueDiscTestItem>(Create<Packet>(size), dest, ecnCapable));
 
  619    Simulator::Destroy();
 
Red Queue Disc Test Case.
 
void RunRedTest(QueueSizeUnit mode)
Run RED test function.
 
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
 
void DoRun() override
Implementation to actually run this TestCase.
 
Red Queue Disc Test Item.
 
void AddHeader() override
Add the header to the packet.
 
RedQueueDiscTestItem & operator=(const RedQueueDiscTestItem &)=delete
 
RedQueueDiscTestItem()=delete
 
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
 
RedQueueDiscTestItem(const RedQueueDiscTestItem &)=delete
 
bool m_ecnCapablePacket
ECN capable packet?
 
Red Queue Disc Test Suite.
 
a polymophic address class
 
AttributeValue implementation for Boolean.
 
This class can be used to hold variables of floating point type such as 'double' or 'float'.
 
uint64_t GetUid() const
Returns the packet's Uid.
 
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
 
Class for representing queue sizes.
 
AttributeValue implementation for QueueSize.
 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
 
@ UNIT
This test suite implements a Unit Test.
 
QueueSizeUnit
Enumeration of the operating modes of queues.
 
@ BYTES
Use number of bytes for queue size.
 
@ PACKETS
Use number of packets for queue size.
 
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
 
RedQueueDiscTestSuite g_redQueueTestSuite
the test suite
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
Structure that keeps the queue disc statistics.
 
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
 
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
 
uint32_t pktSize
packet size used for the simulation (in bytes)