26 #include "ns3/cobalt-queue-disc.h" 27 #include "ns3/packet.h" 28 #include "ns3/uinteger.h" 29 #include "ns3/string.h" 30 #include "ns3/double.h" 32 #include "ns3/simulator.h" 54 virtual void AddHeader (
void);
55 virtual bool Mark (
void);
75 m_ecnCapablePacket (ecnCapable)
113 virtual void DoRun (
void);
128 :
TestCase (
"Basic enqueue and dequeue operations, and attribute setting" +
std::to_string (mode))
139 uint32_t modeSize = 0;
144 "Verify that we can actually set the attribute Interval");
146 "Verify that we can actually set the attribute Target");
157 true,
"Verify that we can actually set the attribute MaxSize");
169 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p1, dest,0,
false));
171 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p2, dest,0,
false));
173 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p3, dest,0,
false));
175 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p4, dest,0,
false));
177 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p5, dest,0,
false));
179 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p6, dest,0,
false));
194 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
204 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (),
"Was this the fourth packet ?");
232 virtual void DoRun (
void);
251 :
TestCase (
"Drop tests verification for both packets and bytes mode")
260 uint32_t modeSize = 0;
272 queue = CreateObject<CobaltQueueDisc> ();
274 true,
"Verify that we can actually set the attribute MaxSize");
287 Simulator::Stop (
Seconds (8.0));
302 for (uint32_t i = 0; i < nPkt; i++)
312 for (uint32_t i = 0; i < nPkt; i++)
314 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
323 Simulator::Destroy ();
341 virtual void DoRun (
void);
372 :
TestCase (
"Basic mark operations")
397 uint32_t modeSize = 0;
411 true,
"Verify that we can actually set the attribute MaxSize");
413 true,
"Verify that we can actually set the attribute UseEcn");
427 Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->
GetInterval ();
431 Simulator::Destroy ();
434 queue = CreateObject<CobaltQueueDisc> ();
436 true,
"Verify that we can actually set the attribute MaxSize");
438 true,
"Verify that we can actually set the attribute UseEcn");
461 Simulator::Destroy ();
464 queue = CreateObject<CobaltQueueDisc> ();
466 true,
"Verify that we can actually set the attribute MaxSize");
468 true,
"Verify that we can actually set the attribute UseEcn");
493 Simulator::Destroy ();
500 for (uint32_t i = 0; i < nPkt; i++)
502 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0, ecnCapable));
513 uint32_t currentDropCount = 0;
514 uint32_t currentMarkCount = 0;
516 if (initialMarkCount > 0 && currentTime.
GetNanoSeconds () > initialDropNext && testCase == 3)
521 if (initialQSize != 0)
527 if (currentDropCount != 0)
534 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
536 if (currentTime < queue->GetInterval ())
543 "Sojourn time has just gone above target from below." 544 "Hence, there should be no marked packets");
552 "Sojourn time has been above target for at least interval." 553 "We enter the dropping state and perform initial packet marking" 554 "So there should be only 1 more packet dequeued.");
559 else if (initialMarkCount > 0)
566 "Sojourn is still above target." 567 "There should be only 1 more packet dequeued");
570 "current dropnext is equal to current time.");
577 "It's time for packet to be marked" 578 "So there should be only 1 more packet dequeued");
582 "to number of packets in the queue before first mark as the behavior until packet N should be the same.");
586 else if (testCase == 3)
588 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
590 if (currentTime < queue->GetInterval ())
597 "Sojourn time has just gone above target from below." 598 "Hence, there should be no marked packets");
605 "Sojourn time has been above target for at least interval." 606 "We enter the dropping state and perform initial packet marking" 607 "So there should be only 1 more packet dequeued.");
612 else if (initialMarkCount > 0)
619 "Sojourn is still above target." 620 "So there should be only 1 more packet dequeued");
623 "as dropnext is equal to current time");
630 "It's time for packet to be dropped as packets are not ecnCapable" 631 "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
Structure that keeps the queue disc statistics.
uint64_t GetUid(void) const
Returns the packet's Uid.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Boolean.
Class for representing queue sizes.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
uint32_t GetValue() const
Get the underlying value.
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 Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
void EnqueueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_UNUSED(x)
Mark a local variable as unused.
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.
Time GetInterval(void)
Get the interval.
uint32_t nPacketsBeforeFirstDrop
Number of packets in the queue before first drop.
Test 1: simple enqueue/dequeue with no drops.
virtual void DoRun(void)
Implementation to actually run this TestCase.
CobaltQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.
a polymophic address class
Cobalt Queue Disc Test Item.
CobaltQueueDiscTestItem()
int64_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
virtual void AddHeader(void)
Add the header to the packet.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Use number of packets for queue size.
#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.
QueueSizeUnit m_mode
Queue test size function.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
const Stats & GetStats(void)
Retrieve all the collected statistics.
CobaltQueueDiscTestSuite()
void DropNextTracer(int64_t oldVal, int64_t newVal)
Drop next tracer function.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t nPacketsBeforeFirstMark
Number of packets in the queue before first mark.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Test 3: Cobalt Queue Disc ECN marking Test Item.
Test 2: Cobalt Queue Disc Drop Test Item.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
bool m_ecnCapablePacket
ECN capable packet?
CobaltQueueDiscDropTest()
CobaltQueueDiscTestSuite g_cobaltQueueTestSuite
the test suite
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
CobaltQueueDiscMarkTest(QueueSizeUnit mode)
Constructor.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
double GetPdrop()
Get the drop probability of Blue.
void RunDropTest(QueueSizeUnit mode)
Run Cobalt test function.
This test suite implements a Unit Test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t pktSize
packet size used for the simulation (in bytes)
Time GetTarget(void)
Get the target queue delay.
Use number of bytes for queue size.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
void Dequeue(Ptr< CobaltQueueDisc > queue, uint32_t modeSize, uint32_t testCase)
Dequeue function.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual ~CobaltQueueDiscTestItem()