54 #include "ns3/core-module.h"
55 #include "ns3/network-module.h"
56 #include "ns3/internet-module.h"
57 #include "ns3/point-to-point-module.h"
58 #include "ns3/applications-module.h"
59 #include "ns3/config-store-module.h"
60 #include "ns3/error-model.h"
61 #include "ns3/tcp-header.h"
62 #include "ns3/udp-header.h"
64 #include "ns3/event-id.h"
65 #include "ns3/ipv4-global-routing-helper.h"
66 #include "ns3/traffic-control-module.h"
75 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
82 if (cwndTrFileName.compare (
"") == 0)
97 *stream->
GetStream () << newval << std::endl;
104 if (sojournTrFileName.compare (
"") == 0)
119 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
126 if (queueLengthTrFileName.compare (
"") == 0)
128 NS_LOG_DEBUG (
"No trace file for queue length provided");
148 if (everyDropTrFileName.compare (
"") == 0)
150 NS_LOG_DEBUG (
"No trace file for every drop event provided");
163 if (oldVal ==
false && newVal ==
true)
168 else if (oldVal ==
true && newVal ==
false)
179 if (dropStateTrFileName.compare (
"") == 0)
181 NS_LOG_DEBUG (
"No trace file for dropping state provided");
214 int main (
int argc,
char *argv[])
216 std::string serverCmtsDelay =
"15ms";
217 std::string cmtsRouterDelay =
"6ms";
218 std::string routerHostDelay =
"0.1ms";
219 std::string serverLanDataRate =
"10Gbps";
220 std::string cmtsLanDataRate =
"10Gbps";
221 std::string cmtsWanDataRate =
"22Mbps";
222 std::string routerWanDataRate =
"5Mbps";
223 std::string routerLanDataRate =
"10Gbps";
224 std::string hostLanDataRate =
"10Gbps";
226 std::string routerWanQueueDiscType =
"CoDel";
228 uint32_t queueSize = 1000;
229 uint32_t numOfUpLoadBulkFlows = 1;
230 uint32_t numOfDownLoadBulkFlows = 1;
231 uint32_t numOfUpLoadOnOffFlows = 1;
232 uint32_t numOfDownLoadOnOffFlows = 1;
233 bool isPcapEnabled =
true;
236 float simDuration = 60;
238 std::string fileNamePrefix =
"codel-vs-pfifo-fast-asymmetric";
242 cmd.AddValue (
"serverCmtsDelay",
"Link delay between server and CMTS", serverCmtsDelay);
243 cmd.AddValue (
"cmtsRouterDelay",
"Link delay between CMTS and rounter", cmtsRouterDelay);
244 cmd.AddValue (
"routerHostDelay",
"Link delay between router and host", routerHostDelay);
245 cmd.AddValue (
"serverLanDataRate",
"Server LAN net device data rate", serverLanDataRate);
246 cmd.AddValue (
"cmtsLanDataRate",
"CMTS LAN net device data rate", cmtsLanDataRate);
247 cmd.AddValue (
"cmtsWanDataRate",
"CMTS WAN net device data rate", cmtsWanDataRate);
248 cmd.AddValue (
"routerWanDataRate",
"Router WAN net device data rate", routerWanDataRate);
249 cmd.AddValue (
"routerLanDataRate",
"Router LAN net device data rate", routerLanDataRate);
250 cmd.AddValue (
"hostLanDataRate",
"Host LAN net device data rate", hostLanDataRate);
251 cmd.AddValue (
"routerWanQueueDiscType",
"Router WAN queue disc type: "
252 "PfifoFast, CoDel", routerWanQueueDiscType);
253 cmd.AddValue (
"queueSize",
"Queue size in packets", queueSize);
254 cmd.AddValue (
"pktSize",
"Packet size in bytes",
pktSize);
255 cmd.AddValue (
"numOfUpLoadBulkFlows",
"Number of upload bulk transfer flows", numOfUpLoadBulkFlows);
256 cmd.AddValue (
"numOfDownLoadBulkFlows",
"Number of download bulk transfer flows", numOfDownLoadBulkFlows);
257 cmd.AddValue (
"numOfUpLoadOnOffFlows",
"Number of upload OnOff flows", numOfUpLoadOnOffFlows);
258 cmd.AddValue (
"numOfDownLoadOnOffFlows",
"Number of download OnOff flows", numOfDownLoadOnOffFlows);
259 cmd.AddValue (
"startTime",
"Simulation start time",
startTime);
260 cmd.AddValue (
"simDuration",
"Simulation duration in seconds", simDuration);
261 cmd.AddValue (
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
262 cmd.AddValue (
"logging",
"Flag to enable/disable logging", logging);
263 cmd.Parse (argc, argv);
267 std::string pcapFileName = fileNamePrefix +
"-" + routerWanQueueDiscType;
268 std::string cwndTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-cwnd" +
".tr";
269 std::string attributeFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
".attr";
270 std::string sojournTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-sojourn" +
".tr";
271 std::string queueLengthTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-length" +
".tr";
272 std::string everyDropTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop" +
".tr";
273 std::string dropStateTrFileName = fileNamePrefix +
"-" + routerWanQueueDiscType +
"-drop-state" +
".tr";
312 NS_LOG_INFO (
"Create channels and install net devices on nodes");
320 serverLanDev->SetAttribute (
"DataRate",
StringValue (serverLanDataRate));
322 cmtsLanDev->SetAttribute (
"DataRate",
StringValue (cmtsLanDataRate));
329 cmtsWanDev->SetAttribute (
"DataRate",
StringValue (cmtsWanDataRate));
331 routerWanDev->SetAttribute (
"DataRate",
StringValue (routerWanDataRate));
338 routerLanDev->SetAttribute (
"DataRate",
StringValue (routerLanDataRate));
340 hostLanDev->SetAttribute (
"DataRate",
StringValue (hostLanDataRate));
342 NS_LOG_INFO (
"Install Internet stack on all nodes");
352 tchPfifo.
Install (serverCmtsDev);
354 if (routerWanQueueDiscType.compare (
"PfifoFast") == 0)
356 tchPfifo.
Install (routerWanDev);
358 else if (routerWanQueueDiscType.compare (
"CoDel") == 0)
360 tchCoDel.
Install (routerWanDev);
367 tchPfifo.
Install (routerHostDev);
371 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
373 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
375 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
382 uint16_t port1 = 50000;
389 while (numOfDownLoadBulkFlows)
392 numOfDownLoadBulkFlows--;
395 while (numOfDownLoadOnOffFlows)
398 numOfDownLoadOnOffFlows--;
402 uint16_t port2 = 50001;
409 while (numOfUpLoadBulkFlows)
412 numOfUpLoadBulkFlows--;
415 while (numOfUpLoadOnOffFlows)
418 numOfUpLoadOnOffFlows--;
423 if (routerWanQueueDiscType.compare (
"CoDel") == 0)
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
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.
AttributeValue implementation for Boolean.
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.
Introspection did not find any typical Config paths.
void ConfigureDefaults(void)
Configure the default values.
void ConfigureAttributes(void)
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.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static Ipv4Address GetAny(void)
static void PopulateRoutingTables(void)
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.
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(void)
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.
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 ...
Build a set of PointToPointNetDevice objects.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) 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 CwndTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
static void TraceCwnd(std::string cwndTrFileName)
static void TraceDroppingState(std::string dropStateTrFileName)
static void QueueLengthTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
static void EveryDropTracer(Ptr< OutputStreamWrapper >stream, Ptr< const QueueDiscItem > item)
static void DroppingStateTracer(Ptr< OutputStreamWrapper >stream, bool oldVal, bool newVal)
void CreateBulkFlow(AddressValue remoteAddress, Ptr< Node > sender, uint32_t pktSize, float stopTime)
static void SojournTracer(Ptr< OutputStreamWrapper >stream, Time newval)
void CreateOnOffFlow(AddressValue remoteAddress, Ptr< Node > sender, float stopTime)
static void TraceSojourn(std::string sojournTrFileName)
static void TraceEveryDrop(std::string everyDropTrFileName)
static void TraceQueueLength(std::string queueLengthTrFileName)
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.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
@ 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.
@ LOG_LEVEL_FUNCTION
LOG_FUNCTION and above.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
uint32_t pktSize
packet size used for the simulation (in bytes)