127#include "ns3/core-module.h"
128#include "ns3/csma-module.h"
129#include "ns3/internet-module.h"
130#include "ns3/network-module.h"
139 ipv4Interface->AddAddress(ifaceAddr);
140 std::cout <<
"\nArp caches after add address 10.1.1.4 to n1" << std::endl;
146 ipv6Interface->AddAddress(ifaceAddr);
147 std::cout <<
"\nNdisc caches after add address 2001:1::200:ff:fe00:4 n1" << std::endl;
153 ipv4Interface->RemoveAddress(index);
154 std::cout <<
"\nArp caches after remove the first address (10.1.1.1) from n1" << std::endl;
160 ipv6Interface->RemoveAddress(index);
161 std::cout <<
"\nNdisc caches after remove the second address (2001:1::200:ff:fe00:1) from n1"
166main(
int argc,
char* argv[])
168 bool useIpv6 =
false;
169 bool enableLog =
false;
172 cmd.AddValue(
"useIPv6",
"Use IPv6 instead of IPv4", useIpv6);
173 cmd.AddValue(
"enableLog",
"Enable ArpL3Protocol and Icmpv6L4Protocol logging", enableLog);
174 cmd.Parse(argc, argv);
196 stack.SetIpv6StackInstall(
false);
200 stack.SetIpv4StackInstall(
false);
202 stack.Install(csmaNodes);
207 address.SetBase(
"10.1.1.0",
"255.255.255.0");
Parse command-line arguments.
build a set of CsmaNetDevice objects
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Implement the IPv4 layer.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
Helper class to auto-assign global IPv6 unicast addresses.
Describes an IPv6 address.
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
IPv6 layer implementation.
Describes an IPv6 prefix.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chan...
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_LOGIC
LOG_LOGIC and above.
void RemoveIpv6Address(Ptr< Ipv6Interface > ipv6Interface, uint32_t index)
void AddIpv6Address(Ptr< Ipv6Interface > ipv6Interface, Ipv6InterfaceAddress ifaceAddr)
void RemoveIpv4Address(Ptr< Ipv4Interface > ipv4Interface, uint32_t index)
void AddIpv4Address(Ptr< Ipv4Interface > ipv4Interface, Ipv4InterfaceAddress ifaceAddr)