10#include "ns3/fifo-queue-disc.h"
12#include "ns3/packet-filter.h"
13#include "ns3/packet.h"
14#include "ns3/prio-queue-disc.h"
15#include "ns3/simulator.h"
16#include "ns3/socket.h"
17#include "ns3/string.h"
131 void DoRun()
override;
135 :
TestCase(
"Sanity check on the prio queue disc implementation")
144 std::string
priomap(
"0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3");
146 std::array<std::queue<uint64_t>, 4>
uids;
154 for (uint8_t
i = 0;
i < 4;
i++)
160 qdisc->AddQueueDiscClass(
c);
166 "Verify that the queue disc has 4 child queue discs");
170 "Verify that we can actually set the attribute Priomap");
175 "Verify that we can actually get the attribute Priomap");
184 for (uint16_t
i = 0;
i < 4;
i++)
188 "There should be no packets in the child queue disc " <<
i);
193 uids[
i].push(
item->GetPacket()->GetUid());
197 "There should be one packet in the child queue disc " <<
i);
209 for (uint16_t
i = 0;
i < 4;
i++)
213 "There should be one packet in the child queue disc " <<
i);
218 uids[
i].push(
item->GetPacket()->GetUid());
222 "There should be two packets in the child queue disc " <<
i);
233 for (uint16_t
i = 0;
i < 4;
i++)
235 pf2->SetReturnValue(
i);
238 "There should be two packets in the child queue disc " <<
i);
243 uids[
i].push(
item->GetPacket()->GetUid());
247 "There should be three packets in the child queue disc " <<
i);
257 for (uint16_t
i = 0;
i < 4;
i++)
259 pf2->SetReturnValue(4 +
i);
262 "The band for priority 0 must be band 0");
265 "There should be " <<
i + 3 <<
" packets in the child queue disc "
266 <<
qdisc->GetBandForPriority(0));
271 uids[0].push(
item->GetPacket()->GetUid());
275 "There should be " <<
i + 4 <<
" packets in the child queue disc "
276 <<
qdisc->GetBandForPriority(0));
285 for (uint16_t
i = 0;
i < 4;
i++)
291 "Band " <<
i <<
" should be empty");
295 item->GetPacket()->GetUid(),
296 "The dequeued packet is not the one we expected");
Prio Queue Disc Test Case.
void DoRun() override
Implementation to actually run this TestCase.
Prio Queue Disc Test Packet Filter.
~PrioQueueDiscTestFilter() override
PrioQueueDiscTestFilter(bool cls)
Constructor.
bool m_cls
whether this filter is able to classify a PrioQueueDiscTestItem
int32_t DoClassify(Ptr< QueueDiscItem > item) const override
Classify a packet.
bool CheckProtocol(Ptr< QueueDiscItem > item) const override
Checks if the filter is able to classify a kind of items.
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.
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
PrioQueueDiscTestItem(Ptr< Packet > p, const Address &addr, uint8_t priority)
Constructor.
void AddHeader() override
Add the header to the packet.
Prio Queue Disc Test Suite.
a polymophic address class
PacketFilter is the abstract base class for filters used by queue discs to classify packets.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static constexpr auto UNIT
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.