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
69 *stream->
GetStream () << dev->GetBytesInNetmapTxRing () << std::endl;
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");
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);
215 uint32_t interface0 = ipv4->AddInterface (device0);
217 ipv4->AddAddress (interface0, address0);
218 ipv4->SetMetric (interface0, 0);
219 ipv4->SetForwarding (interface0,
true);
220 ipv4->SetUp (interface0);
223 uint32_t interface1 = ipv4->AddInterface (device1);
225 ipv4->AddAddress (interface1, address1);
226 ipv4->SetMetric (interface1, 0);
227 ipv4->SetForwarding (interface1,
true);
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)
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.
AttributeValue implementation for Boolean.
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.
Helper class that adds ns3::Ipv4GlobalRouting objects.
static void PopulateRoutingTables(void)
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.
AttributeValue implementation for Mac48Address.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
std::ostream * GetStream(void)
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 GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
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.