72 #include "ns3/abort.h" 73 #include "ns3/core-module.h" 74 #include "ns3/internet-module.h" 75 #include "ns3/network-module.h" 76 #include "ns3/fd-net-device-module.h" 77 #include "ns3/internet-apps-module.h" 78 #include "ns3/ipv4-static-routing-helper.h" 79 #include "ns3/ipv4-list-routing-helper.h" 92 main (
int argc,
char *argv[])
96 std::string deviceName (
"tap0");
97 std::string remote (
"192.0.43.10");
98 std::string network (
"1.2.3.4");
99 std::string mask (
"255.255.255.0");
100 std::string pi (
"no");
107 cmd.AddValue (
"deviceName",
"Device name", deviceName);
108 cmd.AddValue (
"remote",
"Remote IP address (dotted decimal only please)", remote);
109 cmd.AddValue (
"tapNetwork",
"Network address to assign the TAP device IP address (dotted decimal only please)", network);
110 cmd.AddValue (
"tapMask",
"Network mask for configure the TAP device (dotted decimal only please)", mask);
111 cmd.AddValue (
"modePi",
"If 'yes' a PI header will be added to the traffic traversing the device(flag IFF_NOPI will be unset).", pi);
112 cmd.Parse (argc, argv);
114 NS_ABORT_MSG_IF (network ==
"1.2.3.4",
"You must change the local IP address before running this example");
120 bool modePi = ( pi ==
"yes" ? true :
false);
149 addresses.
SetBase (tapNetwork, tapMask);
167 internetStackHelper.
Install (node);
175 uint32_t
interface = ipv4->AddInterface (device);
180 ipv4->
SetUp (interface);
218 helper.
EnablePcap (
"fd-tap-ping", device,
true);
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void SetStopTime(Time stop)
Specify application stop time.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Boolean.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Hold variables of type string.
a class to represent an Ipv4 address mask
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
build a set of FdNetDevice objects attached to a virtual TAP network interface
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
static void PingRtt(std::string context, Time rtt)
void SetTapIpv4Address(Ipv4Address address)
Set the device IPv4 address.
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
virtual void SetUp(uint32_t interface)=0
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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...
Parse command-line arguments.
void Connect(std::string path, const CallbackBase &cb)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Access to the IPv4 forwarding table, interfaces, and configuration.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
AttributeValue implementation for Ipv4Address.
void SetTapIpv4Mask(Ipv4Mask mask)
Set the IPv4 network mask for the TAP device.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
a class to store IPv4 address information on an interface
Helper class that adds ns3::Ipv4StaticRouting objects.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
void SetModePi(bool pi)
Set flag IFF_NO_PI on the device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetStartTime(Time start)
Specify application start time.
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...
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.