43 #include "ns3/core-module.h"    44 #include "ns3/network-module.h"    45 #include "ns3/internet-module.h"    46 #include "ns3/point-to-point-module.h"    47 #include "ns3/applications-module.h"    48 #include "ns3/traffic-control-module.h"    51 std::string 
dir = 
"results/";
    63   std::ofstream fPlotQueue (std::stringstream (
dir + 
"queue-size.dat").str ().c_str (), std::ios::out | std::ios::app);
    72   std::ofstream fPlotQueue (
dir + 
"cwndTraces/n0.dat", std::ios::out | std::ios::app);
    94                       uint32_t nodeId, uint32_t cwndWindow,
   114 int main (
int argc, 
char *argv[])
   117   std::string socketFactory = 
"ns3::TcpSocketFactory";
   118   std::string tcpTypeId = 
"ns3::TcpLinuxReno";
   119   std::string qdiscTypeId = 
"ns3::FifoQueueDisc";
   121   uint32_t delAckCount = 1;
   122   std::string recovery = 
"ns3::TcpClassicRecovery";
   125   cmd.AddValue (
"tcpTypeId", 
"TCP variant to use (e.g., ns3::TcpNewReno, ns3::TcpLinuxReno, etc.)", tcpTypeId);
   126   cmd.AddValue (
"qdiscTypeId", 
"Queue disc for gateway (e.g., ns3::CoDelQueueDisc)", qdiscTypeId);
   127   cmd.AddValue (
"segmentSize", 
"TCP segment size (bytes)", 
segmentSize);
   128   cmd.AddValue (
"delAckCount", 
"Delayed ack count", delAckCount);
   129   cmd.AddValue (
"enableSack", 
"Flag to enable/disable sack in TCP", isSack);
   130   cmd.AddValue (
"stopTime", 
"Stop time for applications / simulation time will be stopTime", 
stopTime);
   131   cmd.AddValue (
"recovery", 
"Recovery algorithm type to use (e.g., ns3::TcpPrrRecovery", recovery);
   132   cmd.Parse (argc, argv);
   139   if (tcpTypeId.compare (
"ns3::TcpWestwoodPlus") == 0)
   159   std::vector <NetDeviceContainer> leftToRouter;
   160   std::vector <NetDeviceContainer> routerToRight;
   172   leftToRouter.push_back (pointToPointLeaf.
Install (leftNodes.
Get (0), routers.
Get (0)));
   173   routerToRight.push_back (pointToPointLeaf.
Install (routers.
Get (1), rightNodes.
Get (0)));
   177   internetStack.
Install (leftNodes);
   178   internetStack.
Install (rightNodes);
   179   internetStack.
Install (routers);
   185   ipAddresses.NewNetwork ();
   187   std::vector <Ipv4InterfaceContainer> leftToRouterIPAddress;
   188   leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [0]));
   189   ipAddresses.NewNetwork ();
   191   std::vector <Ipv4InterfaceContainer> routerToRightIPAddress;
   192   routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [0]));
   215   if ((stat (
dir.c_str (), &buffer)) == 0)
   217       std::string dirToRemove = 
"rm -rf " + 
dir;
   218       retVal = system (dirToRemove.c_str ());
   221   std::string dirToSave = 
"mkdir -p " + 
dir;
   222   retVal = system (dirToSave.c_str ());
   224   retVal = system ((dirToSave + 
"/pcap/").c_str ());
   226   retVal = system ((dirToSave + 
"/queueTraces/").c_str ());
   228   retVal = system ((dirToSave + 
"/cwndTraces/").c_str ());
   252   streamWrapper = asciiTraceHelper.CreateFileStream (
dir + 
"/queueTraces/drop-0.dat");
   256   uint16_t 
port = 50000;
   269   std::ofstream myfile;
   270   myfile.open (
dir + 
"queueStats.txt", std::fstream::in | std::fstream::out | std::fstream::app);
   272   myfile << 
"Stat for Queue 1";
   277   myfile.open (
dir + 
"config.txt", std::fstream::in | std::fstream::out | std::fstream::app);
   278   myfile << 
"qdiscTypeId " << qdiscTypeId << 
"\n";
   279   myfile << 
"stream  " << stream << 
"\n";
   281   myfile << 
"delAckCount " << delAckCount << 
"\n";
 
holds a vector of ns3::Application pointers. 
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay. 
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit. 
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<Ipv4> 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. 
uint32_t GetValue() const
Get the underlying value. 
NetDeviceContainer Install(NodeContainer c)
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node. 
static void DropAtQueue(Ptr< OutputStreamWrapper > stream, Ptr< const QueueDiscItem > item)
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise. 
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument. 
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices...
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit. 
static void Run(void)
Run the simulation. 
aggregate IP/TCP/UDP functionality to existing Nodes. 
#define NS_UNUSED(x)
Mark a local variable as unused. 
void TraceCwnd(uint32_t node, uint32_t cwndWindow, Callback< void, uint32_t, uint32_t > CwndTrace)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name. 
Build a set of PointToPointNetDevice objects. 
void Uninstall(NetDeviceContainer c)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper. 
Holds a vector of ns3::QueueDisc pointers. 
static void CwndChange(uint32_t oldCwnd, uint32_t newCwnd)
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 ...
Hold variables of type enum. 
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now. 
void InstallPacketSink(Ptr< Node > node, uint16_t port, std::string socketFactory)
Hold an unsigned integer type. 
holds a vector of ns3::NetDevice pointers 
  AttributeValue implementation for TypeId. 
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Build a set of QueueDisc objects. 
void InstallBulkSend(Ptr< Node > node, Ipv4Address address, uint16_t port, std::string socketFactory, uint32_t nodeId, uint32_t cwndWindow, Callback< void, uint32_t, uint32_t > CwndTrace)
const Stats & GetStats(void)
Retrieve all the collected statistics. 
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. 
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...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy(). 
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
keep track of a set of node pointers. 
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index. 
static TypeId GetTypeId(void)
Get the type ID. 
static Time Now(void)
Return the current simulation virtual time. 
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper. 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class. 
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message. 
static void Stop(void)
Tell the Simulator the calling event should be the last one executed. 
Time Seconds(double value)
Construct a Time in the indicated unit. 
void SetDefault(std::string name, const AttributeValue &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index. 
void CheckQueueSize(Ptr< QueueDisc > queue)
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 CwndTrace(Ptr< OutputStreamWrapper > stream, uint32_t oldCwnd, uint32_t newCwnd)
a unique identifier for an interface. 
void Add(QueueDiscContainer other)
Append the contents of another QueueDiscContainer to the end of this container. 
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper. 
static TypeId LookupByName(std::string name)
Get a TypeId by name.