A helper class to populate neighbor cache. More...
#include "neighbor-cache-helper.h"
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 | |
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.
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.
ns3::NeighborCacheHelper::~NeighborCacheHelper | ( | ) |
Definition at line 31 of file neighbor-cache-helper.cc.
References NS_LOG_FUNCTION.
|
private |
Add an auto_generated entry to the ARP cache of an interface.
netDeviceInterface | the Ipv4Interface that ARP cache belongs to |
ipv4Address | the IPv4 address will be added to the cache. |
macAddress | the 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().
|
private |
Add an auto_generated entry to the NDISC cache of an interface.
netDeviceInterface | the Ipv6Interface that NDISC cache belongs to |
ipv6Address | the IPv6 address will be added to the cache. |
macAddress | the 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().
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().
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().
void ns3::NeighborCacheHelper::PopulateNeighborCache | ( | const Ipv4InterfaceContainer & | c | ) | const |
Populate neighbor ARP caches for all IPv4 interfaces in the given Ipv4InterfaceContainer.
c | the 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().
void ns3::NeighborCacheHelper::PopulateNeighborCache | ( | const Ipv6InterfaceContainer & | c | ) | const |
Populate neighbor NDISC caches for all IPv6 interfaces in the given Ipv6InterfaceContainer.
c | the 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().
void ns3::NeighborCacheHelper::PopulateNeighborCache | ( | const NetDeviceContainer & | c | ) | const |
Populate neighbor ARP and NDISC caches for all devices in the given NetDeviceContainer.
c | the 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().
Populate neighbor ARP and NDISC caches for all devices in the given Channel.
channel | the Channel to process |
Definition at line 49 of file neighbor-cache-helper.cc.
References NS_LOG_FUNCTION, PopulateNeighborEntriesIpv4(), and PopulateNeighborEntriesIpv6().
|
private |
Populate neighbor ARP entries for given IPv4 interface.
ipv4Interface | the Ipv4Interface to process |
neighborDeviceInterface | the 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().
|
private |
Populate neighbor NDISC entries for given IPv6 interface.
ipv6Interface | the Ipv6Interface to process |
neighborDeviceInterface | the 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().
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.
enable | enable 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().
|
private |
Update neighbor caches when an address is added to a Ipv4Interface with auto generated neighbor cache.
interface | the Ipv4Interface that address added to. |
ifAddr | the 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().
|
private |
Update neighbor caches when an address is removed from a Ipv4Interface with auto generated neighbor cache.
interface | the Ipv4Interface that address removed from. |
ifAddr | the 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().
|
private |
Update neighbor cache when an address is added to a Ipv6Interface with auto generated neighbor cache.
interface | the Ipv6Interface that address added to. |
ifAddr | the 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().
|
private |
Update neighbor caches when an address is removed from a Ipv6Interface with auto generated neighbor cache.
interface | the Ipv6Interface that address removed from. |
ifAddr | the 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().
|
private |
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().
|
private |
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().