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");
148 "Disable Blue enhancement");
159 true,
"Verify that we can actually set the attribute MaxSize");
171 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p1, dest,0,
false));
173 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p2, dest,0,
false));
175 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p3, dest,0,
false));
177 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p4, dest,0,
false));
179 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p5, dest,0,
false));
181 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p6, dest,0,
false));
196 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
206 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (),
"Was this the fourth packet ?");
234 virtual void DoRun (
void);
253 :
TestCase (
"Drop tests verification for both packets and bytes mode")
262 uint32_t modeSize = 0;
274 queue = CreateObject<CobaltQueueDisc> ();
276 true,
"Verify that we can actually set the attribute MaxSize");
278 "Disable Blue enhancement");
290 Simulator::Stop (
Seconds (8.0));
305 for (uint32_t i = 0; i < nPkt; i++)
315 for (uint32_t i = 0; i < nPkt; i++)
317 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
326 Simulator::Destroy ();
344 virtual void DoRun (
void);
375 :
TestCase (
"Basic mark operations")
400 uint32_t modeSize = 0;
414 true,
"Verify that we can actually set the attribute MaxSize");
416 true,
"Verify that we can actually set the attribute UseEcn");
418 "Disable Blue enhancement");
431 Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->
GetInterval ();
435 Simulator::Destroy ();
438 queue = CreateObject<CobaltQueueDisc> ();
440 true,
"Verify that we can actually set the attribute MaxSize");
442 true,
"Verify that we can actually set the attribute UseEcn");
444 "Disable Blue enhancement");
466 Simulator::Destroy ();
469 queue = CreateObject<CobaltQueueDisc> ();
471 true,
"Verify that we can actually set the attribute MaxSize");
473 true,
"Verify that we can actually set the attribute UseEcn");
475 "Disable Blue enhancement");
499 Simulator::Destroy ();
506 for (uint32_t i = 0; i < nPkt; i++)
508 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0, ecnCapable));
519 uint32_t currentDropCount = 0;
520 uint32_t currentMarkCount = 0;
522 if (initialMarkCount > 0 && currentTime.
GetNanoSeconds () > initialDropNext && testCase == 3)
527 if (initialQSize != 0)
533 if (currentDropCount != 0)
540 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
542 if (currentTime < queue->GetInterval ())
549 "Sojourn time has just gone above target from below." 550 "Hence, there should be no marked packets");
558 "Sojourn time has been above target for at least interval." 559 "We enter the dropping state and perform initial packet marking" 560 "So there should be only 1 more packet dequeued.");
565 else if (initialMarkCount > 0)
572 "Sojourn is still above target." 573 "There should be only 1 more packet dequeued");
576 "current dropnext is equal to current time.");
583 "It's time for packet to be marked" 584 "So there should be only 1 more packet dequeued");
588 "to number of packets in the queue before first mark as the behavior until packet N should be the same.");
592 else if (testCase == 3)
594 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
596 if (currentTime < queue->GetInterval ())
603 "Sojourn time has just gone above target from below." 604 "Hence, there should be no marked packets");
611 "Sojourn time has been above target for at least interval." 612 "We enter the dropping state and perform initial packet marking" 613 "So there should be only 1 more packet dequeued.");
618 else if (initialMarkCount > 0)
625 "Sojourn is still above target." 626 "So there should be only 1 more packet dequeued");
629 "as dropnext is equal to current time");
636 "It's time for packet to be dropped as packets are not ecnCapable" 637 "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
659 virtual void DoRun (
void);
693 :
TestCase (
"Test CE Threshold marking")
706 for (uint32_t i = 0; i < nPkt; i++)
708 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
715 for (uint32_t i = 0; i < nPkt; i++)
729 "mark, the delay between the enqueueing of the packets decreased after the" 730 "1st mark (packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms." 731 "Queue delay remains below or equal to 1ms for the packet enqueued before 28ms");
736 "marks, the delay between the enqueueing of the packets decreased after 1st mark" 737 "(packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms." 738 "Queue delay remains below 1ms for the packets enqueued before 28ms and increases" 739 "for the packets enqueued after 28ms.");
746 for (uint32_t i = 0; i < nPkt; i++)
757 uint32_t modeSize = 0;
769 true,
"Verify that we can actually set the attribute UseEcn");
771 true,
"Verify that we can actually set the attribute UseEcn");
773 "Disable Blue enhancement");
794 Time waitUntilDecreasingEnqueueDelay = waitUntilFirstMark +
MilliSeconds(9);
801 Simulator::Destroy ();
824 virtual void DoRun (
void);
848 :
TestCase (
"Enhanced Blue tests verification for both packets and bytes mode")
862 uint32_t modeSize = 0;
875 Enqueue (queue, modeSize, 200);
878 Simulator::Stop (
Seconds (8.0));
884 NS_TEST_EXPECT_MSG_EQ (queue->
GetPdrop (), 0.234375,
"Pdrop should be increased by 1/256 for every packet whose sojourn time is above 400ms." 885 " From the 41st dequeue until the last one, sojourn time is above 400ms, so 60 packets have sojourn time above 400ms" 886 "hence Pdrop should be increased 60*(1/256) which is 0.234375");
888 Simulator::Destroy ();
891 queue = CreateObject<CobaltQueueDisc> ();
893 true,
"Verify that we can actually set the attribute UseEcn");
895 "Disable Blue enhancement");
897 Enqueue (queue, modeSize, 200);
900 Simulator::Stop (
Seconds (8.0));
907 Simulator::Destroy ();
914 for (uint32_t i = 0; i < nPkt; i++)
916 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
929 for (uint32_t i = 0; i < nPkt; i++)
Structure that keeps the queue disc statistics.
void Dequeue(Ptr< CobaltQueueDisc > queue)
Dequeue function.
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)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
#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.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
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()
virtual void AddHeader(void)
Add the header to the packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
CobaltQueueDiscEnhancedBlueTest(QueueSizeUnit mode)
AttributeValue implementation for Time.
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.
virtual ~CobaltQueueDiscCeThresholdTest()
void EnqueueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt, Time delay)
Enqueue with delay function.
CobaltQueueDiscTestSuite()
Test 5: Cobalt Queue Disc Enhanced Blue Test Item This test checks that the Blue Enhancement is worki...
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...
Time GetTarget(void) const
Get the target queue delay.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
double GetPdrop() const
Get the drop probability of Blue.
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.
int64_t GetDropNext(void) const
Get the time for next packet drop while in the dropping state.
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.
void Dequeue(Ptr< CobaltQueueDisc > queue, uint32_t modeSize)
Dequeue function.
bool m_ecnCapablePacket
ECN capable packet?
virtual void DoRun(void)
Implementation to actually run this TestCase.
CobaltQueueDiscDropTest()
CobaltQueueDiscTestSuite g_cobaltQueueTestSuite
the test suite
Time GetInterval(void) const
Get the interval.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test 4: Cobalt Queue Disc CE Threshold marking Test Item.
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 MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
virtual ~CobaltQueueDiscEnhancedBlueTest()
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)
CobaltQueueDiscCeThresholdTest(QueueSizeUnit mode)
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.
void DequeueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t nPkt, Time delay)
Dequeue with delay 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.
void DequeueWithDelay(Ptr< CobaltQueueDisc > queue, uint32_t modeSize, uint32_t nPkt, Time delay)
Dequeue with delay function.
virtual ~CobaltQueueDiscTestItem()
void Enqueue(Ptr< CobaltQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.