A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::NeighborCacheHelper Class Reference

A helper class to populate neighbor cache. More...

#include "neighbor-cache-helper.h"

+ Collaboration diagram for ns3::NeighborCacheHelper:

Public Member Functions

 NeighborCacheHelper ()
 Construct a helper class to make life easier while creating neighbor cache.
 
 ~NeighborCacheHelper ()
 
void FlushAutoGenerated () const
 Remove entries generated from NeighborCacheHelper from ARP cache and NDISC cache.
 
void PopulateNeighborCache ()
 Populate neighbor ARP and NDISC caches for all devices.
 
void PopulateNeighborCache (const Ipv4InterfaceContainer &c) const
 Populate neighbor ARP caches for all IPv4 interfaces in the given Ipv4InterfaceContainer.
 
void PopulateNeighborCache (const Ipv6InterfaceContainer &c) const
 Populate neighbor NDISC caches for all IPv6 interfaces in the given Ipv6InterfaceContainer.
 
void PopulateNeighborCache (const NetDeviceContainer &c) const
 Populate neighbor ARP and NDISC caches for all devices in the given NetDeviceContainer.
 
void PopulateNeighborCache (Ptr< Channel > channel) const
 Populate neighbor ARP and NDISC caches for all devices in the given Channel.
 
void SetDynamicNeighborCache (bool enable)
 Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses changed when dynamic neighbor cache enabled.
 

Private Member Functions

void AddEntry (Ptr< Ipv4Interface > netDeviceInterface, Ipv4Address ipv4Address, Address macAddress) const
 Add an auto_generated entry to the ARP cache of an interface.
 
void AddEntry (Ptr< Ipv6Interface > netDeviceInterface, Ipv6Address ipv6Address, Address macAddress) const
 Add an auto_generated entry to the NDISC cache of an interface.
 
void PopulateNeighborEntriesIpv4 (Ptr< Ipv4Interface > ipv4Interface, Ptr< Ipv4Interface > neighborDeviceInterface) const
 Populate neighbor ARP entries for given IPv4 interface.
 
void PopulateNeighborEntriesIpv6 (Ptr< Ipv6Interface > ipv6Interface, Ptr< Ipv6Interface > neighborDeviceInterface) const
 Populate neighbor NDISC entries for given IPv6 interface.
 
void UpdateCacheByIpv4AddressAdded (const Ptr< Ipv4Interface > interface, const Ipv4InterfaceAddress ifAddr) const
 Update neighbor caches when an address is added to a Ipv4Interface with auto generated neighbor cache.
 
void UpdateCacheByIpv4AddressRemoved (const Ptr< Ipv4Interface > interface, const Ipv4InterfaceAddress ifAddr) const
 Update neighbor caches when an address is removed from a Ipv4Interface with auto generated neighbor cache.
 
void UpdateCacheByIpv6AddressAdded (const Ptr< Ipv6Interface > interface, const Ipv6InterfaceAddress ifAddr) const
 Update neighbor cache when an address is added to a Ipv6Interface with auto generated neighbor cache.
 
void UpdateCacheByIpv6AddressRemoved (const Ptr< Ipv6Interface > interface, const Ipv6InterfaceAddress ifAddr) const
 Update neighbor caches when an address is removed from a Ipv6Interface with auto generated neighbor cache.
 

Private Attributes

bool m_dynamicNeighborCache
 flag will set true if dynamic neighbor cache is enabled.
 
bool m_globalNeighborCache
 flag will set true if neighbor caches were generated for all devices
 

Detailed Description

A helper class to populate neighbor cache.

This class is used to populate neighbor cache. Permanent entries will be added on the scope of a channel, a NetDeviceContainer, an InterfaceContainer or globally.

Definition at line 39 of file neighbor-cache-helper.h.

Constructor & Destructor Documentation

◆ NeighborCacheHelper()

