|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
84 #include "ns3/abort.h"
85 #include "ns3/core-module.h"
86 #include "ns3/internet-module.h"
87 #include "ns3/network-module.h"
88 #include "ns3/fd-net-device-module.h"
89 #include "ns3/internet-apps-module.h"
90 #include "ns3/ipv4-static-routing-helper.h"
91 #include "ns3/ipv4-list-routing-helper.h"
104 main (
int argc,
char *argv[])
108 std::string deviceName (
"eth0");
109 std::string remote (
"8.8.8.8");
110 std::string localAddress (
"1.2.3.4");
111 std::string localGateway (
"1.2.3.4");
113 std::string emuMode (
"raw");
114 #elif HAVE_NETMAP_USER_H
115 std::string emuMode (
"netmap");
116 #else // HAVE_DPDK_USER_H is true (otherwise this example is not compiled)
117 std::string emuMode (
"dpdk");
125 cmd.AddValue (
"deviceName",
"Device name (in raw, netmap mode) or Device address (in dpdk mode, eg: 0000:00:1f.6). Use `lspci` to find device address.", deviceName);
126 cmd.AddValue (
"remote",
"Remote IP address (dotted decimal only please)", remote);
127 cmd.AddValue (
"localIp",
"Local IP address (dotted decimal only please)", localAddress);
128 cmd.AddValue (
"gateway",
"Gateway address (dotted decimal only please)", localGateway);
129 cmd.AddValue (
"emuMode",
"Emulation mode in {raw, netmap, dpdk}", emuMode);
130 cmd.Parse (argc, argv);
134 NS_ABORT_MSG_IF (localIp ==
"1.2.3.4",
"You must change the local IP address before running this example");
136 Ipv4Mask localMask (
"255.255.255.0");
182 if (emuMode ==
"raw")
189 #ifdef HAVE_NETMAP_USER_H
190 if (emuMode ==
"netmap")
197 #ifdef HAVE_DPDK_USER_H
198 if (emuMode ==
"dpdk")
213 if (helper ==
nullptr)
232 internetStackHelper.
Install (node);
236 uint32_t
interface = ipv4->AddInterface (device);
240 ipv4->
SetUp (interface);
256 NS_ABORT_MSG_IF (gateway ==
"1.2.3.4",
"You must change the gateway IP address before running this example");
290 helper->
EnablePcap (emuMode +
"-emu-ping", device,
true);
295 NS_LOG_INFO (
"Run Emulation in " << emuMode <<
" mode.");
holds a vector of ns3::NetDevice pointers
virtual NetDeviceContainer Install(Ptr< Node > node) const
This method creates a FdNetDevice and associates it to a node.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Parse command-line arguments.
AttributeValue implementation for Boolean.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void SetUp(uint32_t interface)=0
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ipv4 addresses are stored in host order in this class.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
AttributeValue implementation for Mac48Address.
void SetStopTime(Time stop)
Specify application stop time.
Access to the IPv4 forwarding table, interfaces, and configuration.
Helper class that adds ns3::Ipv4StaticRouting objects.
void SetStartTime(Time start)
Specify application start time.
build a set of FdNetDevice objects attached to a physical network interface
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 Stop(void)
Tell the Simulator the calling event should be the last one executed.
a class to store IPv4 address information on an interface
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
build a DpdkNetDevice object attached to a physical network interface
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
Simulation virtual time values and global simulation resolution.
#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.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static void Run(void)
Run the simulation.
Hold variables of type string.
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...
void Connect(std::string path, const CallbackBase &cb)
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however,...
Time Seconds(double value)
Construct a Time in the indicated unit.
static void PingRtt(std::string context, Time rtt)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
a class to represent an Ipv4 address mask
build a set of FdNetDevice objects attached to a physical network interface
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
aggregate IP/TCP/UDP functionality to existing Nodes.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
void SetPmdLibrary(std::string pmdLibrary)
Sets PMD Library to be used for the NIC.
AttributeValue implementation for Ipv4Address.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.