1.1 --- a/src/internet-stack/arp-cache.cc Tue May 05 19:06:25 2009 +0100
1.2 +++ b/src/internet-stack/arp-cache.cc Wed May 06 18:24:45 2009 +0100
1.3 @@ -185,7 +185,7 @@
1.4 for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++)
1.5 {
1.6 entry = (*i).second;
1.7 - if (entry != 0 && entry->IsWaitReply () && entry->IsExpired ())
1.8 + if (entry != 0 && entry->IsWaitReply ())
1.9 {
1.10 if (entry->GetRetries () < m_maxRetries)
1.11 {
1.12 @@ -232,6 +232,11 @@
1.13 delete (*i).second;
1.14 }
1.15 m_arpCache.erase (m_arpCache.begin (), m_arpCache.end ());
1.16 + if (m_waitReplyTimer.IsRunning ())
1.17 + {
1.18 + NS_LOG_LOGIC ("Stopping WaitReplyTimer at " << Simulator::Now ().GetSeconds () << " due to ArpCache flush");
1.19 + m_waitReplyTimer.Cancel ();
1.20 + }
1.21 }
1.22
1.23 ArpCache::Entry *
1.24 @@ -353,37 +358,34 @@
1.25 NS_LOG_FUNCTION (this << destination);
1.26 m_ipv4Address = destination;
1.27 }
1.28 -
1.29 +Time
1.30 +ArpCache::Entry::GetTimeout (void) const
1.31 +{
1.32 + switch (m_state) {
1.33 + case ArpCache::Entry::WAIT_REPLY:
1.34 + return m_arp->GetWaitReplyTimeout ();
1.35 + case ArpCache::Entry::DEAD:
1.36 + return m_arp->GetDeadTimeout ();
1.37 + case ArpCache::Entry::ALIVE:
1.38 + return m_arp->GetAliveTimeout ();
1.39 + default:
1.40 + NS_ASSERT (false);
1.41 + return Seconds (0);
1.42 + /* NOTREACHED */
1.43 + }
1.44 +}
1.45 bool
1.46 -ArpCache::Entry::IsExpired (void)
1.47 +ArpCache::Entry::IsExpired (void) const
1.48 {
1.49 NS_LOG_FUNCTION_NOARGS ();
1.50 - Time timeout;
1.51 - switch (m_state) {
1.52 - case ArpCache::Entry::WAIT_REPLY:
1.53 - timeout = m_arp->GetWaitReplyTimeout ();
1.54 - break;
1.55 - case ArpCache::Entry::DEAD:
1.56 - timeout = m_arp->GetDeadTimeout ();
1.57 - break;
1.58 - case ArpCache::Entry::ALIVE:
1.59 - timeout = m_arp->GetAliveTimeout ();
1.60 - break;
1.61 - default:
1.62 - NS_ASSERT (false);
1.63 - timeout = Seconds (0);
1.64 - /* NOTREACHED */
1.65 - break;
1.66 - }
1.67 + Time timeout = GetTimeout ();
1.68 Time delta = Simulator::Now () - m_lastSeen;
1.69 - if (delta >= timeout)
1.70 + NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s");
1.71 + if (delta > timeout)
1.72 {
1.73 return true;
1.74 }
1.75 - else
1.76 - {
1.77 - return false;
1.78 - }
1.79 + return false;
1.80 }
1.81 Ptr<Packet>
1.82 ArpCache::Entry::DequeuePending (void)
1.83 @@ -403,13 +405,13 @@
1.84 void
1.85 ArpCache::Entry::UpdateSeen (void)
1.86 {
1.87 - NS_LOG_FUNCTION_NOARGS ();
1.88 + NS_LOG_FUNCTION (m_macAddress << m_ipv4Address);
1.89 m_lastSeen = Simulator::Now ();
1.90 }
1.91 uint32_t
1.92 ArpCache::Entry::GetRetries (void) const
1.93 {
1.94 - NS_LOG_FUNCTION_NOARGS ();
1.95 + NS_LOG_FUNCTION (m_macAddress << m_ipv4Address);
1.96 return m_retries;
1.97 }
1.98 void
2.1 --- a/src/internet-stack/arp-cache.h Tue May 05 19:06:25 2009 +0100
2.2 +++ b/src/internet-stack/arp-cache.h Wed May 06 18:24:45 2009 +0100
2.3 @@ -160,10 +160,12 @@
2.4 */
2.5 void SetIpv4Address (Ipv4Address destination);
2.6 /**
2.7 - * \return True if this entry has timedout; false otherwise.
2.8 + * \return True if this entry has timed out; false otherwise.
2.9 + *
2.10 + * This function returns true if the time elapsed strictly exceeds
2.11 + * the timeout value (i.e., is not less than or equal to the timeout).
2.12 */
2.13 - bool IsExpired (void);
2.14 -
2.15 + bool IsExpired (void) const;
2.16 /**
2.17 * \returns 0 is no packet is pending, the next packet to send if
2.18 * packets are pending.
2.19 @@ -191,6 +193,7 @@
2.20 };
2.21
2.22 void UpdateSeen (void);
2.23 + Time GetTimeout (void) const;
2.24 ArpCache *m_arp;
2.25 ArpCacheEntryState_e m_state;
2.26 Time m_lastSeen;
3.1 --- a/src/internet-stack/arp-l3-protocol.cc Tue May 05 19:06:25 2009 +0100
3.2 +++ b/src/internet-stack/arp-l3-protocol.cc Wed May 06 18:24:45 2009 +0100
3.3 @@ -17,6 +17,9 @@
3.4 *
3.5 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
3.6 */
3.7 +
3.8 +#define NS_LOG_APPEND_CONTEXT if (m_node) { std::clog << "[node " << m_node->GetId () << "] "; }
3.9 +
3.10 #include "ns3/packet.h"
3.11 #include "ns3/log.h"
3.12 #include "ns3/node.h"
3.13 @@ -199,7 +202,7 @@
3.14 Ptr<ArpCache> cache,
3.15 Address *hardwareDestination)
3.16 {
3.17 - NS_LOG_FUNCTION_NOARGS ();
3.18 + NS_LOG_FUNCTION (destination);
3.19 ArpCache::Entry *entry = cache->Lookup (destination);
3.20 if (entry != 0)
3.21 {
3.22 @@ -221,7 +224,7 @@
3.23 }
3.24 else if (entry->IsWaitReply ())
3.25 {
3.26 - NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report if this is ever hit");
3.27 + NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit");
3.28 }
3.29 }
3.30 else