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

(-)a/src/internet/model/arp-cache.cc (+18 lines)
 Lines 295-300    Link Here 
295
    }
295
    }
296
}
296
}
297
297
298
std::list<ArpCache::Entry *>
299
ArpCache::LookupInverse (Address to)
300
{
301
  NS_LOG_FUNCTION (this << to);
302
303
  std::list<ArpCache::Entry *> entryList;
304
  for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++)
305
    {
306
      ArpCache::Entry *entry = (*i).second;
307
      if (entry->GetMacAddress () == to)
308
        {
309
          entryList.push_back (entry);
310
        }
311
    }
312
  return entryList;
313
}
314
315
298
ArpCache::Entry *
316
ArpCache::Entry *
299
ArpCache::Lookup (Ipv4Address to)
317
ArpCache::Lookup (Ipv4Address to)
300
{
318
{
(-)a/src/internet/model/arp-cache.h (-5 / +12 lines)
 Lines 148-153    Link Here 
148
   */
148
   */
149
  ArpCache::Entry *Lookup (Ipv4Address destination);
149
  ArpCache::Entry *Lookup (Ipv4Address destination);
150
  /**
150
  /**
151
   * \brief Do lookup in the ARP cache against a MAC address
152
   * \param destination The destination MAC address to lookup
153
   * of
154
   * \return A std::list of ArpCache::Entry with info about layer 2
155
   */
156
  std::list<ArpCache::Entry *> LookupInverse (Address destination);
157
  /**
151
   * \brief Add an Ipv4Address to this ARP cache
158
   * \brief Add an Ipv4Address to this ARP cache
152
   */
159
   */
153
  ArpCache::Entry *Add (Ipv4Address to);
160
  ArpCache::Entry *Add (Ipv4Address to);
 Lines 269-274    Link Here 
269
     */
276
     */
270
    void ClearRetries (void);
277
    void ClearRetries (void);
271
278
279
    /**
280
     * \brief Update the entry when seeing a packet
281
     */
282
    void UpdateSeen (void);
283
272
private:
284
private:
273
    /**
285
    /**
274
     * \brief ARP cache entry states
286
     * \brief ARP cache entry states
 Lines 281-291    Link Here 
281
    };
293
    };
282
294
283
    /**
295
    /**
284
     * \brief Update the entry when seeing a packet
285
     */
286
    void UpdateSeen (void);
287
288
    /**
289
     * \brief Returns the entry timeout
296
     * \brief Returns the entry timeout
290
     * \returns the entry timeout
297
     * \returns the entry timeout
291
     */
298
     */
(-)a/src/internet/model/ipv4-l3-protocol.cc (+31 lines)
 Lines 36-41    Link Here 
36
36
37
#include "loopback-net-device.h"
37
#include "loopback-net-device.h"
38
#include "arp-l3-protocol.h"
38
#include "arp-l3-protocol.h"
39
#include "arp-cache.h"
39
#include "ipv4-l3-protocol.h"
40
#include "ipv4-l3-protocol.h"
40
#include "icmpv4-l4-protocol.h"
41
#include "icmpv4-l4-protocol.h"
41
#include "ipv4-interface.h"
42
#include "ipv4-interface.h"
 Lines 598-603    Link Here 
598
      return;
599
      return;
599
    }
600
    }
600
601
602
  // the packet is valid, we update the ARP cache entry (if present)
603
  Ptr<ArpCache> arpCache = ipv4Interface->GetArpCache ();
604
  if (arpCache)
605
    {
606
      // case one, it's a a direct routing.
607
      ArpCache::Entry *entry = arpCache->Lookup (ipHeader.GetSource ());
608
      if (entry)
609
        {
610
          if (entry->IsAlive ())
611
            {
612
              entry->UpdateSeen ();
613
            }
614
        }
615
      else
616
        {
617
          // It's not in the direct routing, so it's the router, and it could have multiple IP addresses.
618
          // In doubt, update all of them.
619
          // Note: it's a confirmed behavior for Linux routers.
620
          std::list<ArpCache::Entry *> entryList = arpCache->LookupInverse (from);
621
          std::list<ArpCache::Entry *>::iterator iter;
622
          for (iter = entryList.begin (); iter != entryList.end (); iter ++)
623
            {
624
              if ((*iter)->IsAlive ())
625
                {
626
                  (*iter)->UpdateSeen ();
627
                }
628
            }
629
        }
630
    }
631
601
  for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i)
632
  for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i)
602
    {
633
    {
603
      NS_LOG_LOGIC ("Forwarding to raw socket"); 
634
      NS_LOG_LOGIC ("Forwarding to raw socket"); 
(-)a/src/internet/model/ipv6-l3-protocol.cc (+26 lines)
 Lines 975-980    Link Here 
975
      packet->RemoveAtEnd (packet->GetSize () - hdr.GetPayloadLength ());
975
      packet->RemoveAtEnd (packet->GetSize () - hdr.GetPayloadLength ());
976
    }
976
    }
977
977
978
  // the packet is valid, we update the NDISC cache entry (if present)
979
  Ptr<NdiscCache> ndiscCache = ipv6Interface->GetNdiscCache ();
980
  if (ndiscCache)
981
    {
982
      // case one, it's a a direct routing.
983
      NdiscCache::Entry *entry = ndiscCache->Lookup (hdr.GetSourceAddress ());
984
      if (entry)
985
        {
986
          entry->UpdateReachableTimer ();
987
        }
988
      else
989
        {
990
          // It's not in the direct routing, so it's the router, and it could have multiple IP addresses.
991
          // In doubt, update all of them.
992
          // Note: it's a confirmed behavior for Linux routers.
993
          std::list<NdiscCache::Entry *> entryList = ndiscCache->LookupInverse (from);
994
          std::list<NdiscCache::Entry *>::iterator iter;
995
          for (iter = entryList.begin (); iter != entryList.end (); iter ++)
996
            {
997
              (*iter)->UpdateReachableTimer ();
998
            }
999
        }
1000
    }
