Lines 32-46
class DcfStateTest : public DcfState
|
Link Here
|
---|
|
32 |
{ |
32 |
{ |
33 |
public: |
33 |
public: |
34 |
DcfStateTest (DcfManagerTest *test, uint32_t i); |
34 |
DcfStateTest (DcfManagerTest *test, uint32_t i); |
35 |
void QueueTx (uint64_t txTime, uint64_t expectedGrantTime); |
35 |
void QueueTx (uint64_t txTime, uint64_t expectedGrantTime, uint32_t nBackoffSlots); |
36 |
private: |
36 |
private: |
37 |
friend class DcfManagerTest; |
37 |
friend class DcfManagerTest; |
38 |
virtual void DoNotifyAccessGranted (void); |
38 |
virtual void DoNotifyAccessGranted (void); |
39 |
virtual void DoNotifyInternalCollision (void); |
39 |
virtual void DoNotifyInternalCollision (void); |
40 |
virtual void DoNotifyCollision (void); |
40 |
virtual void DoNotifyCollision (void); |
41 |
|
41 |
|
42 |
typedef std::pair<uint64_t,uint64_t> ExpectedGrant; |
42 |
struct ExpectedGrant { |
43 |
typedef std::list<ExpectedGrant> ExpectedGrants; |
43 |
uint64_t m_txTime; |
|
|
44 |
uint64_t m_expectedGrantTime; |
45 |
uint32_t m_nBackoffSlots; |
46 |
}; |
47 |
typedef std::list<struct ExpectedGrant> ExpectedGrants; |
48 |
|
44 |
struct ExpectedCollision { |
49 |
struct ExpectedCollision { |
45 |
uint64_t at; |
50 |
uint64_t at; |
46 |
uint32_t nSlots; |
51 |
uint32_t nSlots; |
|
78 |
void AddNavReset (uint64_t at, uint64_t duration); |
83 |
void AddNavReset (uint64_t at, uint64_t duration); |
79 |
void AddNavStart (uint64_t at, uint64_t duration); |
84 |
void AddNavStart (uint64_t at, uint64_t duration); |
80 |
void AddAckTimeoutReset (uint64_t at); |
85 |
void AddAckTimeoutReset (uint64_t at); |
81 |
void AddAccessRequest (uint64_t at, uint64_t txTime, |
86 |
void AddAccessRequest (uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, |
82 |
uint64_t expectedGrantTime, uint32_t from); |
87 |
uint32_t nBackoffSlots, uint32_t from); |
83 |
void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, |
88 |
void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, |
84 |
uint64_t expectedGrantTime, uint32_t from); |
89 |
uint32_t nBackoffSlots, uint32_t from); |
85 |
///\param ackDelay is delay of the ack after txEnd |
90 |
///\param ackDelay is delay of the ack after txEnd |
86 |
void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, |
91 |
void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, |
87 |
uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from); |
92 |
uint32_t nBackoffSlots, uint32_t ackDelay, uint32_t from); |
88 |
void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state); |
93 |
void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, uint32_t nBackoffSlots, DcfStateTest *state); |
89 |
|
94 |
|
90 |
typedef std::vector<DcfStateTest *> DcfStates; |
95 |
typedef std::vector<DcfStateTest *> DcfStates; |
91 |
|
96 |
|
Lines 101-109
DcfStateTest::DcfStateTest (DcfManagerTe
|
Link Here
|
---|
|
101 |
: m_test (test), m_i(i) |
106 |
: m_test (test), m_i(i) |
102 |
{} |
107 |
{} |
103 |
void |
108 |
void |
104 |
DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime) |
109 |
DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime, uint32_t nBackoffSlots) |
105 |
{ |
110 |
{ |
106 |
m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime)); |
111 |
struct ExpectedGrant grant; |
|
|
112 |
grant.m_txTime = txTime; |
113 |
grant.m_expectedGrantTime = expectedGrantTime; |
114 |
grant.m_nBackoffSlots = nBackoffSlots; |
115 |
m_expectedGrants.push_back (grant); |
107 |
} |
116 |
} |
108 |
void |
117 |
void |
109 |
DcfStateTest::DoNotifyAccessGranted (void) |
118 |
DcfStateTest::DoNotifyAccessGranted (void) |
Lines 133-143
DcfManagerTest::NotifyAccessGranted (uin
|
Link Here
|
---|
|
133 |
DcfStateTest *state = m_dcfStates[i]; |
142 |
DcfStateTest *state = m_dcfStates[i]; |
134 |
bool result = true; |
143 |
bool result = true; |
135 |
NS_TEST_ASSERT (!state->m_expectedGrants.empty ()); |
144 |
NS_TEST_ASSERT (!state->m_expectedGrants.empty ()); |
136 |
std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front (); |
145 |
struct DcfStateTest::ExpectedGrant expected = state->m_expectedGrants.front (); |
137 |
state->m_expectedGrants.pop_front (); |
146 |
state->m_expectedGrants.pop_front (); |
138 |
NS_TEST_ASSERT_EQUAL (Simulator::Now (), MicroSeconds (expected.second)); |
147 |
NS_TEST_ASSERT_EQUAL (Simulator::Now (), MicroSeconds (expected.m_expectedGrantTime)); |
139 |
m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first)); |
148 |
m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.m_txTime)); |
140 |
m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue + expected.first)); |
149 |
state->StartBackoffNow (expected.m_nBackoffSlots); |
|
|
150 |
m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue + expected.m_txTime)); |
141 |
if (!result) |
151 |
if (!result) |
142 |
{ |
152 |
{ |
143 |
m_result = result; |
153 |
m_result = result; |
Lines 275-307
DcfManagerTest::AddAckTimeoutReset (uint
|
Link Here
|
---|
|
275 |
&DcfManager::NotifyAckTimeoutResetNow, m_dcfManager); |
285 |
&DcfManager::NotifyAckTimeoutResetNow, m_dcfManager); |
276 |
} |
286 |
} |
277 |
void |
287 |
void |
278 |
DcfManagerTest::AddAccessRequest (uint64_t at, uint64_t txTime, |
288 |
DcfManagerTest::AddAccessRequest (uint64_t at, uint64_t txTime, |
279 |
uint64_t expectedGrantTime, uint32_t from) |
289 |
uint64_t expectedGrantTime, uint32_t nBackoffSlots, |
|
|
290 |
uint32_t from) |
280 |
{ |
291 |
{ |
281 |
AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, from); |
292 |
AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, nBackoffSlots, from); |
282 |
} |
293 |
} |
283 |
void |
294 |
void |
284 |
DcfManagerTest::AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, |
295 |
DcfManagerTest::AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, |
285 |
uint64_t expectedGrantTime, uint32_t from) |
296 |
uint32_t nBackoffSlots, uint32_t from) |
286 |
{ |
297 |
{ |
287 |
Simulator::Schedule (MicroSeconds (at) - Now (), |
298 |
Simulator::Schedule (MicroSeconds (at) - Now (), |
288 |
&DcfManagerTest::DoAccessRequest, this, |
299 |
&DcfManagerTest::DoAccessRequest, this, |
289 |
txTime, expectedGrantTime, m_dcfStates[from]); |
300 |
txTime, expectedGrantTime, nBackoffSlots, m_dcfStates[from]); |
290 |
} |
301 |
} |
291 |
void |
302 |
void |
292 |
DcfManagerTest::AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, |
303 |
DcfManagerTest::AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, |
293 |
uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from) |
304 |
uint32_t ackDelay, uint32_t nBackoffSlots, uint32_t from) |
294 |
{ |
305 |
{ |
295 |
NS_ASSERT(ackDelay < m_ackTimeoutValue); |
306 |
NS_ASSERT(ackDelay < m_ackTimeoutValue); |
296 |
Simulator::Schedule (MicroSeconds (at) - Now (), |
307 |
Simulator::Schedule (MicroSeconds (at) - Now (), |
297 |
&DcfManagerTest::DoAccessRequest, this, |
308 |
&DcfManagerTest::DoAccessRequest, this, |
298 |
txTime, expectedGrantTime, m_dcfStates[from]); |
309 |
txTime, expectedGrantTime, nBackoffSlots, m_dcfStates[from]); |
299 |
AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay); |
310 |
AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay); |
300 |
} |
311 |
} |
301 |
void |
312 |
void |
302 |
DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state) |
313 |
DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, uint32_t nBackoffSlots, |
|
|
314 |
DcfStateTest *state) |
303 |
{ |
315 |
{ |
304 |
state->QueueTx (txTime, expectedGrantTime); |
316 |
state->QueueTx (txTime, expectedGrantTime, nBackoffSlots); |
305 |
m_dcfManager->RequestAccess (state); |
317 |
m_dcfManager->RequestAccess (state); |
306 |
} |
318 |
} |
307 |
|
319 |
|
Lines 318-325
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
318 |
// |
330 |
// |
319 |
StartTest (1, 3, 10); |
331 |
StartTest (1, 3, 10); |
320 |
AddDcfState (1); |
332 |
AddDcfState (1); |
321 |
AddAccessRequest (1, 1, 4, 0); |
333 |
AddAccessRequest (1, 1, 4, 1, 0); |
322 |
AddAccessRequest (10, 2, 10, 0); |
334 |
AddAccessRequest (10, 2, 10, 0, 0); |
323 |
EndTest (); |
335 |
EndTest (); |
324 |
|
336 |
|
325 |
// The test below mainly intends to test the case where the medium |
337 |
// The test below mainly intends to test the case where the medium |
Lines 335-341
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
335 |
AddDcfState (1); |
347 |
AddDcfState (1); |
336 |
AddRxOkEvt (20, 40); |
348 |
AddRxOkEvt (20, 40); |
337 |
AddRxOkEvt (80, 20); |
349 |
AddRxOkEvt (80, 20); |
338 |
AddAccessRequest (30, 2, 118, 0); |
350 |
AddAccessRequest (30, 2, 118, 4, 0); |
339 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
351 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
340 |
EndTest (); |
352 |
EndTest (); |
341 |
|
353 |
|
Lines 348-357
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
348 |
StartTest (4, 6 , 10); |
360 |
StartTest (4, 6 , 10); |
349 |
AddDcfState (1); |
361 |
AddDcfState (1); |
350 |
AddRxOkEvt (20, 40); |
362 |
AddRxOkEvt (20, 40); |
351 |
AddAccessRequest (30, 2, 70, 0); |
363 |
AddAccessRequest (30, 2, 70, 0, 0); |
352 |
ExpectCollision (30, 0, 0); // backoff: 0 slots |
364 |
ExpectCollision (30, 0, 0); // backoff: 0 slots |
353 |
EndTest (); |
365 |
EndTest (); |
354 |
|
366 |
|
|
|
367 |
// Test case where two packets are queued at DcaTxop, the first send starts |
368 |
// immediately and the second is also immediately indicated but has to wait |
369 |
// for its backoff. |
370 |
// |
371 |
// 20 60 66 70 80 |
372 |
// | tx | sifs | aifs | tx | |
373 |
// |20: request access for both packets |
374 |
StartTest (4, 6 , 10); |
375 |
AddDcfState (1); |
376 |
AddAccessRequest (20, 40, 20, 0, 0); |
377 |
AddAccessRequest (20, 10, 70, 0, 0); |
378 |
EndTest (); |
379 |
|
380 |
// Test case where two packets are queued at DcaTxop, the first send starts |
381 |
// immediately and the second is also immediately indicated but has to wait |
382 |
// for its backoff. |
383 |
// |
384 |
// 20 60 66 70 78 88 |
385 |
// | tx | sifs | aifs | backoff | tx | |
386 |
// |20: request access for both packets |
387 |
StartTest (4, 6 , 10); |
388 |
AddDcfState (1); |
389 |
AddAccessRequest (20, 40, 20, 2, 0); |
390 |
AddAccessRequest (20, 10, 78, 0, 0); |
391 |
EndTest (); |
392 |
|
355 |
// The test below is subject to some discussion because I am |
393 |
// The test below is subject to some discussion because I am |
356 |
// not sure I understand the intent of the spec here. |
394 |
// not sure I understand the intent of the spec here. |
357 |
// i.e., what happens if you make a request to get access |
395 |
// i.e., what happens if you make a request to get access |
Lines 368-374
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
368 |
StartTest (4, 6 , 10); |
406 |
StartTest (4, 6 , 10); |
369 |
AddDcfState (1); |
407 |
AddDcfState (1); |
370 |
AddRxOkEvt (20, 40); |
408 |
AddRxOkEvt (20, 40); |
371 |
AddAccessRequest (62, 2, 70, 0); |
409 |
AddAccessRequest (62, 2, 70, 0, 0); |
372 |
EndTest (); |
410 |
EndTest (); |
373 |
|
411 |
|
374 |
|
412 |
|
Lines 381-387
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
381 |
StartTest (4, 6, 10); |
419 |
StartTest (4, 6, 10); |
382 |
AddDcfState (1); |
420 |
AddDcfState (1); |
383 |
AddRxErrorEvt (20, 40); |
421 |
AddRxErrorEvt (20, 40); |
384 |
AddAccessRequest (30, 2, 96, 0); |
422 |
AddAccessRequest (30, 2, 96, 4, 0); |
385 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
423 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
386 |
EndTest (); |
424 |
EndTest (); |
387 |
|
425 |
|
Lines 394-400
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
394 |
StartTest (4, 6, 10); |
432 |
StartTest (4, 6, 10); |
395 |
AddDcfState (1); |
433 |
AddDcfState (1); |
396 |
AddRxErrorEvt (20, 40); |
434 |
AddRxErrorEvt (20, 40); |
397 |
AddAccessRequest (30, 2, 101, 0); |
435 |
AddAccessRequest (30, 2, 101, 4, 0); |
398 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
436 |
ExpectCollision (30, 4, 0); // backoff: 4 slots |
399 |
AddRxOkEvt (69, 6); |
437 |
AddRxOkEvt (69, 6); |
400 |
EndTest (); |
438 |
EndTest (); |
Lines 411-420
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
411 |
AddDcfState (1); // high priority DCF |
449 |
AddDcfState (1); // high priority DCF |
412 |
AddDcfState (3); // low priority DCF |
450 |
AddDcfState (3); // low priority DCF |
413 |
AddRxOkEvt (20, 40); |
451 |
AddRxOkEvt (20, 40); |
414 |
AddAccessRequest (30, 10, 78, 0); |
452 |
AddAccessRequest (30, 10, 78, 2, 0); |
415 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
453 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
416 |
|
454 |
|
417 |
AddAccessRequest (40, 2, 110, 1); |
455 |
AddAccessRequest (40, 2, 110, 0, 1); |
418 |
ExpectCollision (40, 0, 1); // backoff: 0 slot |
456 |
ExpectCollision (40, 0, 1); // backoff: 0 slot |
419 |
ExpectInternalCollision (78, 1, 1); // backoff: 1 slot |
457 |
ExpectInternalCollision (78, 1, 1); // backoff: 1 slot |
420 |
EndTest (); |
458 |
EndTest (); |
Lines 429-436
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
429 |
StartTest (4, 6, 10); |
467 |
StartTest (4, 6, 10); |
430 |
AddDcfState (2); // high priority DCF |
468 |
AddDcfState (2); // high priority DCF |
431 |
AddDcfState (0); // low priority DCF |
469 |
AddDcfState (0); // low priority DCF |
432 |
AddAccessRequestWithAckTimeout (20, 20, 20, 0); |
470 |
AddAccessRequestWithAckTimeout (20, 20, 20, 0, 0); |
433 |
AddAccessRequest (50, 10, 66, 1); |
471 |
AddAccessRequest (50, 10, 66, 0, 1); |
434 |
EndTest (); |
472 |
EndTest (); |
435 |
|
473 |
|
436 |
// Test of AckTimeout handling: |
474 |
// Test of AckTimeout handling: |
Lines 445-452
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
445 |
StartTest (4, 6, 10); |
483 |
StartTest (4, 6, 10); |
446 |
AddDcfState (2); // high priority DCF |
484 |
AddDcfState (2); // high priority DCF |
447 |
AddDcfState (0); // low priority DCF |
485 |
AddDcfState (0); // low priority DCF |
448 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0); |
486 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0, 0); |
449 |
AddAccessRequest (41, 10, 48, 1); |
487 |
AddAccessRequest (41, 10, 48, 0, 1); |
450 |
EndTest (); |
488 |
EndTest (); |
451 |
|
489 |
|
452 |
//Repeat the same but with one queue: |
490 |
//Repeat the same but with one queue: |
Lines 455-462
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
455 |
// ^ request access |
493 |
// ^ request access |
456 |
StartTest (4, 6, 10); |
494 |
StartTest (4, 6, 10); |
457 |
AddDcfState (2); |
495 |
AddDcfState (2); |
458 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0); |
496 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0, 0); |
459 |
AddAccessRequest (41, 10, 56, 0); |
497 |
AddAccessRequest (41, 10, 56, 0, 0); |
460 |
EndTest (); |
498 |
EndTest (); |
461 |
|
499 |
|
462 |
//Repeat the same when ack was delayed: |
500 |
//Repeat the same when ack was delayed: |
Lines 466-474
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
466 |
// ^ request access |
504 |
// ^ request access |
467 |
StartTest (4, 6, 10); |
505 |
StartTest (4, 6, 10); |
468 |
AddDcfState (2); |
506 |
AddDcfState (2); |
469 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0); |
507 |
AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 2, 0); |
470 |
AddAccessRequest (39, 10, 64, 0); |
508 |
AddAccessRequest (39, 10, 64, 0, 0); |
471 |
ExpectCollision (39, 2, 0); // backoff: 2 slot |
509 |
// this situation is not supposed to fire an internal or external collison. |
|
|
510 |
// ExpectCollision (39, 2, 0); // backoff: 2 slot |
472 |
EndTest (); |
511 |
EndTest (); |
473 |
|
512 |
|
474 |
// |
513 |
// |
Lines 482-488
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
482 |
AddNavStart (60, 15); |
521 |
AddNavStart (60, 15); |
483 |
AddRxOkEvt (66, 5); |
522 |
AddRxOkEvt (66, 5); |
484 |
AddNavStart (71, 0); |
523 |
AddNavStart (71, 0); |
485 |
AddAccessRequest (30, 10, 93, 0); |
524 |
AddAccessRequest (30, 10, 93, 0, 0); |
486 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
525 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
487 |
EndTest (); |
526 |
EndTest (); |
488 |
|
527 |
|
Lines 497-503
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
497 |
AddNavStart (60, 15); |
536 |
AddNavStart (60, 15); |
498 |
AddRxOkEvt (66, 5); |
537 |
AddRxOkEvt (66, 5); |
499 |
AddNavReset (71, 2); |
538 |
AddNavReset (71, 2); |
500 |
AddAccessRequest (30, 10, 91, 0); |
539 |
AddAccessRequest (30, 10, 91, 0, 0); |
501 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
540 |
ExpectCollision (30, 2, 0); // backoff: 2 slot |
502 |
EndTest (); |
541 |
EndTest (); |
503 |
|
542 |
|
Lines 505-511
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
505 |
StartTest (4, 6, 10); |
544 |
StartTest (4, 6, 10); |
506 |
AddDcfState (2); |
545 |
AddDcfState (2); |
507 |
AddRxOkEvt (20, 40); |
546 |
AddRxOkEvt (20, 40); |
508 |
AddAccessRequest (80, 10, 80, 0); |
547 |
AddAccessRequest (80, 10, 80, 0, 0); |
509 |
EndTest (); |
548 |
EndTest (); |
510 |
|
549 |
|
511 |
|
550 |
|
Lines 513-522
DcfManagerTest::RunTests (void)
|
Link Here
|
---|
|
513 |
AddDcfState (2); |
552 |
AddDcfState (2); |
514 |
AddRxOkEvt (20, 40); |
553 |
AddRxOkEvt (20, 40); |
515 |
AddRxOkEvt (78, 8); |
554 |
AddRxOkEvt (78, 8); |
516 |
AddAccessRequest (30, 50, 108, 0); |
555 |
AddAccessRequest (30, 50, 108, 0, 0); |
517 |
ExpectCollision (30, 3, 0); // backoff: 3 slots |
556 |
ExpectCollision (30, 3, 0); // backoff: 3 slots |
518 |
EndTest (); |
557 |
EndTest (); |
519 |
|
|
|
520 |
|
558 |
|
521 |
return m_result; |
559 |
return m_result; |
522 |
} |
560 |
} |