View | Details | Raw Unified | Return to bug 2070
Collapse All | Expand All

(-)i/src/internet/test/codel-queue-test-suite.cc (-18 / +63 lines)
 Lines 61-66   class CoDelQueueBasicEnqueueDequeue : public TestCase Link Here 
61
public:
61
public:
62
  CoDelQueueBasicEnqueueDequeue (std::string mode);
62
  CoDelQueueBasicEnqueueDequeue (std::string mode);
63
  virtual void DoRun (void);
63
  virtual void DoRun (void);
64
65
  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
66
  {
67
    if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
68
      {
69
        NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
70
      }
71
    else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
72
      {
73
        NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
74
      }
75
76
    NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
77
  }
78
64
private:
79
private:
65
  StringValue m_mode;
80
  StringValue m_mode;
66
};
81
};
 Lines 109-127   CoDelQueueBasicEnqueueDequeue::DoRun (void) Link Here 
109
  p5 = Create<Packet> (pktSize);
124
  p5 = Create<Packet> (pktSize);
110
  p6 = Create<Packet> (pktSize);
125
  p6 = Create<Packet> (pktSize);
111
126
112
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in queue");
127
  QueueTestSize (queue, 0 * modeSize, "There should be no packets in queue");
113
  queue->Enqueue (p1);
128
  queue->Enqueue (p1);
114
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in queue");
129
  QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
115
  queue->Enqueue (p2);
130
  queue->Enqueue (p2);
116
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in queue");
131
  QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
117
  queue->Enqueue (p3);
132
  queue->Enqueue (p3);
118
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets in queue");
133
  QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
119
  queue->Enqueue (p4);
134
  queue->Enqueue (p4);
120
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets in queue");
135
  QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
121
  queue->Enqueue (p5);
136
  queue->Enqueue (p5);
122
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in queue");
137
  QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
123
  queue->Enqueue (p6);
138
  queue->Enqueue (p6);
124
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 6 * modeSize, "There should be six packets in queue");
139
  QueueTestSize (queue, 6 * modeSize, "There should be six packets in queue");
125
140
126
  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 0, "There should be no packets being dropped due to full queue");
141
  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 0, "There should be no packets being dropped due to full queue");
127
142
 Lines 129-160   CoDelQueueBasicEnqueueDequeue::DoRun (void) Link Here 
129
144
130
  p = queue->Dequeue ();
145
  p = queue->Dequeue ();
131
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet");
146
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet");
132
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in queue");
147
  QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
133
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?");
148
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?");
134
149
135
  p = queue->Dequeue ();
150
  p = queue->Dequeue ();
136
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the second packet");
151
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the second packet");
137
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets in queue");
152
  QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
138
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p2->GetUid (), "Was this the second packet ?");
153
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p2->GetUid (), "Was this the second packet ?");
139
154
140
  p = queue->Dequeue ();
155
  p = queue->Dequeue ();
141
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the third packet");
156
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the third packet");
142
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets in queue");
157
  QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
143
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p3->GetUid (), "Was this the third packet ?");
158
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p3->GetUid (), "Was this the third packet ?");
144
159
145
  p = queue->Dequeue ();
160
  p = queue->Dequeue ();
146
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the forth packet");
161
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the forth packet");
147
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in queue");
162
  QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
148
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
163
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
149
164
150
  p = queue->Dequeue ();
165
  p = queue->Dequeue ();
151
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the fifth packet");
166
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the fifth packet");
152
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in queue");
167
  QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
153
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
168
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
154
169
155
  p = queue->Dequeue ();
170
  p = queue->Dequeue ();
156
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the last packet");
171
  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the last packet");
157
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be zero packet in queue");
172
  QueueTestSize (queue, 0 * modeSize, "There should be zero packet in queue");
158
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
173
  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
159
174
160
  p = queue->Dequeue ();
175
  p = queue->Dequeue ();
 Lines 169-174   class CoDelQueueBasicOverflow : public TestCase Link Here 
169
public:
184
public:
170
  CoDelQueueBasicOverflow (std::string mode);
185
  CoDelQueueBasicOverflow (std::string mode);
