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"    54   virtual void AddHeader (
void);
    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++)
   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);
   209       uids[i].push (item->GetPacket ()->GetUid ());
   212                              1, 
"There should be one packet in the child queue disc " << i);
   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);
   232       uids[i].push (item->GetPacket ()->GetUid ());
   235                              2, 
"There should be two packets in the child queue disc " << i);
   246   for (uint16_t i = 0; i < 4; i++)
   250                              2, 
"There should be two packets in the child queue disc " << i);
   252       item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, 0);
   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++)
   273                              "There should be " << i+3 << 
" packets in the child queue disc "   276       item = Create<PrioQueueDiscTestItem> (Create<Packet> (100), dest, 1);
   279       uids[0].push (item->GetPacket ()->GetUid ());
   282                              "There should be " << i+4 << 
" packets in the child queue disc "   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 ();
 uint64_t GetUid(void) const
Returns the packet's Uid. 
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes. 
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline. 
Hold variables of type string. 
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class. 
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
virtual ~PrioQueueDiscTestFilter()
#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. 
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros. 
Ptr< Packet > GetPacket(void) const
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items. 
PrioQueueDiscTestFilter(bool cls)
Constructor. 
a polymophic address class 
virtual void AddHeader(void)
Add the header to the packet. 
virtual ~PrioQueueDiscTestItem()
make Callback use a separate empty type 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag. 
indicates whether the socket has a priority set. 
PrioQueueDiscTestItem(Ptr< Packet > p, const Address &addr, uint8_t priority)
Constructor. 
Prio Queue Disc Test Case. 
void SetReturnValue(int32_t ret)
Set the value returned by DoClassify. 
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class. 
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet. 
Prio Queue Disc Test Packet Filter. 
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. 
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes. 
PrioQueueDiscTestSuite g_prioQueueTestSuite
the test suite 
int32_t m_ret
the value that DoClassify returns if m_cls is true 
Prio Queue Disc Test Suite. 
PacketFilter is the abstract base class for filters used by queue discs to classify packets...
uint16_t GetBandForPriority(uint8_t prio) const
Get the band (class) assigned to packets with specified priority. 
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets. 
This test suite implements a Unit Test. 
void SetPriority(uint8_t priority)
Set the tag's priority. 
Prio Queue Disc Test Item. 
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one. 
bool m_cls
whether this filter is able to classify a PrioQueueDiscTestItem 
virtual void DoRun(void)
Implementation to actually run this TestCase.