|
511 |
void |
511 |
void |
512 |
DcfManager::UpdateBackoff (void) |
512 |
DcfManager::UpdateBackoff (void) |
513 |
{ |
513 |
{ |
|
|
514 |
long double slotNanoSeconds = m_slotTime.GetNanoSeconds (); |
514 |
uint32_t k = 0; |
515 |
uint32_t k = 0; |
515 |
for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++) |
516 |
for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++) |
516 |
{ |
517 |
{ |
|
519 |
Time backoffStart = GetBackoffStartFor (state); |
520 |
Time backoffStart = GetBackoffStartFor (state); |
520 |
if (backoffStart <= Simulator::Now ()) |
521 |
if (backoffStart <= Simulator::Now ()) |
521 |
{ |
522 |
{ |
522 |
Scalar nSlots = (Simulator::Now () - backoffStart) / m_slotTime; |
523 |
long double inBackoffNanoSeconds = Simulator::Now ().GetNanoSeconds () - backoffStart.GetNanoSeconds (); |
523 |
uint32_t nIntSlots = lrint (nSlots.GetDouble ()); |
524 |
long double nSlots = inBackoffNanoSeconds / slotNanoSeconds; |
|
|
525 |
uint32_t nIntSlots = lrintl (nSlots); |
524 |
uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); |
526 |
uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); |
525 |
MY_DEBUG ("dcf " << k << " dec backoff slots=" << n); |
527 |
MY_DEBUG ("dcf " << k << " dec backoff slots=" << n); |
526 |
Time backoffUpdateBound = backoffStart + Scalar (n) * m_slotTime; |
528 |
Time backoffUpdateBound = backoffStart + Scalar (n) * m_slotTime; |