62#include "ns3/core-module.h"
63#include "ns3/fd-net-device-module.h"
64#include "ns3/internet-apps-module.h"
65#include "ns3/internet-module.h"
66#include "ns3/ipv4-list-routing-helper.h"
67#include "ns3/ipv4-static-routing-helper.h"
68#include "ns3/network-module.h"
77 NS_LOG_UNCOND(
"Received " << seqNo <<
" Response with RTT = " << rtt);
81main(
int argc,
char* argv[])
85 std::string deviceName(
"tap0");
86 std::string remote(
"192.0.43.10");
87 std::string network(
"1.2.3.4");
88 std::string mask(
"255.255.255.0");
96 cmd.AddValue(
"deviceName",
"Device name", deviceName);
97 cmd.AddValue(
"remote",
"Remote IP address (dotted decimal only please)", remote);
98 cmd.AddValue(
"tapNetwork",
99 "Network address to assign the TAP device IP address (dotted decimal only please)",
101 cmd.AddValue(
"tapMask",
102 "Network mask for configure the TAP device (dotted decimal only please)",
104 cmd.AddValue(
"modePi",
105 "If 'yes' a PI header will be added to the traffic traversing the device(flag "
106 "IFF_NOPI will be unset).",
108 cmd.Parse(argc, argv);
111 "You must change the local IP address before running this example");
117 bool modePi = (pi ==
"yes");
146 addresses.
SetBase(tapNetwork, tapMask);
164 internetStackHelper.
Install(node);
175 ipv4->AddAddress(interface, address);
176 ipv4->SetMetric(interface, 1);
177 ipv4->SetUp(interface);
185 staticRouting->SetDefaultRoute(tapIp, interface);
196 app->SetAttribute(
"VerboseMode",
EnumValue(Ping::VerboseMode::VERBOSE));
197 node->AddApplication(app);
215 helper.
EnablePcap(
"fd-tap-ping", device,
true);
Parse command-line arguments.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
Hold variables of type enum.
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
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.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4Address NewAddress()
Increment the IP address counter used to allocate IP addresses.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
holds a vector of ns3::NetDevice pointers
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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.
build a set of FdNetDevice objects attached to a virtual TAP network interface
void SetTapIpv4Mask(Ipv4Mask mask)
Set the IPv4 network mask for the TAP device.
void SetTapIpv4Address(Ipv4Address address)
Set the device IPv4 address.
void SetModePi(bool pi)
Set flag IFF_NO_PI on the device.
Simulation virtual time values and global simulation resolution.
static void PingRtt(std::string context, uint16_t seqNo, Time rtt)
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
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...