49 #include "ns3/applications-module.h"
50 #include "ns3/config-store.h"
51 #include "ns3/core-module.h"
53 #include "ns3/error-model.h"
54 #include "ns3/event-id.h"
55 #include "ns3/internet-module.h"
56 #include "ns3/ipv4-global-routing-helper.h"
57 #include "ns3/network-module.h"
58 #include "ns3/point-to-point-module.h"
59 #include "ns3/tcp-header.h"
60 #include "ns3/traffic-control-module.h"
61 #include "ns3/udp-header.h"
81 *stream->
GetStream() << oldval <<
" " << newval << std::endl;
93 if (cwndTrFileName.empty())
102 "/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
116 *stream->
GetStream() << newval << std::endl;
128 if (sojournTrFileName.empty())
137 "$ns3::CoDelQueueDisc/SojournTime",
152 *stream->
GetStream() << oldval <<
" " << newval << std::endl;
164 if (queueLengthTrFileName.empty())
166 NS_LOG_DEBUG(
"No trace file for queue length provided");
173 "/NodeList/2/$ns3::TrafficControlLayer/RootQueueDiscList/0/BytesInQueue",
199 if (everyDropTrFileName.empty())
201 NS_LOG_DEBUG(
"No trace file for every drop event provided");
208 "/NodeList/2/$ns3::TrafficControlLayer/RootQueueDiscList/0/Drop",
223 if (!oldVal && newVal)
228 else if (oldVal && !newVal)
244 if (dropStateTrFileName.empty())
246 NS_LOG_DEBUG(
"No trace file for dropping state provided");
253 "$ns3::CoDelQueueDisc/DropState",
297 main(
int argc,
char* argv[])
299 std::string serverCmtsDelay =
"15ms";
300 std::string cmtsRouterDelay =
"6ms";
301 std::string routerHostDelay =
"0.1ms";
302 std::string serverLanDataRate =
"10Gbps";
303 std::string cmtsLanDataRate =
"10Gbps";
304 std::string cmtsWanDataRate =
"22Mbps";
305 std::string routerWanDataRate =
"5Mbps";
306 std::string routerLanDataRate =
"10Gbps";
307 std::string hostLanDataRate =
"10Gbps";
309 std::string routerWanQueueDiscType =
"CoDel";
312 uint32_t numOfUpLoadBulkFlows = 1;
313 uint32_t numOfDownLoadBulkFlows = 1;
314 uint32_t numOfUpLoadOnOffFlows = 1;
315 uint32_t numOfDownLoadOnOffFlows = 1;
316 bool isPcapEnabled =
true;
318 float startTime = 0.1F;
319 float simDuration = 60;
321 std::string fileNamePrefix =
"codel-vs-pfifo-fast-asymmetric";
325 cmd.AddValue(
"serverCmtsDelay",
"Link delay between server and CMTS", serverCmtsDelay);
326 cmd.AddValue(
"cmtsRouterDelay",
"Link delay between CMTS and rounter", cmtsRouterDelay);
327 cmd.AddValue(
"routerHostDelay",
"Link delay between router and host", routerHostDelay);
328 cmd.AddValue(
"serverLanDataRate",
"Server LAN net device data rate", serverLanDataRate);
329 cmd.AddValue(
"cmtsLanDataRate",
"CMTS LAN net device data rate", cmtsLanDataRate);
330 cmd.AddValue(
"cmtsWanDataRate",
"CMTS WAN net device data rate", cmtsWanDataRate);
331 cmd.AddValue(
"routerWanDataRate",
"Router WAN net device data rate", routerWanDataRate);
332 cmd.AddValue(
"routerLanDataRate",
"Router LAN net device data rate", routerLanDataRate);
333 cmd.AddValue(
"hostLanDataRate",
"Host LAN net device data rate", hostLanDataRate);
334 cmd.AddValue(
"routerWanQueueDiscType",
335 "Router WAN queue disc type: "
337 routerWanQueueDiscType);
338 cmd.AddValue(
"queueSize",
"Queue size in packets",
queueSize);
339 cmd.AddValue(
"pktSize",
"Packet size in bytes",
pktSize);
340 cmd.AddValue(
"numOfUpLoadBulkFlows",
341 "Number of upload bulk transfer flows",
342 numOfUpLoadBulkFlows);
343 cmd.AddValue(
"numOfDownLoadBulkFlows",
344 "Number of download bulk transfer flows",
345 numOfDownLoadBulkFlows);
346 cmd.AddValue(
"numOfUpLoadOnOffFlows",
"Number of upload OnOff flows", numOfUpLoadOnOffFlows);
347 cmd.AddValue(
"numOfDownLoadOnOffFlows",
348 "Number of download OnOff flows",
349 numOfDownLoadOnOffFlows);
350 cmd.AddValue(
"startTime",
"Simulation start time", startTime);
351 cmd.AddValue(
"simDuration",
"Simulation duration in seconds", simDuration);
352 cmd.AddValue(
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
353 cmd.AddValue(
"logging",
"Flag to enable/disable logging", logging);
354 cmd.Parse(argc, argv);
356 float stopTime = startTime + simDuration;
358 std::string pcapFileName = fileNamePrefix +
"-" + routerWanQueueDiscType;
359 std::string cwndTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-cwnd" +
".tr";
360 std::string attributeFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
".attr";
361 std::string sojournTrFileName =
362 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-sojourn" +
".tr";
363 std::string queueLengthTrFileName =
364 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-length" +
".tr";
365 std::string everyDropTrFileName =
366 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop" +
".tr";
367 std::string dropStateTrFileName =
368 fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop-state" +
".tr";
407 NS_LOG_INFO(
"Create channels and install net devices on nodes");
415 DynamicCast<PointToPointNetDevice>(serverCmtsDev.
Get(0));
416 serverLanDev->SetAttribute(
"DataRate",
StringValue(serverLanDataRate));
418 DynamicCast<PointToPointNetDevice>(serverCmtsDev.
Get(1));
419 cmtsLanDev->SetAttribute(
"DataRate",
StringValue(cmtsLanDataRate));
426 DynamicCast<PointToPointNetDevice>(cmtsRouterDev.
Get(0));
427 cmtsWanDev->SetAttribute(
"DataRate",
StringValue(cmtsWanDataRate));
429 DynamicCast<PointToPointNetDevice>(cmtsRouterDev.
Get(1));
430 routerWanDev->SetAttribute(
"DataRate",
StringValue(routerWanDataRate));
437 DynamicCast<PointToPointNetDevice>(routerHostDev.
Get(0));
438 routerLanDev->SetAttribute(
"DataRate",
StringValue(routerLanDataRate));
440 DynamicCast<PointToPointNetDevice>(routerHostDev.
Get(1));
441 hostLanDev->SetAttribute(
"DataRate",
StringValue(hostLanDataRate));
443 NS_LOG_INFO(
"Install Internet stack on all nodes");
453 tchPfifo.
Install(serverCmtsDev);
455 if (routerWanQueueDiscType ==
"PfifoFast")
457 tchPfifo.
Install(routerWanDev);
459 else if (routerWanQueueDiscType ==
"CoDel")
461 tchCoDel.
Install(routerWanDev);
468 tchPfifo.
Install(routerHostDev);
472 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
474 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
476 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
483 uint16_t port1 = 50000;
490 while (numOfDownLoadBulkFlows)
493 numOfDownLoadBulkFlows--;
496 while (numOfDownLoadOnOffFlows)
499 numOfDownLoadOnOffFlows--;
503 uint16_t port2 = 50001;
510 while (numOfUpLoadBulkFlows)
513 numOfUpLoadBulkFlows--;
516 while (numOfUpLoadOnOffFlows)
519 numOfUpLoadOnOffFlows--;
524 if (routerWanQueueDiscType ==
"CoDel")
532 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.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
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.
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.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Build a set of PointToPointNetDevice objects.
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.
@ PACKETS
Use number of packets for queue size.
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_FUNCTION
LOG_FUNCTION and above.
uint32_t pktSize
packet size used for the simulation (in bytes)