23#include "ns3/prio-queue-disc.h" 
   24#include "ns3/fifo-queue-disc.h" 
   25#include "ns3/packet-filter.h" 
   26#include "ns3/packet.h" 
   27#include "ns3/socket.h" 
   28#include "ns3/string.h" 
   30#include "ns3/simulator.h" 
   55  virtual bool Mark (
void);
 
  152  virtual void DoRun (
void);
 
  156  : 
TestCase (
"Sanity check on the prio queue disc implementation")
 
  165  std::string priomap (
"0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3");
 
  167  std::array<std::queue<uint64_t>,4> uids;
 
  172  qdisc = CreateObject<PrioQueueDisc> ();
 
  175  for (uint8_t i = 0; i < 4; i++)
 
  178      child->Initialize ();
 
  180      c->SetQueueDisc (child);
 
  181      qdisc->AddQueueDiscClass (c);
 
  183  qdisc->Initialize ();
 
  185  NS_TEST_ASSERT_MSG_EQ (qdisc->GetNQueueDiscClasses (), 4, 
"Verify that the queue disc has 4 child queue discs");
 
  188                         true, 
"Verify that we can actually set the attribute Priomap");
 
  192                         true, 
"Verify that we can actually get the attribute Priomap");
 
  201  for (uint16_t i = 0; i < 4; i++)
 
  204                             0, 
"There should be no packets in the child queue disc " << i);
 
  206      item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, i);
 
  207      qdisc->Enqueue (item);
 
  209      uids[i].push (item->GetPacket ()->GetUid ());
 
  212                             1, 
"There should be one packet in the child queue disc " << i);
 
  221  qdisc->AddPacketFilter (pf1);
 
  224  for (uint16_t i = 0; i < 4; i++)
 
  227                             1, 
"There should be one packet in the child queue disc " << i);
 
  229      item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, i+4);
 
  230      qdisc->Enqueue (item);
 
  232      uids[i].push (item->GetPacket ()->GetUid ());
 
  235                             2, 
"There should be two packets in the child queue disc " << i);
 
  243  qdisc->AddPacketFilter (pf2);
 
  246  for (uint16_t i = 0; i < 4; i++)
 
  248      pf2->SetReturnValue (i);
 
  250                             2, 
"There should be two packets in the child queue disc " << i);
 
  252      item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, 0);
 
  253      qdisc->Enqueue (item);
 
  255      uids[i].push (item->GetPacket ()->GetUid ());
 
  258                             3, 
"There should be three packets in the child queue disc " << i);
 
  268  for (uint16_t i = 0; i < 4; i++)
 
  270      pf2->SetReturnValue (4+i);
 
  273                             "There should be " << i+3 << 
" packets in the child queue disc " 
  274                             << qdisc->GetBandForPriority (0));
 
  276      item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, 1);
 
  277      qdisc->Enqueue (item);
 
  279      uids[0].push (item->GetPacket ()->GetUid ());
 
  282                             "There should be " << i+4 << 
" packets in the child queue disc " 
  283                             << qdisc->GetBandForPriority (0));
 
  290  while ((item = qdisc->Dequeue ()))
 
  292      for (uint16_t i = 0; i < 4; i++)
 
  294          if (uids[i].
empty ())
 
  297                                     0, 
"Band " << i << 
" should be empty");
 
  301                                 "The dequeued packet is not the one we expected");
 
  307  Simulator::Destroy ();
 
Prio Queue Disc Test Case.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
Prio Queue Disc Test Packet Filter.
 
PrioQueueDiscTestFilter(bool cls)
Constructor.
 
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
 
bool m_cls
whether this filter is able to classify a PrioQueueDiscTestItem
 
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
 
virtual ~PrioQueueDiscTestFilter()
 
void SetReturnValue(int32_t ret)
Set the value returned by DoClassify.
 
int32_t m_ret
the value that DoClassify returns if m_cls is true
 
Prio Queue Disc Test Item.
 
virtual void AddHeader(void)
Add the header to the packet.
 
PrioQueueDiscTestItem(Ptr< Packet > p, const Address &addr, uint8_t priority)
Constructor.
 
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
 
virtual ~PrioQueueDiscTestItem()
 
Prio Queue Disc Test Suite.
 
a polymophic address class
 
PacketFilter is the abstract base class for filters used by queue discs to classify packets.
 
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
 
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
 
indicates whether the socket has a priority set.
 
void SetPriority(uint8_t priority)
Set the tag's priority.
 
Hold variables of type string.
 
std::string Get(void) const
 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
 
@ UNIT
This test suite implements a Unit Test.
 
make Callback use a separate empty type
 
#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.
 
PrioQueueDiscTestSuite g_prioQueueTestSuite
the test suite
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.