32#include "ns3/core-module.h"
33#include "ns3/fd-net-device-module.h"
34#include "ns3/internet-apps-module.h"
35#include "ns3/internet-module.h"
36#include "ns3/ipv4-list-routing-helper.h"
37#include "ns3/network-module.h"
38#include "ns3/traffic-control-module.h"
49 << q->GetNBytes() <<
"b "
50 <<
" dropped " << q->GetStats().nTotalDroppedPackets <<
"p "
51 << q->GetStats().nTotalDroppedBytes <<
"b " << std::endl;
54#ifdef HAVE_NETMAP_USER_H
59 *stream->GetStream() << dev->GetBytesInNetmapTxRing() << std::endl;
64main(
int argc,
char* argv[])
68 std::string deviceName0(
"enx503f56005a2a");
69 std::string deviceName1(
"eno1");
70 std::string ip0(
"10.0.1.2");
71 std::string ip1(
"10.0.2.1");
72 std::string mask0(
"255.255.255.0");
73 std::string mask1(
"255.255.255.0");
74 std::string m0(
"00:00:00:aa:00:01");
75 std::string
m1(
"00:00:00:aa:00:02");
76 std::string queueDiscType =
"PfifoFast";
82 std::string emuMode(
"raw");
84 std::string emuMode(
"netmap");
88 cmd.AddValue(
"deviceName0",
"Device name", deviceName0);
89 cmd.AddValue(
"deviceName1",
"Device name", deviceName1);
90 cmd.AddValue(
"ip0",
"Local IP address", ip0);
91 cmd.AddValue(
"ip1",
"Local IP address", ip1);
92 cmd.AddValue(
"mask0",
"Local mask", mask0);
93 cmd.AddValue(
"mask1",
"Local mask", mask1);
94 cmd.AddValue(
"m0",
"Mac address", m0);
95 cmd.AddValue(
"m1",
"Mac address",
m1);
96 cmd.AddValue(
"writer",
"Enable write stats", writer);
97 cmd.AddValue(
"queueDiscType",
98 "Bottleneck queue disc type in {PfifoFast, ARED, CoDel, FqCoDel, PIE}",
100 cmd.AddValue(
"bql",
"Enable byte queue limits on bottleneck netdevice", bql);
101 cmd.AddValue(
"index",
"Experiment index", index);
102 cmd.AddValue(
"emuMode",
"Emulation mode in {raw, netmap}", emuMode);
103 cmd.Parse(argc, argv);
158 if (emuMode ==
"raw")
169#ifdef HAVE_NETMAP_USER_H
170 if (emuMode ==
"netmap")
182 if ((helper0 ==
nullptr) || (helper1 ==
nullptr))
191 device0->SetAttribute(
"Address", mac0);
194 device1->SetAttribute(
"Address", mac1);
202 internetStackHelper.
Install(node);
209 ipv4->AddAddress(interface0, address0);
210 ipv4->SetMetric(interface0, 0);
211 ipv4->SetForwarding(interface0,
true);
212 ipv4->SetUp(interface0);
217 ipv4->AddAddress(interface1, address1);
218 ipv4->SetMetric(interface1, 0);
219 ipv4->SetForwarding(interface1,
true);
220 ipv4->SetUp(interface1);
233 if (queueDiscType ==
"PfifoFast")
237 else if (queueDiscType ==
"ARED")
248 else if (queueDiscType ==
"CoDel")
252 else if (queueDiscType ==
"FqCoDel")
256 else if (queueDiscType ==
"PIE")
283 ascii.
CreateFileStream(
"exp-" + std::to_string(index) +
"-router-tc-stats.txt");
286#ifdef HAVE_NETMAP_USER_H
287 if (emuMode.compare(
"netmap") == 0)
291 ascii.
CreateFileStream(
"exp-" + std::to_string(index) +
"-router-inflight.txt");
Manage ASCII trace files for device models.
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.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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.
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...
Ipv4 addresses are stored in host order in this class.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
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
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
build a set of FdNetDevice objects attached to a physical network interface
void SetDeviceName(std::string deviceName)
Set the device name of this device.
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::QueueDisc pointers.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
Class for representing queue sizes.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
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.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
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.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
Hold an unsigned integer type.
void TcPacketsInQueue(Ptr< QueueDisc > q, Ptr< OutputStreamWrapper > stream)
void SetDefault(std::string name, const AttributeValue &value)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
const double m1
First component modulus, 232 - 209.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.