42 #include "ns3/abort.h"
43 #include "ns3/core-module.h"
44 #include "ns3/fd-net-device-module.h"
45 #include "ns3/internet-apps-module.h"
46 #include "ns3/internet-module.h"
47 #include "ns3/ipv4-list-routing-helper.h"
48 #include "ns3/network-module.h"
49 #include "ns3/traffic-control-module.h"
65 #ifdef HAVE_NETMAP_USER_H
70 *stream->
GetStream() << dev->GetBytesInNetmapTxRing() << std::endl;
75 main(
int argc,
char* argv[])
79 std::string deviceName0(
"enx503f56005a2a");
80 std::string deviceName1(
"eno1");
81 std::string ip0(
"10.0.1.2");
82 std::string ip1(
"10.0.2.1");
83 std::string mask0(
"255.255.255.0");
84 std::string mask1(
"255.255.255.0");
85 std::string m0(
"00:00:00:aa:00:01");
86 std::string
m1(
"00:00:00:aa:00:02");
87 std::string queueDiscType =
"PfifoFast";
93 std::string emuMode(
"raw");
95 std::string emuMode(
"netmap");
99 cmd.AddValue(
"deviceName0",
"Device name", deviceName0);
100 cmd.AddValue(
"deviceName1",
"Device name", deviceName1);
101 cmd.AddValue(
"ip0",
"Local IP address", ip0);
102 cmd.AddValue(
"ip1",
"Local IP address", ip1);
103 cmd.AddValue(
"mask0",
"Local mask", mask0);
104 cmd.AddValue(
"mask1",
"Local mask", mask1);
105 cmd.AddValue(
"m0",
"Mac address", m0);
106 cmd.AddValue(
"m1",
"Mac address",
m1);
107 cmd.AddValue(
"writer",
"Enable write stats", writer);
108 cmd.AddValue(
"queueDiscType",
109 "Bottleneck queue disc type in {PfifoFast, ARED, CoDel, FqCoDel, PIE}",
111 cmd.AddValue(
"bql",
"Enable byte queue limits on bottleneck netdevice", bql);
112 cmd.AddValue(
"index",
"Experiment index", index);
113 cmd.AddValue(
"emuMode",
"Emulation mode in {raw, netmap}", emuMode);
114 cmd.Parse(argc, argv);
120 Mac48AddressValue mac0(m0.c_str());
121 Mac48AddressValue mac1(
m1.c_str());
169 if (emuMode ==
"raw")
180 #ifdef HAVE_NETMAP_USER_H
181 if (emuMode ==
"netmap")
193 if ((helper0 ==
nullptr) || (helper1 ==
nullptr))
202 device0->SetAttribute(
"Address", mac0);
205 device1->SetAttribute(
"Address", mac1);
213 internetStackHelper.
Install(node);
218 uint32_t interface0 =
ipv4->AddInterface(device0);
220 ipv4->AddAddress(interface0, address0);
221 ipv4->SetMetric(interface0, 0);
222 ipv4->SetForwarding(interface0,
true);
223 ipv4->SetUp(interface0);
226 uint32_t interface1 =
ipv4->AddInterface(device1);
228 ipv4->AddAddress(interface1, address1);
229 ipv4->SetMetric(interface1, 0);
230 ipv4->SetForwarding(interface1,
true);
231 ipv4->SetUp(interface1);
244 if (queueDiscType ==
"PfifoFast")
248 else if (queueDiscType ==
"ARED")
259 else if (queueDiscType ==
"CoDel")
263 else if (queueDiscType ==
"FqCoDel")
267 else if (queueDiscType ==
"PIE")
297 #ifdef HAVE_NETMAP_USER_H
298 if (emuMode.compare(
"netmap") == 0)
308 Create<OutputStreamWrapper>(
"router-routes.txt", std::ios::out);
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
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.
uint32_t GetNPackets() const
Get the number of packets stored by the queue disc.
uint32_t GetNBytes() const
Get the amount of bytes stored by the queue disc.
const Stats & GetStats()
Retrieve all the collected statistics.
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.
@ BYTES
Use number of bytes for queue size.
@ PACKETS
Use number of packets for queue size.
Time Seconds(double value)
Construct a Time in the indicated unit.
const double m1
First component modulus, 232 - 209.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t nTotalDroppedPackets
Total dropped packets.
uint64_t nTotalDroppedBytes
Total dropped bytes.