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 () << oldval << 
" " << 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";           
 
  227   uint32_t pktSize = 1458;                
 
  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);
 
  265   float stopTime = startTime + simDuration;
 
  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));
 
  329   cmtsWanDev->SetAttribute (
"DataRate", 
StringValue (cmtsWanDataRate));
 
  338   routerLanDev->SetAttribute (
"DataRate", 
StringValue (routerLanDataRate));
 
  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)
 
holds a vector of ns3::Application pointers. 
 
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)
 
AttributeValue implementation for Boolean. 
 
QueueDiscContainer Install(NetDeviceContainer c)
 
Class for representing queue sizes. 
 
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
 
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)
 
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument. 
 
void CreateBulkFlow(AddressValue remoteAddress, Ptr< Node > sender, uint32_t pktSize, float stopTime)
 
static void SojournTracer(Ptr< OutputStreamWrapper >stream, Time oldval, Time newval)
 
static void Run(void)
Run the simulation. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
aggregate IP/TCP/UDP functionality to existing Nodes. 
 
void CreateOnOffFlow(AddressValue remoteAddress, Ptr< Node > sender, float stopTime)
 
#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...
 
static void QueueLengthTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
 
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. 
 
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
 
static void DroppingStateTracer(Ptr< OutputStreamWrapper >stream, bool oldVal, bool newVal)
 
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 LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component. 
 
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 EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay. 
 
void InstallAll(void) const 
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation. 
 
Hold an unsigned integer type. 
 
Use number of packets for queue size. 
 
holds a vector of ns3::NetDevice pointers 
 
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
 
static void TraceQueueLength(std::string queueLengthTrFileName)
 
Build a set of QueueDisc objects. 
 
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...
 
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
 
static void EveryDropTracer(Ptr< OutputStreamWrapper >stream, Ptr< const QueueDiscItem > item)
 
Parse command-line arguments. 
 
static void CwndTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
 
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy(). 
 
void ConfigureDefaults(void)
Configure the default values. 
 
static void TraceCwnd(std::string cwndTrFileName)
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
keep track of a set of node pointers. 
 
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
 
static void TraceSojourn(std::string sojournTrFileName)
 
static Time Now(void)
Return the current simulation virtual time. 
 
static void TraceEveryDrop(std::string everyDropTrFileName)
 
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper. 
 
static void TraceDroppingState(std::string dropStateTrFileName)
 
AttributeValue implementation for 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)
Configure the attribute values. 
 
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
 
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD. 
 
static void Stop(void)
Tell the Simulator the calling event should be the last one executed. 
 
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. 
 
void SetDefault(std::string name, const AttributeValue &value)
 
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...
 
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful. 
 
ApplicationContainer Install(NodeContainer c) const 
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
 
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. 
 
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const