|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
43 #include "ns3/abort.h"
44 #include "ns3/core-module.h"
45 #include "ns3/internet-module.h"
46 #include "ns3/network-module.h"
47 #include "ns3/fd-net-device-module.h"
48 #include "ns3/internet-apps-module.h"
49 #include "ns3/ipv4-list-routing-helper.h"
50 #include "ns3/traffic-control-module.h"
64 #ifdef HAVE_NETMAP_USER_H
74 main (
int argc,
char *argv[])
78 std::string deviceName0 (
"enx503f56005a2a");
79 std::string deviceName1 (
"eno1");
80 std::string ip0 (
"10.0.1.2");
81 std::string ip1 (
"10.0.2.1");
82 std::string mask0 (
"255.255.255.0");
83 std::string mask1 (
"255.255.255.0");
84 std::string m0 (
"00:00:00:aa:00:01");
85 std::string
m1 (
"00:00:00:aa:00:02");
86 std::string queueDiscType =
"PfifoFast";
92 std::string emuMode (
"raw");
93 #else // HAVE_NETMAP_USER_H is true (otherwise this example is not compiled)
94 std::string emuMode (
"netmap");
98 cmd.AddValue (
"deviceName0",
"Device name", deviceName0);
99 cmd.AddValue (
"deviceName1",
"Device name", deviceName1);
100 cmd.AddValue (
"ip0",
"Local IP address", ip0);
101 cmd.AddValue (
"ip1",
"Local IP address", ip1);
102 cmd.AddValue (
"mask0",
"Local mask", mask0);
103 cmd.AddValue (
"mask1",
"Local mask", mask1);
104 cmd.AddValue (
"m0",
"Mac address", m0);
105 cmd.AddValue (
"m1",
"Mac address",
m1);
106 cmd.AddValue (
"writer",
"Enable write stats", writer);
107 cmd.AddValue (
"queueDiscType",
"Bottleneck queue disc type in {PfifoFast, ARED, CoDel, FqCoDel, PIE}", queueDiscType);
108 cmd.AddValue (
"bql",
"Enable byte queue limits on bottleneck netdevice", bql);
109 cmd.AddValue (
"index",
"Experiment index", index);
110 cmd.AddValue (
"emuMode",
"Emulation mode in {raw, netmap}", emuMode);
111 cmd.Parse (argc, argv);
166 if (emuMode ==
"raw")
177 #ifdef HAVE_NETMAP_USER_H
178 if (emuMode ==
"netmap")
190 if ((helper0 ==
nullptr) || (helper1 ==
nullptr))
210 internetStackHelper.
Install (node);
220 ipv4->
SetUp (interface0);
228 ipv4->
SetUp (interface1);
241 if (queueDiscType.compare (
"PfifoFast") == 0)
245 else if (queueDiscType.compare (
"ARED") == 0)
256 else if (queueDiscType.compare (
"CoDel") == 0)
260 else if (queueDiscType.compare (
"FqCoDel") == 0)
264 else if (queueDiscType.compare (
"PIE") == 0)
293 #ifdef HAVE_NETMAP_USER_H
294 if (emuMode.compare (
"netmap") == 0)
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.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
Parse command-line arguments.
AttributeValue implementation for Boolean.
uint16_t SetRootQueueDisc(const std::string &type, Args &&... args)
Helper function used to set a root queue disc of the given type and with the given attributes.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const double m1
First component modulus, 232 - 209.
virtual void SetUp(uint32_t interface)=0
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint32_t nTotalDroppedPackets
Total dropped packets.
Ipv4 addresses are stored in host order in this class.
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.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
@ PACKETS
Use number of packets for queue size.
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
AttributeValue implementation for Mac48Address.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
build a set of FdNetDevice objects attached to a physical network interface
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
QueueDiscContainer Install(NetDeviceContainer c)
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.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Holds a vector of ns3::QueueDisc pointers.
void SetDeviceName(std::string deviceName)
Set the device name of this device.
virtual void SetForwarding(uint32_t interface, bool val)=0
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 TcPacketsInQueue(Ptr< QueueDisc > q, Ptr< OutputStreamWrapper > stream)
Manage ASCII trace files for device models.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
build a set of FdNetDevice objects Normally we eschew multiple inheritance, however,...
Time Seconds(double value)
Construct a Time in the indicated unit.
Build a set of QueueDisc objects.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
@ BYTES
Use number of bytes for queue size.
AttributeValue implementation for Time.
a class to represent an Ipv4 address mask
build a set of FdNetDevice objects attached to a physical network interface
Helper class that adds ns3::Ipv4GlobalRouting objects.
uint64_t nTotalDroppedBytes
Total dropped bytes.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
uint32_t GetBytesInNetmapTxRing()
Get the number of bytes currently in the netmap transmission ring.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Class for representing queue sizes.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.