A Discrete-Event Network Simulator
API
fq-cobalt-queue-disc-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
4  * Copyright (c) 2020 NITK Surathkal (adapted for COBALT)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Pasquale Imputato <p.imputato@gmail.com>
20  * Stefano Avallone <stefano.avallone@unina.it>
21  * Modified by: Bhaskar Kataria <bhaskar.k7920@gmail.com> (COBALT changes)
22  */
23 
24 #include "ns3/test.h"
25 #include "ns3/simulator.h"
26 #include "ns3/fq-cobalt-queue-disc.h"
27 #include "ns3/cobalt-queue-disc.h"
28 #include "ns3/ipv4-header.h"
29 #include "ns3/ipv4-packet-filter.h"
30 #include "ns3/ipv4-queue-disc-item.h"
31 #include "ns3/ipv4-address.h"
32 #include "ns3/ipv6-header.h"
33 #include "ns3/ipv6-packet-filter.h"
34 #include "ns3/ipv6-queue-disc-item.h"
35 #include "ns3/tcp-header.h"
36 #include "ns3/udp-header.h"
37 #include "ns3/string.h"
38 #include "ns3/pointer.h"
39 
40 using namespace ns3;
41 
42 // Variable to assign m_hash to a new packet's flow
43 int32_t m_hash;
44 
50 public:
55  static TypeId GetTypeId (void);
56 
58  virtual ~Ipv4FqCobaltTestPacketFilter ();
59 
60 private:
61  virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
62  virtual bool CheckProtocol (Ptr<QueueDiscItem> item) const;
63 };
64 
65 TypeId
67 {
68  static TypeId tid = TypeId ("ns3::Ipv4FqCobaltTestPacketFilter")
70  .SetGroupName ("Internet")
71  .AddConstructor<Ipv4FqCobaltTestPacketFilter> ()
72  ;
73  return tid;
74 }
75 
77 {
78 }
79 
81 {
82 }
83 
84 int32_t
86 {
87  return m_hash;
88 }
89 
90 bool
92 {
93  return true;
94 }
95 
100 {
101 public:
104 
105 private:
106  virtual void DoRun (void);
107 };
108 
110  : TestCase ("Test packets that are not classified by any filter")
111 {
112 }
113 
115 {
116 }
117 
118 void
120 {
121  // Packets that cannot be classified by the available filters should be dropped
122  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("4p"));
123  Ptr<Ipv4FqCobaltTestPacketFilter> filter = CreateObject<Ipv4FqCobaltTestPacketFilter> ();
124  queueDisc->AddPacketFilter (filter);
125 
126  m_hash = -1;
127  queueDisc->SetQuantum (1500);
128  queueDisc->Initialize ();
129 
130  Ptr<Packet> p;
131  p = Create<Packet> ();
133  Ipv6Header ipv6Header;
134  Address dest;
135  item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
136  queueDisc->Enqueue (item);
137  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0, "no flow queue should have been created");
138 
139  p = Create<Packet> (reinterpret_cast<const uint8_t*> ("hello, world"), 12);
140  item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
141  queueDisc->Enqueue (item);
142  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0, "no flow queue should have been created");
143 
144  Simulator::Destroy ();
145 }
146 
151 {
152 public:
155 
156 private:
157  virtual void DoRun (void);
163  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
164 };
165 
167  : TestCase ("Test IP flows separation and packet limit")
168 {
169 }
170 
172 {
173 }
174 
175 void
177 {
178  Ptr<Packet> p = Create<Packet> (100);
179  Address dest;
180  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, hdr);
181  queue->Enqueue (item);
182 }
183 
184 void
186 {
187  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("4p"));
188 
189  queueDisc->SetQuantum (1500);
190  queueDisc->Initialize ();
191 
192  Ipv4Header hdr;
193  hdr.SetPayloadSize (100);
194  hdr.SetSource (Ipv4Address ("10.10.1.1"));
195  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
196  hdr.SetProtocol (7);
197 
198  // Add three packets from the first flow
199  AddPacket (queueDisc, hdr);
200  AddPacket (queueDisc, hdr);
201  AddPacket (queueDisc, hdr);
202  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3, "unexpected number of packets in the queue disc");
203  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the flow queue");
204 
205  // Add two packets from the second flow
206  hdr.SetDestination (Ipv4Address ("10.10.1.7"));
207  // Add the first packet
208  AddPacket (queueDisc, hdr);
209  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4, "unexpected number of packets in the queue disc");
210  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the flow queue");
211  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the flow queue");
212  // Add the second packet that causes two packets to be dropped from the fat flow (max backlog = 300, threshold = 150)
213  AddPacket (queueDisc, hdr);
214  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3, "unexpected number of packets in the queue disc");
215  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the flow queue");
216  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the flow queue");
217 
218  Simulator::Destroy ();
219 }
220 
225 {
226 public:
228  virtual ~FqCobaltQueueDiscDeficit ();
229 
230 private:
231  virtual void DoRun (void);
237  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
238 };
239 
241  : TestCase ("Test credits and flows status")
242 {
243 }
244 
246 {
247 }
248 
249 void
251 {
252  Ptr<Packet> p = Create<Packet> (100);
253  Address dest;
254  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, hdr);
255  queue->Enqueue (item);
256 }
257 
258 void
260 {
261  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ();
262 
263  queueDisc->SetQuantum (90);
264  queueDisc->Initialize ();
265 
266  Ipv4Header hdr;
267  hdr.SetPayloadSize (100);
268  hdr.SetSource (Ipv4Address ("10.10.1.1"));
269  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
270  hdr.SetProtocol (7);
271 
272  // Add a packet from the first flow
273  AddPacket (queueDisc, hdr);
274  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1, "unexpected number of packets in the queue disc");
275  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the first flow queue");
276  Ptr<FqCobaltFlow> flow1 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (0));
277  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), static_cast<int32_t> (queueDisc->GetQuantum ()), "the deficit of the first flow must equal the quantum");
278  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW, "the first flow must be in the list of new queues");
279  // Dequeue a packet
280  queueDisc->Dequeue ();
281  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0, "unexpected number of packets in the queue disc");
282  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0, "unexpected number of packets in the first flow queue");
283  // the deficit for the first flow becomes 90 - (100+20) = -30
284  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), -30, "unexpected deficit for the first flow");
285 
286  // Add two packets from the first flow
287  AddPacket (queueDisc, hdr);
288  AddPacket (queueDisc, hdr);
289  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2, "unexpected number of packets in the queue disc");
290  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the first flow queue");
291  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW, "the first flow must still be in the list of new queues");
292 
293  // Add two packets from the second flow
294  hdr.SetDestination (Ipv4Address ("10.10.1.10"));
295  AddPacket (queueDisc, hdr);
296  AddPacket (queueDisc, hdr);
297  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4, "unexpected number of packets in the queue disc");
298  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the first flow queue");
299  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the second flow queue");
300  Ptr<FqCobaltFlow> flow2 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (1));
301  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), static_cast<int32_t> (queueDisc->GetQuantum ()), "the deficit of the second flow must equal the quantum");
302  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW, "the second flow must be in the list of new queues");
303 
304  // Dequeue a packet (from the second flow, as the first flow has a negative deficit)
305  queueDisc->Dequeue ();
306  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3, "unexpected number of packets in the queue disc");
307  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the first flow queue");
308  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
309  // the first flow got a quantum of deficit (-30+90=60) and has been moved to the end of the list of old queues
310  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), 60, "unexpected deficit for the first flow");
311  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW, "the first flow must be in the list of old queues");
312  // the second flow has a negative deficit (-30) and is still in the list of new queues
313  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), -30, "unexpected deficit for the second flow");
314  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW, "the second flow must be in the list of new queues");
315 
316  // Dequeue a packet (from the first flow, as the second flow has a negative deficit)
317  queueDisc->Dequeue ();
318  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2, "unexpected number of packets in the queue disc");
319  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the first flow queue");
320  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
321  // the first flow has a negative deficit (60-(100+20)= -60) and stays in the list of old queues
322  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), -60, "unexpected deficit for the first flow");
323  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW, "the first flow must be in the list of old queues");
324  // the second flow got a quantum of deficit (-30+90=60) and has been moved to the end of the list of old queues
325  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), 60, "unexpected deficit for the second flow");
326  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW, "the second flow must be in the list of new queues");
327 
328  // Dequeue a packet (from the second flow, as the first flow has a negative deficit)
329  queueDisc->Dequeue ();
330  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1, "unexpected number of packets in the queue disc");
331  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the first flow queue");
332  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0, "unexpected number of packets in the second flow queue");
333  // the first flow got a quantum of deficit (-60+90=30) and has been moved to the end of the list of old queues
334  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), 30, "unexpected deficit for the first flow");
335  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW, "the first flow must be in the list of old queues");
336  // the second flow has a negative deficit (60-(100+20)= -60)
337  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), -60, "unexpected deficit for the second flow");
338  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW, "the second flow must be in the list of new queues");
339 
340  // Dequeue a packet (from the first flow, as the second flow has a negative deficit)
341  queueDisc->Dequeue ();
342  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0, "unexpected number of packets in the queue disc");
343  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0, "unexpected number of packets in the first flow queue");
344  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0, "unexpected number of packets in the second flow queue");
345  // the first flow has a negative deficit (30-(100+20)= -90)
346  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), -90, "unexpected deficit for the first flow");
347  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW, "the first flow must be in the list of old queues");
348  // the second flow got a quantum of deficit (-60+90=30) and has been moved to the end of the list of old queues
349  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), 30, "unexpected deficit for the second flow");
350  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW, "the second flow must be in the list of new queues");
351 
352  // Dequeue a packet
353  queueDisc->Dequeue ();
354  // the first flow is at the head of the list of old queues but has a negative deficit, thus it gets a quantun
355  // of deficit (-90+90=0) and is moved to the end of the list of old queues. Then, the second flow (which has a
356  // positive deficit) is selected, but the second flow is empty and thus it is set to inactive. The first flow is
357  // reconsidered, but it has a null deficit, hence it gets another quantum of deficit (0+90=90). Then, the first
358  // flow is reconsidered again, now it has a positive deficit and hence it is selected. But, it is empty and
359  // therefore is set to inactive, too.
360  NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (), 90, "unexpected deficit for the first flow");
361  NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::INACTIVE, "the first flow must be inactive");
362  NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (), 30, "unexpected deficit for the second flow");
363  NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::INACTIVE, "the second flow must be inactive");
364 
365  Simulator::Destroy ();
366 }
367 
372 {
373 public:
376 
377 private:
378  virtual void DoRun (void);
385  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header ipHdr, TcpHeader tcpHdr);
386 };
387 
389  : TestCase ("Test TCP flows separation")
390 {
391 }
392 
394 {
395 }
396 
397 void
399 {
400  Ptr<Packet> p = Create<Packet> (100);
401  p->AddHeader (tcpHdr);
402  Address dest;
403  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, ipHdr);
404  queue->Enqueue (item);
405 }
406 
407 void
409 {
410  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10p"));
411 
412  queueDisc->SetQuantum (1500);
413  queueDisc->Initialize ();
414 
415  Ipv4Header hdr;
416  hdr.SetPayloadSize (100);
417  hdr.SetSource (Ipv4Address ("10.10.1.1"));
418  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
419  hdr.SetProtocol (6);
420 
421  TcpHeader tcpHdr;
422  tcpHdr.SetSourcePort (7);
423  tcpHdr.SetDestinationPort (27);
424 
425  // Add three packets from the first flow
426  AddPacket (queueDisc, hdr, tcpHdr);
427  AddPacket (queueDisc, hdr, tcpHdr);
428  AddPacket (queueDisc, hdr, tcpHdr);
429  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3, "unexpected number of packets in the queue disc");
430  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
431 
432  // Add a packet from the second flow
433  tcpHdr.SetSourcePort (8);
434  AddPacket (queueDisc, hdr, tcpHdr);
435  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4, "unexpected number of packets in the queue disc");
436  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
437  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
438 
439  // Add a packet from the third flow
440  tcpHdr.SetDestinationPort (28);
441  AddPacket (queueDisc, hdr, tcpHdr);
442  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5, "unexpected number of packets in the queue disc");
443  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
444  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
445  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the third flow queue");
446 
447  // Add two packets from the fourth flow
448  tcpHdr.SetSourcePort (7);
449  AddPacket (queueDisc, hdr, tcpHdr);
450  AddPacket (queueDisc, hdr, tcpHdr);
451  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7, "unexpected number of packets in the queue disc");
452  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
453  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
454  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the third flow queue");
455  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the third flow queue");
456 
457  Simulator::Destroy ();
458 }
459 
464 {
465 public:
468 
469 private:
470  virtual void DoRun (void);
477  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header ipHdr, UdpHeader udpHdr);
478 };
479 
481  : TestCase ("Test UDP flows separation")
482 {
483 }
484 
486 {
487 }
488 
489 void
491 {
492  Ptr<Packet> p = Create<Packet> (100);
493  p->AddHeader (udpHdr);
494  Address dest;
495  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, ipHdr);
496  queue->Enqueue (item);
497 }
498 
499 void
501 {
502  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10p"));
503 
504  queueDisc->SetQuantum (1500);
505  queueDisc->Initialize ();
506 
507  Ipv4Header hdr;
508  hdr.SetPayloadSize (100);
509  hdr.SetSource (Ipv4Address ("10.10.1.1"));
510  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
511  hdr.SetProtocol (17);
512 
513  UdpHeader udpHdr;
514  udpHdr.SetSourcePort (7);
515  udpHdr.SetDestinationPort (27);
516 
517  // Add three packets from the first flow
518  AddPacket (queueDisc, hdr, udpHdr);
519  AddPacket (queueDisc, hdr, udpHdr);
520  AddPacket (queueDisc, hdr, udpHdr);
521  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3, "unexpected number of packets in the queue disc");
522  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
523 
524  // Add a packet from the second flow
525  udpHdr.SetSourcePort (8);
526  AddPacket (queueDisc, hdr, udpHdr);
527  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4, "unexpected number of packets in the queue disc");
528  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
529  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
530 
531  // Add a packet from the third flow
532  udpHdr.SetDestinationPort (28);
533  AddPacket (queueDisc, hdr, udpHdr);
534  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5, "unexpected number of packets in the queue disc");
535  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
536  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
537  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the third flow queue");
538 
539  // Add two packets from the fourth flow
540  udpHdr.SetSourcePort (7);
541  AddPacket (queueDisc, hdr, udpHdr);
542  AddPacket (queueDisc, hdr, udpHdr);
543  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7, "unexpected number of packets in the queue disc");
544  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3, "unexpected number of packets in the first flow queue");
545  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the second flow queue");
546  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1, "unexpected number of packets in the third flow queue");
547  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2, "unexpected number of packets in the third flow queue");
548 
549  Simulator::Destroy ();
550 }
551 
569 {
570 public:
572  virtual ~FqCobaltQueueDiscEcnMarking ();
573 
574 private:
575  virtual void DoRun (void);
584  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows);
590  void Dequeue (Ptr<FqCobaltQueueDisc> queue, uint32_t nPkt);
597  void DequeueWithDelay (Ptr<FqCobaltQueueDisc> queue, double delay, uint32_t nPkt);
603  void DropNextTracer (int64_t oldVal, int64_t newVal);
604  uint32_t m_dropNextCount;
605 };
606 
608  : TestCase ("Test ECN marking")
609 {
610  m_dropNextCount = 0;
611 }
612 
614 {
615 }
616 
617 void
618 FqCobaltQueueDiscEcnMarking::AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
619 {
620  Address dest;
621  Ptr<Packet> p = Create<Packet> (100);
622  for (uint32_t i = 0; i < nPkt; i++)
623  {
624  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, hdr);
625  queue->Enqueue (item);
626  }
627  NS_TEST_EXPECT_MSG_EQ (queue->GetNQueueDiscClasses (), nQueueFlows, "unexpected number of flow queues");
628  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), nPktEnqueued, "unexpected number of enqueued packets");
629 }
630 
631 void
633 {
634  Ptr<CobaltQueueDisc> q3 = queue->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
635 
636  // Trace DropNext after the first dequeue as m_dropNext value is set after the first dequeue
637  if (q3->GetNPackets () == 19)
638  {
640  }
641 
642  for (uint32_t i = 0; i < nPkt; i++)
643  {
644  Ptr<QueueDiscItem> item = queue->Dequeue ();
645  }
646 }
647 
648 void
650 {
651  for (uint32_t i = 0; i < nPkt; i++)
652  {
653  Simulator::Schedule (Time (Seconds ((i + 1) * delay)), &FqCobaltQueueDiscEcnMarking::Dequeue, this, queue, 1);
654  }
655 }
656 
657 void
658 FqCobaltQueueDiscEcnMarking::DropNextTracer (int64_t oldVal, int64_t newVal)
659 {
660  NS_UNUSED (oldVal);
661  NS_UNUSED (newVal);
662  m_dropNextCount++;
663 }
664 
665 void
667 {
668  // Test is divided into 3 sub test cases:
669  // 1) CeThreshold disabled
670  // 2) CeThreshold enabled
671  // 3) Same as 2 but with higher queue delay
672 
673  // Test case 1, CeThreshold disabled
674  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10240p"), "UseEcn", BooleanValue (true),
675  "Perturbation", UintegerValue (0), "BlueThreshold", TimeValue (Time::Max ()));
676 
677  queueDisc->SetQuantum (1514);
678  queueDisc->Initialize ();
679  Ipv4Header hdr;
680  hdr.SetPayloadSize (100);
681  hdr.SetSource (Ipv4Address ("10.10.1.1"));
682  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
683  hdr.SetProtocol (7);
684  hdr.SetEcn (Ipv4Header::ECN_ECT0);
685 
686  // Add 20 ECT0 (ECN capable) packets from the first flow
687  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 20, 1);
688 
689  // Add 20 ECT0 (ECN capable) packets from second flow
690  hdr.SetDestination (Ipv4Address ("10.10.1.10"));
691  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 40, 2);
692 
693  // Add 20 ECT0 (ECN capable) packets from third flow
694  hdr.SetDestination (Ipv4Address ("10.10.1.20"));
695  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 60, 3);
696 
697  // Add 20 NotECT packets from fourth flow
698  hdr.SetDestination (Ipv4Address ("10.10.1.30"));
699  hdr.SetEcn (Ipv4Header::ECN_NotECT);
700  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 80, 4);
701 
702  // Add 20 NotECT packets from fifth flow
703  hdr.SetDestination (Ipv4Address ("10.10.1.40"));
704  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 100, 5);
705 
706  //Dequeue 60 packets with delay 110ms to induce packet drops and keep some remaining packets in each queue
707  DequeueWithDelay (queueDisc, 0.11, 60);
708  Simulator::Run ();
709  Simulator::Stop (Seconds (8.0));
710  Ptr<CobaltQueueDisc> q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
711  Ptr<CobaltQueueDisc> q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
712  Ptr<CobaltQueueDisc> q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
713  Ptr<CobaltQueueDisc> q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
714  Ptr<CobaltQueueDisc> q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
715 
716  // As packets in flow queues are ECN capable
717  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 19, "There should be 19 marked packets."
718  "As there is no CoDel minBytes parameter so all the packets apart from the first one gets marked. As q3 and q4 have"
719  "NotEct packets and the queue delay is much higher than 5ms so the queue gets empty pretty quickly so more"
720  "packets from q0 can be dequeued.");
721  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
722  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 16, "There should be 16 marked packets"
723  "As there is no CoDel minBytes parameter so all the packets apart from the first one until no more packets are dequeued"
724  "are marked.");
725  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
726  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 12, "There should be 12 marked packets"
727  "Each packet size is 120 bytes and the quantum is 1500 bytes so in the first turn (1514/120 = 12.61) 13 packets are"
728  "dequeued and apart from the first one, all the packets are marked.");
729  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
730 
731  // As packets in flow queues are not ECN capable
732  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), m_dropNextCount, "The number of drops should"
733  "be equal to the number of times m_dropNext is updated");
734  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0, "There should not be any marked packets");
735  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), m_dropNextCount, "The number of drops should"
736  "be equal to the number of times m_dropNext is updated");
737  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0, "There should not be any marked packets");
738 
739  Simulator::Destroy ();
740 
741  // Test case 2, CeThreshold set to 2ms
742  queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10240p"), "UseEcn", BooleanValue (true),
743  "CeThreshold", TimeValue (MilliSeconds (2)));
744  queueDisc->SetQuantum (1514);
745  queueDisc->Initialize ();
746 
747  // Add 20 ECT0 (ECN capable) packets from first flow
748  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
749  hdr.SetEcn (Ipv4Header::ECN_ECT0);
750  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 20, 1);
751 
752  // Add 20 ECT0 (ECN capable) packets from second flow
753  hdr.SetDestination (Ipv4Address ("10.10.1.10"));
754  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 40, 2);
755 
756  // Add 20 ECT0 (ECN capable) packets from third flow
757  hdr.SetDestination (Ipv4Address ("10.10.1.20"));
758  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 60, 3);
759 
760  // Add 20 NotECT packets from fourth flow
761  hdr.SetDestination (Ipv4Address ("10.10.1.30"));
762  hdr.SetEcn (Ipv4Header::ECN_NotECT);
763  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 80, 4);
764 
765  // Add 20 NotECT packets from fifth flow
766  hdr.SetDestination (Ipv4Address ("10.10.1.40"));
767  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 100, 5);
768 
769  //Dequeue 60 packets with delay 0.1ms to induce packet drops and keep some remaining packets in each queue
770  DequeueWithDelay (queueDisc, 0.0001, 60);
771  Simulator::Run ();
772  Simulator::Stop (Seconds (8.0));
773  q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
774  q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
775  q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
776  q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
777  q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
778 
779  // As packets in flow queues are ECN capable
780  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
781  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0, "There should not be any marked packets"
782  "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is"
783  "less than CE threshold");
784  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
785  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 6, "There should be 6 marked packets"
786  "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater"
787  "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
788  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
789  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 13, "There should be 13 marked packets"
790  "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
791 
792  // As packets in flow queues are not ECN capable
793  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0, "There should not be any marked packets");
794  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
795  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0, "There should not be any marked packets");
796  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 1, "There should 1 dropped packet. As the queue"
797  "delay for the first dequeue is greater than the target (5ms), Cobalt overloads the m_dropNext field as an activity timeout"
798  "and dropNext is to set to the current Time value so on the next dequeue a packet is dropped.");
799 
800  Simulator::Destroy ();
801 
802  // Test case 3, CeThreshold set to 2ms with higher queue delay. This test is mainly to check that the packets are not getting marked twice.
803  queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10240p"), "UseEcn", BooleanValue (true),
804  "CeThreshold", TimeValue (MilliSeconds (2)), "BlueThreshold", TimeValue (Time::Max()));
805  queueDisc->SetQuantum (1514);
806  queueDisc->Initialize ();
807 
808  // Add 20 ECT0 (ECN capable) packets from first flow
809  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
810  hdr.SetEcn (Ipv4Header::ECN_ECT0);
811  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 20, 1);
812 
813  // Add 20 ECT0 (ECN capable) packets from second flow
814  hdr.SetDestination (Ipv4Address ("10.10.1.10"));
815  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 40, 2);
816 
817  // Add 20 ECT0 (ECN capable) packets from third flow
818  hdr.SetDestination (Ipv4Address ("10.10.1.20"));
819  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 60, 3);
820 
821  // Add 20 NotECT packets from fourth flow
822  hdr.SetDestination (Ipv4Address ("10.10.1.30"));
823  hdr.SetEcn (Ipv4Header::ECN_NotECT);
824  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 80, 4);
825 
826  // Add 20 NotECT packets from fifth flow
827  hdr.SetDestination (Ipv4Address ("10.10.1.40"));
828  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscEcnMarking::AddPacket, this, queueDisc, hdr, 20, 100, 5);
829 
830  // Reset m_dropNextCount value;
831  m_dropNextCount = 0;
832 
833  //Dequeue 60 packets with delay 110ms to induce packet drops and keep some remaining packets in each queue
834  DequeueWithDelay (queueDisc, 0.110, 60);
835  Simulator::Run ();
836  Simulator::Stop (Seconds (8.0));
837  q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
838  q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
839  q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
840  q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
841  q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
842 
843  // As packets in flow queues are ECN capable
844  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
845  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
846  q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q0->GetNPackets (), "Number of CE threshold"
847  " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
848  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
849  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
850  q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q1->GetNPackets (), "Number of CE threshold"
851  " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
852  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
853  NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
854  q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q2->GetNPackets (), "Number of CE threshold"
855  " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
856 
857  // As packets in flow queues are not ECN capable
858  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0, "There should not be any marked packets");
859  NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), m_dropNextCount, "The number of drops should"
860  "be equal to the number of times m_dropNext is updated");
861  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0, "There should not be any marked packets");
862  NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), m_dropNextCount, "The number of drops should"
863  "be equal to the number of times m_dropNext is updated");
864 
865  Simulator::Destroy ();
866 }
867 
890 {
891 public:
894 private:
895  virtual void DoRun (void);
901  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
902 };
903 
905  : TestCase ("Test credits and flows status")
906 {
907 }
908 
910 {
911 }
912 
913 void
915 {
916  Ptr<Packet> p = Create<Packet> (100);
917  Address dest;
918  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, hdr);
919  queue->Enqueue (item);
920 }
921 
922 void
924 {
925  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("EnableSetAssociativeHash", BooleanValue (true));
926  queueDisc->SetQuantum (90);
927  queueDisc->Initialize ();
928 
929  Ptr<Ipv4FqCobaltTestPacketFilter> filter = CreateObject<Ipv4FqCobaltTestPacketFilter> ();
930  queueDisc->AddPacketFilter (filter);
931 
932  Ipv4Header hdr;
933  hdr.SetPayloadSize (100);
934  hdr.SetSource (Ipv4Address ("10.10.1.1"));
935  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
936  hdr.SetProtocol (7);
937 
938  m_hash = 0;
939  AddPacket (queueDisc, hdr);
940  m_hash = 1;
941  AddPacket (queueDisc, hdr);
942  AddPacket (queueDisc, hdr);
943  m_hash = 2;
944  AddPacket (queueDisc, hdr);
945  m_hash = 3;
946  AddPacket (queueDisc, hdr);
947  m_hash = 4;
948  AddPacket (queueDisc, hdr);
949  AddPacket (queueDisc, hdr);
950  m_hash = 5;
951  AddPacket (queueDisc, hdr);
952  m_hash = 6;
953  AddPacket (queueDisc, hdr);
954  m_hash = 7;
955  AddPacket (queueDisc, hdr);
956  m_hash = 1024;
957  AddPacket (queueDisc, hdr);
958 
959  NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 11,
960  "unexpected number of packets in the queue disc");
961  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
962  "unexpected number of packets in the first flow queue of set one");
963  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
964  "unexpected number of packets in the second flow queue of set one");
965  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
966  "unexpected number of packets in the third flow queue of set one");
967  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 1,
968  "unexpected number of packets in the fourth flow queue of set one");
969  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetNPackets (), 2,
970  "unexpected number of packets in the fifth flow queue of set one");
971  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (5)->GetQueueDisc ()->GetNPackets (), 1,
972  "unexpected number of packets in the sixth flow queue of set one");
973  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (6)->GetQueueDisc ()->GetNPackets (), 1,
974  "unexpected number of packets in the seventh flow queue of set one");
975  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (7)->GetQueueDisc ()->GetNPackets (), 1,
976  "unexpected number of packets in the eighth flow queue of set one");
977  m_hash = 1025;
978  AddPacket (queueDisc, hdr);
979  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
980  "unexpected number of packets in the first flow of set one");
981  m_hash = 10;
982  AddPacket (queueDisc, hdr);
983  NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (8)->GetQueueDisc ()->GetNPackets (), 1,
984  "unexpected number of packets in the first flow of set two");
985  Simulator::Destroy ();
986 }
987 
988 
1001 {
1002 public:
1004  virtual ~FqCobaltQueueDiscL4sMode ();
1005 
1006 private:
1007  virtual void DoRun (void);
1014  void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt);
1022  void AddPacketWithDelay (Ptr<FqCobaltQueueDisc> queue,Ipv4Header hdr, double delay, uint32_t nPkt);
1028  void Dequeue (Ptr<FqCobaltQueueDisc> queue, uint32_t nPkt);
1035  void DequeueWithDelay (Ptr<FqCobaltQueueDisc> queue, double delay, uint32_t nPkt);
1036 };
1037 
1039  : TestCase ("Test L4S mode")
1040 {
1041 }
1042 
1044 {
1045 }
1046 
1047 void
1049 {
1050  Address dest;
1051  Ptr<Packet> p = Create<Packet> (100);
1052  for (uint32_t i = 0; i < nPkt; i++)
1053  {
1054  Ptr<Ipv4QueueDiscItem> item = Create<Ipv4QueueDiscItem> (p, dest, 0, hdr);
1055  queue->Enqueue (item);
1056  }
1057 }
1058 
1059 void
1061 {
1062  for (uint32_t i = 0; i < nPkt; i++)
1063  {
1064  Simulator::Schedule (Time (Seconds ((i + 1) * delay)), &FqCobaltQueueDiscL4sMode::AddPacket, this, queue, hdr, 1);
1065  }
1066 }
1067 
1068 void
1070 {
1071  for (uint32_t i = 0; i < nPkt; i++)
1072  {
1073  Ptr<QueueDiscItem> item = queue->Dequeue ();
1074  }
1075 }
1076 
1077 void
1079 {
1080  for (uint32_t i = 0; i < nPkt; i++)
1081  {
1082  Simulator::Schedule (Time (Seconds ((i + 1) * delay)), &FqCobaltQueueDiscL4sMode::Dequeue, this, queue, 1);
1083  }
1084 }
1085 
1086 void
1088 {
1089  // Test is divided into 2 sub test cases:
1090  // 1) Without hash collisions
1091  // 2) With hash collisions
1092 
1093  // Test case 1, Without hash collisions
1094  Ptr<FqCobaltQueueDisc> queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10240p"), "UseEcn", BooleanValue (true),
1095  "Perturbation", UintegerValue (0), "UseL4s", BooleanValue (true),
1096  "CeThreshold", TimeValue (MilliSeconds (2)));
1097 
1098  queueDisc->SetQuantum (1514);
1099  queueDisc->Initialize ();
1100  Ipv4Header hdr;
1101  hdr.SetPayloadSize (100);
1102  hdr.SetSource (Ipv4Address ("10.10.1.1"));
1103  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
1104  hdr.SetProtocol (7);
1105  hdr.SetEcn (Ipv4Header::ECN_ECT1);
1106 
1107  // Add 70 ECT1 (ECN capable) packets from the first flow
1108  // Set delay = 0.5ms
1109  double delay = 0.0005;
1110  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscL4sMode::AddPacketWithDelay, this, queueDisc, hdr, delay, 70);
1111 
1112  // Add 70 ECT0 (ECN capable) packets from second flow
1113  hdr.SetEcn (Ipv4Header::ECN_ECT0);
1114  hdr.SetDestination (Ipv4Address ("10.10.1.10"));
1115  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscL4sMode::AddPacketWithDelay, this, queueDisc, hdr, delay, 70);
1116 
1117  //Dequeue 140 packets with delay 1ms
1118  delay = 0.001;
1119  DequeueWithDelay (queueDisc, delay, 140);
1120  Simulator::Run ();
1121  Simulator::Stop (Seconds (8.0));
1122  Ptr<CobaltQueueDisc> q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
1123  Ptr<CobaltQueueDisc> q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
1124 
1125  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 66, "There should be 66 marked packets"
1126  "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold"
1127  "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1128  "greater than CE threshold so all the packets after 4th packet are marked");
1129  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
1130  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0, "There should not be any marked packets");
1131  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 2, "There should be 2 marked packets. Packets are dequeued"
1132  "from q0 first, which leads to delay greater than 5ms for the first dequeue from q1. Because of inactivity (started with high queue delay)"
1133  "Cobalt keeps drop_next as now and the next packet is marked. With second dequeue count increases to 2, drop_next becomes now plus around"
1134  "70ms which is less than the running time(140), and as the queue delay is persistantly higher than 5ms, second packet is marked.");
1135  NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
1136 
1137  Simulator::Destroy ();
1138 
1139  // Test case 2, With hash collisions
1140  queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> ("MaxSize", StringValue ("10240p"), "UseEcn", BooleanValue (true),
1141  "Perturbation", UintegerValue (0), "UseL4s", BooleanValue (true),
1142  "CeThreshold", TimeValue (MilliSeconds (2)));
1143 
1144  queueDisc->SetQuantum (1514);
1145  queueDisc->Initialize ();
1146  hdr.SetPayloadSize (100);
1147  hdr.SetSource (Ipv4Address ("10.10.1.1"));
1148  hdr.SetDestination (Ipv4Address ("10.10.1.2"));
1149  hdr.SetProtocol (7);
1150  hdr.SetEcn (Ipv4Header::ECN_ECT1);
1151 
1152  // Add 70 ECT1 (ECN capable) packets from the first flow
1153  // Set delay = 1ms
1154  delay = 0.001;
1155  Simulator::Schedule (Time (Seconds (0.0005)), &FqCobaltQueueDiscL4sMode::AddPacket, this, queueDisc, hdr, 1);
1156  Simulator::Schedule (Time (Seconds (0.0005)), &FqCobaltQueueDiscL4sMode::AddPacketWithDelay, this, queueDisc, hdr, delay, 69);
1157 
1158  // Add 70 ECT0 (ECN capable) packets from first flow
1159  hdr.SetEcn (Ipv4Header::ECN_ECT0);
1160  Simulator::Schedule (Time (Seconds (0)), &FqCobaltQueueDiscL4sMode::AddPacketWithDelay, this, queueDisc, hdr, delay, 70);
1161 
1162  //Dequeue 140 packets with delay 1ms
1163  DequeueWithDelay (queueDisc, delay, 140);
1164  Simulator::Run ();
1165  Simulator::Stop (Seconds (8.0));
1166  q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
1167  q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <CobaltQueueDisc> ();
1168 
1169  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 68, "There should be 68 marked packets"
1170  "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold"
1171  "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1172  "greater than CE threshold so all the packets after 2nd packet are marked");
1173  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0, "There should not be any dropped packets");
1174  NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 1, "There should be 1 marked packets");
1175 
1176  Simulator::Destroy ();
1177 
1178 }
1179 
1184 {
1185 public:
1187 };
1188 
1190  : TestSuite ("fq-cobalt-queue-disc", UNIT)
1191 {
1192  AddTestCase (new FqCobaltQueueDiscNoSuitableFilter, TestCase::QUICK);
1194  AddTestCase (new FqCobaltQueueDiscDeficit, TestCase::QUICK);
1195  AddTestCase (new FqCobaltQueueDiscTCPFlowsSeparation, TestCase::QUICK);
1196  AddTestCase (new FqCobaltQueueDiscUDPFlowsSeparation, TestCase::QUICK);
1197  AddTestCase (new FqCobaltQueueDiscEcnMarking, TestCase::QUICK);
1198  AddTestCase (new FqCobaltQueueDiscSetLinearProbing, TestCase::QUICK);
1199  AddTestCase (new FqCobaltQueueDiscL4sMode, TestCase::QUICK);
1200 }
1201 
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
FqCobaltQueueDiscDeficit::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:259
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
FqCobaltQueueDiscDeficit::FqCobaltQueueDiscDeficit
FqCobaltQueueDiscDeficit()
Definition: fq-cobalt-queue-disc-test-suite.cc:240
FqCobaltQueueDiscL4sMode::AddPacketWithDelay
void AddPacketWithDelay(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
Enqueue the given number of packets at different times.
Definition: fq-cobalt-queue-disc-test-suite.cc:1060
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
Definition: fq-cobalt-queue-disc-test-suite.cc:166
FqCobaltQueueDiscTCPFlowsSeparation
This class tests the TCP flows separation.
Definition: fq-cobalt-queue-disc-test-suite.cc:372
ns3::TcpHeader::SetSourcePort
void SetSourcePort(uint16_t port)
Set the source port.
Definition: tcp-header.cc:89
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
FqCobaltQueueDiscUDPFlowsSeparation
This class tests the UDP flows separation.
Definition: fq-cobalt-queue-disc-test-suite.cc:464
Ipv4FqCobaltTestPacketFilter::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: fq-cobalt-queue-disc-test-suite.cc:66
FqCobaltQueueDiscL4sMode::FqCobaltQueueDiscL4sMode
FqCobaltQueueDiscL4sMode()
Definition: fq-cobalt-queue-disc-test-suite.cc:1038
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
ns3::FqCobaltQueueDisc::GetQuantum
uint32_t GetQuantum(void) const
Get the quantum value.
Definition: fq-cobalt-queue-disc.cc:221
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
FqCobaltQueueDiscL4sMode
This class tests L4S mode.
Definition: fq-cobalt-queue-disc-test-suite.cc:1001
FqCobaltQueueDiscEcnMarking
This class tests ECN marking The test is divided into 3 sub test cases.
Definition: fq-cobalt-queue-disc-test-suite.cc:569
FqCobaltQueueDiscSetLinearProbing::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:914
ns3::QueueDisc::GetQueueDiscClass
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:662
FqCobaltQueueDiscL4sMode::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:1087
FqCobaltQueueDiscUDPFlowsSeparation::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
Enqueue a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:490
ns3::QueueDisc::Enqueue
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Definition: queue-disc.cc:861
FqCobaltQueueDiscEcnMarking::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
Enqueue the given number of packets.
Definition: fq-cobalt-queue-disc-test-suite.cc:618
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4FqCobaltTestPacketFilter::DoClassify
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:85
FqCobaltQueueDiscTestSuite
FQ-COBALT queue disc test suite.
Definition: fq-cobalt-queue-disc-test-suite.cc:1184
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::~FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit
virtual ~FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
Definition: fq-cobalt-queue-disc-test-suite.cc:171
ns3::UdpHeader::SetSourcePort
void SetSourcePort(uint16_t port)
Definition: udp-header.cc:60
ns3::Ipv6Header
Packet header for IPv6.
Definition: ipv6-header.h:36
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
FqCobaltQueueDiscEcnMarking::DequeueWithDelay
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
Definition: fq-cobalt-queue-disc-test-suite.cc:649
ns3::TestCase
encapsulates test code
Definition: test.h:1154
ns3::FqCobaltFlow::GetStatus
FlowStatus GetStatus(void) const
Get the status of this flow.
Definition: fq-cobalt-queue-disc.cc:93
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
FqCobaltQueueDiscTestSuite::FqCobaltQueueDiscTestSuite
FqCobaltQueueDiscTestSuite()
Definition: fq-cobalt-queue-disc-test-suite.cc:1189
FqCobaltQueueDiscSetLinearProbing::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:923
FqCobaltQueueDiscDeficit
This class tests the deficit per flow.
Definition: fq-cobalt-queue-disc-test-suite.cc:225
ns3::Ipv4PacketFilter
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets.
Definition: ipv4-packet-filter.h:38
FqCobaltQueueDiscTCPFlowsSeparation::FqCobaltQueueDiscTCPFlowsSeparation
FqCobaltQueueDiscTCPFlowsSeparation()
Definition: fq-cobalt-queue-disc-test-suite.cc:388
FqCobaltQueueDiscNoSuitableFilter::~FqCobaltQueueDiscNoSuitableFilter
virtual ~FqCobaltQueueDiscNoSuitableFilter()
Definition: fq-cobalt-queue-disc-test-suite.cc:114
ns3::QueueDisc::Stats::GetNMarkedPackets
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Definition: queue-disc.cc:152
FqCobaltQueueDiscTCPFlowsSeparation::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:408
ns3::Address
a polymophic address class
Definition: address.h:91
Ipv4FqCobaltTestPacketFilter::CheckProtocol
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
Definition: fq-cobalt-queue-disc-test-suite.cc:91
FqCobaltQueueDiscSetLinearProbing
This class tests linear probing, collision response, and set creation capability of set associative h...
Definition: fq-cobalt-queue-disc-test-suite.cc:890
FqCobaltQueueDiscEcnMarking::Dequeue
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
Definition: fq-cobalt-queue-disc-test-suite.cc:632
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:176
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
ns3::QueueDisc::Stats::GetNDroppedPackets
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:110
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
FqCobaltQueueDiscNoSuitableFilter::FqCobaltQueueDiscNoSuitableFilter
FqCobaltQueueDiscNoSuitableFilter()
Definition: fq-cobalt-queue-disc-test-suite.cc:109
NS_TEST_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
ns3::FqCobaltQueueDisc::SetQuantum
void SetQuantum(uint32_t quantum)
Set the quantum value.
Definition: fq-cobalt-queue-disc.cc:214
FqCobaltQueueDiscSetLinearProbing::FqCobaltQueueDiscSetLinearProbing
FqCobaltQueueDiscSetLinearProbing()
Definition: fq-cobalt-queue-disc-test-suite.cc:904
FqCobaltQueueDiscTCPFlowsSeparation::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
Enqueue a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:398
ns3::UdpHeader
Packet header for UDP packets.
Definition: udp-header.h:40
ns3::CobaltQueueDisc
Cobalt packet queue disc.
Definition: cobalt-queue-disc.h:60
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:185
ns3::Ipv4Header::SetSource
void SetSource(Ipv4Address source)
Definition: ipv4-header.cc:285
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
ns3::QueueDisc::Dequeue
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any,...
Definition: queue-disc.cc:896
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
FqCobaltQueueDiscEcnMarking::~FqCobaltQueueDiscEcnMarking
virtual ~FqCobaltQueueDiscEcnMarking()
Definition: fq-cobalt-queue-disc-test-suite.cc:613
ns3::QueueDisc::GetNPackets
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:440
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
FqCobaltQueueDiscEcnMarking::m_dropNextCount
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
Definition: fq-cobalt-queue-disc-test-suite.cc:604
FqCobaltQueueDiscUDPFlowsSeparation::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:500
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:166
ns3::QueueDisc::AddPacketFilter
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
Definition: queue-disc.cc:614
ns3::Ipv4Header::SetEcn
void SetEcn(EcnType ecn)
Set ECN Field.
Definition: ipv4-header.cc:97
FqCobaltQueueDiscUDPFlowsSeparation::FqCobaltQueueDiscUDPFlowsSeparation
FqCobaltQueueDiscUDPFlowsSeparation()
Definition: fq-cobalt-queue-disc-test-suite.cc:480
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
FqCobaltQueueDiscTCPFlowsSeparation::~FqCobaltQueueDiscTCPFlowsSeparation
virtual ~FqCobaltQueueDiscTCPFlowsSeparation()
Definition: fq-cobalt-queue-disc-test-suite.cc:393
Ipv4FqCobaltTestPacketFilter
Simple test packet filter able to classify IPv4 packets.
Definition: fq-cobalt-queue-disc-test-suite.cc:49
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit
This class tests the IP flows separation and the packet limit.
Definition: fq-cobalt-queue-disc-test-suite.cc:151
FqCobaltQueueDiscDeficit::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
Definition: fq-cobalt-queue-disc-test-suite.cc:250
ns3::UdpHeader::SetDestinationPort
void SetDestinationPort(uint16_t port)
Definition: udp-header.cc:55
ns3::INACTIVE
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
Definition: lr-wpan-mac.h:93
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
ns3::Ipv4Header::SetProtocol
void SetProtocol(uint8_t num)
Definition: ipv4-header.cc:278
fqCobaltQueueDiscTestSuite
static FqCobaltQueueDiscTestSuite fqCobaltQueueDiscTestSuite
Definition: fq-cobalt-queue-disc-test-suite.cc:1202
FqCobaltQueueDiscDeficit::~FqCobaltQueueDiscDeficit
virtual ~FqCobaltQueueDiscDeficit()
Definition: fq-cobalt-queue-disc-test-suite.cc:245
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
FqCobaltQueueDiscEcnMarking::FqCobaltQueueDiscEcnMarking
FqCobaltQueueDiscEcnMarking()
Definition: fq-cobalt-queue-disc-test-suite.cc:607
FqCobaltQueueDiscNoSuitableFilter::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:119
FqCobaltQueueDiscL4sMode::~FqCobaltQueueDiscL4sMode
virtual ~FqCobaltQueueDiscL4sMode()
Definition: fq-cobalt-queue-disc-test-suite.cc:1043
ns3::ObjectBase::TraceConnectWithoutContext
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
FqCobaltQueueDiscSetLinearProbing::~FqCobaltQueueDiscSetLinearProbing
virtual ~FqCobaltQueueDiscSetLinearProbing()
Definition: fq-cobalt-queue-disc-test-suite.cc:909
ns3::QueueDisc::GetStats
const Stats & GetStats(void)
Retrieve all the collected statistics.
Definition: queue-disc.cc:421
m_hash
int32_t m_hash
Definition: fq-cobalt-queue-disc-test-suite.cc:43
ns3::QueueDisc::GetNQueueDiscClasses
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:669
FqCobaltQueueDiscL4sMode::AddPacket
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt)
Enqueue the given number of packets.
Definition: fq-cobalt-queue-disc-test-suite.cc:1048
Ipv4FqCobaltTestPacketFilter::Ipv4FqCobaltTestPacketFilter
Ipv4FqCobaltTestPacketFilter()
Definition: fq-cobalt-queue-disc-test-suite.cc:76
ns3::TcpHeader::SetDestinationPort
void SetDestinationPort(uint16_t port)
Set the destination port.
Definition: tcp-header.cc:95
ns3::Object::Initialize
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
FqCobaltQueueDiscEcnMarking::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: fq-cobalt-queue-disc-test-suite.cc:666
Max
#define Max(a, b)
Definition: aarf-wifi-manager.cc:26
ns3::Ipv4Header::SetDestination
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:298
FqCobaltQueueDiscNoSuitableFilter
This class tests packets for which there is no suitable filter.
Definition: fq-cobalt-queue-disc-test-suite.cc:100
Ipv4FqCobaltTestPacketFilter::~Ipv4FqCobaltTestPacketFilter
virtual ~Ipv4FqCobaltTestPacketFilter()
Definition: fq-cobalt-queue-disc-test-suite.cc:80
ns3::FqCobaltFlow::GetDeficit
int32_t GetDeficit(void) const
Get the deficit for this flow.
Definition: fq-cobalt-queue-disc.cc:72
FqCobaltQueueDiscL4sMode::Dequeue
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
Definition: fq-cobalt-queue-disc-test-suite.cc:1069
FqCobaltQueueDiscUDPFlowsSeparation::~FqCobaltQueueDiscUDPFlowsSeparation
virtual ~FqCobaltQueueDiscUDPFlowsSeparation()
Definition: fq-cobalt-queue-disc-test-suite.cc:485
ns3::Ipv4Header::SetPayloadSize
void SetPayloadSize(uint16_t size)
Definition: ipv4-header.cc:56
FqCobaltQueueDiscEcnMarking::DropNextTracer
void DropNextTracer(int64_t oldVal, int64_t newVal)
Tracer for the DropNext attribute.
Definition: fq-cobalt-queue-disc-test-suite.cc:658
FqCobaltQueueDiscL4sMode::DequeueWithDelay
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
Definition: fq-cobalt-queue-disc-test-suite.cc:1078