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 ();
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.
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.
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.
Test 1: simple enqueue/dequeue with no drops.
CobaltQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.
a polymophic address class
Cobalt Queue Disc Test Item.
CobaltQueueDiscTestItem()
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.
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()
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.
Test 2: Cobalt Queue Disc Drop Test Item.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
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)
Use number of bytes for queue size.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual ~CobaltQueueDiscTestItem()