84#include "ns3/core-module.h"
85#include "ns3/fd-net-device-module.h"
86#include "ns3/internet-apps-module.h"
87#include "ns3/internet-module.h"
88#include "ns3/ipv4-list-routing-helper.h"
89#include "ns3/ipv4-static-routing-helper.h"
90#include "ns3/network-module.h"
103main(
int argc,
char* argv[])
107 std::string deviceName(
"eth0");
108 std::string remote(
"8.8.8.8");
109 std::string localAddress(
"1.2.3.4");
110 std::string localGateway(
"1.2.3.4");
112 std::string emuMode(
"raw");
113#elif HAVE_NETMAP_USER_H
114 std::string emuMode(
"netmap");
116 std::string emuMode(
"dpdk");
124 cmd.AddValue(
"deviceName",
125 "Device name (in raw, netmap mode) or Device address (in dpdk mode, eg: "
126 "0000:00:1f.6). Use `lspci` to find device address.",
128 cmd.AddValue(
"remote",
"Remote IP address (dotted decimal only please)", remote);
129 cmd.AddValue(
"localIp",
"Local IP address (dotted decimal only please)", localAddress);
130 cmd.AddValue(
"gateway",
"Gateway address (dotted decimal only please)", localGateway);
131 cmd.AddValue(
"emuMode",
"Emulation mode in {raw, netmap, dpdk}", emuMode);
132 cmd.Parse(argc, argv);
137 "You must change the local IP address before running this example");
139 Ipv4Mask localMask(
"255.255.255.0");
145 GlobalValue::Bind(
"SimulatorImplementationType",
StringValue(
"ns3::RealtimeSimulatorImpl"));
151 GlobalValue::Bind(
"ChecksumEnabled",
BooleanValue(
true));
185 if (emuMode ==
"raw")
192#ifdef HAVE_NETMAP_USER_H
193 if (emuMode ==
"netmap")
200#ifdef HAVE_DPDK_USER_H
201 if (emuMode ==
"dpdk")
216 if (helper ==
nullptr)
235 internetStackHelper.
Install(node);
239 uint32_t interface = ipv4->AddInterface(device);
241 ipv4->AddAddress(interface,
address);
242 ipv4->SetMetric(interface, 1);
243 ipv4->SetUp(interface);
260 "You must change the gateway IP address before running this example");
264 staticRouting->SetDefaultRoute(gateway, interface);
277 app->SetStartTime(
Seconds(1.0));
278 app->SetStopTime(
Seconds(22.0));
284 Names::Add(
"app", app);
294 helper->
EnablePcap(emuMode +
"-emu-ping", device,
true);
299 NS_LOG_INFO(
"Run Emulation in " << emuMode <<
" mode.");
300 Simulator::Stop(
Seconds(23.0));
302 Simulator::Destroy();
AttributeValue implementation for Boolean.
Parse command-line arguments.
build a DpdkNetDevice object attached to a physical network interface
void SetPmdLibrary(std::string pmdLibrary)
Sets PMD Library to be used for the NIC.
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
build a set of FdNetDevice objects attached to a physical network interface
void SetDeviceName(std::string deviceName)
Set the device name of this device.
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however,...
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
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...
Ipv4 addresses are stored in host order in this class.
AttributeValue implementation for Ipv4Address.
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...
AttributeValue implementation for Mac48Address.
holds a vector of ns3::NetDevice pointers
build a set of FdNetDevice objects attached to a physical network interface
void SetDeviceName(std::string deviceName)
Set the device name of this device.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
static void PingRtt(std::string context, Time rtt)
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#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.
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...