13#include "ns3/cobalt-queue-disc.h"
14#include "ns3/double.h"
16#include "ns3/packet.h"
17#include "ns3/simulator.h"
18#include "ns3/string.h"
20#include "ns3/uinteger.h"
58 m_ecnCapablePacket(ecnCapable)
91 void DoRun()
override;
106 :
TestCase(
"Basic enqueue and dequeue operations, and attribute setting" +
std::to_string(mode))
123 "Verify that we can actually set the attribute Interval");
126 "Verify that we can actually set the attribute Target");
129 "Disable Blue enhancement");
131 if (
m_mode == QueueSizeUnit::BYTES)
135 else if (
m_mode == QueueSizeUnit::PACKETS)
142 "Verify that we can actually set the attribute MaxSize");
160 "There should be no packets in queue");
164 "There should be one packet in queue");
168 "There should be two packets in queue");
172 "There should be three packets in queue");
176 "There should be four packets in queue");
180 "There should be five packets in queue");
184 "There should be six packets in queue");
188 "There should be no packets being dropped due to full queue");
192 item = queue->Dequeue();
196 "There should be five packets in queue");
199 item = queue->Dequeue();
203 "There should be four packets in queue");
206 "Was this the second packet ?");
208 item = queue->Dequeue();
212 "There should be three packets in queue");
215 item = queue->Dequeue();
219 "There should be two packets in queue");
222 "Was this the fourth packet ?");
224 item = queue->Dequeue();
228 "There should be one packet in queue");
231 item = queue->Dequeue();
235 "There should be zero packet in queue");
238 item = queue->Dequeue();
244 "There should be no packet drops according to Cobalt algorithm");
256 void DoRun()
override;
281 :
TestCase(
"Drop tests verification for both packets and bytes mode")
293 if (mode == QueueSizeUnit::BYTES)
297 else if (mode == QueueSizeUnit::PACKETS)
306 "Verify that we can actually set the attribute MaxSize");
309 "Disable Blue enhancement");
312 if (mode == QueueSizeUnit::BYTES)
330 "Drops due to queue overflow should be non-zero");
381 void DoRun()
override;
439 if (
m_mode == QueueSizeUnit::BYTES)
443 else if (
m_mode == QueueSizeUnit::PACKETS)
451 "Verify that we can actually set the attribute MaxSize");
454 "Verify that we can actually set the attribute UseEcn");
457 "Disable Blue enhancement");
464 "There should be 20 packets in queue.");
468 Time waitUntilFirstDequeue = 2 * queue->GetTarget();
477 Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval();
493 "Verify that we can actually set the attribute MaxSize");
496 "Verify that we can actually set the attribute UseEcn");
499 "Disable Blue enhancement");
506 "There should be 20 packets in queue.");
550 "Verify that we can actually set the attribute MaxSize");
553 "Verify that we can actually set the attribute UseEcn");
556 "Disable Blue enhancement");
565 "There should be 20 packets in queue.");
622 uint32_t initialQSize = queue->GetCurrentSize().GetValue();
623 uint32_t initialDropNext = queue->GetDropNext();
628 if (initialMarkCount > 0 && currentTime.
GetNanoSeconds() > initialDropNext && testCase == 3)
630 queue->TraceConnectWithoutContext(
635 if (initialQSize != 0)
642 if (currentDropCount != 0)
649 if (initialMarkCount == 0 && currentTime > queue->GetTarget())
651 if (currentTime < queue->GetInterval())
658 initialQSize - modeSize,
659 "There should be 1 packet dequeued.");
662 "There should not be any packet drops");
665 "We are not in dropping state."
666 "Sojourn time has just gone above target from below."
667 "Hence, there should be no marked packets");
669 else if (currentTime >= queue->GetInterval())
677 queue->GetCurrentSize().GetValue(),
678 initialQSize - modeSize,
679 "Sojourn time has been above target for at least interval."
680 "We enter the dropping state and perform initial packet marking"
681 "So there should be only 1 more packet dequeued.");
684 "There should not be any packet drops");
688 else if (initialMarkCount > 0)
697 initialQSize - modeSize,
698 "We are in dropping state."
699 "Sojourn is still above target."
700 "There should be only 1 more packet dequeued");
703 "There should not be any packet drops");
706 "There should be 2 marked packet as."
707 "current dropnext is equal to current time.");
716 initialQSize - modeSize,
717 "We are in dropping state."
718 "It's time for packet to be marked"
719 "So there should be only 1 more packet dequeued");
722 "There should not be any packet drops");
727 "Number of packets in the queue before drop should be equal"
728 "to number of packets in the queue before first mark as the behavior until "
729 "packet N should be the same.");
733 else if (testCase == 3)
735 if (initialMarkCount == 0 && currentTime > queue->GetTarget())
737 if (currentTime < queue->GetInterval())
744 initialQSize - modeSize,
745 "There should be 1 packet dequeued.");
748 "There should not be any packet drops");
751 "We are not in dropping state."
752 "Sojourn time has just gone above target from below."
753 "Hence, there should be no marked packets");
755 else if (currentTime >= queue->GetInterval())
762 queue->GetCurrentSize().GetValue(),
763 initialQSize - modeSize,
764 "Sojourn time has been above target for at least interval."
765 "We enter the dropping state and perform initial packet marking"
766 "So there should be only 1 more packet dequeued.");
769 "There should not be any packet drops");
773 else if (initialMarkCount > 0)
782 initialQSize - modeSize,
783 "We are in dropping state."
784 "Sojourn is still above target."
785 "So there should be only 1 more packet dequeued");
788 "There should not be any packet drops");
791 "There should be 2 marked packet"
792 "as dropnext is equal to current time");
801 queue->GetCurrentSize().GetValue(),
803 "We are in dropping state."
804 "It's time for packet to be dropped as packets are not ecnCapable"
805 "The number of packets dequeued equals to the number of times m_dropNext "
806 "is updated plus initial dequeue");
810 "The number of drops equals to the number of times m_dropNext is updated");
813 "There should still be only 2 marked packet");
837 void DoRun()
override;
871 :
TestCase(
"Test CE Threshold marking")
917 "There should be only 1 packet"
918 "mark, the delay between the enqueueing of the packets decreased after the"
919 "1st mark (packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms."
920 "Queue delay remains below or equal to 1ms for the packet enqueued before 28ms");
927 "There should be 3 packet"
928 "marks, the delay between the enqueueing of the packets decreased after 1st mark"
929 "(packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms."
930 "Queue delay remains below 1ms for the packets enqueued before 28ms and increases"
931 "for the packets enqueued after 28ms.");
958 if (
m_mode == QueueSizeUnit::BYTES)
962 else if (
m_mode == QueueSizeUnit::PACKETS)
969 "Verify that we can actually set the attribute UseEcn");
972 "Verify that we can actually set the attribute UseEcn");
975 "Disable Blue enhancement");
1009 Time waitUntilDecreasingEnqueueDelay = waitUntilFirstMark +
MilliSeconds(9);
1055 void DoRun()
override;
1079 :
TestCase(
"Enhanced Blue tests verification for both packets and bytes mode")
1096 if (
m_mode == QueueSizeUnit::BYTES)
1100 else if (
m_mode == QueueSizeUnit::PACKETS)
1104 queue->Initialize();
1105 queue->AssignStreams(1);
1106 Enqueue(queue, modeSize, 200);
1118 "Pdrop should be increased by 1/256 for every packet whose sojourn time is above 400ms."
1119 " From the 41st dequeue until the last one, sojourn time is above 400ms, so 60 packets "
1120 "have sojourn time above 400ms"
1121 "hence Pdrop should be increased 60*(1/256) which is 0.234375");
1124 "There should a fixed number of drops (49 here)");
1130 "Verify that we can actually set the attribute UseEcn");
1133 "Disable Blue enhancement");
1134 queue->Initialize();
1135 Enqueue(queue, modeSize, 200);
1141 st = queue->GetStats();
1146 "There should not any dropped packets");
1154 for (
uint32_t i = 0; i < nPkt; i++)
1171 for (
uint32_t i = 0; i < nPkt; i++)
Test 1: simple enqueue/dequeue with no drops.
QueueSizeUnit m_mode
Queue test size function.
void DoRun() override
Implementation to actually run this TestCase.
CobaltQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.
Test 4: Cobalt Queue Disc CE Threshold marking Test Item.
~CobaltQueueDiscCeThresholdTest() override
CobaltQueueDiscCeThresholdTest(QueueSizeUnit mode)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
void DequeueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t modeSize, uint32_t nPkt, Time delay)
Dequeue with delay function.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
void EnqueueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt, Time delay)
Enqueue with delay function.
void Dequeue(Ptr< CobaltQueueDisc > queue, uint32_t modeSize)
Dequeue function.
Test 2: Cobalt Queue Disc Drop Test Item.
void DoRun() override
Implementation to actually run this TestCase.
void RunDropTest(QueueSizeUnit mode)
Run Cobalt test function.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
void EnqueueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue the given number of packets, each of the given size, at different times.
CobaltQueueDiscDropTest()
Test 5: Cobalt Queue Disc Enhanced Blue Test Item This test checks that the Blue Enhancement is worki...
CobaltQueueDiscEnhancedBlueTest(QueueSizeUnit mode)
Constructor.
void Dequeue(Ptr< CobaltQueueDisc > queue)
Dequeue function.
void DoRun() override
Implementation to actually run this TestCase.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
void DequeueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t nPkt, Time delay)
Dequeue with delay function.
~CobaltQueueDiscEnhancedBlueTest() override
Test 3: Cobalt Queue Disc ECN marking Test Item.
CobaltQueueDiscMarkTest(QueueSizeUnit mode)
Constructor.
uint32_t nPacketsBeforeFirstMark
Number of packets in the queue before first mark.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
void DropNextTracer(int64_t oldVal, int64_t newVal)
Drop next tracer function.
uint32_t nPacketsBeforeFirstDrop
Number of packets in the queue before first drop.
void DoRun() override
Implementation to actually run this TestCase.
void Dequeue(Ptr< CobaltQueueDisc > queue, uint32_t modeSize, uint32_t testCase)
Dequeue function.
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
Cobalt Queue Disc Test Item.
bool m_ecnCapablePacket
ECN capable packet?
CobaltQueueDiscTestItem()=delete
~CobaltQueueDiscTestItem() override
CobaltQueueDiscTestItem & operator=(const CobaltQueueDiscTestItem &)=delete
void AddHeader() override
Add the header to the packet.
CobaltQueueDiscTestItem(const CobaltQueueDiscTestItem &)=delete
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
The COBALT queue disc test suite.
CobaltQueueDiscTestSuite()
a polymophic address class
AttributeValue implementation for Boolean.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
AttributeValue implementation for Time.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#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_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
CobaltQueueDiscTestSuite g_cobaltQueueTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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 pktSize
packet size used for the simulation (in bytes)