64#include "ns3/core-module.h"
65#include "ns3/internet-apps-module.h"
66#include "ns3/internet-module.h"
67#include "ns3/network-module.h"
68#include "ns3/nix-vector-routing-module.h"
69#include "ns3/point-to-point-module.h"
78main(
int argc,
char* argv[])
84 std::string destinationStr;
86 std::string sourceStr;
93 cmd.AddValue(
"logging",
"Tell application to log if true", logging);
94 cmd.AddValue(
"interval",
"The time to wait between two packets", interPacketInterval);
95 cmd.AddValue(
"size",
"Data bytes to be sent, per-packet", size);
96 cmd.AddValue(
"count",
"Number of packets to be sent", count);
97 cmd.AddValue(
"destination",
98 "Destination IPv4 or IPv6 address, e.g., \"10.1.2.2\"",
100 cmd.AddValue(
"source",
101 "Source address, needed only for multicast or broadcast destinations",
103 cmd.Parse(argc, argv);
105 if (!destinationStr.empty())
109 if (v4Dst.IsInitialized())
114 else if (v6Dst.IsInitialized())
121 if (!sourceStr.empty())
125 if (v4Src.IsInitialized())
129 else if (v6Src.IsInitialized())
134 if (sourceStr.empty())
141 std::cout <<
"Specify a source address to use when pinging multicast addresses"
143 std::cout <<
"Program exiting..." << std::endl;
150 if (v4Dst.IsInitialized() && (v4Dst.IsBroadcast() || v4Dst.IsMulticast()))
152 std::cout <<
"Specify a source address to use when pinging broadcast or multicast "
155 std::cout <<
"Program exiting..." << std::endl;
188 std::list<uint32_t> dropList;
196 errorModel->SetList(dropList);
197 p2pSender->SetReceiveErrorModel(errorModel);
203 stack.SetRoutingHelper(nixRouting);
204 stack.SetIpv6StackInstall(
false);
208 addressV4.
SetBase(
"10.1.1.0",
"255.255.255.0");
209 addressV4.
Assign(link1Devices);
215 destination = link2InterfacesV4.
GetAddress(1, 0);
222 stack.SetRoutingHelper(nixRouting);
223 stack.SetIpv4StackInstall(
false);
227 addressV6.
SetBase(
"2001:1::", 64);
228 addressV6.
Assign(link1Devices);
234 destination = link2InterfacesV6.
GetAddress(1, 1);
240 pingHelper.SetAttribute(
"Interval",
TimeValue(interPacketInterval));
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address NewNetwork()
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
void NewNetwork()
Allocate a new network.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
bool IsInitialized() const
Keep track of a set of IPv6 interfaces.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Helper class that adds Nix-vector routing to nodes.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Create a ping application and associate it to a node.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
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.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.