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))
138 uint32_t pktSize = 1000;
139 uint32_t modeSize = 0;
144 "Verify that we can actually set the attribute MinBytes");
146 "Verify that we can actually set the attribute Interval");
148 "Verify that we can actually set the attribute Target");
159 true,
"Verify that we can actually set the attribute MaxSize");
163 p1 = Create<Packet> (pktSize);
164 p2 = Create<Packet> (pktSize);
165 p3 = Create<Packet> (pktSize);
166 p4 = Create<Packet> (pktSize);
167 p5 = Create<Packet> (pktSize);
168 p6 = Create<Packet> (pktSize);
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")
261 uint32_t pktSize = 1500;
262 uint32_t modeSize = 0;
274 queue = CreateObject<CobaltQueueDisc> ();
276 true,
"Verify that we can actually set the attribute MaxSize");
289 Simulator::Stop (
Seconds (8.0));
304 for (uint32_t i = 0; i < nPkt; i++)
314 for (uint32_t i = 0; i < nPkt; i++)
316 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
325 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.
Hold an unsigned integer type.
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.
Use number of bytes for queue size.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual ~CobaltQueueDiscTestItem()