24 #include "ns3/red-queue-disc.h"
25 #include "ns3/drop-tail-queue.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/string.h"
28 #include "ns3/double.h"
30 #include "ns3/simulator.h"
38 virtual void AddHeader (
void);
64 virtual void DoRun (
void);
71 :
TestCase (
"Sanity check on the red queue implementation")
80 uint32_t modeSize = 1;
88 "Verify that we can actually set the attribute Mode");
90 "Verify that we can actually set the attribute MinTh");
92 "Verify that we can actually set the attribute MaxTh");
94 "Verify that we can actually set the attribute QueueLimit");
96 "Verify that we can actually set the attribute QW");
100 if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
104 queue->
SetTh (minTh * modeSize, maxTh * modeSize);
109 p1 = Create<Packet> (pktSize);
110 p2 = Create<Packet> (pktSize);
111 p3 = Create<Packet> (pktSize);
112 p4 = Create<Packet> (pktSize);
113 p5 = Create<Packet> (pktSize);
114 p6 = Create<Packet> (pktSize);
115 p7 = Create<Packet> (pktSize);
116 p8 = Create<Packet> (pktSize);
120 queue->
Enqueue (Create<RedQueueDiscTestItem> (p1, dest, 0));
122 queue->
Enqueue (Create<RedQueueDiscTestItem> (p2, dest, 0));
124 queue->
Enqueue (Create<RedQueueDiscTestItem> (p3, dest, 0));
125 queue->
Enqueue (Create<RedQueueDiscTestItem> (p4, dest, 0));
126 queue->
Enqueue (Create<RedQueueDiscTestItem> (p5, dest, 0));
127 queue->
Enqueue (Create<RedQueueDiscTestItem> (p6, dest, 0));
128 queue->
Enqueue (Create<RedQueueDiscTestItem> (p7, dest, 0));
129 queue->
Enqueue (Create<RedQueueDiscTestItem> (p8, dest, 0));
142 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
160 queue = CreateObject<RedQueueDisc> ();
161 minTh = 70 * modeSize;
162 maxTh = 150 * modeSize;
163 qSize = 300 * modeSize;
165 "Verify that we can actually set the attribute Mode");
167 "Verify that we can actually set the attribute MinTh");
169 "Verify that we can actually set the attribute MaxTh");
171 "Verify that we can actually set the attribute QueueLimit");
190 queue = CreateObject<RedQueueDisc> ();
192 "Verify that we can actually set the attribute Mode");
194 "Verify that we can actually set the attribute MinTh");
196 "Verify that we can actually set the attribute MaxTh");
198 "Verify that we can actually set the attribute QueueLimit");
200 "Verify that we can actually set the attribute QW");
203 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
209 maxTh = 100 * modeSize;
210 queue = CreateObject<RedQueueDisc> ();
212 "Verify that we can actually set the attribute Mode");
214 "Verify that we can actually set the attribute MinTh");
216 "Verify that we can actually set the attribute MaxTh");
218 "Verify that we can actually set the attribute QueueLimit");
220 "Verify that we can actually set the attribute QW");
223 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
229 maxTh = 150 * modeSize;
230 queue = CreateObject<RedQueueDisc> ();
232 "Verify that we can actually set the attribute Mode");
234 "Verify that we can actually set the attribute MinTh");
236 "Verify that we can actually set the attribute MaxTh");
238 "Verify that we can actually set the attribute QueueLimit");
240 "Verify that we can actually set the attribute QW");
242 "Verify that we can actually set the attribute LInterm");
245 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
251 queue = CreateObject<RedQueueDisc> ();
253 "Verify that we can actually set the attribute Mode");
255 "Verify that we can actually set the attribute MinTh");
257 "Verify that we can actually set the attribute MaxTh");
259 "Verify that we can actually set the attribute QueueLimit");
261 "Verify that we can actually set the attribute QW");
263 "Verify that we can actually set the attribute Gentle");
266 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
272 queue = CreateObject<RedQueueDisc> ();
274 "Verify that we can actually set the attribute Mode");
276 "Verify that we can actually set the attribute MinTh");
278 "Verify that we can actually set the attribute MaxTh");
280 "Verify that we can actually set the attribute QueueLimit");
282 "Verify that we can actually set the attribute QW");
284 "Verify that we can actually set the attribute Wait");
287 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
296 for (uint32_t i = 0; i < nPkt; i++)
298 queue->
Enqueue (Create<RedQueueDiscTestItem> (Create<Packet> (size), dest, 0));
307 Simulator::Destroy ();
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
AttributeValue implementation for Boolean.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
virtual void AddHeader(void)
Add the header to the packet.
uint64_t GetUid(void) const
Returns the packet's Uid.
#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.
RedQueueDiscTestSuite g_redQueueTestSuite
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt)
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
This test suite implements a Unit Test.
a polymophic address class
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
uint32_t forcedDrop
Forced drops, qavg > max threshold.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
uint32_t qLimDrop
Drops due to queue limits.
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual ~RedQueueDiscTestItem()
Queue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
void RunRedTest(StringValue mode)
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t unforcedDrop
Early probability drops.