LEFT | RIGHT |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/test.h" | 21 #include "ns3/test.h" |
22 #include "ns3/simulator.h" | 22 #include "ns3/simulator.h" |
23 #include "ns3/dcf-state.h" | |
24 #include "ns3/dcf-manager.h" | 23 #include "ns3/dcf-manager.h" |
25 #include "ns3/dca-txop.h" | 24 #include "ns3/dca-txop.h" |
26 | 25 |
27 using namespace ns3; | 26 using namespace ns3; |
28 | 27 |
29 class DcfManagerTest; | 28 class DcfManagerTest; |
30 | 29 |
31 /** | 30 /** |
32 * \ingroup wifi-test | 31 * \ingroup wifi-test |
33 * \ingroup tests | 32 * \ingroup tests |
34 * | 33 * |
35 * \brief Dcf State Test | 34 * \brief Dca Txop Test |
36 */ | 35 */ |
37 class DcfStateTest : public DcfState | 36 class DcaTxopTest : public DcaTxop |
38 { | 37 { |
39 public: | 38 public: |
40 /** | 39 /** |
41 * Constructor | 40 * Constructor |
42 * | 41 * |
43 * \param dca the DCA TXOP | 42 * \param test the test DCF manager |
44 */ | 43 * \param i the DCF state |
45 DcfStateTest (Ptr<DcaTxop> dca); | 44 */ |
| 45 DcaTxopTest (DcfManagerTest *test, std::size_t i); |
| 46 |
46 /** | 47 /** |
47 * Queue transmit function | 48 * Queue transmit function |
48 * \param txTime the transmit time | 49 * \param txTime the transmit time |
49 * \param expectedGrantTime the expected grant time | 50 * \param expectedGrantTime the expected grant time |
50 */ | 51 */ |
51 void QueueTx (uint64_t txTime, uint64_t expectedGrantTime); | 52 void QueueTx (uint64_t txTime, uint64_t expectedGrantTime); |
52 | |
53 | 53 |
54 private: | 54 private: |
55 /// allow DcfManagerTest class access | 55 /// allow DcfManagerTest class access |
56 friend class DcfManagerTest; | 56 friend class DcfManagerTest; |
57 | 57 |
58 typedef std::pair<uint64_t,uint64_t> ExpectedGrant; //!< the expected grant ty
pedef | 58 typedef std::pair<uint64_t,uint64_t> ExpectedGrant; //!< the expected grant ty
pedef |
59 typedef std::list<ExpectedGrant> ExpectedGrants; //!< the collection of expect
ed grants typedef | 59 typedef std::list<ExpectedGrant> ExpectedGrants; //!< the collection of expect
ed grants typedef |
60 /// ExpectedCollision structure | 60 /// ExpectedCollision structure |
61 struct ExpectedCollision | 61 struct ExpectedCollision |
62 { | 62 { |
63 uint64_t at; //!< at | 63 uint64_t at; //!< at |
64 uint32_t nSlots; //!< number of slots | 64 uint32_t nSlots; //!< number of slots |
65 }; | 65 }; |
66 typedef std::list<struct ExpectedCollision> ExpectedCollisions; //!< expected
collisions typedef | 66 typedef std::list<struct ExpectedCollision> ExpectedCollisions; //!< expected
collisions typedef |
67 | 67 |
68 ExpectedCollisions m_expectedInternalCollision; //!< expected internal collisi
ons | 68 ExpectedCollisions m_expectedInternalCollision; //!< expected internal collisi
ons |
69 ExpectedCollisions m_expectedCollision; //!< expected collision | 69 ExpectedCollisions m_expectedCollision; //!< expected collision |
70 ExpectedGrants m_expectedGrants; //!< expected grants | 70 ExpectedGrants m_expectedGrants; //!< expected grants |
71 }; | 71 |
72 | 72 bool IsAccessRequested (void) const; |
73 | 73 void NotifyAccessRequested (void); |
74 /** | |
75 * \ingroup wifi-test | |
76 * \ingroup tests | |
77 * | |
78 * \brief Dca Txop Test | |
79 */ | |
80 class DcaTxopTest : public DcaTxop | |
81 { | |
82 public: | |
83 /** | |
84 * Constructor | |
85 * | |
86 * \param test the test DCF manager | |
87 * \param i the DCF state | |
88 */ | |
89 DcaTxopTest (DcfManagerTest *test, std::size_t i); | |
90 | |
91 | |
92 private: | |
93 void NotifyAccessGranted (void); | 74 void NotifyAccessGranted (void); |
94 void NotifyInternalCollision (void); | 75 void NotifyInternalCollision (void); |
95 void NotifyCollision (void); | 76 void NotifyCollision (void); |
96 void NotifyChannelSwitching (void); | 77 void NotifyChannelSwitching (void); |
97 void NotifySleep (void); | 78 void NotifySleep (void); |
98 void NotifyWakeUp (void); | 79 void NotifyWakeUp (void); |
99 void DoDispose (void); | 80 void DoDispose (void); |
100 | 81 |
101 DcfManagerTest *m_test; //!< the test DCF manager | 82 DcfManagerTest *m_test; //!< the test DCF manager |
102 std::size_t m_i; //!< the DCF state | 83 std::size_t m_i; //!< the DCF state |
| 84 bool m_accessRequested; //!< true if access requested |
103 }; | 85 }; |
104 | 86 |
105 | 87 |
106 /** | 88 /** |
107 * \ingroup wifi-test | 89 * \ingroup wifi-test |
108 * \ingroup tests | 90 * \ingroup tests |
109 * | 91 * |
110 * \brief Dcf Manager Test | 92 * \brief Dcf Manager Test |
111 */ | 93 */ |
112 class DcfManagerTest : public TestCase | 94 class DcfManagerTest : public TestCase |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 * \param expectedGrantTime the expected grant time | 197 * \param expectedGrantTime the expected grant time |
216 * \param from | 198 * \param from |
217 */ | 199 */ |
218 void AddAccessRequest (uint64_t at, uint64_t txTime, | 200 void AddAccessRequest (uint64_t at, uint64_t txTime, |
219 uint64_t expectedGrantTime, uint32_t from); | 201 uint64_t expectedGrantTime, uint32_t from); |
220 /** | 202 /** |
221 * Add access request with ack timeout | 203 * Add access request with ack timeout |
222 * \param at time to schedule DoAccessRequest event | 204 * \param at time to schedule DoAccessRequest event |
223 * \param txTime DoAccessRequest txTime | 205 * \param txTime DoAccessRequest txTime |
224 * \param expectedGrantTime DoAccessRequest expectedGrantTime | 206 * \param expectedGrantTime DoAccessRequest expectedGrantTime |
225 * \param from DoAccessRequest DcfStateTest | 207 * \param from DoAccessRequest DcaTxopTest |
226 */ | 208 */ |
227 void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, | 209 void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, |
228 uint64_t expectedGrantTime, uint32_t from
); | 210 uint64_t expectedGrantTime, uint32_t from
); |
229 /** | 211 /** |
230 * Add access request with successful ack | 212 * Add access request with successful ack |
231 * \param at time to schedule DoAccessRequest event | 213 * \param at time to schedule DoAccessRequest event |
232 * \param txTime DoAccessRequest txTime | 214 * \param txTime DoAccessRequest txTime |
233 * \param expectedGrantTime DoAccessRequest expectedGrantTime | 215 * \param expectedGrantTime DoAccessRequest expectedGrantTime |
234 * \param ackDelay is delay of the ack after txEnd | 216 * \param ackDelay is delay of the ack after txEnd |
235 * \param from DoAccessRequest DcfStateTest | 217 * \param from DoAccessRequest DcaTxopTest |
236 */ | 218 */ |
237 void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, | 219 void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, |
238 uint64_t expectedGrantTime, uint32_t
ackDelay, uint32_t from); | 220 uint64_t expectedGrantTime, uint32_t
ackDelay, uint32_t from); |
239 /** | 221 /** |
240 * Add access request with successful ack | 222 * Add access request with successful ack |
241 * \param txTime DoAccessRequest txTime | 223 * \param txTime DoAccessRequest txTime |
242 * \param expectedGrantTime DoAccessRequest expectedGrantTime | 224 * \param expectedGrantTime DoAccessRequest expectedGrantTime |
243 * \param state DcfStateTest | 225 * \param state DcaTxopTest |
244 */ | 226 */ |
245 void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, Ptr<DcfStat
eTest> state); | 227 void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, Ptr<DcaTxop
Test> state); |
246 /** | 228 /** |
247 * Add CCA busy event function | 229 * Add CCA busy event function |
248 * \param at the event time | 230 * \param at the event time |
249 * \param duration the duration | 231 * \param duration the duration |
250 */ | 232 */ |
251 void AddCcaBusyEvt (uint64_t at, uint64_t duration); | 233 void AddCcaBusyEvt (uint64_t at, uint64_t duration); |
252 /** | 234 /** |
253 * Add switching event function | 235 * Add switching event function |
254 * \param at the event time | 236 * \param at the event time |
255 * \param duration the duration | 237 * \param duration the duration |
256 */ | 238 */ |
257 void AddSwitchingEvt (uint64_t at, uint64_t duration); | 239 void AddSwitchingEvt (uint64_t at, uint64_t duration); |
258 /** | 240 /** |
259 * Add receive start event function | 241 * Add receive start event function |
260 * \param at the event time | 242 * \param at the event time |
261 * \param duration the duration | 243 * \param duration the duration |
262 */ | 244 */ |
263 void AddRxStartEvt (uint64_t at, uint64_t duration); | 245 void AddRxStartEvt (uint64_t at, uint64_t duration); |
264 | 246 |
265 typedef std::vector<Ptr<DcfStateTest> > DcfStates; //!< the DCF test states ty
pedef | |
266 typedef std::vector<Ptr<DcaTxopTest> > Dca; //!< the DCA TXOP tests typedef | 247 typedef std::vector<Ptr<DcaTxopTest> > Dca; //!< the DCA TXOP tests typedef |
267 | 248 |
268 Ptr<DcfManager> m_dcfManager; //!< the DCF manager | 249 Ptr<DcfManager> m_dcfManager; //!< the DCF manager |
269 DcfStates m_dcfStates; //!< the DCF states | |
270 Dca m_dca; //!< the DCA | 250 Dca m_dca; //!< the DCA |
271 uint32_t m_ackTimeoutValue; //!< the ack timeout value | 251 uint32_t m_ackTimeoutValue; //!< the ack timeout value |
272 }; | 252 }; |
273 | 253 |
274 DcfStateTest::DcfStateTest (Ptr<DcaTxop> dca) | 254 void |
275 : DcfState (dca) | 255 DcaTxopTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime) |
276 { | |
277 } | |
278 | |
279 void | |
280 DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime) | |
281 { | 256 { |
282 m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime)); | 257 m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime)); |
283 } | 258 } |
284 | 259 |
285 DcaTxopTest::DcaTxopTest (DcfManagerTest *test, std::size_t i) | 260 DcaTxopTest::DcaTxopTest (DcfManagerTest *test, std::size_t i) |
286 : m_test (test), | 261 : m_test (test), |
287 m_i (i) | 262 m_i (i), |
| 263 m_accessRequested (false) |
288 { | 264 { |
289 } | 265 } |
290 | 266 |
291 void | 267 void |
292 DcaTxopTest::DoDispose (void) | 268 DcaTxopTest::DoDispose (void) |
293 { | 269 { |
294 m_test = 0; | 270 m_test = 0; |
295 DcaTxop::DoDispose (); | 271 DcaTxop::DoDispose (); |
296 } | 272 } |
297 | 273 |
| 274 bool |
| 275 DcaTxopTest::IsAccessRequested (void) const |
| 276 { |
| 277 return m_accessRequested; |
| 278 } |
| 279 |
| 280 void |
| 281 DcaTxopTest::NotifyAccessRequested (void) |
| 282 { |
| 283 m_accessRequested = true; |
| 284 } |
| 285 |
298 void | 286 void |
299 DcaTxopTest::NotifyAccessGranted (void) | 287 DcaTxopTest::NotifyAccessGranted (void) |
300 { | 288 { |
| 289 m_accessRequested = false; |
301 m_test->NotifyAccessGranted (m_i); | 290 m_test->NotifyAccessGranted (m_i); |
302 } | 291 } |
303 | 292 |
304 void | 293 void |
305 DcaTxopTest::NotifyInternalCollision (void) | 294 DcaTxopTest::NotifyInternalCollision (void) |
306 { | 295 { |
307 m_test->NotifyInternalCollision (m_i); | 296 m_test->NotifyInternalCollision (m_i); |
308 } | 297 } |
309 | 298 |
310 void | 299 void |
(...skipping 19 matching lines...) Expand all Loading... |
330 } | 319 } |
331 | 320 |
332 DcfManagerTest::DcfManagerTest () | 321 DcfManagerTest::DcfManagerTest () |
333 : TestCase ("DcfManager") | 322 : TestCase ("DcfManager") |
334 { | 323 { |
335 } | 324 } |
336 | 325 |
337 void | 326 void |
338 DcfManagerTest::NotifyAccessGranted (std::size_t i) | 327 DcfManagerTest::NotifyAccessGranted (std::size_t i) |
339 { | 328 { |
340 Ptr<DcfStateTest> state = m_dcfStates[i]; | 329 Ptr<DcaTxopTest> state = m_dca[i]; |
341 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), false, "Have expected
grants"); | 330 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), false, "Have expected
grants"); |
342 if (!state->m_expectedGrants.empty ()) | 331 if (!state->m_expectedGrants.empty ()) |
343 { | 332 { |
344 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); | 333 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); |
345 state->m_expectedGrants.pop_front (); | 334 state->m_expectedGrants.pop_front (); |
346 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected access grant is now"); | 335 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected access grant is now"); |
347 m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first)); | 336 m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first)); |
348 m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue +
expected.first)); | 337 m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue +
expected.first)); |
349 } | 338 } |
350 } | 339 } |
351 | 340 |
352 void | 341 void |
353 DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration) | 342 DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration) |
354 { | 343 { |
355 Simulator::Schedule (MicroSeconds (at) - Now (), | 344 Simulator::Schedule (MicroSeconds (at) - Now (), |
356 &DcfManager::NotifyTxStartNow, m_dcfManager, | 345 &DcfManager::NotifyTxStartNow, m_dcfManager, |
357 MicroSeconds (duration)); | 346 MicroSeconds (duration)); |
358 } | 347 } |
359 | 348 |
360 void | 349 void |
361 DcfManagerTest::NotifyInternalCollision (std::size_t i) | 350 DcfManagerTest::NotifyInternalCollision (std::size_t i) |
362 { | 351 { |
363 Ptr<DcfStateTest> state = m_dcfStates[i]; | 352 Ptr<DcaTxopTest> state = m_dca[i]; |
364 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), false, "Ha
ve expected internal collisions"); | 353 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), false, "Ha
ve expected internal collisions"); |
365 if (!state->m_expectedInternalCollision.empty ()) | 354 if (!state->m_expectedInternalCollision.empty ()) |
366 { | 355 { |
367 struct DcfStateTest::ExpectedCollision expected = state->m_expectedInterna
lCollision.front (); | 356 struct DcaTxopTest::ExpectedCollision expected = state->m_expectedInternal
Collision.front (); |
368 state->m_expectedInternalCollision.pop_front (); | 357 state->m_expectedInternalCollision.pop_front (); |
369 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected internal collision time is now"); | 358 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected internal collision time is now"); |
370 state->StartBackoffNow (expected.nSlots); | 359 state->StartBackoffNow (expected.nSlots); |
371 } | 360 } |
372 } | 361 } |
373 | 362 |
374 void | 363 void |
375 DcfManagerTest::NotifyCollision (std::size_t i) | 364 DcfManagerTest::NotifyCollision (std::size_t i) |
376 { | 365 { |
377 Ptr<DcfStateTest> state = m_dcfStates[i]; | 366 Ptr<DcaTxopTest> state = m_dca[i]; |
378 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), false, "Have expec
ted collisions"); | 367 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), false, "Have expec
ted collisions"); |
379 if (!state->m_expectedCollision.empty ()) | 368 if (!state->m_expectedCollision.empty ()) |
380 { | 369 { |
381 struct DcfStateTest::ExpectedCollision expected = state->m_expectedCollisi
on.front (); | 370 struct DcaTxopTest::ExpectedCollision expected = state->m_expectedCollisio
n.front (); |
382 state->m_expectedCollision.pop_front (); | 371 state->m_expectedCollision.pop_front (); |
383 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected collision is now"); | 372 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.at), "Exp
ected collision is now"); |
384 state->StartBackoffNow (expected.nSlots); | 373 state->StartBackoffNow (expected.nSlots); |
385 } | 374 } |
386 } | 375 } |
387 | 376 |
388 void | 377 void |
389 DcfManagerTest::NotifyChannelSwitching (std::size_t i) | 378 DcfManagerTest::NotifyChannelSwitching (std::size_t i) |
390 { | 379 { |
391 Ptr<DcfStateTest> state = m_dcfStates[i]; | 380 Ptr<DcaTxopTest> state = m_dca[i]; |
392 if (!state->m_expectedGrants.empty ()) | 381 if (!state->m_expectedGrants.empty ()) |
393 { | 382 { |
394 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); | 383 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); |
395 state->m_expectedGrants.pop_front (); | 384 state->m_expectedGrants.pop_front (); |
396 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected grant is now"); | 385 NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second),
"Expected grant is now"); |
397 } | 386 } |
| 387 state->m_accessRequested = false; |
398 } | 388 } |
399 | 389 |
400 void | 390 void |
401 DcfManagerTest::ExpectInternalCollision (uint64_t time, uint32_t nSlots, uint32_
t from) | 391 DcfManagerTest::ExpectInternalCollision (uint64_t time, uint32_t nSlots, uint32_
t from) |
402 { | 392 { |
403 Ptr<DcfStateTest> state = m_dcfStates[from]; | 393 Ptr<DcaTxopTest> state = m_dca[from]; |
404 struct DcfStateTest::ExpectedCollision col; | 394 struct DcaTxopTest::ExpectedCollision col; |
405 col.at = time; | 395 col.at = time; |
406 col.nSlots = nSlots; | 396 col.nSlots = nSlots; |
407 state->m_expectedInternalCollision.push_back (col); | 397 state->m_expectedInternalCollision.push_back (col); |
408 } | 398 } |
409 | 399 |
410 void | 400 void |
411 DcfManagerTest::ExpectCollision (uint64_t time, uint32_t nSlots, uint32_t from) | 401 DcfManagerTest::ExpectCollision (uint64_t time, uint32_t nSlots, uint32_t from) |
412 { | 402 { |
413 Ptr<DcfStateTest> state = m_dcfStates[from]; | 403 Ptr<DcaTxopTest> state = m_dca[from]; |
414 struct DcfStateTest::ExpectedCollision col; | 404 struct DcaTxopTest::ExpectedCollision col; |
415 col.at = time; | 405 col.at = time; |
416 col.nSlots = nSlots; | 406 col.nSlots = nSlots; |
417 state->m_expectedCollision.push_back (col); | 407 state->m_expectedCollision.push_back (col); |
418 } | 408 } |
419 | 409 |
420 void | 410 void |
421 DcfManagerTest::StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifs
NoSifs, uint32_t ackTimeoutValue) | 411 DcfManagerTest::StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifs
NoSifs, uint32_t ackTimeoutValue) |
422 { | 412 { |
423 m_dcfManager = CreateObject<DcfManager> (); | 413 m_dcfManager = CreateObject<DcfManager> (); |
424 m_dcfManager->SetSlot (MicroSeconds (slotTime)); | 414 m_dcfManager->SetSlot (MicroSeconds (slotTime)); |
425 m_dcfManager->SetSifs (MicroSeconds (sifs)); | 415 m_dcfManager->SetSifs (MicroSeconds (sifs)); |
426 m_dcfManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs + sifs)); | 416 m_dcfManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs + sifs)); |
427 m_ackTimeoutValue = ackTimeoutValue; | 417 m_ackTimeoutValue = ackTimeoutValue; |
428 } | 418 } |
429 | 419 |
430 void | 420 void |
431 DcfManagerTest::AddDcfState (uint32_t aifsn) | 421 DcfManagerTest::AddDcfState (uint32_t aifsn) |
432 { | 422 { |
433 Ptr<DcaTxopTest> dca = CreateObject<DcaTxopTest> (this, m_dcfStates.size ()); | 423 Ptr<DcaTxopTest> dca = CreateObject<DcaTxopTest> (this, m_dca.size ()); |
| 424 dca->SetAifsn (aifsn); |
434 m_dca.push_back (dca); | 425 m_dca.push_back (dca); |
435 Ptr<DcfStateTest> state = CreateObject<DcfStateTest> (dca); | 426 m_dcfManager->Add (dca); |
436 state->SetAifsn (aifsn); | |
437 m_dcfStates.push_back (state); | |
438 m_dcfManager->Add (state); | |
439 } | 427 } |
440 | 428 |
441 void | 429 void |
442 DcfManagerTest::EndTest (void) | 430 DcfManagerTest::EndTest (void) |
443 { | 431 { |
444 Simulator::Run (); | 432 Simulator::Run (); |
445 Simulator::Destroy (); | 433 Simulator::Destroy (); |
446 | 434 |
447 for (DcfStates::const_iterator i = m_dcfStates.begin (); i != m_dcfStates.end
(); i++) | 435 for (Dca::const_iterator i = m_dca.begin (); i != m_dca.end (); i++) |
448 { | 436 { |
449 Ptr<DcfStateTest> state = *i; | 437 Ptr<DcaTxopTest> state = *i; |
450 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), true, "Have no ex
pected grants"); | 438 NS_TEST_EXPECT_MSG_EQ (state->m_expectedGrants.empty (), true, "Have no ex
pected grants"); |
451 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), true,
"Have no internal collisions"); | 439 NS_TEST_EXPECT_MSG_EQ (state->m_expectedInternalCollision.empty (), true,
"Have no internal collisions"); |
452 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), true, "Have no
expected collisions"); | 440 NS_TEST_EXPECT_MSG_EQ (state->m_expectedCollision.empty (), true, "Have no
expected collisions"); |
453 state = 0; | 441 state = 0; |
454 } | 442 } |
455 m_dcfStates.clear (); | 443 m_dca.clear (); |
456 | 444 |
457 for (Dca::const_iterator i = m_dca.begin (); i != m_dca.end (); i++) | 445 for (Dca::const_iterator i = m_dca.begin (); i != m_dca.end (); i++) |
458 { | 446 { |
459 Ptr<DcaTxopTest> dca = *i; | 447 Ptr<DcaTxopTest> dca = *i; |
460 dca->Dispose (); | 448 dca->Dispose (); |
461 dca = 0; | 449 dca = 0; |
462 } | 450 } |
463 m_dca.clear (); | 451 m_dca.clear (); |
464 | 452 |
465 m_dcfManager = 0; | 453 m_dcfManager = 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 { | 510 { |
523 AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, from); | 511 AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, from); |
524 } | 512 } |
525 | 513 |
526 void | 514 void |
527 DcfManagerTest::AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, | 515 DcfManagerTest::AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, |
528 uint64_t expectedGrantTime, uint
32_t from) | 516 uint64_t expectedGrantTime, uint
32_t from) |
529 { | 517 { |
530 Simulator::Schedule (MicroSeconds (at) - Now (), | 518 Simulator::Schedule (MicroSeconds (at) - Now (), |
531 &DcfManagerTest::DoAccessRequest, this, | 519 &DcfManagerTest::DoAccessRequest, this, |
532 txTime, expectedGrantTime, m_dcfStates[from]); | 520 txTime, expectedGrantTime, m_dca[from]); |
533 } | 521 } |
534 | 522 |
535 void | 523 void |
536 DcfManagerTest::AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime
, | 524 DcfManagerTest::AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime
, |
537 uint64_t expectedGrantTime,
uint32_t ackDelay, uint32_t from) | 525 uint64_t expectedGrantTime,
uint32_t ackDelay, uint32_t from) |
538 { | 526 { |
539 NS_ASSERT (ackDelay < m_ackTimeoutValue); | 527 NS_ASSERT (ackDelay < m_ackTimeoutValue); |
540 Simulator::Schedule (MicroSeconds (at) - Now (), | 528 Simulator::Schedule (MicroSeconds (at) - Now (), |
541 &DcfManagerTest::DoAccessRequest, this, | 529 &DcfManagerTest::DoAccessRequest, this, |
542 txTime, expectedGrantTime, m_dcfStates[from]); | 530 txTime, expectedGrantTime, m_dca[from]); |
543 AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay); | 531 AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay); |
544 } | 532 } |
545 | 533 |
546 void | 534 void |
547 DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, Pt
r<DcfStateTest> state) | 535 DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, Pt
r<DcaTxopTest> state) |
548 { | 536 { |
549 state->QueueTx (txTime, expectedGrantTime); | 537 state->QueueTx (txTime, expectedGrantTime); |
550 m_dcfManager->RequestAccess (state); | 538 m_dcfManager->RequestAccess (state); |
551 } | 539 } |
552 | 540 |
553 void | 541 void |
554 DcfManagerTest::AddCcaBusyEvt (uint64_t at, uint64_t duration) | 542 DcfManagerTest::AddCcaBusyEvt (uint64_t at, uint64_t duration) |
555 { | 543 { |
556 Simulator::Schedule (MicroSeconds (at) - Now (), | 544 Simulator::Schedule (MicroSeconds (at) - Now (), |
557 &DcfManager::NotifyMaybeCcaBusyStartNow, m_dcfManager, | 545 &DcfManager::NotifyMaybeCcaBusyStartNow, m_dcfManager, |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 DcfTestSuite (); | 912 DcfTestSuite (); |
925 }; | 913 }; |
926 | 914 |
927 DcfTestSuite::DcfTestSuite () | 915 DcfTestSuite::DcfTestSuite () |
928 : TestSuite ("devices-wifi-dcf", UNIT) | 916 : TestSuite ("devices-wifi-dcf", UNIT) |
929 { | 917 { |
930 AddTestCase (new DcfManagerTest, TestCase::QUICK); | 918 AddTestCase (new DcfManagerTest, TestCase::QUICK); |
931 } | 919 } |
932 | 920 |
933 static DcfTestSuite g_dcfTestSuite; | 921 static DcfTestSuite g_dcfTestSuite; |
LEFT | RIGHT |