53 #include "ns3/core-module.h"
54 #include "ns3/network-module.h"
55 #include "ns3/internet-module.h"
56 #include "ns3/point-to-point-module.h"
57 #include "ns3/applications-module.h"
58 #include "ns3/config-store-module.h"
59 #include "ns3/error-model.h"
60 #include "ns3/tcp-header.h"
61 #include "ns3/udp-header.h"
63 #include "ns3/event-id.h"
64 #include "ns3/ipv4-global-routing-helper.h"
73 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
80 if (cwndTrFileName.compare (
"") == 0)
95 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
102 if (sojournTrFileName.compare (
"") == 0)
117 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
124 if (queueLengthTrFileName.compare (
"") == 0)
126 NS_LOG_DEBUG (
"No trace file for queue length provided");
146 if (everyDropTrFileName.compare (
"") == 0)
148 NS_LOG_DEBUG (
"No trace file for every drop event provided");
161 if (oldVal ==
false && newVal ==
true)
166 else if (oldVal ==
true && newVal ==
false)
177 if (dropStateTrFileName.compare (
"") == 0)
179 NS_LOG_DEBUG (
"No trace file for dropping state provided");
212 int main (
int argc,
char *argv[])
214 std::string serverCmtsDelay =
"15ms";
215 std::string cmtsRouterDelay =
"6ms";
216 std::string routerHostDelay =
"0.1ms";
217 std::string serverLanDataRate =
"10Gbps";
218 std::string cmtsLanDataRate =
"10Gbps";
219 std::string cmtsWanDataRate =
"22Mbps";
220 std::string routerWanDataRate =
"5Mbps";
221 std::string routerLanDataRate =
"10Gbps";
222 std::string hostLanDataRate =
"10Gbps";
224 std::string routerWanQueueType =
"CoDel";
225 uint32_t pktSize = 1458;
226 uint32_t queueSize = 1000;
227 uint32_t numOfUpLoadBulkFlows = 1;
228 uint32_t numOfDownLoadBulkFlows = 1;
229 uint32_t numOfUpLoadOnOffFlows = 1;
230 uint32_t numOfDownLoadOnOffFlows = 1;
231 bool isPcapEnabled =
true;
234 float simDuration = 60;
236 std::string fileNamePrefix =
"codel-vs-droptail-asymmetric";
240 cmd.
AddValue (
"serverCmtsDelay",
"Link delay between server and CMTS", serverCmtsDelay);
241 cmd.
AddValue (
"cmtsRouterDelay",
"Link delay between CMTS and rounter", cmtsRouterDelay);
242 cmd.
AddValue (
"routerHostDelay",
"Link delay between router and host", routerHostDelay);
243 cmd.
AddValue (
"serverLanDataRate",
"Server LAN net device data rate", serverLanDataRate);
244 cmd.
AddValue (
"cmtsLanDataRate",
"CMTS LAN net device data rate", cmtsLanDataRate);
245 cmd.
AddValue (
"cmtsWanDataRate",
"CMTS WAN net device data rate", cmtsWanDataRate);
246 cmd.
AddValue (
"routerWanDataRate",
"Router WAN net device data rate", routerWanDataRate);
247 cmd.
AddValue (
"routerLanDataRate",
"Router LAN net device data rate", routerLanDataRate);
248 cmd.
AddValue (
"hostLanDataRate",
"Host LAN net device data rate", hostLanDataRate);
249 cmd.
AddValue (
"routerWanQueueType",
"Router WAN net device queue type", routerWanQueueType);
250 cmd.
AddValue (
"queueSize",
"Queue size in packets", queueSize);
251 cmd.
AddValue (
"pktSize",
"Packet size in bytes", pktSize);
252 cmd.
AddValue (
"numOfUpLoadBulkFlows",
"Number of upload bulk transfer flows", numOfUpLoadBulkFlows);
253 cmd.
AddValue (
"numOfDownLoadBulkFlows",
"Number of download bulk transfer flows", numOfDownLoadBulkFlows);
254 cmd.
AddValue (
"numOfUpLoadOnOffFlows",
"Number of upload OnOff flows", numOfUpLoadOnOffFlows);
255 cmd.
AddValue (
"numOfDownLoadOnOffFlows",
"Number of download OnOff flows", numOfDownLoadOnOffFlows);
256 cmd.
AddValue (
"startTime",
"Simulation start time", startTime);
257 cmd.
AddValue (
"simDuration",
"Simulation duration in seconds", simDuration);
258 cmd.
AddValue (
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
259 cmd.
AddValue (
"logging",
"Flag to enable/disable logging", logging);
260 cmd.
Parse (argc, argv);
262 float stopTime = startTime + simDuration;
264 std::string pcapFileName = fileNamePrefix +
"-" + routerWanQueueType;
265 std::string cwndTrFileName = fileNamePrefix +
"-" + routerWanQueueType +
"-cwnd" +
".tr";
266 std::string attributeFileName = fileNamePrefix +
"-" + routerWanQueueType +
".attr";
267 std::string sojournTrFileName = fileNamePrefix +
"-" + routerWanQueueType +
"-sojourn" +
".tr";
268 std::string queueLengthTrFileName = fileNamePrefix +
"-" + routerWanQueueType +
"-length" +
".tr";
269 std::string everyDropTrFileName = fileNamePrefix +
"-" + routerWanQueueType +
"-drop" +
".tr";
270 std::string dropStateTrFileName = fileNamePrefix +
"-" + routerWanQueueType +
"-drop-state" +
".tr";
309 NS_LOG_INFO (
"Install Internet stack on all nodes");
313 NS_LOG_INFO (
"Create channels and install net devices on nodes");
321 serverLanDev->SetAttribute (
"DataRate",
StringValue (serverLanDataRate));
330 cmtsWanDev->SetAttribute (
"DataRate",
StringValue (cmtsWanDataRate));
333 DynamicCast<DropTailQueue> (queue)->SetAttribute (
"MaxBytes",
UintegerValue (256000));
336 routerWanDev->SetAttribute (
"DataRate",
StringValue (routerWanDataRate));
337 if (routerWanQueueType.compare (
"DropTail") == 0)
339 Ptr<Queue> dropTail = CreateObject<DropTailQueue> ();
340 routerWanDev->SetQueue (dropTail);
342 else if (routerWanQueueType.compare (
"CoDel") == 0)
344 Ptr<Queue> codel = CreateObject<CoDelQueue> ();
345 routerWanDev->SetQueue (codel);
353 routerLanDev->SetAttribute (
"DataRate",
StringValue (routerLanDataRate));
359 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
361 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
363 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
370 uint16_t port1 = 50000;
377 while (numOfDownLoadBulkFlows)
380 numOfDownLoadBulkFlows--;
383 while (numOfDownLoadOnOffFlows)
386 numOfDownLoadOnOffFlows--;
390 uint16_t port2 = 50001;
397 while (numOfUpLoadBulkFlows)
400 numOfUpLoadBulkFlows--;
403 while (numOfUpLoadOnOffFlows)
406 numOfUpLoadOnOffFlows--;
411 if (routerWanQueueType.compare (
"CoDel") == 0)
holds a vector of ns3::Application pointers.
Doxygen introspection did not find any typical Config paths.
Simulation virtual time values and global simulation resolution.
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
void CreateBulkFlow(AddressValue remoteAddress, Ptr< Node > sender, uint32_t pktSize, float stopTime)
holds a vector of std::pair of Ptr and interface index.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
static void TraceQueueLength(std::string queueLengthTrFileName)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
static void DroppingStateTracer(Ptr< OutputStreamWrapper >stream, bool oldVal, bool newVal)
static void Run(void)
Run the simulation until one of:
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
static void TraceCwnd(std::string cwndTrFileName)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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. ...
Build a set of PointToPointNetDevice objects.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
static void SojournTracer(Ptr< OutputStreamWrapper >stream, Time oldval, Time newval)
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
a polymophic address class
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr
void CreateOnOffFlow(AddressValue remoteAddress, Ptr< Node > sender, float stopTime)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
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 ...
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
static void Bind(std::string name, const AttributeValue &value)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
static void TraceEveryDrop(std::string everyDropTrFileName)
void ConfigureDefaults(void)
Use number of bytes for maximum queue size.
void SetDefault(std::string name, const AttributeValue &value)
static void QueueLengthTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
keep track of a set of node pointers.
int main(int argc, char *argv[])
static Time Now(void)
Return the "current simulation time".
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
void ConfigureAttributes(void)
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static void TraceSojourn(std::string sojournTrFileName)
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void TraceDroppingState(std::string dropStateTrFileName)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes...
static void CwndTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
void SetAttribute(std::string name, const AttributeValue &value)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
static void EveryDropTracer(Ptr< OutputStreamWrapper >stream, Ptr< const Packet > p)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const