38#include "ns3/applications-module.h"
39#include "ns3/config-store.h"
40#include "ns3/core-module.h"
42#include "ns3/error-model.h"
43#include "ns3/event-id.h"
44#include "ns3/internet-module.h"
45#include "ns3/ipv4-global-routing-helper.h"
46#include "ns3/network-module.h"
47#include "ns3/point-to-point-module.h"
48#include "ns3/tcp-header.h"
49#include "ns3/traffic-control-module.h"
50#include "ns3/udp-header.h"
70 *stream->GetStream() << oldval <<
" " << newval << std::endl;
82 if (cwndTrFileName.empty())
91 "/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
105 *stream->GetStream() << newval << std::endl;
117 if (sojournTrFileName.empty())
126 "$ns3::CoDelQueueDisc/SojournTime",
141 *stream->GetStream() << oldval <<
" " << newval << std::endl;
153 if (queueLengthTrFileName.empty())
155 NS_LOG_DEBUG(
"No trace file for queue length provided");
162 "/NodeList/2/$ns3::TrafficControlLayer/RootQueueDiscList/0/BytesInQueue",
188 if (everyDropTrFileName.empty())
190 NS_LOG_DEBUG(
"No trace file for every drop event provided");
197 "/NodeList/2/$ns3::TrafficControlLayer/RootQueueDiscList/0/Drop",
212 if (!oldVal && newVal)
217 else if (oldVal && !newVal)
233 if (dropStateTrFileName.empty())
235 NS_LOG_DEBUG(
"No trace file for dropping state provided");
242 "$ns3::CoDelQueueDisc/DropState",
286main(
int argc,
char* argv[])
288 std::string serverCmtsDelay =
"15ms";
289 std::string cmtsRouterDelay =
"6ms";
290 std::string routerHostDelay =
"0.1ms";
291 std::string serverLanDataRate =
"10Gbps";
292 std::string cmtsLanDataRate =
"10Gbps";
293 std::string cmtsWanDataRate =
"22Mbps";
294 std::string routerWanDataRate =
"5Mbps";
295 std::string routerLanDataRate =
"10Gbps";
296 std::string hostLanDataRate =
"10Gbps";
298 std::string routerWanQueueDiscType =
"CoDel";
302 uint32_t numOfDownLoadBulkFlows = 1;
304 uint32_t numOfDownLoadOnOffFlows = 1;
305 bool isPcapEnabled =
true;
307 float startTime = 0.1F;
308 float simDuration = 60;
310 std::string fileNamePrefix =
"codel-vs-pfifo-fast-asymmetric";
314 cmd.AddValue(
"serverCmtsDelay",
"Link delay between server and CMTS", serverCmtsDelay);
315 cmd.AddValue(
"cmtsRouterDelay",
"Link delay between CMTS and rounter", cmtsRouterDelay);
316 cmd.AddValue(
"routerHostDelay",
"Link delay between router and host", routerHostDelay);
317 cmd.AddValue(
"serverLanDataRate",
"Server LAN net device data rate", serverLanDataRate);
318 cmd.AddValue(
"cmtsLanDataRate",
"CMTS LAN net device data rate", cmtsLanDataRate);
319 cmd.AddValue(
"cmtsWanDataRate",
"CMTS WAN net device data rate", cmtsWanDataRate);
320 cmd.AddValue(
"routerWanDataRate",
"Router WAN net device data rate", routerWanDataRate);
321 cmd.AddValue(
"routerLanDataRate",
"Router LAN net device data rate", routerLanDataRate);
322 cmd.AddValue(
"hostLanDataRate",
"Host LAN net device data rate", hostLanDataRate);
323 cmd.AddValue(
"routerWanQueueDiscType",
324 "Router WAN queue disc type: "
326 routerWanQueueDiscType);
327 cmd.AddValue(
"queueSize",
"Queue size in packets",
queueSize);
328 cmd.AddValue(
"pktSize",
"Packet size in bytes",
pktSize);
329 cmd.AddValue(
"numOfUpLoadBulkFlows",
330 "Number of upload bulk transfer flows",
331 numOfUpLoadBulkFlows);
332 cmd.AddValue(
"numOfDownLoadBulkFlows",
333 "Number of download bulk transfer flows",
334 numOfDownLoadBulkFlows);
335 cmd.AddValue(
"numOfUpLoadOnOffFlows",
"Number of upload OnOff flows", numOfUpLoadOnOffFlows);
336 cmd.AddValue(
"numOfDownLoadOnOffFlows",
337 "Number of download OnOff flows",
338 numOfDownLoadOnOffFlows);
339 cmd.AddValue(
"startTime",
"Simulation start time", startTime);
340 cmd.AddValue(
"simDuration",
"Simulation duration in seconds", simDuration);
341 cmd.AddValue(
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
342 cmd.AddValue(
"logging",
"Flag to enable/disable logging", logging);
343 cmd.Parse(argc, argv);
345 float stopTime = startTime + simDuration;
347 std::string pcapFileName = fileNamePrefix +
"-" + routerWanQueueDiscType;
348 std::string cwndTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-cwnd" +
".tr";
349 std::string attributeFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
".attr";
350 std::string sojournTrFileName =
351 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-sojourn" +
".tr";
352 std::string queueLengthTrFileName =
353 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-length" +
".tr";
354 std::string everyDropTrFileName =
355 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop" +
".tr";
356 std::string dropStateTrFileName =
357 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop-state" +
".tr";
396 NS_LOG_INFO(
"Create channels and install net devices on nodes");
405 serverLanDev->SetAttribute(
"DataRate",
StringValue(serverLanDataRate));
408 cmtsLanDev->SetAttribute(
"DataRate",
StringValue(cmtsLanDataRate));
416 cmtsWanDev->SetAttribute(
"DataRate",
StringValue(cmtsWanDataRate));
419 routerWanDev->SetAttribute(
"DataRate",
StringValue(routerWanDataRate));
427 routerLanDev->SetAttribute(
"DataRate",
StringValue(routerLanDataRate));
430 hostLanDev->SetAttribute(
"DataRate",
StringValue(hostLanDataRate));
432 NS_LOG_INFO(
"Install Internet stack on all nodes");
442 tchPfifo.
Install(serverCmtsDev);
444 if (routerWanQueueDiscType ==
"PfifoFast")
446 tchPfifo.
Install(routerWanDev);
448 else if (routerWanQueueDiscType ==
"CoDel")
450 tchCoDel.
Install(routerWanDev);
457 tchPfifo.
Install(routerHostDev);
461 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
463 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
465 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
472 uint16_t port1 = 50000;
479 while (numOfDownLoadBulkFlows)
482 numOfDownLoadBulkFlows--;
485 while (numOfDownLoadOnOffFlows)
488 numOfDownLoadOnOffFlows--;
492 uint16_t port2 = 50001;
499 while (numOfUpLoadBulkFlows)
502 numOfUpLoadBulkFlows--;
505 while (numOfUpLoadOnOffFlows)
508 numOfUpLoadOnOffFlows--;
513 if (routerWanQueueDiscType ==
"CoDel")
521 p2p.EnablePcapAll(pcapFileName);
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.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
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.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
Parse command-line arguments.
void ConfigureDefaults()
Configure the default values.
void ConfigureAttributes()
Configure the attribute values.
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
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
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.
Simulation virtual time values and global simulation resolution.
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.
Hold an unsigned integer type.
static void TraceCwnd(std::string cwndTrFileName)
Setup for TCP congestion window tracking.
static void SojournTracer(Ptr< OutputStreamWrapper > stream, Time newval)
Traffic Control Sojourn tracker.
static void TraceDroppingState(std::string dropStateTrFileName)
Setup for Traffic Control dropping tracking.
void CreateBulkFlow(AddressValue remoteAddress, Ptr< Node > sender, uint32_t pktSize, float stopTime)
Create a Bulk Flow application.
static void CwndTracer(Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
TCP Congestion window tracker.
static void DroppingStateTracer(Ptr< OutputStreamWrapper > stream, bool oldVal, bool newVal)
Traffic Control Dropping state trace.
static void EveryDropTracer(Ptr< OutputStreamWrapper > stream, Ptr< const QueueDiscItem > item)
Traffic control drop trace.
void CreateOnOffFlow(AddressValue remoteAddress, Ptr< Node > sender, float stopTime)
Create a On Off Flow application.
static void TraceSojourn(std::string sojournTrFileName)
Setup for Traffic Control Sojourn time tracking.
static void TraceEveryDrop(std::string everyDropTrFileName)
Setup for Traffic Control drop tracking.
static void TraceQueueLength(std::string queueLengthTrFileName)
Setup for Traffic Control Queue length tracking.
static void QueueLengthTracer(Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
Traffic Control Queue length tracker.
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
@ LOG_LEVEL_FUNCTION
LOG_FUNCTION and above.
uint32_t pktSize
packet size used for the simulation (in bytes)