View | Details | Raw Unified | Return to bug 451
Collapse All | Expand All

(-)a/src/internet-stack/arp-cache.cc (-28 / +38 lines)
 Lines 185-191   ArpCache::HandleWaitReplyTimeout (void) Link Here 
185
  for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) 
185
  for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++) 
186
    {
186
    {
187
      entry = (*i).second;
187
      entry = (*i).second;
188
      if (entry != 0 && entry->IsWaitReply () && entry->IsExpired ())
188
      if (entry != 0 && entry->IsWaitReply () && entry->IsExpiring () )
189
          {
189
          {
190
          if (entry->GetRetries () < m_maxRetries)
190
          if (entry->GetRetries () < m_maxRetries)
191
            {
191
            {
 Lines 358-394   ArpCache::Entry::SetIpv4Address (Ipv4Add Link Here 
358
  NS_LOG_FUNCTION (this << destination);
358
  NS_LOG_FUNCTION (this << destination);
359
  m_ipv4Address = destination;
359
  m_ipv4Address = destination;
360
}
360
}
361
361
Time
362
bool 
362
ArpCache::Entry::GetTimeout (void) const
363
ArpCache::Entry::IsExpired (void)
363
{
364
  switch (m_state) {
365
  case ArpCache::Entry::WAIT_REPLY:
366
    return m_arp->GetWaitReplyTimeout ();
367
  case ArpCache::Entry::DEAD:
368
    return m_arp->GetDeadTimeout ();
369
  case ArpCache::Entry::ALIVE:
370
    return m_arp->GetAliveTimeout ();
371
  default:
372
    NS_ASSERT (false);
373
    return Seconds (0);
374
    /* NOTREACHED */
375
  }
376
}
377
bool
378
ArpCache::Entry::IsExpiring (void) const
364
{
379
{
365
  NS_LOG_FUNCTION_NOARGS ();
380
  NS_LOG_FUNCTION_NOARGS ();
366
  Time timeout;
381
  Time timeout = GetTimeout ();
367
  switch (m_state) {
368
  case ArpCache::Entry::WAIT_REPLY:
369
    timeout = m_arp->GetWaitReplyTimeout ();
370
    break;
371
  case ArpCache::Entry::DEAD:
372
    timeout = m_arp->GetDeadTimeout ();
373
    break;
374
  case ArpCache::Entry::ALIVE:
375
    timeout = m_arp->GetAliveTimeout ();
376
    break;
377
  default:
378
    NS_ASSERT (false);
379
    timeout = Seconds (0);
380
    /* NOTREACHED */
381
    break;
382
  }
383
  Time delta = Simulator::Now () - m_lastSeen;
382
  Time delta = Simulator::Now () - m_lastSeen;
384
  if (delta >= timeout) 
383
  NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s");
384
  if (delta >= timeout)
385
    {
386
      return true;
387
    }
388
  return false;
389
}
390
bool 
391
ArpCache::Entry::IsExpired (void) const
392
{
393
  NS_LOG_FUNCTION_NOARGS ();
394
  Time timeout = GetTimeout ();
395
  Time delta = Simulator::Now () - m_lastSeen;
396
  NS_LOG_DEBUG ("delta=" << delta.GetSeconds () << "s");
397
  if (delta > timeout) 
385
    {
398
    {
386
      return true;
399
      return true;
387
    } 
400
    } 
388
  else 
401
  return false;
389
    {
390
      return false;
391
    }
392
}
402
}
393
Ptr<Packet> 
403
Ptr<Packet> 
394
ArpCache::Entry::DequeuePending (void)
404
ArpCache::Entry::DequeuePending (void)
 Lines 408-420   void Link Here 
408
void 
418
void 
409
ArpCache::Entry::UpdateSeen (void)
419
ArpCache::Entry::UpdateSeen (void)
410
{
420
{
411
  NS_LOG_FUNCTION_NOARGS ();
421
  NS_LOG_FUNCTION (m_macAddress << m_ipv4Address);
412
  m_lastSeen = Simulator::Now ();
422
  m_lastSeen = Simulator::Now ();
413
}
423
}
414
uint32_t
424
uint32_t
415
ArpCache::Entry::GetRetries (void) const
425
ArpCache::Entry::GetRetries (void) const
416
{
426
{
417
  NS_LOG_FUNCTION_NOARGS ();
427
  NS_LOG_FUNCTION (m_macAddress << m_ipv4Address);
418
  return m_retries;
428
  return m_retries;
419
}
429
}
420
void
430
void
(-)a/src/internet-stack/arp-cache.h (-2 / +19 lines)
 Lines 160-168   public: Link Here 
160
     */
160
     */
161
    void SetIpv4Address (Ipv4Address destination);
161
    void SetIpv4Address (Ipv4Address destination);
162
    /**
162
    /**
163
     * \return True if this entry has timedout; false otherwise.
163
     * \return True if this entry has timed out; false otherwise.
164
     *
165
     * This function returns true if the time elapsed strictly exceeds
166
     * the timeout value (i.e., is not less than or equal to the timeout).
167
     * Differs from IsExpiring() only in the boundary condition 
168
     * delta == timeout.
169
     * \see IsExpiring
164
     */
170
     */
165
    bool IsExpired (void);
171
    bool IsExpired (void) const;
172
    /**
173
     * \return True if this entry is timing out or has already timed out; 
174
     * false otherwise.
175
     *
176
     * This function returns true if the time elapsed is equal to or exceeds
177
     * the timeout value.  Differs from IsExpired() only in the boundary 
178
     * condition delta == timeout.
179
     * \see IsExpired
180
     */
181
    bool IsExpiring (void) const;
166
182
167
    /**
183
    /**
168
     * \returns 0 is no packet is pending, the next packet to send if 
184
     * \returns 0 is no packet is pending, the next packet to send if 
 Lines 191-196   public: Link Here 
191
    };
207
    };
192
208
193
    void UpdateSeen (void);
209
    void UpdateSeen (void);
210
    Time GetTimeout (void) const;
194
    ArpCache *m_arp;
211
    ArpCache *m_arp;
195
    ArpCacheEntryState_e m_state;
212
    ArpCacheEntryState_e m_state;
196
    Time m_lastSeen;
213
    Time m_lastSeen;

Return to bug 451