|
|
| 190 |
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) |
190 |
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) |
| 191 |
{ |
191 |
{ |
| 192 |
entry = (*i).second; |
192 |
entry = (*i).second; |
| 193 |
if (entry != 0 && entry->IsWaitReply () && entry->IsExpired ()) |
193 |
if (entry != 0 && entry->IsWaitReply () && entry->IsNearlyExpired ()) |
| 194 |
{ |
194 |
{ |
| 195 |
if (entry->GetRetries () < m_maxRetries) |
195 |
if (entry->GetRetries () < m_maxRetries) |
| 196 |
{ |
196 |
{ |
|
|
| 367 |
NS_LOG_FUNCTION (this << destination); |
367 |
NS_LOG_FUNCTION (this << destination); |
| 368 |
m_ipv4Address = destination; |
368 |
m_ipv4Address = destination; |
| 369 |
} |
369 |
} |
| 370 |
|
370 |
Time |
|
|
371 |
ArpCache::Entry::GetTimeout (void) const |
| 372 |
{ |
| 373 |
switch (m_state) { |
| 374 |
case ArpCache::Entry::WAIT_REPLY: |
| 375 |
return m_arp->GetWaitReplyTimeout (); |
| 376 |
case ArpCache::Entry::DEAD: |
| 377 |
return m_arp->GetDeadTimeout (); |
| 378 |
case ArpCache::Entry::ALIVE: |
| 379 |
return m_arp->GetAliveTimeout (); |
| 380 |
default: |
| 381 |
NS_ASSERT (false); |
| 382 |
return Seconds (0); |
| 383 |
/* NOTREACHED */ |
| 384 |
} |
| 385 |
} |
| 386 |
bool |
| 387 |
ArpCache::Entry::IsNearlyExpired (void) |
| 388 |
{ |
| 389 |
NS_LOG_FUNCTION_NOARGS (); |
| 390 |
Time timeout = GetTimeout (); |
| 391 |
Time delta = Simulator::Now () - m_lastSeen; |
| 392 |
NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); |
| 393 |
if (delta >= timeout) |
| 394 |
{ |
| 395 |
return true; |
| 396 |
} |
| 397 |
else |
| 398 |
{ |
| 399 |
return false; |
| 400 |
} |
| 401 |
} |
| 371 |
bool |
402 |
bool |
| 372 |
ArpCache::Entry::IsExpired (void) |
403 |
ArpCache::Entry::IsExpired (void) |
| 373 |
{ |
404 |
{ |
| 374 |
NS_LOG_FUNCTION_NOARGS (); |
405 |
NS_LOG_FUNCTION_NOARGS (); |
| 375 |
Time timeout; |
406 |
Time timeout = GetTimeout (); |
| 376 |
switch (m_state) { |
|
|
| 377 |
case ArpCache::Entry::WAIT_REPLY: |
| 378 |
timeout = m_arp->GetWaitReplyTimeout (); |
| 379 |
break; |
| 380 |
case ArpCache::Entry::DEAD: |
| 381 |
timeout = m_arp->GetDeadTimeout (); |
| 382 |
break; |
| 383 |
case ArpCache::Entry::ALIVE: |
| 384 |
timeout = m_arp->GetAliveTimeout (); |
| 385 |
break; |
| 386 |
default: |
| 387 |
NS_ASSERT (false); |
| 388 |
timeout = Seconds (0); |
| 389 |
/* NOTREACHED */ |
| 390 |
break; |
| 391 |
} |
| 392 |
Time delta = Simulator::Now () - m_lastSeen; |
407 |
Time delta = Simulator::Now () - m_lastSeen; |
| 393 |
if (delta >= timeout) |
408 |
NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); |
|
|
409 |
if (delta > timeout) |
| 394 |
{ |
410 |
{ |
| 395 |
return true; |
411 |
return true; |
| 396 |
} |
412 |
} |
|
|
| 417 |
void |
433 |
void |
| 418 |
ArpCache::Entry::UpdateSeen (void) |
434 |
ArpCache::Entry::UpdateSeen (void) |
| 419 |
{ |
435 |
{ |
| 420 |
NS_LOG_FUNCTION_NOARGS (); |
436 |
NS_LOG_FUNCTION (m_macAddress << m_ipv4Address); |
| 421 |
m_lastSeen = Simulator::Now (); |
437 |
m_lastSeen = Simulator::Now (); |
| 422 |
} |
438 |
} |
| 423 |
uint32_t |
439 |
uint32_t |
| 424 |
ArpCache::Entry::GetRetries (void) const |
440 |
ArpCache::Entry::GetRetries (void) const |
| 425 |
{ |
441 |
{ |
| 426 |
NS_LOG_FUNCTION_NOARGS (); |
442 |
NS_LOG_FUNCTION (m_ipv4Address << m_retries); |
| 427 |
return m_retries; |
443 |
return m_retries; |
| 428 |
} |
444 |
} |
| 429 |
void |
445 |
void |