A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
neighbor-cache-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 ZHIHENG DONG
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Zhiheng Dong <dzh2077@gmail.com>
7 */
8
10
11#include "ns3/assert.h"
12#include "ns3/channel-list.h"
13#include "ns3/ipv4.h"
14#include "ns3/ipv6.h"
15#include "ns3/log.h"
16#include "ns3/net-device.h"
17#include "ns3/node.h"
18#include "ns3/ptr.h"
19#include "ns3/simulator.h"
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("NeighborCacheHelper");
25
30
35
36void
47
48void
50{
51 NS_LOG_FUNCTION(this << channel);
52 for (std::size_t i = 0; i < channel->GetNDevices(); ++i)
53 {
54 Ptr<NetDevice> netDevice = channel->GetDevice(i);
55 Ptr<Node> node = netDevice->GetNode();
56
57 int32_t ipv4InterfaceIndex = -1;
58 if (node->GetObject<Ipv4>())
59 {
60 ipv4InterfaceIndex = node->GetObject<Ipv4>()->GetInterfaceForDevice(netDevice);
61 }
62 int32_t ipv6InterfaceIndex = -1;
63 if (node->GetObject<Ipv6>())
64 {
65 ipv6InterfaceIndex = node->GetObject<Ipv6>()->GetInterfaceForDevice(netDevice);
66 }
67
68 for (std::size_t j = 0; j < channel->GetNDevices(); ++j)
69 {
70 Ptr<NetDevice> neighborDevice = channel->GetDevice(j);
71 Ptr<Node> neighborNode = neighborDevice->GetNode();
72
73 int32_t ipv4NeighborInterfaceIndex = -1;
74 if (neighborNode->GetObject<Ipv4>())
75 {
76 ipv4NeighborInterfaceIndex =
77 neighborNode->GetObject<Ipv4>()->GetInterfaceForDevice(neighborDevice);
78 }
79 int32_t ipv6NeighborInterfaceIndex = -1;
80 if (neighborNode->GetObject<Ipv6>())
81 {
82 ipv6NeighborInterfaceIndex =
83 neighborNode->GetObject<Ipv6>()->GetInterfaceForDevice(neighborDevice);
84 }
85
86 if (neighborDevice != netDevice)
87 {
88 if (ipv4InterfaceIndex != -1)
89 {
90 Ptr<Ipv4Interface> ipv4Interface =
91 node->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4InterfaceIndex);
92 if (ipv4NeighborInterfaceIndex != -1)
93 {
94 Ptr<Ipv4Interface> ipv4NeighborInterface =
95 neighborNode->GetObject<Ipv4L3Protocol>()->GetInterface(
96 ipv4NeighborInterfaceIndex);
97 PopulateNeighborEntriesIpv4(ipv4Interface, ipv4NeighborInterface);
98 }
99 }
100 if (ipv6InterfaceIndex != -1)
101 {
102 Ptr<Ipv6Interface> ipv6Interface =
103 node->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6InterfaceIndex);
104 if (ipv6NeighborInterfaceIndex != -1)
105 {
106 Ptr<Ipv6Interface> ipv6NeighborInterface =
107 neighborNode->GetObject<Ipv6L3Protocol>()->GetInterface(
108 ipv6NeighborInterfaceIndex);
109 PopulateNeighborEntriesIpv6(ipv6Interface, ipv6NeighborInterface);
110 }
111 }
112 }
113 }
114 }
115}
116
117void
119{
120 NS_LOG_FUNCTION(this);
121 for (uint32_t i = 0; i < c.GetN(); ++i)
122 {
123 Ptr<NetDevice> netDevice = c.Get(i);
124 Ptr<Channel> channel = netDevice->GetChannel();
125 Ptr<Node> node = netDevice->GetNode();
126
127 int32_t ipv4InterfaceIndex = -1;
128 if (node->GetObject<Ipv4>())
129 {
130 ipv4InterfaceIndex = node->GetObject<Ipv4>()->GetInterfaceForDevice(netDevice);
131 }
132 int32_t ipv6InterfaceIndex = -1;
133 if (node->GetObject<Ipv6>())
134 {
135 ipv6InterfaceIndex = node->GetObject<Ipv6>()->GetInterfaceForDevice(netDevice);
136 }
137
138 for (std::size_t j = 0; j < channel->GetNDevices(); ++j)
139 {
140 Ptr<NetDevice> neighborDevice = channel->GetDevice(j);
141 Ptr<Node> neighborNode = neighborDevice->GetNode();
142
143 int32_t ipv4NeighborInterfaceIndex = -1;
144 if (neighborNode->GetObject<Ipv4>())
145 {
146 ipv4NeighborInterfaceIndex =
147 neighborNode->GetObject<Ipv4>()->GetInterfaceForDevice(neighborDevice);
148 }
149 int32_t ipv6NeighborInterfaceIndex = -1;
150 if (neighborNode->GetObject<Ipv6>())
151 {
152 ipv6NeighborInterfaceIndex =
153 neighborNode->GetObject<Ipv6>()->GetInterfaceForDevice(neighborDevice);
154 }
155
156 if (neighborDevice != netDevice)
157 {
158 if (ipv4InterfaceIndex != -1)
159 {
160 Ptr<Ipv4Interface> ipv4Interface =
161 node->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4InterfaceIndex);
162 if (ipv4NeighborInterfaceIndex != -1)
163 {
164 Ptr<Ipv4Interface> ipv4NeighborInterface =
165 neighborNode->GetObject<Ipv4L3Protocol>()->GetInterface(
166 ipv4NeighborInterfaceIndex);
167 PopulateNeighborEntriesIpv4(ipv4Interface, ipv4NeighborInterface);
168 }
169 }
170 if (ipv6InterfaceIndex != -1)
171 {
172 Ptr<Ipv6Interface> ipv6Interface =
173 node->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6InterfaceIndex);
174 if (ipv6NeighborInterfaceIndex != -1)
175 {
176 Ptr<Ipv6Interface> ipv6NeighborInterface =
177 neighborNode->GetObject<Ipv6L3Protocol>()->GetInterface(
178 ipv6NeighborInterfaceIndex);
179 PopulateNeighborEntriesIpv6(ipv6Interface, ipv6NeighborInterface);
180 }
181 }
182 }
183 }
184 }
185}
186
187void
189{
190 NS_LOG_FUNCTION(this);
191 for (uint32_t i = 0; i < c.GetN(); ++i)
192 {
193 std::pair<Ptr<Ipv4>, uint32_t> returnValue = c.Get(i);
194 Ptr<Ipv4> ipv4 = returnValue.first;
195 uint32_t index = returnValue.second;
196 Ptr<Ipv4Interface> ipv4Interface = DynamicCast<Ipv4L3Protocol>(ipv4)->GetInterface(index);
197 if (ipv4Interface)
198 {
199 Ptr<NetDevice> netDevice = ipv4Interface->GetDevice();
200 Ptr<Channel> channel = netDevice->GetChannel();
201 for (std::size_t j = 0; j < channel->GetNDevices(); ++j)
202 {
203 Ptr<NetDevice> neighborDevice = channel->GetDevice(j);
204 if (neighborDevice != netDevice)
205 {
206 Ptr<Node> neighborNode = neighborDevice->GetNode();
207 int32_t ipv4NeighborInterfaceIndex =
208 neighborNode->GetObject<Ipv4>()->GetInterfaceForDevice(neighborDevice);
209 if (ipv4NeighborInterfaceIndex != -1)
210 {
211 Ptr<Ipv4Interface> ipv4NeighborInterface =
212 neighborNode->GetObject<Ipv4L3Protocol>()->GetInterface(
213 ipv4NeighborInterfaceIndex);
214 PopulateNeighborEntriesIpv4(ipv4Interface, ipv4NeighborInterface);
215 }
216 }
217 }
218 }
219 }
220}
221
222void
224{
225 NS_LOG_FUNCTION(this);
226 for (uint32_t i = 0; i < c.GetN(); ++i)
227 {
228 std::pair<Ptr<Ipv6>, uint32_t> returnValue = c.Get(i);
229 Ptr<Ipv6> ipv6 = returnValue.first;
230 uint32_t index = returnValue.second;
231 Ptr<Ipv6Interface> ipv6Interface = DynamicCast<Ipv6L3Protocol>(ipv6)->GetInterface(index);
232 if (ipv6Interface)
233 {
234 Ptr<NetDevice> netDevice = ipv6Interface->GetDevice();
235 Ptr<Channel> channel = netDevice->GetChannel();
236 for (std::size_t j = 0; j < channel->GetNDevices(); ++j)
237 {
238 Ptr<NetDevice> neighborDevice = channel->GetDevice(j);
239 if (neighborDevice != netDevice)
240 {
241 Ptr<Node> neighborNode = neighborDevice->GetNode();
242 int32_t ipv6NeighborInterfaceIndex =
243 neighborNode->GetObject<Ipv6>()->GetInterfaceForDevice(neighborDevice);
244 if (ipv6NeighborInterfaceIndex != -1)
245 {
246 Ptr<Ipv6Interface> ipv6NeighborInterface =
247 neighborNode->GetObject<Ipv6L3Protocol>()->GetInterface(
248 ipv6NeighborInterfaceIndex);
249 PopulateNeighborEntriesIpv6(ipv6Interface, ipv6NeighborInterface);
250 }
251 }
252 }
253 }
254 }
255}
256
257void
259 Ptr<Ipv4Interface> neighborDeviceInterface) const
260{
261 uint32_t netDeviceAddresses = ipv4Interface->GetNAddresses();
262 uint32_t neighborDeviceAddresses = neighborDeviceInterface->GetNAddresses();
264 {
265 ipv4Interface->RemoveAddressCallback(
268 {
269 ipv4Interface->AddAddressCallback(
271 }
272 }
273 for (uint32_t n = 0; n < netDeviceAddresses; ++n)
274 {
275 Ipv4InterfaceAddress netDeviceIfAddr = ipv4Interface->GetAddress(n);
276 for (uint32_t m = 0; m < neighborDeviceAddresses; ++m)
277 {
278 Ipv4InterfaceAddress neighborDeviceIfAddr = neighborDeviceInterface->GetAddress(m);
279 if (netDeviceIfAddr.IsInSameSubnet(neighborDeviceIfAddr.GetLocal()))
280 {
281 Ptr<NetDevice> neighborDevice = neighborDeviceInterface->GetDevice();
282 // Add Arp entry of neighbor interface to current interface's Arp cache
283 AddEntry(ipv4Interface,
284 neighborDeviceIfAddr.GetAddress(),
285 neighborDevice->GetAddress());
286 }
287 }
288 }
289}
290
291void
293 Ptr<Ipv6Interface> neighborDeviceInterface) const
294{
295 uint32_t netDeviceAddresses = ipv6Interface->GetNAddresses();
296 uint32_t neighborDeviceAddresses = neighborDeviceInterface->GetNAddresses();
298 {
299 ipv6Interface->RemoveAddressCallback(
302 {
303 ipv6Interface->AddAddressCallback(
305 }
306 }
307 for (uint32_t n = 0; n < netDeviceAddresses; ++n)
308 {
309 Ipv6InterfaceAddress netDeviceIfAddr = ipv6Interface->GetAddress(n);
310 // Ignore if it is a linklocal address, which will be added along with the global address
311 if (netDeviceIfAddr.GetScope() == Ipv6InterfaceAddress::LINKLOCAL ||
312 netDeviceIfAddr.GetScope() == Ipv6InterfaceAddress::HOST)
313 {
314 NS_LOG_LOGIC("Skip the LINKLOCAL or LOCALHOST interface " << netDeviceIfAddr);
315 continue;
316 }
317 for (uint32_t m = 0; m < neighborDeviceAddresses; ++m)
318 {
319 // Ignore if it is a linklocal address, which will be added along with the global
320 // address
321 Ipv6InterfaceAddress neighborDeviceIfAddr = neighborDeviceInterface->GetAddress(m);
322 if (neighborDeviceIfAddr.GetScope() == Ipv6InterfaceAddress::LINKLOCAL ||
323 neighborDeviceIfAddr.GetScope() == Ipv6InterfaceAddress::HOST)
324 {
325 NS_LOG_LOGIC("Skip the LINKLOCAL or LOCALHOST interface " << neighborDeviceIfAddr);
326 continue;
327 }
328 if (netDeviceIfAddr.IsInSameSubnet(neighborDeviceIfAddr.GetAddress()))
329 {
330 Ptr<NetDevice> neighborDevice = neighborDeviceInterface->GetDevice();
331 // Add neighbor's Ndisc entries of global address and linklocal address to current
332 // interface's Ndisc cache
333 AddEntry(ipv6Interface,
334 neighborDeviceIfAddr.GetAddress(),
335 neighborDevice->GetAddress());
336 Ipv6InterfaceAddress neighborlinkLocalAddr =
337 neighborDeviceInterface->GetLinkLocalAddress();
338 AddEntry(ipv6Interface,
339 neighborlinkLocalAddr.GetAddress(),
340 neighborDevice->GetAddress());
341 }
342 }
343 }
344}
345
346void
348 Ipv4Address ipv4Address,
349 Address macAddress) const
350{
351 NS_LOG_FUNCTION(this << netDeviceInterface << ipv4Address << macAddress);
352 Ptr<ArpCache> arpCache = netDeviceInterface->GetArpCache();
353 if (!arpCache)
354 {
356 "ArpCache doesn't exist, might be a point-to-point NetDevice without ArpCache");
357 return;
358 }
359 ArpCache::Entry* entry = arpCache->Lookup(ipv4Address);
360 if (!entry)
361 {
362 NS_LOG_FUNCTION("ADD an ARP entry");
363 entry = arpCache->Add(ipv4Address);
364 }
365 entry->SetMacAddress(macAddress);
366 entry->MarkAutoGenerated();
367}
368
369void
371 Ipv6Address ipv6Address,
372 Address macAddress) const
373{
374 NS_LOG_FUNCTION(this << netDeviceInterface << ipv6Address << macAddress);
375 Ptr<NdiscCache> ndiscCache = netDeviceInterface->GetNdiscCache();
376 if (!ndiscCache)
377 {
379 "NdiscCache doesn't exist, might be a point-to-point NetDevice without NdiscCache");
380 return;
381 }
382 NdiscCache::Entry* entry = ndiscCache->Lookup(ipv6Address);
383 if (!entry)
384 {
385 NS_LOG_FUNCTION("ADD a NDISC entry");
386 entry = ndiscCache->Add(ipv6Address);
387 }
388 entry->SetMacAddress(macAddress);
389 entry->MarkAutoGenerated();
390}
391
392void
394{
395 NS_LOG_FUNCTION(this);
396 for (uint32_t i = 0; i < NodeList::GetNNodes(); ++i)
397 {
399 for (uint32_t j = 0; j < node->GetNDevices(); ++j)
400 {
401 Ptr<NetDevice> netDevice = node->GetDevice(j);
402 int32_t ipv4InterfaceIndex = node->GetObject<Ipv4>()->GetInterfaceForDevice(netDevice);
403 int32_t ipv6InterfaceIndex = node->GetObject<Ipv6>()->GetInterfaceForDevice(netDevice);
404 if (ipv4InterfaceIndex != -1)
405 {
406 Ptr<Ipv4Interface> ipv4Interface =
407 node->GetObject<Ipv4L3Protocol>()->GetInterface(ipv4InterfaceIndex);
408 Ptr<ArpCache> arpCache = ipv4Interface->GetArpCache();
409 if (arpCache)
410 {
411 NS_LOG_FUNCTION("Remove an ARP entry");
412 arpCache->RemoveAutoGeneratedEntries();
413 }
414 }
415 if (ipv6InterfaceIndex != -1)
416 {
417 Ptr<Ipv6Interface> ipv6Interface =
418 node->GetObject<Ipv6L3Protocol>()->GetInterface(ipv6InterfaceIndex);
419 Ptr<NdiscCache> ndiscCache = ipv6Interface->GetNdiscCache();
420 if (ndiscCache)
421 {
422 NS_LOG_FUNCTION("Remove a NDISC entry");
423 ndiscCache->RemoveAutoGeneratedEntries();
424 }
425 }
426 }
427 }
428}
429
430void
432 const Ipv4InterfaceAddress ifAddr) const
433{
434 NS_LOG_FUNCTION(this);
435 Ptr<NetDevice> netDevice = interface->GetDevice();
436 Ptr<Channel> channel = netDevice->GetChannel();
437 for (std::size_t i = 0; i < channel->GetNDevices(); ++i)
438 {
439 Ptr<NetDevice> neighborDevice = channel->GetDevice(i);
440 Ptr<Node> neighborNode = neighborDevice->GetNode();
441 int32_t neighborInterfaceIndex =
442 neighborNode->GetObject<Ipv4>()->GetInterfaceForDevice(neighborDevice);
443 if (neighborInterfaceIndex != -1)
444 {
445 Ptr<Ipv4Interface> neighborInterface =
446 neighborNode->GetObject<Ipv4L3Protocol>()->GetInterface(neighborInterfaceIndex);
447 Ptr<ArpCache> arpCache = neighborInterface->GetArpCache();
448 if (!arpCache)
449 {
450 NS_LOG_LOGIC("ArpCache doesn't exist");
451 return;
452 }
453 ArpCache::Entry* entry = arpCache->Lookup(ifAddr.GetLocal());
454 if (entry)
455 {
456 arpCache->Remove(entry);
457 }
458 }
459 }
460}
461
462void
464 const Ipv4InterfaceAddress ifAddr) const
465{
466 NS_LOG_FUNCTION(this);
467 Ptr<NetDevice> netDevice = interface->GetDevice();
468 Ptr<Channel> channel = netDevice->GetChannel();
469 for (std::size_t i = 0; i < channel->GetNDevices(); ++i)
470 {
471 Ptr<NetDevice> neighborDevice = channel->GetDevice(i);
472 if (neighborDevice != netDevice)
473 {
474 Ptr<Node> neighborNode = neighborDevice->GetNode();
475 int32_t neighborInterfaceIndex =
476 neighborNode->GetObject<Ipv4>()->GetInterfaceForDevice(neighborDevice);
477 if (neighborInterfaceIndex != -1)
478 {
479 Ptr<Ipv4Interface> neighborInterface =
480 neighborNode->GetObject<Ipv4L3Protocol>()->GetInterface(neighborInterfaceIndex);
481 uint32_t neighborDeviceAddresses = neighborInterface->GetNAddresses();
482 for (uint32_t m = 0; m < neighborDeviceAddresses; ++m)
483 {
484 Ipv4InterfaceAddress neighborDeviceIfAddr = neighborInterface->GetAddress(m);
485 if (ifAddr.IsInSameSubnet(neighborDeviceIfAddr.GetLocal()))
486 {
487 // Add Arp entity of current interface to its neighbor's Arp cache
488 AddEntry(neighborInterface, ifAddr.GetAddress(), netDevice->GetAddress());
489 }
490 }
491 }
492 }
493 }
494}
495
496void
498 const Ipv6InterfaceAddress ifAddr) const
499{
500 NS_LOG_FUNCTION(this);
501 Ptr<NetDevice> netDevice = interface->GetDevice();
502 Ptr<Channel> channel = netDevice->GetChannel();
503 for (std::size_t i = 0; i < channel->GetNDevices(); ++i)
504 {
505 Ptr<NetDevice> neighborDevice = channel->GetDevice(i);
506 Ptr<Node> neighborNode = neighborDevice->GetNode();
507 int32_t neighborInterfaceIndex =
508 neighborNode->GetObject<Ipv6>()->GetInterfaceForDevice(neighborDevice);
509 if (neighborInterfaceIndex != -1)
510 {
511 Ptr<Ipv6Interface> neighborInterface =
512 neighborNode->GetObject<Ipv6L3Protocol>()->GetInterface(neighborInterfaceIndex);
513 Ptr<NdiscCache> ndiscCache = neighborInterface->GetNdiscCache();
514 if (!ndiscCache)
515 {
516 NS_LOG_LOGIC("ndiscCache doesn't exist");
517 return;
518 }
519 NdiscCache::Entry* entry = ndiscCache->Lookup(ifAddr.GetAddress());
520 if (entry)
521 {
522 ndiscCache->Remove(entry);
523 }
524 }
525 }
526}
527
528void
530 const Ipv6InterfaceAddress ifAddr) const
531{
532 NS_LOG_FUNCTION(this);
533 Ptr<NetDevice> netDevice = interface->GetDevice();
534 Ptr<Channel> channel = netDevice->GetChannel();
535 for (std::size_t i = 0; i < channel->GetNDevices(); ++i)
536 {
537 Ptr<NetDevice> neighborDevice = channel->GetDevice(i);
538 if (neighborDevice != netDevice)
539 {
540 Ptr<Node> neighborNode = neighborDevice->GetNode();
541 int32_t neighborInterfaceIndex =
542 neighborNode->GetObject<Ipv6>()->GetInterfaceForDevice(neighborDevice);
543 if (neighborInterfaceIndex != -1)
544 {
545 Ptr<Ipv6Interface> neighborInterface =
546 neighborNode->GetObject<Ipv6L3Protocol>()->GetInterface(neighborInterfaceIndex);
547 uint32_t neighborDeviceAddresses = neighborInterface->GetNAddresses();
548 for (uint32_t m = 0; m < neighborDeviceAddresses; ++m)
549 {
550 Ipv6InterfaceAddress neighborDeviceIfAddr = neighborInterface->GetAddress(m);
551 if (ifAddr.IsInSameSubnet(neighborDeviceIfAddr.GetAddress()))
552 {
553 // Add Arp entity of current interface to its neighbor's Arp cache
554 AddEntry(neighborInterface, ifAddr.GetAddress(), netDevice->GetAddress());
555 }
556 }
557 }
558 }
559 }
560}
561
562void
568
569} // namespace ns3
a polymophic address class
Definition address.h:90
A record that that holds information about an ArpCache entry.
Definition arp-cache.h:173
void MarkAutoGenerated()
Changes the state of this entry to auto-generated.
Definition arp-cache.cc:446
void SetMacAddress(Address macAddress)
Definition arp-cache.cc:495
static Ptr< Channel > GetChannel(uint32_t n)
static uint32_t GetNChannels()
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
a class to store IPv4 address information on an interface
bool IsInSameSubnet(const Ipv4Address b) const
Checks if the address is in the same subnet.
Ipv4Address GetAddress() const
Get the local address.
Ipv4Address GetLocal() const
Get the local address.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
Implement the IPv4 layer.
Describes an IPv6 address.
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition ipv6.h:71
IPv6 address associated with an interface.
Ipv6Address GetAddress() const
Get the IPv6 address.
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
bool IsInSameSubnet(Ipv6Address b) const
Checks if the address is in the same subnet.
@ LINKLOCAL
Link-local address (fe80::/64)
Keep track of a set of IPv6 interfaces.
std::pair< Ptr< Ipv6 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
IPv6 layer implementation.
A record that holds information about a NdiscCache entry.
void MarkAutoGenerated()
Changes the state of this entry to auto-generated.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
bool m_globalNeighborCache
flag will set true if neighbor caches were generated for all devices
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 AddEntry(Ptr< Ipv4Interface > netDeviceInterface, Ipv4Address ipv4Address, Address macAddress) const
Add an auto_generated entry to the ARP cache of an interface.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
bool m_dynamicNeighborCache
flag will set true if dynamic neighbor cache is enabled.
NeighborCacheHelper()
Construct a helper class to make life easier while creating neighbor cache.
void PopulateNeighborEntriesIpv4(Ptr< Ipv4Interface > ipv4Interface, Ptr< Ipv4Interface > neighborDeviceInterface) const
Populate neighbor ARP entries for given IPv4 interface.
void SetDynamicNeighborCache(bool enable)
Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chan...
void PopulateNeighborEntriesIpv6(Ptr< Ipv6Interface > ipv6Interface, Ptr< Ipv6Interface > neighborDeviceInterface) const
Populate neighbor NDISC entries for given IPv6 interface.
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 c...
void FlushAutoGenerated() const
Remove entries generated from NeighborCacheHelper from ARP cache and NDISC cache.
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 c...
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static uint32_t GetNNodes()
Definition node-list.cc:247
static Ptr< Node > GetNode(uint32_t n)
Definition node-list.cc:240
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580