|
243 |
m_lastSwitchingStart (MicroSeconds (0)), |
243 |
m_lastSwitchingStart (MicroSeconds (0)), |
244 |
m_lastSwitchingDuration (MicroSeconds (0)), |
244 |
m_lastSwitchingDuration (MicroSeconds (0)), |
245 |
m_rxing (false), |
245 |
m_rxing (false), |
246 |
m_slotTime (Seconds (0.0)), |
246 |
m_slotTimeUs (0), |
247 |
m_sifs (Seconds (0.0)), |
247 |
m_sifs (Seconds (0.0)), |
248 |
m_phyListener (0), |
248 |
m_phyListener (0), |
249 |
m_lowListener (0) |
249 |
m_lowListener (0) |
|
273 |
void |
273 |
void |
274 |
DcfManager::SetSlot (Time slotTime) |
274 |
DcfManager::SetSlot (Time slotTime) |
275 |
{ |
275 |
{ |
276 |
m_slotTime = slotTime; |
276 |
m_slotTimeUs = slotTime.GetMicroSeconds (); |
277 |
} |
277 |
} |
278 |
void |
278 |
void |
279 |
DcfManager::SetSifs (Time sifs) |
279 |
DcfManager::SetSifs (Time sifs) |
|
497 |
DcfManager::GetBackoffStartFor (DcfState *state) |
497 |
DcfManager::GetBackoffStartFor (DcfState *state) |
498 |
{ |
498 |
{ |
499 |
Time mostRecentEvent = MostRecent (state->GetBackoffStart (), |
499 |
Time mostRecentEvent = MostRecent (state->GetBackoffStart (), |
500 |
GetAccessGrantStart () + Scalar (state->GetAifsn ()) * m_slotTime); |
500 |
GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs)); |
501 |
|
501 |
|
502 |
return mostRecentEvent; |
502 |
return mostRecentEvent; |
503 |
} |
503 |
} |
|
505 |
Time |
505 |
Time |
506 |
DcfManager::GetBackoffEndFor (DcfState *state) |
506 |
DcfManager::GetBackoffEndFor (DcfState *state) |
507 |
{ |
507 |
{ |
508 |
return GetBackoffStartFor (state) + Scalar (state->GetBackoffSlots ()) * m_slotTime; |
508 |
return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs); |
509 |
} |
509 |
} |
510 |
|
510 |
|
511 |
void |
511 |
void |
|
519 |
Time backoffStart = GetBackoffStartFor (state); |
519 |
Time backoffStart = GetBackoffStartFor (state); |
520 |
if (backoffStart <= Simulator::Now ()) |
520 |
if (backoffStart <= Simulator::Now ()) |
521 |
{ |
521 |
{ |
522 |
Scalar nSlots = (Simulator::Now () - backoffStart) / m_slotTime; |
522 |
uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds (); |
523 |
uint32_t nIntSlots = lrint (nSlots.GetDouble ()); |
523 |
uint32_t nIntSlots = nus / m_slotTimeUs; |
524 |
uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); |
524 |
uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); |
525 |
MY_DEBUG ("dcf " << k << " dec backoff slots=" << n); |
525 |
MY_DEBUG ("dcf " << k << " dec backoff slots=" << n); |
526 |
Time backoffUpdateBound = backoffStart + Scalar (n) * m_slotTime; |
526 |
Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs); |
527 |
state->UpdateBackoffSlotsNow (n, backoffUpdateBound); |
527 |
state->UpdateBackoffSlotsNow (n, backoffUpdateBound); |
528 |
} |
528 |
} |
529 |
} |
529 |
} |