A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dcf-manager-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/test.h"
22 #include "ns3/simulator.h"
23 #include "ns3/dcf-manager.h"
24 
25 namespace ns3 {
26 
27 class DcfManagerTest;
28 
29 class DcfStateTest : public DcfState
30 {
31 public:
32  DcfStateTest (DcfManagerTest *test, uint32_t i);
33  void QueueTx (uint64_t txTime, uint64_t expectedGrantTime);
34 private:
35  friend class DcfManagerTest;
36  virtual void DoNotifyAccessGranted (void);
37  virtual void DoNotifyInternalCollision (void);
38  virtual void DoNotifyCollision (void);
39  virtual void DoNotifyChannelSwitching (void);
40 
41  typedef std::pair<uint64_t,uint64_t> ExpectedGrant;
42  typedef std::list<ExpectedGrant> ExpectedGrants;
44  {
45  uint64_t at;
46  uint32_t nSlots;
47  };
48  typedef std::list<struct ExpectedCollision> ExpectedCollisions;
49 
54  uint32_t m_i;
55 };
56 
57 
58 class DcfManagerTest : public TestCase
59 {
60 public:
61  DcfManagerTest ();
62  virtual void DoRun (void);
63 
64 
65  void NotifyAccessGranted (uint32_t i);
66  void NotifyInternalCollision (uint32_t i);
67  void NotifyCollision (uint32_t i);
68  void NotifyChannelSwitching (uint32_t i);
69 
70 
71 private:
72  void StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue = 20);
73  void AddDcfState (uint32_t aifsn);
74  void EndTest (void);
75  void ExpectInternalCollision (uint64_t time, uint32_t from, uint32_t nSlots);
76  void ExpectCollision (uint64_t time, uint32_t from, uint32_t nSlots);
77  void AddRxOkEvt (uint64_t at, uint64_t duration);
78  void AddRxErrorEvt (uint64_t at, uint64_t duration);
79  void AddRxInsideSifsEvt (uint64_t at, uint64_t duration);
80  void AddTxEvt (uint64_t at, uint64_t duration);
81  void AddNavReset (uint64_t at, uint64_t duration);
82  void AddNavStart (uint64_t at, uint64_t duration);
83  void AddAckTimeoutReset (uint64_t at);
84  void AddAccessRequest (uint64_t at, uint64_t txTime,
85  uint64_t expectedGrantTime, uint32_t from);
86  void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime,
87  uint64_t expectedGrantTime, uint32_t from);
93  void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime,
94  uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from);
95  void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state);
96  void AddCcaBusyEvt (uint64_t at, uint64_t duration);
97  void AddSwitchingEvt (uint64_t at, uint64_t duration);
98  void AddRxStartEvt (uint64_t at, uint64_t duration);
99 
100  typedef std::vector<DcfStateTest *> DcfStates;
101 
105 };
106 
107 
108 
110  : m_test (test),
111  m_i (i)
112 {
113 }
114 void
115 DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime)
116 {
117  m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime));
118 }
119 void
121 {
123 }
124 void
126 {
128 }
129 void
131 {
133 }
134 void
136 {
138 }
139 
140 
142  : TestCase ("DcfManager")
143 {
144 }
145 
146 void
148 {
149  DcfStateTest *state = m_dcfStates[i];
150  NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), false, "Have expected grants");
151  std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front ();
152  state->m_expectedGrants.pop_front ();
153  NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second), "Expected access grant is now");
154  m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first));
155  m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue + expected.first));
156 }
157 void
158 DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration)
159 {
160  Simulator::Schedule (MicroSeconds (at) - Now (),
162  MicroSeconds (duration));
163 }
164 void
166 {
167  DcfStateTest *state = m_dcfStates[i];
168  NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), false, "Have expected internal collisions");
169  struct DcfStateTest::ExpectedCollision expected = state->m_expectedInternalCollision.front ();
170  state->m_expectedInternalCollision.pop_front ();
171  NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Expected internal collision time is now");
172  state->StartBackoffNow (expected.nSlots);
173 }
174 void
176 {
177  DcfStateTest *state = m_dcfStates[i];
178  NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), false, "Have expected collisions");
179  struct DcfStateTest::ExpectedCollision expected = state->m_expectedCollision.front ();
180  state->m_expectedCollision.pop_front ();
181  NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Expected collision is now");
182  state->StartBackoffNow (expected.nSlots);
183 }
184 void
186 {
187  DcfStateTest *state = m_dcfStates[i];
188  if (!state->m_expectedGrants.empty ())
189  {
190  std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front ();
191  state->m_expectedGrants.pop_front ();
192  NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second), "Expected grant is now");
193  }
194 }
195 
196 void
197 DcfManagerTest::ExpectInternalCollision (uint64_t time, uint32_t nSlots, uint32_t from)
198 {
199  DcfStateTest *state = m_dcfStates[from];
201  col.at = time;
202  col.nSlots = nSlots;
203  state->m_expectedInternalCollision.push_back (col);
204 }
205 void
206 DcfManagerTest::ExpectCollision (uint64_t time, uint32_t nSlots, uint32_t from)
207 {
208  DcfStateTest *state = m_dcfStates[from];
210  col.at = time;
211  col.nSlots = nSlots;
212  state->m_expectedCollision.push_back (col);
213 }
214 
215 void
216 DcfManagerTest::StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue)
217 {
218  m_dcfManager = new DcfManager ();
219  m_dcfManager->SetSlot (MicroSeconds (slotTime));
220  m_dcfManager->SetSifs (MicroSeconds (sifs));
221  m_dcfManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs + sifs));
222  m_ackTimeoutValue = ackTimeoutValue;
223 }
224 
225 void
227 {
228  DcfStateTest *state = new DcfStateTest (this, m_dcfStates.size ());
229  state->SetAifsn (aifsn);
230  m_dcfStates.push_back (state);
231  m_dcfManager->Add (state);
232 }
233 
234 void
236 {
237  Simulator::Run ();
239  for (DcfStates::const_iterator i = m_dcfStates.begin (); i != m_dcfStates.end (); i++)
240  {
241  DcfStateTest *state = *i;
242  NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), true, "Have no expected grants");
243  NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), true, "Have no internal collisions");
244  NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), true, "Have no expected collisions");
245  delete state;
246  }
247  m_dcfStates.clear ();
248  delete m_dcfManager;
249 }
250 
251 void
252 DcfManagerTest::AddRxOkEvt (uint64_t at, uint64_t duration)
253 {
254  Simulator::Schedule (MicroSeconds (at) - Now (),
256  MicroSeconds (duration));
257  Simulator::Schedule (MicroSeconds (at + duration) - Now (),
259 }
260 void
261 DcfManagerTest::AddRxInsideSifsEvt (uint64_t at, uint64_t duration)
262 {
263  Simulator::Schedule (MicroSeconds (at) - Now (),
265  MicroSeconds (duration));
266 }
267 void
268 DcfManagerTest::AddRxErrorEvt (uint64_t at, uint64_t duration)
269 {
270  Simulator::Schedule (MicroSeconds (at) - Now (),
272  MicroSeconds (duration));
273  Simulator::Schedule (MicroSeconds (at + duration) - Now (),
275 }
276 
277 void
278 DcfManagerTest::AddNavReset (uint64_t at, uint64_t duration)
279 {
280  Simulator::Schedule (MicroSeconds (at) - Now (),
282  MicroSeconds (duration));
283 }
284 void
285 DcfManagerTest::AddNavStart (uint64_t at, uint64_t duration)
286 {
287  Simulator::Schedule (MicroSeconds (at) - Now (),
289  MicroSeconds (duration));
290 }
291 void
293 {
294  Simulator::Schedule (MicroSeconds (at) - Now (),
296 }
297 void
298 DcfManagerTest::AddAccessRequest (uint64_t at, uint64_t txTime,
299  uint64_t expectedGrantTime, uint32_t from)
300 {
301  AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, from);
302 }
303 void
305  uint64_t expectedGrantTime, uint32_t from)
306 {
307  Simulator::Schedule (MicroSeconds (at) - Now (),
309  txTime, expectedGrantTime, m_dcfStates[from]);
310 }
311 void
313  uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from)
314 {
315  NS_ASSERT (ackDelay < m_ackTimeoutValue);
316  Simulator::Schedule (MicroSeconds (at) - Now (),
318  txTime, expectedGrantTime, m_dcfStates[from]);
319  AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay);
320 }
321 void
322 DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state)
323 {
324  state->QueueTx (txTime, expectedGrantTime);
325  m_dcfManager->RequestAccess (state);
326 }
327 void
328 DcfManagerTest::AddCcaBusyEvt (uint64_t at, uint64_t duration)
329 {
330  Simulator::Schedule (MicroSeconds (at) - Now (),
332  MicroSeconds (duration));
333 }
334 void
335 DcfManagerTest::AddSwitchingEvt (uint64_t at, uint64_t duration)
336 {
337  Simulator::Schedule (MicroSeconds (at) - Now (),
339  MicroSeconds (duration));
340 }
341 void
342 DcfManagerTest::AddRxStartEvt (uint64_t at, uint64_t duration)
343 {
344  Simulator::Schedule (MicroSeconds (at) - Now (),
346  MicroSeconds (duration));
347 }
348 
349 
350 
351 void
353 {
354  // 0 3 4 5 8 9 10 12
355  // | sifs | aifsn | tx | sifs | aifsn | | tx |
356  //
357  StartTest (1, 3, 10);
358  AddDcfState (1);
359  AddAccessRequest (1, 1, 4, 0);
360  AddAccessRequest (10, 2, 10, 0);
361  EndTest ();
362  // Check that receiving inside SIFS shall be cancelled properly:
363  // 0 3 4 5 8 9 12 13 14
364  // | sifs | aifsn | tx | sifs | ack | sifs | aifsn | |tx |
365  //
366  StartTest (1, 3, 10);
367  AddDcfState (1);
368  AddAccessRequest (1, 1, 4, 0);
369  AddRxInsideSifsEvt (6, 10);
370  AddTxEvt (8, 1);
371  AddAccessRequest (14, 2, 14, 0);
372  EndTest ();
373 
374 
375  // The test below mainly intends to test the case where the medium
376  // becomes busy in the middle of a backoff slot: the backoff counter
377  // must not be decremented for this backoff slot. This is the case
378  // below for the backoff slot starting at time 78us.
379  //
380  // 20 60 66 70 74 78 80 100 106 110 114 118 120
381  // | rx | sifs | aifsn | bslot0 | bslot1 | | rx | sifs | aifsn | bslot2 | bslot3 | tx |
382  // |
383  // 30 request access. backoff slots: 4
384  StartTest (4, 6, 10);
385  AddDcfState (1);
386  AddRxOkEvt (20, 40);
387  AddRxOkEvt (80, 20);
388  AddAccessRequest (30, 2, 118, 0);
389  ExpectCollision (30, 4, 0); // backoff: 4 slots
390  EndTest ();
391 
392  // Test the case where the backoff slots is zero.
393  //
394  // 20 60 66 70 72
395  // | rx | sifs | aifsn | tx |
396  // |
397  // 30 request access. backoff slots: 0
398  StartTest (4, 6, 10);
399  AddDcfState (1);
400  AddRxOkEvt (20, 40);
401  AddAccessRequest (30, 2, 70, 0);
402  ExpectCollision (30, 0, 0); // backoff: 0 slots
403  EndTest ();
404  // Test shows when two frames are received without interval between
405  // them:
406  // 20 60 100 106 110 112
407  // | rx | rx |sifs | aifsn | tx |
408  // |
409  // 30 request access. backoff slots: 0
410 
411  StartTest (4, 6, 10);
412  AddDcfState (1);
413  AddRxOkEvt (20, 40);
414  AddRxOkEvt (60, 40);
415  AddAccessRequest (30, 2, 110, 0);
416  ExpectCollision (30, 0, 0); // backoff: 0 slots
417  EndTest ();
418 
419 
420  // The test below is subject to some discussion because I am
421  // not sure I understand the intent of the spec here.
422  // i.e., what happens if you make a request to get access
423  // to the medium during the difs idle time after a busy period ?
424  // do you need to start a backoff ? Or do you need to wait until
425  // the end of difs and access the medium ?
426  // Here, we wait until the end of difs and access the medium.
427  //
428  // 20 60 66 70 72
429  // | rx | sifs | aifsn | tx |
430  // |
431  // 62 request access.
432  //
433  StartTest (4, 6, 10);
434  AddDcfState (1);
435  AddRxOkEvt (20, 40);
436  AddAccessRequest (62, 2, 70, 0);
437  EndTest ();
438 
439 
440  // Test an EIFS
441  //
442  // 20 60 66 76 86 90 94 98 102 106
443  // | rx | sifs | acktxttime | sifs + aifsn | bslot0 | bslot1 | bslot2 | bslot3 | tx |
444  // | | <------eifs------>|
445  // 30 request access. backoff slots: 4
446  StartTest (4, 6, 10);
447  AddDcfState (1);
448  AddRxErrorEvt (20, 40);
449  AddAccessRequest (30, 2, 102, 0);
450  ExpectCollision (30, 4, 0); // backoff: 4 slots
451  EndTest ();
452 
453  // Test an EIFS which is interupted by a successfull transmission.
454  //
455  // 20 60 66 69 75 81 85 89 93 97 101 103
456  // | rx | sifs | | rx | sifs | aifsn | bslot0 | bslot1 | bslot2 | bslot3 | tx |
457  // | | <--eifs-->|
458  // 30 request access. backoff slots: 4
459  StartTest (4, 6, 10);
460  AddDcfState (1);
461  AddRxErrorEvt (20, 40);
462  AddAccessRequest (30, 2, 101, 0);
463  ExpectCollision (30, 4, 0); // backoff: 4 slots
464  AddRxOkEvt (69, 6);
465  EndTest ();
466 
467 
468  // Test two DCFs which suffer an internal collision. the first DCF has a higher
469  // priority than the second DCF.
470  //
471  // 20 60 66 70 74 78 88
472  // DCF0 | rx | sifs | aifsn | bslot0 | bslot1 | tx |
473  // DCF1 | rx | sifs | aifsn | aifsn | aifsn | | sifs | aifsn | aifsn | aifsn | bslot | tx |
474  // 94 98 102 106 110 112
475  StartTest (4, 6, 10);
476  AddDcfState (1); // high priority DCF
477  AddDcfState (3); // low priority DCF
478  AddRxOkEvt (20, 40);
479  AddAccessRequest (30, 10, 78, 0);
480  ExpectCollision (30, 2, 0); // backoff: 2 slot
481 
482  AddAccessRequest (40, 2, 110, 1);
483  ExpectCollision (40, 0, 1); // backoff: 0 slot
484  ExpectInternalCollision (78, 1, 1); // backoff: 1 slot
485  EndTest ();
486 
487  // Test of AckTimeout handling: First queue requests access and ack procedure fails,
488  // inside the ack timeout second queue with higher priority requests access.
489  //
490  // 20 40 50 60 66 76
491  // DCF0 - low | tx | ack timeout |sifs| |
492  // DCF1 - high | | |sifs| tx |
493  // ^ request access
494  StartTest (4, 6, 10);
495  AddDcfState (2); // high priority DCF
496  AddDcfState (0); // low priority DCF
497  AddAccessRequestWithAckTimeout (20, 20, 20, 0);
498  AddAccessRequest (50, 10, 66, 1);
499  EndTest ();
500 
501  // Test of AckTimeout handling:
502  //
503  // First queue requests access and ack is 2 us delayed (got ack interval at the picture),
504  // inside this interval second queue with higher priority requests access.
505  //
506  // 20 40 41 42 48 58
507  // DCF0 - low | tx |got ack |sifs| |
508  // DCF1 - high | | |sifs| tx |
509  // ^ request access
510  StartTest (4, 6, 10);
511  AddDcfState (2); // high priority DCF
512  AddDcfState (0); // low priority DCF
513  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
514  AddAccessRequest (41, 10, 48, 1);
515  EndTest ();
516 
517  //Repeat the same but with one queue:
518  // 20 40 41 42 48 58
519  // DCF0 - low | tx |got ack |sifs| |
520  // ^ request access
521  StartTest (4, 6, 10);
522  AddDcfState (2);
523  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
524  AddAccessRequest (41, 10, 56, 0);
525  EndTest ();
526 
527  //Repeat the same when ack was delayed:
528  //and request the next access before previous tx end:
529  // 20 39 40 42 64 74
530  // DCF0 - low | tx |got ack |sifs + 4 * slot| |
531  // ^ request access
532  StartTest (4, 6, 10);
533  AddDcfState (2);
534  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
535  AddAccessRequest (39, 10, 64, 0);
536  ExpectCollision (39, 2, 0); // backoff: 2 slot
537  EndTest ();
538 
539  //
540  // test simple NAV count. This scenario modelizes a simple DATA+ACK handshake
541  // where the data rate used for the ACK is higher than expected by the DATA source
542  // so, the data exchange completes before the end of nav.
543  //
544  StartTest (4, 6, 10);
545  AddDcfState (1);
546  AddRxOkEvt (20, 40);
547  AddNavStart (60, 15);
548  AddRxOkEvt (66, 5);
549  AddNavStart (71, 0);
550  AddAccessRequest (30, 10, 93, 0);
551  ExpectCollision (30, 2, 0); // backoff: 2 slot
552  EndTest ();
553 
554  //
555  // test more complex NAV handling by a CF-poll. This scenario modelizes a
556  // simple DATA+ACK handshake interrupted by a CF-poll which resets the
557  // NAV counter.
558  //
559  StartTest (4, 6, 10);
560  AddDcfState (1);
561  AddRxOkEvt (20, 40);
562  AddNavStart (60, 15);
563  AddRxOkEvt (66, 5);
564  AddNavReset (71, 2);
565  AddAccessRequest (30, 10, 91, 0);
566  ExpectCollision (30, 2, 0); // backoff: 2 slot
567  EndTest ();
568 
569 
570  StartTest (4, 6, 10);
571  AddDcfState (2);
572  AddRxOkEvt (20, 40);
573  AddAccessRequest (80, 10, 80, 0);
574  EndTest ();
575 
576 
577  StartTest (4, 6, 10);
578  AddDcfState (2);
579  AddRxOkEvt (20, 40);
580  AddRxOkEvt (78, 8);
581  AddAccessRequest (30, 50, 108, 0);
582  ExpectCollision (30, 3, 0); // backoff: 3 slots
583  EndTest ();
584 
585 
586  // Channel switching tests
587 
588  // 0 20 23 24 25
589  // | switching | sifs | aifsn | tx |
590  // |
591  // 21 access request.
592  StartTest (1, 3, 10);
593  AddDcfState (1);
594  AddSwitchingEvt (0,20);
595  AddAccessRequest (21, 1, 24, 0);
596  EndTest ();
597 
598  // 20 40 50 53 54 55
599  // | switching | busy | sifs | aifsn | tx |
600  // | |
601  // 30 busy. 45 access request.
602  //
603  StartTest (1, 3, 10);
604  AddDcfState (1);
605  AddSwitchingEvt (20,20);
606  AddCcaBusyEvt (30,20);
607  AddAccessRequest (45, 1, 54, 0);
608  EndTest ();
609 
610  // 20 30 50 53 54 55
611  // | rx | switching | sifs | aifsn | tx |
612  // |
613  // 51 access request.
614  //
615  StartTest (1, 3, 10);
616  AddDcfState (1);
617  AddRxStartEvt (20,40);
618  AddSwitchingEvt (30,20);
619  AddAccessRequest (51, 1, 54, 0);
620  EndTest ();
621 
622  // 20 30 50 53 54 55
623  // | busy | switching | sifs | aifsn | tx |
624  // |
625  // 51 access request.
626  //
627  StartTest (1, 3, 10);
628  AddDcfState (1);
629  AddCcaBusyEvt (20,40);
630  AddSwitchingEvt (30,20);
631  AddAccessRequest (51, 1, 54, 0);
632  EndTest ();
633 
634  // 20 30 50 53 54 55
635  // | nav | switching | sifs | aifsn | tx |
636  // |
637  // 51 access request.
638  //
639  StartTest (1, 3, 10);
640  AddDcfState (1);
641  AddNavStart (20,40);
642  AddSwitchingEvt (30,20);
643  AddAccessRequest (51, 1, 54, 0);
644  EndTest ();
645 
646  // 20 40 50 55 58 59 60
647  // | tx | ack timeout | switching | sifs | aifsn | tx |
648  // | |
649  // 45 access request. 56 access request.
650  //
651  StartTest (1, 3, 10);
652  AddDcfState (1);
653  AddAccessRequestWithAckTimeout (20, 20, 20, 0);
654  AddAccessRequest (45, 1, 50, 0);
655  AddSwitchingEvt (50,5);
656  AddAccessRequest (56, 1, 59, 0);
657  EndTest ();
658 
659  // 20 60 66 70 74 78 80 100 106 110 112
660  // | rx | sifs | aifsn | bslot0 | bslot1 | | switching | sifs | aifsn | tx |
661  // | |
662  // 30 access request. 101 access request.
663  //
664  StartTest (4, 6, 10);
665  AddDcfState (1);
666  AddRxOkEvt (20,40);
667  AddAccessRequest (30, 2, 80, 0);
668  ExpectCollision (30, 4, 0); // backoff: 4 slots
669  AddSwitchingEvt (80,20);
670  AddAccessRequest (101, 2, 110, 0);
671  EndTest ();
672 }
673 
674 //-----------------------------------------------------------------------------
675 
676 class DcfTestSuite : public TestSuite
677 {
678 public:
679  DcfTestSuite ();
680 };
681 
683  : TestSuite ("devices-wifi-dcf", UNIT)
684 {
686 }
687 
689 
690 } // namespace ns3
void AddNavStart(uint64_t at, uint64_t duration)
virtual void DoNotifyCollision(void)
Called by DcfManager to notify a DcfState subclass that a normal collision occured, that is, that the medium was busy when access was requested.
void AddSwitchingEvt(uint64_t at, uint64_t duration)
A suite of tests to run.
Definition: test.h:1025
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:423
#define NS_ASSERT(condition)
Definition: assert.h:64
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
void DoAccessRequest(uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state)
void AddAckTimeoutReset(uint64_t at)
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:57
encapsulates test code
Definition: test.h:849
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
ExpectedCollisions m_expectedCollision
void Add(DcfState *dcf)
Definition: dcf-manager.cc:343
std::list< ExpectedGrant > ExpectedGrants
std::pair< uint64_t, uint64_t > ExpectedGrant
ExpectedCollisions m_expectedInternalCollision
void AddAccessRequestWithAckTimeout(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t from)
static DcfTestSuite g_dcfTestSuite
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:747
std::vector< DcfStateTest * > DcfStates
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:638
void AddRxInsideSifsEvt(uint64_t at, uint64_t duration)
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:656
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:779
#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:244
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:229
void AddAccessRequestWithSuccessfullAck(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from)
keep track of the state needed for a single DCF function.
Definition: dcf-manager.h:46
void AddCcaBusyEvt(uint64_t at, uint64_t duration)
void ExpectCollision(uint64_t time, uint32_t from, uint32_t nSlots)
void AddTxEvt(uint64_t at, uint64_t duration)
void NotifyCollision(uint32_t i)
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
void AddRxStartEvt(uint64_t at, uint64_t duration)
DcfStateTest(DcfManagerTest *test, uint32_t i)
void QueueTx(uint64_t txTime, uint64_t expectedGrantTime)
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:109
virtual void DoRun(void)
Implementation to actually run this TestCase.
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:647
virtual void DoNotifyInternalCollision(void)
Called by DcfManager to notify a DcfState subclass that an 'internal' collision occured, that is, that the backoff timer of a higher priority DcfState expired at the same time and that access was granted to this higher priority DcfState.
void StartTest(uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue=20)
std::list< struct ExpectedCollision > ExpectedCollisions
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:330
virtual void DoNotifyChannelSwitching(void)
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
void ExpectInternalCollision(uint64_t time, uint32_t from, uint32_t nSlots)
void AddRxOkEvt(uint64_t at, uint64_t duration)
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:676
void AddDcfState(uint32_t aifsn)
void NotifyAccessGranted(uint32_t i)
Fast test.
Definition: test.h:857
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:318
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:786
void NotifyInternalCollision(uint32_t i)
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:764
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
void NotifyChannelSwitching(uint32_t i)
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:628
void AddAccessRequest(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t from)
ExpectedGrants m_expectedGrants
virtual void DoNotifyAccessGranted(void)
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:687
void AddNavReset(uint64_t at, uint64_t duration)
void test(void)
void AddRxErrorEvt(uint64_t at, uint64_t duration)
void SetSifs(Time sifs)
Definition: dcf-manager.cc:324
DcfManagerTest * m_test