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

(-)a/src/internet-stack/arp-cache.cc (-22 / +38 lines)
 Lines 190-196    Link Here 
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
            {
 Lines 367-396    Link Here 
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
    } 
 Lines 417-429    Link Here 
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
(-)a/src/internet-stack/arp-cache.h (+6 lines)
 Lines 163-168    Link Here 
163
     * \return True if this entry has timedout; false otherwise.
163
     * \return True if this entry has timedout; false otherwise.
164
     */
164
     */
165
    bool IsExpired (void);
165
    bool IsExpired (void);
166
    /**
167
     * \return True if this entry has nearly timedout; false otherwise.
168
     */
169
    bool IsNearlyExpired (void);
166
170
167
    /**
171
    /**
168
     * \returns 0 is no packet is pending, the next packet to send if 
172
     * \returns 0 is no packet is pending, the next packet to send if 
 Lines 184-189    Link Here 
184
    void ClearRetries (void);
188
    void ClearRetries (void);
185
189
186
  private:
190
  private:
191
    Time GetTimeout (void) const;
192
187
    enum ArpCacheEntryState_e {
193
    enum ArpCacheEntryState_e {
188
      ALIVE,
194
      ALIVE,
189
      WAIT_REPLY,
195
      WAIT_REPLY,

Return to bug 451