1001
1002
1003
978
  /* forward up to IPv6 raw sockets */
1004
  /* forward up to IPv6 raw sockets */
979
  for (SocketList::iterator it = m_sockets.begin (); it != m_sockets.end (); ++it)
1005
  for (SocketList::iterator it = m_sockets.begin (); it != m_sockets.end (); ++it)
980
    {
1006
    {
(-)a/src/internet/model/ndisc-cache.cc (-5 / +33 lines)
 Lines 100-105    Link Here 
100
  return 0;
100
  return 0;
101
}
101
}
102
102
103
std::list<NdiscCache::Entry*> NdiscCache::LookupInverse (Address dst)
104
{
105
  NS_LOG_FUNCTION (this << dst);
106
107
  std::list<NdiscCache::Entry *> entryList;
108
  for (CacheI i = m_ndCache.begin (); i != m_ndCache.end (); i++)
109
    {
110
      NdiscCache::Entry *entry = (*i).second;
111
      if (entry->GetMacAddress () == dst)
112
        {
113
          entryList.push_back (entry);
114
        }
115
    }
116
  return entryList;
117
}
118
119
103
NdiscCache::Entry* NdiscCache::Add (Ipv6Address to)
120
NdiscCache::Entry* NdiscCache::Add (Ipv6Address to)
104
{
121
{
105
  NS_LOG_FUNCTION (this << to);
122
  NS_LOG_FUNCTION (this << to);
 Lines 397-407    Link Here 
397
  return m_lastReachabilityConfirmation;
414
  return m_lastReachabilityConfirmation;
398
}
415
}
399
416
400
void NdiscCache::Entry::UpdateLastReachabilityconfirmation ()
401
{
402
  NS_LOG_FUNCTION_NOARGS ();
403
}
404
405
void NdiscCache::Entry::StartReachableTimer ()
417
void NdiscCache::Entry::StartReachableTimer ()
406
{
418
{
407
  NS_LOG_FUNCTION_NOARGS ();
419
  NS_LOG_FUNCTION_NOARGS ();
 Lines 410-420    Link Here 
410
      m_nudTimer.Cancel ();
422
      m_nudTimer.Cancel ();
411
    }
423
    }
412
424
425
  m_lastReachabilityConfirmation = Simulator::Now ();
413
  m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this);
426
  m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this);
414
  m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::REACHABLE_TIME));
427
  m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::REACHABLE_TIME));
415
  m_nudTimer.Schedule ();
428
  m_nudTimer.Schedule ();
416
}
429
}
417
430
431
void NdiscCache::Entry::UpdateReachableTimer ()
432
{
433
  NS_LOG_FUNCTION_NOARGS ();
434
435
  if (m_state == REACHABLE)
436
    {
437
      m_lastReachabilityConfirmation = Simulator::Now ();
438
      if (m_nudTimer.IsRunning ())
439
        {
440
          m_nudTimer.Cancel ();
441
        }
442
      m_nudTimer.Schedule ();
443
    }
444
}
445
418
void NdiscCache::Entry::StartProbeTimer ()
446
void NdiscCache::Entry::StartProbeTimer ()
419
{
447
{
420
  NS_LOG_FUNCTION_NOARGS ();
448
  NS_LOG_FUNCTION_NOARGS ();
(-)a/src/internet/model/ndisc-cache.h (-7 / +14 lines)
 Lines 83-94    Link Here 
83
83
84
  /**
84
  /**
85
   * \brief Lookup in the cache.
85
   * \brief Lookup in the cache.
86
   * \param dst destination address
86
   * \param dst destination address.
87
   * \return the entry if found, 0 otherwise
87
   * \return the entry if found, 0 otherwise.
88
   */
88
   */
89
  NdiscCache::Entry* Lookup (Ipv6Address dst);
89
  NdiscCache::Entry* Lookup (Ipv6Address dst);
90
90
91
  /**
91
  /**
92
   * \brief Lookup in the cache for a MAC address.
93
   * \param dst destination MAC address.
94
   * \return a list of matching entries.
95
   */
96
  std::list<NdiscCache::Entry*> LookupInverse (Address dst);
97
98
  /**
92
   * \brief Add an entry.
99
   * \brief Add an entry.
93
   * \param to address to add
100
   * \param to address to add
94
   * \return an new Entry
101
   * \return an new Entry
 Lines 273-288    Link Here 
273
    Time GetLastReachabilityConfirmation () const;
280
    Time GetLastReachabilityConfirmation () const;
274
281
275
    /**
282
    /**
276
     * \brief Update the time of last reachability confirmation.
277
     */
278
    void UpdateLastReachabilityconfirmation ();
279
280
    /**
281
     * \brief Start the reachable timer.
283
     * \brief Start the reachable timer.
282
     */
284
     */
283
    void StartReachableTimer ();
285
    void StartReachableTimer ();
284
286
285
    /**
287
    /**
288
     * \brief Update the reachable timer.
289
     */
290
    void UpdateReachableTimer ();
291
292
    /**
286
     * \brief Start retransmit timer.
293
     * \brief Start retransmit timer.
287
     */
294
     */
288
    void StartRetransmitTimer ();
295
    void StartRetransmitTimer ();

Return to bug 2057