75 #include "ns3/core-module.h"
76 #include "ns3/internet-apps-module.h"
77 #include "ns3/internet-module.h"
78 #include "ns3/network-module.h"
79 #include "ns3/nix-vector-routing-module.h"
80 #include "ns3/point-to-point-module.h"
89 main(
int argc,
char* argv[])
95 std::string destinationStr;
97 std::string sourceStr;
104 cmd.AddValue(
"logging",
"Tell application to log if true", logging);
105 cmd.AddValue(
"interval",
"The time to wait between two packets", interPacketInterval);
106 cmd.AddValue(
"size",
"Data bytes to be sent, per-packet", size);
107 cmd.AddValue(
"count",
"Number of packets to be sent", count);
108 cmd.AddValue(
"destination",
109 "Destination IPv4 or IPv6 address, e.g., \"10.1.2.2\"",
111 cmd.AddValue(
"source",
112 "Source address, needed only for multicast or broadcast destinations",
114 cmd.Parse(argc, argv);
116 if (!destinationStr.empty())
120 if (v4Dst.IsInitialized())
125 else if (v6Dst.IsInitialized())
132 if (!sourceStr.empty())
136 if (v4Src.IsInitialized())
140 else if (v6Src.IsInitialized())
145 if (sourceStr.empty())
152 std::cout <<
"Specify a source address to use when pinging multicast addresses"
154 std::cout <<
"Program exiting..." << std::endl;
161 if (v4Dst.IsInitialized() && (v4Dst.IsBroadcast() || v4Dst.IsMulticast()))
163 std::cout <<
"Specify a source address to use when pinging broadcast or multicast "
166 std::cout <<
"Program exiting..." << std::endl;
199 std::list<uint32_t> dropList;
207 errorModel->SetList(dropList);
208 p2pSender->SetReceiveErrorModel(errorModel);
215 stack.SetIpv6StackInstall(
false);
219 addressV4.
SetBase(
"10.1.1.0",
"255.255.255.0");
220 addressV4.
Assign(link1Devices);
226 destination = link2InterfacesV4.
GetAddress(1, 0);
234 stack.SetIpv4StackInstall(
false);
238 addressV6.
SetBase(
"2001:1::", 64);
239 addressV6.
Assign(link1Devices);
245 destination = link2InterfacesV6.
GetAddress(1, 1);
251 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.
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.
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.