171
  virtual void DoRun (void);
186
  virtual void DoRun (void);
187
188
  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
189
  {
190
    if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
191
      {
192
        NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
193
      }
194
    else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
195
      {
196
        NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
197
      }
198
199
    NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
200
  }
201
172
private:
202
private:
173
  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
203
  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
174
  StringValue m_mode;
204
  StringValue m_mode;
 Lines 216-222   CoDelQueueBasicOverflow::DoRun (void) Link Here 
216
  queue->Enqueue (p2);
246
  queue->Enqueue (p2);
217
  queue->Enqueue (p3);
247
  queue->Enqueue (p3);
218
248
219
  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 500 * modeSize, "There should be 500 packets in queue");
249
  QueueTestSize (queue, 500 * modeSize, "There should be 500 packets in queue");
220
  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 3, "There should be three packets being dropped due to full queue");
250
  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 3, "There should be three packets being dropped due to full queue");
221
}
251
}
222
252
 Lines 321-326   class CoDelQueueBasicDrop : public TestCase Link Here 
321
public:
351
public:
322
  CoDelQueueBasicDrop (std::string mode);
352
  CoDelQueueBasicDrop (std::string mode);
323
  virtual void DoRun (void);
353
  virtual void DoRun (void);
354
355
  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
356
  {
357
    if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
358
      {
359
        NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
360
      }
361
    else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
362
      {
363
        NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
364
      }
365
366
    NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
367
  }
368
324
private:
369
private:
325
  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
370
  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
326
  void Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize);
371
  void Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize);
 Lines 419-431   CoDelQueueBasicDrop::Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize) Link Here 
419
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
464
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
420
                                     "Sojourn time has just gone above target from below."
465
                                     "Sojourn time has just gone above target from below."
421
                                     "Hence, there should be no packet drops");
466
                                     "Hence, there should be no packet drops");
422
              NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - modeSize, "There should be 1 packet dequeued.");
467
              QueueTestSize (queue, initialQSize - modeSize, "There should be 1 packet dequeued.");
423
468
424
            }
469
            }
425
          else if (currentTime >= queue->GetInterval ())
470
          else if (currentTime >= queue->GetInterval ())
426
            {
471
            {
427
              currentDropCount = queue->GetDropCount ();
472
              currentDropCount = queue->GetDropCount ();
428
              NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
473
              QueueTestSize (queue, initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
429
                                     "We enter the dropping state, perform initial packet drop, and dequeue the next."
474
                                     "We enter the dropping state, perform initial packet drop, and dequeue the next."
430
                                     "So there should be 2 more packets dequeued.");
475
                                     "So there should be 2 more packets dequeued.");
431
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
476
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
 Lines 436-442   CoDelQueueBasicDrop::Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize) Link Here 
436
          if (currentTime.GetMicroSeconds () < initialDropNext)
481
          if (currentTime.GetMicroSeconds () < initialDropNext)
437
            {
482
            {
438
              currentDropCount = queue->GetDropCount ();
483
              currentDropCount = queue->GetDropCount ();
439
              NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - modeSize, "We are in dropping state."
484
              QueueTestSize (queue, initialQSize - modeSize, "We are in dropping state."
440
                                     "Sojourn is still above target."
485
                                     "Sojourn is still above target."
441
                                     "However, it's not time for next drop."
486
                                     "However, it's not time for next drop."
442
                                     "So there should be only 1 more packet dequeued");
487
                                     "So there should be only 1 more packet dequeued");
 Lines 446-452   CoDelQueueBasicDrop::Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize) Link Here 
446
          else if (currentTime.GetMicroSeconds () >= initialDropNext)
491
          else if (currentTime.GetMicroSeconds () >= initialDropNext)
447
            {
492
            {
448
              currentDropCount = queue->GetDropCount ();
493
              currentDropCount = queue->GetDropCount ();
449
              NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
494
              QueueTestSize (queue, initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
450
                                     "It's time for next drop."
495
                                     "It's time for next drop."
451
                                     "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
496
                                     "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
452
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1 + m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated plus 1 from last dequeue");
497
              NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1 + m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated plus 1 from last dequeue");

Return to bug 2070