ns3::NeighborCacheHelper::NeighborCacheHelper ( )

Construct a helper class to make life easier while creating neighbor cache.

Definition at line 26 of file neighbor-cache-helper.cc.

References NS_LOG_FUNCTION.

◆ ~NeighborCacheHelper()

ns3::NeighborCacheHelper::~NeighborCacheHelper ( )

Definition at line 31 of file neighbor-cache-helper.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddEntry() [1/2]

void ns3::NeighborCacheHelper::AddEntry ( Ptr< Ipv4Interface > netDeviceInterface,
Ipv4Address ipv4Address,
Address macAddress ) const
private

Add an auto_generated entry to the ARP cache of an interface.

Parameters
netDeviceInterfacethe Ipv4Interface that ARP cache belongs to
ipv4Addressthe IPv4 address will be added to the cache.
macAddressthe MAC address will be added to the cache.

Definition at line 347 of file neighbor-cache-helper.cc.

References ns3::ArpCache::Entry::MarkAutoGenerated(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::ArpCache::Entry::SetMacAddress().

Referenced by PopulateNeighborEntriesIpv4(), PopulateNeighborEntriesIpv6(), UpdateCacheByIpv4AddressAdded(), and UpdateCacheByIpv6AddressAdded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddEntry() [2/2]

void ns3::NeighborCacheHelper::AddEntry ( Ptr< Ipv6Interface > netDeviceInterface,
Ipv6Address ipv6Address,
Address macAddress ) const
private

Add an auto_generated entry to the NDISC cache of an interface.

Parameters
netDeviceInterfacethe Ipv6Interface that NDISC cache belongs to
ipv6Addressthe IPv6 address will be added to the cache.
macAddressthe MAC address will be added to the cache.

Definition at line 370 of file neighbor-cache-helper.cc.

References ns3::NdiscCache::Entry::MarkAutoGenerated(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::NdiscCache::Entry::SetMacAddress().

+ Here is the call graph for this function:

◆ FlushAutoGenerated()

void ns3::NeighborCacheHelper::FlushAutoGenerated ( ) const

Remove entries generated from NeighborCacheHelper from ARP cache and NDISC cache.

Definition at line 393 of file neighbor-cache-helper.cc.

References ns3::NodeList::GetNNodes(), ns3::NodeList::GetNode(), and NS_LOG_FUNCTION.

Referenced by FlushTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PopulateNeighborCache() [1/5]

void ns3::NeighborCacheHelper::PopulateNeighborCache ( )

Populate neighbor ARP and NDISC caches for all devices.

This method walks the global ChannelList.

Definition at line 37 of file neighbor-cache-helper.cc.

References ns3::ChannelList::GetChannel(), ns3::ChannelList::GetNChannels(), m_globalNeighborCache, NS_LOG_FUNCTION, and PopulateNeighborCache().

Referenced by ChannelTest::DoRun(), DuplicateTest::DoRun(), DynamicNeighborCacheTest::DoRun(), DynamicPartialTest::DoRun(), FlushTest::DoRun(), InterfaceContainerTest::DoRun(), NetDeviceContainerTest::DoRun(), PingTestCase::DoRun(), PopulateNeighborCache(), PopulateNeighborCache(), and NeighborCacheExample::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PopulateNeighborCache() [2/5]

void ns3::NeighborCacheHelper::PopulateNeighborCache ( const Ipv4InterfaceContainer & c) const

Populate neighbor ARP caches for all IPv4 interfaces in the given Ipv4InterfaceContainer.

Parameters
cthe Ipv4InterfaceContainer to process

Definition at line 188 of file neighbor-cache-helper.cc.

References ns3::DynamicCast(), ns3::Ipv4InterfaceContainer::Get(), ns3::Ipv4InterfaceContainer::GetN(), NS_LOG_FUNCTION, and PopulateNeighborEntriesIpv4().

+ Here is the call graph for this function:

◆ PopulateNeighborCache() [3/5]

void ns3::NeighborCacheHelper::PopulateNeighborCache ( const Ipv6InterfaceContainer & c) const

Populate neighbor NDISC caches for all IPv6 interfaces in the given Ipv6InterfaceContainer.

Parameters
cthe Ipv6InterfaceContainer to process

Definition at line 223 of file neighbor-cache-helper.cc.

References ns3::DynamicCast(), ns3::Ipv6InterfaceContainer::Get(), ns3::Ipv6InterfaceContainer::GetN(), NS_LOG_FUNCTION, and PopulateNeighborEntriesIpv6().

+ Here is the call graph for this function:

◆ PopulateNeighborCache() [4/5]

void ns3::NeighborCacheHelper::PopulateNeighborCache ( const NetDeviceContainer & c) const

Populate neighbor ARP and NDISC caches for all devices in the given NetDeviceContainer.

Parameters
cthe NetDevice container to process

Definition at line 118 of file neighbor-cache-helper.cc.

References ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), NS_LOG_FUNCTION, PopulateNeighborEntriesIpv4(), and PopulateNeighborEntriesIpv6().

+ Here is the call graph for this function:

◆ PopulateNeighborCache() [5/5]

void ns3::NeighborCacheHelper::PopulateNeighborCache ( Ptr< Channel > channel) const

Populate neighbor ARP and NDISC caches for all devices in the given Channel.

Parameters
channelthe Channel to process

Definition at line 49 of file neighbor-cache-helper.cc.

References NS_LOG_FUNCTION, PopulateNeighborEntriesIpv4(), and PopulateNeighborEntriesIpv6().

+ Here is the call graph for this function:

◆ PopulateNeighborEntriesIpv4()

void ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv4 ( Ptr< Ipv4Interface > ipv4Interface,
Ptr< Ipv4Interface > neighborDeviceInterface ) const
private

Populate neighbor ARP entries for given IPv4 interface.

Parameters
ipv4Interfacethe Ipv4Interface to process
neighborDeviceInterfacethe potential neighbor Ipv4Interface

Definition at line 258 of file neighbor-cache-helper.cc.

References AddEntry(), ns3::Ipv4InterfaceAddress::GetAddress(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4InterfaceAddress::IsInSameSubnet(), m_dynamicNeighborCache, m_globalNeighborCache, ns3::MakeCallback(), UpdateCacheByIpv4AddressAdded(), and UpdateCacheByIpv4AddressRemoved().

Referenced by PopulateNeighborCache(), PopulateNeighborCache(), and PopulateNeighborCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PopulateNeighborEntriesIpv6()

void ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv6 ( Ptr< Ipv6Interface > ipv6Interface,
Ptr< Ipv6Interface > neighborDeviceInterface ) const
private

Populate neighbor NDISC entries for given IPv6 interface.

Parameters
ipv6Interfacethe Ipv6Interface to process
neighborDeviceInterfacethe potential neighbor Ipv6Interface

Definition at line 292 of file neighbor-cache-helper.cc.

References AddEntry(), ns3::Ipv6InterfaceAddress::GetAddress(), ns3::Ipv6InterfaceAddress::GetScope(), ns3::Ipv6InterfaceAddress::HOST, ns3::Ipv6InterfaceAddress::IsInSameSubnet(), ns3::Ipv6InterfaceAddress::LINKLOCAL, m_dynamicNeighborCache, m_globalNeighborCache, ns3::MakeCallback(), NS_LOG_LOGIC, UpdateCacheByIpv6AddressAdded(), and UpdateCacheByIpv6AddressRemoved().

Referenced by PopulateNeighborCache(), PopulateNeighborCache(), and PopulateNeighborCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetDynamicNeighborCache()

void ns3::NeighborCacheHelper::SetDynamicNeighborCache ( bool enable)

Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses changed when dynamic neighbor cache enabled.

User should ensure that the NeighborCacheHelper object persists for the duration of the simulation when dynamic neighbor cache is enabled.

Parameters
enableenable state

Definition at line 563 of file neighbor-cache-helper.cc.

References m_dynamicNeighborCache, and NS_LOG_FUNCTION.

Referenced by DynamicNeighborCacheTest::DoRun(), and DynamicPartialTest::DoRun().

+ Here is the caller graph for this function:

◆ UpdateCacheByIpv4AddressAdded()

void ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded ( const Ptr< Ipv4Interface > interface,
const Ipv4InterfaceAddress ifAddr ) const
private

Update neighbor caches when an address is added to a Ipv4Interface with auto generated neighbor cache.

Parameters
interfacethe Ipv4Interface that address added to.
ifAddrthe added IPv4 interface address.

Definition at line 463 of file neighbor-cache-helper.cc.

References AddEntry(), ns3::Ipv4InterfaceAddress::GetAddress(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4InterfaceAddress::IsInSameSubnet(), and NS_LOG_FUNCTION.

Referenced by PopulateNeighborEntriesIpv4().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCacheByIpv4AddressRemoved()

void ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressRemoved ( const Ptr< Ipv4Interface > interface,
const Ipv4InterfaceAddress ifAddr ) const
private

Update neighbor caches when an address is removed from a Ipv4Interface with auto generated neighbor cache.

Parameters
interfacethe Ipv4Interface that address removed from.
ifAddrthe removed IPv4 interface address.

Definition at line 431 of file neighbor-cache-helper.cc.

References ns3::Ipv4InterfaceAddress::GetLocal(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by PopulateNeighborEntriesIpv4().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCacheByIpv6AddressAdded()

void ns3::NeighborCacheHelper::UpdateCacheByIpv6AddressAdded ( const Ptr< Ipv6Interface > interface,
const Ipv6InterfaceAddress ifAddr ) const
private

Update neighbor cache when an address is added to a Ipv6Interface with auto generated neighbor cache.

Parameters
interfacethe Ipv6Interface that address added to.
ifAddrthe added IPv6 interface address.

Definition at line 529 of file neighbor-cache-helper.cc.

References AddEntry(), ns3::Ipv6InterfaceAddress::GetAddress(), ns3::Ipv6InterfaceAddress::IsInSameSubnet(), and NS_LOG_FUNCTION.

Referenced by PopulateNeighborEntriesIpv6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCacheByIpv6AddressRemoved()

void ns3::NeighborCacheHelper::UpdateCacheByIpv6AddressRemoved ( const Ptr< Ipv6Interface > interface,
const Ipv6InterfaceAddress ifAddr ) const
private

Update neighbor caches when an address is removed from a Ipv6Interface with auto generated neighbor cache.

Parameters
interfacethe Ipv6Interface that address removed from.
ifAddrthe removed IPv6 interface address.

Definition at line 497 of file neighbor-cache-helper.cc.

References ns3::Ipv6InterfaceAddress::GetAddress(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by PopulateNeighborEntriesIpv6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_dynamicNeighborCache

bool ns3::NeighborCacheHelper::m_dynamicNeighborCache
private
Initial value:
{
false}

flag will set true if dynamic neighbor cache is enabled.

Definition at line 172 of file neighbor-cache-helper.h.

Referenced by PopulateNeighborEntriesIpv4(), PopulateNeighborEntriesIpv6(), and SetDynamicNeighborCache().

◆ m_globalNeighborCache

bool ns3::NeighborCacheHelper::m_globalNeighborCache
private
Initial value:
{
false}

flag will set true if neighbor caches were generated for all devices

Definition at line 169 of file neighbor-cache-helper.h.

Referenced by PopulateNeighborCache(), PopulateNeighborEntriesIpv4(), and PopulateNeighborEntriesIpv6().


The documentation for this class was generated from the following files: