45#include "ns3/applications-module.h"
46#include "ns3/core-module.h"
47#include "ns3/flow-monitor-module.h"
48#include "ns3/internet-apps-module.h"
49#include "ns3/internet-module.h"
50#include "ns3/network-module.h"
51#include "ns3/point-to-point-module.h"
52#include "ns3/traffic-control-module.h"
110 std::cout << context <<
"=" << rtt.
GetMilliSeconds() <<
" ms" << std::endl;
114main(
int argc,
char* argv[])
116 std::string bandwidth =
"10Mbps";
117 std::string delay =
"5ms";
118 std::string queueDiscType =
"PfifoFast";
123 std::string flowsDatarate =
"20Mbps";
126 float startTime = 0.1F;
127 float simDuration = 60;
128 float samplingPeriod = 1;
131 cmd.AddValue(
"bandwidth",
"Bottleneck bandwidth", bandwidth);
132 cmd.AddValue(
"delay",
"Bottleneck delay", delay);
133 cmd.AddValue(
"queueDiscType",
134 "Bottleneck queue disc type in {PfifoFast, ARED, CoDel, FqCoDel, PIE, prio}",
136 cmd.AddValue(
"queueDiscSize",
"Bottleneck queue disc size in packets", queueDiscSize);
137 cmd.AddValue(
"netdevicesQueueSize",
138 "Bottleneck netdevices queue size in packets",
139 netdevicesQueueSize);
140 cmd.AddValue(
"bql",
"Enable byte queue limits on bottleneck netdevices", bql);
141 cmd.AddValue(
"flowsDatarate",
"Upload and download flows datarate", flowsDatarate);
142 cmd.AddValue(
"flowsPacketsSize",
"Upload and download flows packets sizes", flowsPacketsSize);
143 cmd.AddValue(
"startTime",
"Simulation start time", startTime);
144 cmd.AddValue(
"simDuration",
"Simulation duration in seconds", simDuration);
145 cmd.AddValue(
"samplingPeriod",
"Goodput sampling period in seconds", samplingPeriod);
146 cmd.Parse(argc, argv);
148 float stopTime = startTime + simDuration;
167 bottleneckLink.
SetQueue(
"ns3::DropTailQueue",
169 StringValue(std::to_string(netdevicesQueueSize) +
"p"));
181 if (queueDiscType ==
"PfifoFast")
184 "ns3::PfifoFastQueueDisc",
188 else if (queueDiscType ==
"ARED")
195 else if (queueDiscType ==
"CoDel")
201 else if (queueDiscType ==
"FqCoDel")
207 else if (queueDiscType ==
"PIE")
213 else if (queueDiscType ==
"prio")
235 tchPfifoFastAccess.
Install(devicesAccessLink);
237 address.SetBase(
"192.168.0.0",
"255.255.255.0");
243 qdiscs = tchBottleneck.
Install(devicesBottleneckLink);
257 queueDiscType = queueDiscType +
"-bql";
260 queueLimits->TraceConnectWithoutContext(
"Limit",
267 queue->TraceConnectWithoutContext(
"BytesInQueue",
271 n1Interface.
Add(interfacesAccess.
Get(0));
274 n3Interface.
Add(interfacesBottleneck.
Get(1));
290 uploadApp.
Add(sinkHelperUp.Install(n3));
294 onOffHelperUp.SetAttribute(
"Remote",
AddressValue(socketAddressUp));
295 onOffHelperUp.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
296 onOffHelperUp.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
297 onOffHelperUp.SetAttribute(
"PacketSize",
UintegerValue(flowsPacketsSize));
298 onOffHelperUp.SetAttribute(
"DataRate",
StringValue(flowsDatarate));
299 sourceApps.
Add(onOffHelperUp.Install(n1));
306 downloadApp.
Add(sinkHelperDown.Install(n1));
310 onOffHelperDown.SetAttribute(
"Remote",
AddressValue(socketAddressDown));
311 onOffHelperDown.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
312 onOffHelperDown.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
313 onOffHelperDown.SetAttribute(
"PacketSize",
UintegerValue(flowsPacketsSize));
314 onOffHelperDown.SetAttribute(
"DataRate",
StringValue(flowsDatarate));
315 sourceApps.
Add(onOffHelperDown.Install(n3));
319 ping.SetAttribute(
"VerboseMode",
EnumValue(Ping::VerboseMode::QUIET));
344 downloadGoodputStream,
357 flowMonitor->SerializeToXmlFile(queueDiscType +
"-flowMonitor.xml",
true,
true);
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
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.
Hold variables of type enum.
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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.
Network device transmission queue interface.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Create a ping application and associate it to a node.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void SetQueue(std::string type, Ts &&... args)
Each point to point net device must have a queue to pass packets through.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::QueueDisc pointers.
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.
static TypeId GetTypeId()
Get the type ID.
Simulation virtual time values and global simulation resolution.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
std::vector< uint16_t > ClassIdList
Container type for Class IDs.
ClassIdList AddQueueDiscClasses(uint16_t handle, uint16_t count, const std::string &type, Args &&... args)
Helper function used to add the given number of queue disc classes (of the given type and with the gi...
uint16_t AddChildQueueDisc(uint16_t handle, uint16_t classId, const std::string &type, Args &&... args)
Helper function used to attach a child queue disc (of the given type and with the given attributes) t...
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#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.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
void BytesInQueueTrace(Ptr< OutputStreamWrapper > stream, uint32_t oldVal, uint32_t newVal)
Print the bytes in the queue.
static void PingRtt(std::string context, uint16_t, Time rtt)
Print the ping RTT.
static void GoodputSampling(ApplicationContainer app, Ptr< OutputStreamWrapper > stream, float period)
Sample and print the queue goodput.
void LimitsTrace(Ptr< OutputStreamWrapper > stream, uint32_t oldVal, uint32_t newVal)
Print the queue limits.