LEFT | RIGHT |
(no file at all) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 */ | 79 */ |
80 class DcaTxopTest : public DcaTxop | 80 class DcaTxopTest : public DcaTxop |
81 { | 81 { |
82 public: | 82 public: |
83 /** | 83 /** |
84 * Constructor | 84 * Constructor |
85 * | 85 * |
86 * \param test the test DCF manager | 86 * \param test the test DCF manager |
87 * \param i the DCF state | 87 * \param i the DCF state |
88 */ | 88 */ |
89 DcaTxopTest (DcfManagerTest *test, uint32_t i); | 89 DcaTxopTest (DcfManagerTest *test, std::size_t i); |
90 | 90 |
91 | 91 |
92 private: | 92 private: |
93 void NotifyAccessGranted (void); | 93 void NotifyAccessGranted (void); |
94 void NotifyInternalCollision (void); | 94 void NotifyInternalCollision (void); |
95 void NotifyCollision (void); | 95 void NotifyCollision (void); |
96 void NotifyChannelSwitching (void); | 96 void NotifyChannelSwitching (void); |
97 void NotifySleep (void); | 97 void NotifySleep (void); |
98 void NotifyWakeUp (void); | 98 void NotifyWakeUp (void); |
99 void DoDispose (void); | 99 void DoDispose (void); |
100 | 100 |
101 DcfManagerTest *m_test; //!< the test DCF manager | 101 DcfManagerTest *m_test; //!< the test DCF manager |
102 uint32_t m_i; //!< the DCF state | 102 std::size_t m_i; //!< the DCF state |
103 }; | 103 }; |
104 | 104 |
105 | 105 |
106 /** | 106 /** |
107 * \ingroup wifi-test | 107 * \ingroup wifi-test |
108 * \ingroup tests | 108 * \ingroup tests |
109 * | 109 * |
110 * \brief Dcf Manager Test | 110 * \brief Dcf Manager Test |
111 */ | 111 */ |
112 class DcfManagerTest : public TestCase | 112 class DcfManagerTest : public TestCase |
113 { | 113 { |
114 public: | 114 public: |
115 DcfManagerTest (); | 115 DcfManagerTest (); |
116 virtual void DoRun (void); | 116 virtual void DoRun (void); |
117 | 117 |
118 /** | 118 /** |
119 * Notify access granted function | 119 * Notify access granted function |
120 * \param i the DCF state | 120 * \param i the DCF state |
121 */ | 121 */ |
122 void NotifyAccessGranted (uint32_t i); | 122 void NotifyAccessGranted (std::size_t i); |
123 /** | 123 /** |
124 * Notify internal collision function | 124 * Notify internal collision function |
125 * \param i the DCF state | 125 * \param i the DCF state |
126 */ | 126 */ |
127 void NotifyInternalCollision (uint32_t i); | 127 void NotifyInternalCollision (std::size_t i); |
128 /** | 128 /** |
129 * Notify collision function | 129 * Notify collision function |
130 * \param i the DCF state | 130 * \param i the DCF state |
131 */ | 131 */ |
132 void NotifyCollision (uint32_t i); | 132 void NotifyCollision (std::size_t i); |
133 /** | 133 /** |
134 * Notify channel switching function | 134 * Notify channel switching function |
135 * \param i the DCF state | 135 * \param i the DCF state |
136 */ | 136 */ |
137 void NotifyChannelSwitching (uint32_t i); | 137 void NotifyChannelSwitching (std::size_t i); |
138 | 138 |
139 | 139 |
140 private: | 140 private: |
141 /** | 141 /** |
142 * Start test function | 142 * Start test function |
143 * \param slotTime the slot time | 143 * \param slotTime the slot time |
144 * \param sifs the SIFS | 144 * \param sifs the SIFS |
145 * \param eifsNoDifsNoSifs the EIFS no DIFS no SIFS | 145 * \param eifsNoDifsNoSifs the EIFS no DIFS no SIFS |
146 * \param ackTimeoutValue the ack timeout value | 146 * \param ackTimeoutValue the ack timeout value |
147 */ | 147 */ |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 : DcfState (dca) | 275 : DcfState (dca) |
276 { | 276 { |
277 } | 277 } |
278 | 278 |
279 void | 279 void |
280 DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime) | 280 DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime) |
281 { | 281 { |
282 m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime)); | 282 m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime)); |
283 } | 283 } |
284 | 284 |
285 DcaTxopTest::DcaTxopTest (DcfManagerTest *test, uint32_t i) | 285 DcaTxopTest::DcaTxopTest (DcfManagerTest *test, std::size_t i) |
286 : m_test (test), | 286 : m_test (test), |
287 m_i (i) | 287 m_i (i) |
288 { | 288 { |
289 } | 289 } |
290 | 290 |
291 void | 291 void |
292 DcaTxopTest::DoDispose (void) | 292 DcaTxopTest::DoDispose (void) |
293 { | 293 { |
294 m_test = 0; | 294 m_test = 0; |
295 DcaTxop::DoDispose (); | 295 DcaTxop::DoDispose (); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 DcaTxopTest::NotifyWakeUp (void) | 328 DcaTxopTest::NotifyWakeUp (void) |
329 { | 329 { |
330 } | 330 } |
331 | 331 |
332 DcfManagerTest::DcfManagerTest () | 332 DcfManagerTest::DcfManagerTest () |
333 : TestCase ("DcfManager") | 333 : TestCase ("DcfManager") |
334 { | 334 { |
335 } | 335 } |
336 | 336 |
337 void | 337 void |
338 DcfManagerTest::NotifyAccessGranted (uint32_t i) | 338 DcfManagerTest::NotifyAccessGranted (std::size_t i) |
339 { | 339 { |
340 Ptr<DcfStateTest> state = m_dcfStates[i]; | 340 Ptr<DcfStateTest> state = m_dcfStates[i]; |
341 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), false, "Have expected
grants"); | 341 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), false, "Have expected
grants"); |
342 if (!state->m_expectedGrants.empty ()) | 342 if (!state->m_expectedGrants.empty ()) |
343 { | 343 { |
344 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); | 344 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); |
345 state->m_expectedGrants.pop_front (); | 345 state->m_expectedGrants.pop_front (); |
346 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected access grant is now"); | 346 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected access grant is now"); |
347 m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first)); | 347 m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first)); |
348 m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue +
expected.first)); | 348 m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue +
expected.first)); |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 void | 352 void |
353 DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration) | 353 DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration) |
354 { | 354 { |
355 Simulator::Schedule (MicroSeconds (at) - Now (), | 355 Simulator::Schedule (MicroSeconds (at) - Now (), |
356 &DcfManager::NotifyTxStartNow, m_dcfManager, | 356 &DcfManager::NotifyTxStartNow, m_dcfManager, |
357 MicroSeconds (duration)); | 357 MicroSeconds (duration)); |
358 } | 358 } |
359 | 359 |
360 void | 360 void |
361 DcfManagerTest::NotifyInternalCollision (uint32_t i) | 361 DcfManagerTest::NotifyInternalCollision (std::size_t i) |
362 { | 362 { |
363 Ptr<DcfStateTest> state = m_dcfStates[i]; | 363 Ptr<DcfStateTest> state = m_dcfStates[i]; |
364 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), false, "Ha
ve expected internal collisions"); | 364 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), false, "Ha
ve expected internal collisions"); |
365 if (!state->m_expectedInternalCollision.empty ()) | 365 if (!state->m_expectedInternalCollision.empty ()) |
366 { | 366 { |
367 struct DcfStateTest::ExpectedCollision expected = state->m_expectedInterna
lCollision.front (); | 367 struct DcfStateTest::ExpectedCollision expected = state->m_expectedInterna
lCollision.front (); |
368 state->m_expectedInternalCollision.pop_front (); | 368 state->m_expectedInternalCollision.pop_front (); |
369 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected internal collision time is now"); | 369 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected internal collision time is now"); |
370 state->StartBackoffNow (expected.nSlots); | 370 state->StartBackoffNow (expected.nSlots); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 void | 374 void |
375 DcfManagerTest::NotifyCollision (uint32_t i) | 375 DcfManagerTest::NotifyCollision (std::size_t i) |
376 { | 376 { |
377 Ptr<DcfStateTest> state = m_dcfStates[i]; | 377 Ptr<DcfStateTest> state = m_dcfStates[i]; |
378 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), false, "Have expec
ted collisions"); | 378 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), false, "Have expec
ted collisions"); |
379 if (!state->m_expectedCollision.empty ()) | 379 if (!state->m_expectedCollision.empty ()) |
380 { | 380 { |
381 struct DcfStateTest::ExpectedCollision expected = state->m_expectedCollisi
on.front (); | 381 struct DcfStateTest::ExpectedCollision expected = state->m_expectedCollisi
on.front (); |
382 state->m_expectedCollision.pop_front (); | 382 state->m_expectedCollision.pop_front (); |
383 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected collision is now"); | 383 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected collision is now"); |
384 state->StartBackoffNow (expected.nSlots); | 384 state->StartBackoffNow (expected.nSlots); |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 void | 388 void |
389 DcfManagerTest::NotifyChannelSwitching (uint32_t i) | 389 DcfManagerTest::NotifyChannelSwitching (std::size_t i) |
390 { | 390 { |
391 Ptr<DcfStateTest> state = m_dcfStates[i]; | 391 Ptr<DcfStateTest> state = m_dcfStates[i]; |
392 if (!state->m_expectedGrants.empty ()) | 392 if (!state->m_expectedGrants.empty ()) |
393 { | 393 { |
394 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); | 394 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); |
395 state->m_expectedGrants.pop_front (); | 395 state->m_expectedGrants.pop_front (); |
396 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected grant is now"); | 396 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected grant is now"); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 DcfTestSuite (); | 924 DcfTestSuite (); |
925 }; | 925 }; |
926 | 926 |
927 DcfTestSuite::DcfTestSuite () | 927 DcfTestSuite::DcfTestSuite () |
928 : TestSuite ("devices-wifi-dcf", UNIT) | 928 : TestSuite ("devices-wifi-dcf", UNIT) |
929 { | 929 { |
930 AddTestCase (new DcfManagerTest, TestCase::QUICK); | 930 AddTestCase (new DcfManagerTest, TestCase::QUICK); |
931 } | 931 } |
932 | 932 |
933 static DcfTestSuite g_dcfTestSuite; | 933 static DcfTestSuite g_dcfTestSuite; |
LEFT | RIGHT |