34 #include "ns3/applications-module.h"
35 #include "ns3/core-module.h"
36 #include "ns3/flow-monitor-helper.h"
37 #include "ns3/internet-module.h"
38 #include "ns3/network-module.h"
39 #include "ns3/point-to-point-module.h"
40 #include "ns3/traffic-control-module.h"
85 fPlotQueueDisc.close();
90 fPlotQueueDiscAvg.close();
97 uint16_t
port = 50000;
138 main(
int argc,
char* argv[])
142 std::string pieLinkDataRate =
"1.5Mbps";
143 std::string pieLinkDelay =
"20ms";
146 bool writeForPlot =
false;
147 bool writePcap =
false;
148 bool flowMonitor =
false;
150 bool printPieStats =
true;
163 cmd.AddValue(
"pathOut",
164 "Path to save results from --writeForPlot/--writePcap/--writeFlowMonitor",
166 cmd.AddValue(
"writeForPlot",
"<0/1> to write results for plot (gnuplot)", writeForPlot);
167 cmd.AddValue(
"writePcap",
"<0/1> to write results in pcapfile", writePcap);
168 cmd.AddValue(
"writeFlowMonitor",
169 "<0/1> to enable Flow Monitor and write their results",
172 cmd.Parse(argc, argv);
195 uint32_t meanPktSize = 1000;
205 NS_LOG_INFO(
"Install internet stack on all nodes.");
227 p2p.SetQueue(
"ns3::DropTailQueue");
233 p2p.SetQueue(
"ns3::DropTailQueue");
239 p2p.SetQueue(
"ns3::DropTailQueue");
244 queueDiscs = tchPie.
Install(devn2n3);
246 p2p.SetQueue(
"ns3::DropTailQueue");
252 p2p.SetQueue(
"ns3::DropTailQueue");
261 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
264 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
267 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
270 ipv4.SetBase(
"10.1.4.0",
"255.255.255.0");
273 ipv4.SetBase(
"10.1.5.0",
"255.255.255.0");
284 std::stringstream stmp;
285 stmp << pathOut <<
"/pie";
299 <<
"pie-queue-disc.plotme";
301 <<
"pie-queue-disc_avg.plotme";
316 std::cout <<
"There should be no drops due to queue full." << std::endl;
322 std::stringstream stmp;
323 stmp << pathOut <<
"/pie.flowmon";
325 flowmon->SerializeToXmlFile(stmp.str(),
false,
false);
330 std::cout <<
"*** PIE stats from Node 2 queue ***" << std::endl;
332 <<
" drops due to prob mark" << std::endl;
334 <<
" drops due to queue limits" << std::endl;
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.
Parse command-line arguments.
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
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.
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.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
holds a vector of ns3::NetDevice pointers
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.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
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 ...
static constexpr const char * UNFORCED_DROP
Early probability drops: proactive.
static constexpr const char * FORCED_DROP
Drops due to queue limit: reactive.
Build a set of PointToPointNetDevice objects.
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.
QueueSize GetCurrentSize() const
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
const Stats & GetStats()
Retrieve all the collected statistics.
uint32_t GetValue() const
Get the underlying value.
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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
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 AddInternalQueues(uint16_t handle, uint16_t count, std::string type, Args &&... args)
Helper function used to add the given number of internal queues (of the given type and with the given...
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#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.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_INFO
LOG_INFO and above.
Ipv4InterfaceContainer i0i2
std::stringstream filePlotQueueDisc
std::stringstream filePlotQueueDiscAvg
void CheckQueueDiscSize(Ptr< QueueDisc > queue)
Ipv4InterfaceContainer i1i2
Ipv4InterfaceContainer i3i4
Ipv4InterfaceContainer i3i5
Ipv4InterfaceContainer i2i3
Structure that keeps the queue disc statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.