diff -r d01b54f37c59 src/internet-stack/arp-cache.cc --- a/src/internet-stack/arp-cache.cc Fri Dec 19 19:08:23 2008 +0000 +++ b/src/internet-stack/arp-cache.cc Mon Dec 22 12:07:55 2008 +0000 @@ -190,7 +190,7 @@ for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) { entry = (*i).second; - if (entry != 0 && entry->IsWaitReply () && entry->IsExpired ()) + if (entry != 0 && entry->IsWaitReply () && entry->IsNearlyExpired ()) { if (entry->GetRetries () < m_maxRetries) { @@ -367,30 +367,46 @@ NS_LOG_FUNCTION (this << destination); m_ipv4Address = destination; } - +Time +ArpCache::Entry::GetTimeout (void) const +{ + switch (m_state) { + case ArpCache::Entry::WAIT_REPLY: + return m_arp->GetWaitReplyTimeout (); + case ArpCache::Entry::DEAD: + return m_arp->GetDeadTimeout (); + case ArpCache::Entry::ALIVE: + return m_arp->GetAliveTimeout (); + default: + NS_ASSERT (false); + return Seconds (0); + /* NOTREACHED */ + } +} +bool +ArpCache::Entry::IsNearlyExpired (void) +{ + NS_LOG_FUNCTION_NOARGS (); + Time timeout = GetTimeout (); + Time delta = Simulator::Now () - m_lastSeen; + NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); + if (delta >= timeout) + { + return true; + } + else + { + return false; + } +} bool ArpCache::Entry::IsExpired (void) { NS_LOG_FUNCTION_NOARGS (); - Time timeout; - switch (m_state) { - case ArpCache::Entry::WAIT_REPLY: - timeout = m_arp->GetWaitReplyTimeout (); - break; - case ArpCache::Entry::DEAD: - timeout = m_arp->GetDeadTimeout (); - break; - case ArpCache::Entry::ALIVE: - timeout = m_arp->GetAliveTimeout (); - break; - default: - NS_ASSERT (false); - timeout = Seconds (0); - /* NOTREACHED */ - break; - } + Time timeout = GetTimeout (); Time delta = Simulator::Now () - m_lastSeen; - if (delta >= timeout) + NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s"); + if (delta > timeout) { return true; } @@ -417,13 +433,13 @@ void ArpCache::Entry::UpdateSeen (void) { - NS_LOG_FUNCTION_NOARGS (); + NS_LOG_FUNCTION (m_macAddress << m_ipv4Address); m_lastSeen = Simulator::Now (); } uint32_t ArpCache::Entry::GetRetries (void) const { - NS_LOG_FUNCTION_NOARGS (); + NS_LOG_FUNCTION (m_ipv4Address << m_retries); return m_retries; } void diff -r d01b54f37c59 src/internet-stack/arp-cache.h --- a/src/internet-stack/arp-cache.h Fri Dec 19 19:08:23 2008 +0000 +++ b/src/internet-stack/arp-cache.h Mon Dec 22 12:07:55 2008 +0000 @@ -163,6 +163,10 @@ * \return True if this entry has timedout; false otherwise. */ bool IsExpired (void); + /** + * \return True if this entry has nearly timedout; false otherwise. + */ + bool IsNearlyExpired (void); /** * \returns 0 is no packet is pending, the next packet to send if @@ -184,6 +188,8 @@ void ClearRetries (void); private: + Time GetTimeout (void) const; + enum ArpCacheEntryState_e { ALIVE, WAIT_REPLY,