23 #include "ns3/red-queue.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 #include "ns3/double.h"
28 #include "ns3/simulator.h"
36 virtual void DoRun (
void);
38 void Enqueue (
Ptr<RedQueue> queue, uint32_t size, uint32_t nPkt);
43 :
TestCase (
"Sanity check on the red queue implementation")
52 uint32_t modeSize = 1;
60 "Verify that we can actually set the attribute Mode");
62 "Verify that we can actually set the attribute MinTh");
64 "Verify that we can actually set the attribute MaxTh");
66 "Verify that we can actually set the attribute QueueLimit");
68 "Verify that we can actually set the attribute QW");
70 if (queue->
GetMode () == RedQueue::QUEUE_MODE_BYTES)
74 queue->
SetTh (minTh * pktSize, maxTh * pktSize);
79 p1 = Create<Packet> (pktSize);
80 p2 = Create<Packet> (pktSize);
81 p3 = Create<Packet> (pktSize);
82 p4 = Create<Packet> (pktSize);
83 p5 = Create<Packet> (pktSize);
84 p6 = Create<Packet> (pktSize);
85 p7 = Create<Packet> (pktSize);
86 p8 = Create<Packet> (pktSize);
129 queue = CreateObject<RedQueue> ();
130 minTh = 70 * modeSize;
131 maxTh = 150 * modeSize;
132 qSize = 300 * modeSize;
134 "Verify that we can actually set the attribute Mode");
136 "Verify that we can actually set the attribute MinTh");
138 "Verify that we can actually set the attribute MaxTh");
140 "Verify that we can actually set the attribute QueueLimit");
158 queue = CreateObject<RedQueue> ();
160 "Verify that we can actually set the attribute Mode");
162 "Verify that we can actually set the attribute MinTh");
164 "Verify that we can actually set the attribute MaxTh");
166 "Verify that we can actually set the attribute QueueLimit");
168 "Verify that we can actually set the attribute QW");
170 st = StaticCast<RedQueue> (queue)->GetStats ();
176 maxTh = 100 * modeSize;
177 queue = CreateObject<RedQueue> ();
179 "Verify that we can actually set the attribute Mode");
181 "Verify that we can actually set the attribute MinTh");
183 "Verify that we can actually set the attribute MaxTh");
185 "Verify that we can actually set the attribute QueueLimit");
187 "Verify that we can actually set the attribute QW");
189 st = StaticCast<RedQueue> (queue)->GetStats ();
195 maxTh = 150 * modeSize;
196 queue = CreateObject<RedQueue> ();
198 "Verify that we can actually set the attribute Mode");
200 "Verify that we can actually set the attribute MinTh");
202 "Verify that we can actually set the attribute MaxTh");
204 "Verify that we can actually set the attribute QueueLimit");
206 "Verify that we can actually set the attribute QW");
208 "Verify that we can actually set the attribute LInterm");
210 st = StaticCast<RedQueue> (queue)->GetStats ();
216 queue = CreateObject<RedQueue> ();
218 "Verify that we can actually set the attribute Mode");
220 "Verify that we can actually set the attribute MinTh");
222 "Verify that we can actually set the attribute MaxTh");
224 "Verify that we can actually set the attribute QueueLimit");
226 "Verify that we can actually set the attribute QW");
228 "Verify that we can actually set the attribute Gentle");
230 st = StaticCast<RedQueue> (queue)->GetStats ();
236 queue = CreateObject<RedQueue> ();
238 "Verify that we can actually set the attribute Mode");
240 "Verify that we can actually set the attribute MinTh");
242 "Verify that we can actually set the attribute MaxTh");
244 "Verify that we can actually set the attribute QueueLimit");
246 "Verify that we can actually set the attribute QW");
248 "Verify that we can actually set the attribute Wait");
250 st = StaticCast<RedQueue> (queue)->GetStats ();
258 for (uint32_t i = 0; i < nPkt; i++)
260 queue->
Enqueue (Create<Packet> (size));
269 Simulator::Destroy ();
uint32_t qLimDrop
Forced drops, qavg > max threshold.
smart pointer class similar to boost::intrusive_ptr
bool Enqueue(Ptr< Packet > p)
Place a packet into the rear of the Queue.
hold variables of type string
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
uint64_t GetUid(void) const
A packet is allocated a new uid when it is created empty or with zero-filled payload.
void Enqueue(Ptr< RedQueue > queue, uint32_t size, uint32_t nPkt)
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
RedQueue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
Hold an unsigned integer type.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Ptr< Packet > Dequeue(void)
Remove a packet from the front of the Queue.
RedQueueTestSuite g_redQueueTestSuite
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
uint32_t forcedDrop
Early probability drops.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
This test suite implements a Unit Test.
Hold a floating point type.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void RunRedTest(StringValue mode)