A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
neighbor-cache-example.cc File Reference

Generating neighbor caches in various scopes. More...

#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/network-module.h"
+ Include dependency graph for neighbor-cache-example.cc:

Go to the source code of this file.

Classes

class  NeighborCacheExample
 neighbor Cache example class. More...
 

Detailed Description

Generating neighbor caches in various scopes.

This example shows how to generate neighbor caches in various scopes.

This example shows how to generate neighbor caches on the scope of a channel, a NetDeviceContainer, an InterfaceContainer and globally. The example also shows a scenario that auto-generated neighbor caches can avoid dropping packets because of ARP message or Neighbor Discover message. If the user runs the example without any command line option, NeighborCacheHelper will generate neighbor cache for all devices and the output is their ARP table or NDISC table, the user can also generate neighbor cache on different scope by adding command line option –useChannel (on specific channel), –useNetDeviceContainer (on specific netDeviceContainer) and –useInterfaceContainer (on specific netDeviceContainer), –noGenerate (don't generate neighbor cache). The user can also enable –sendTraffic flag to send a data stream from n0 to n1, the output will be the information of received packets, which shows the packets loss are reduced after pre-generate neighbor caches.

IPv4 Network Topology

IPv4 Network Topology
    LAN 10.1.1.0/24
 n0 --------------- n1     n2     n3
                    |      |      |
                    ===============
                    LAN 10.1.2.0/24
IPv6 Network Topology
   LAN 2001:1::/64
n0 --------------- n1     n2     n3
                   |      |      |
                   ===============
                   LAN 2001:2::/64

Expected Outputs: IPv4 (default): Generate ARP caches for all devices (default) :

ARP Cache of node 0 at time 0
10.1.1.2 dev 0 lladdr 02-06-00:00:00:00:00:02 STATIC_AUTOGENERATED
ARP Cache of node 1 at time 0
10.1.1.1 dev 0 lladdr 02-06-00:00:00:00:00:01 STATIC_AUTOGENERATED
10.1.2.2 dev 1 lladdr 02-06-00:00:00:00:00:04 STATIC_AUTOGENERATED
10.1.2.3 dev 1 lladdr 02-06-00:00:00:00:00:05 STATIC_AUTOGENERATED
ARP Cache of node 2 at time 0
10.1.2.1 dev 0 lladdr 02-06-00:00:00:00:00:03 STATIC_AUTOGENERATED
10.1.2.3 dev 0 lladdr 02-06-00:00:00:00:00:05 STATIC_AUTOGENERATED
ARP Cache of node 3 at time 0
10.1.2.1 dev 0 lladdr 02-06-00:00:00:00:00:03 STATIC_AUTOGENERATED
10.1.2.2 dev 0 lladdr 02-06-00:00:00:00:00:04 STATIC_AUTOGENERATED

Generate ARP caches for the left channel (–useChannel):

ARP Cache of node 0 at time 0
10.1.1.2 dev 0 lladdr 02-06-00:00:00:00:00:02 STATIC_AUTOGENERATED
ARP Cache of node 1 at time 0
10.1.1.1 dev 0 lladdr 02-06-00:00:00:00:00:01 STATIC_AUTOGENERATED
ARP Cache of node 2 at time 0
ARP Cache of node 3 at time 0

Generate ARP caches for devices on the right side (–useNetDeviceContainer):

ARP Cache of node 0 at time 0
ARP Cache of node 1 at time 0
10.1.2.2 dev 1 lladdr 02-06-00:00:00:00:00:04 STATIC_AUTOGENERATED
10.1.2.3 dev 1 lladdr 02-06-00:00:00:00:00:05 STATIC_AUTOGENERATED
ARP Cache of node 2 at time 0
10.1.2.1 dev 0 lladdr 02-06-00:00:00:00:00:03 STATIC_AUTOGENERATED
10.1.2.3 dev 0 lladdr 02-06-00:00:00:00:00:05 STATIC_AUTOGENERATED
ARP Cache of node 3 at time 0
10.1.2.1 dev 0 lladdr 02-06-00:00:00:00:00:03 STATIC_AUTOGENERATED
10.1.2.2 dev 0 lladdr 02-06-00:00:00:00:00:04 STATIC_AUTOGENERATED

Generate ARP caches for specific interfaces (–useInterfaceContainer):

ARP Cache of node 0 at time 0
10.1.1.2 dev 0 lladdr 02-06-00:00:00:00:00:02 STATIC_AUTOGENERATED
ARP Cache of node 1 at time 0
ARP Cache of node 2 at time 0
ARP Cache of node 3 at time 0
10.1.2.1 dev 0 lladdr 02-06-00:00:00:00:00:03 STATIC_AUTOGENERATED
10.1.2.2 dev 0 lladdr 02-06-00:00:00:00:00:04 STATIC_AUTOGENERATED

Do not generate neighbor cache (–noGenerate):

ARP Cache of node 0 at time 0
ARP Cache of node 1 at time 0
ARP Cache of node 2 at time 0
ARP Cache of node 3 at time 0

Definition in file neighbor-cache-example.cc.