27#include "ns3/applications-module.h"
28#include "ns3/core-module.h"
29#include "ns3/internet-module.h"
30#include "ns3/network-module.h"
31#include "ns3/point-to-point-module.h"
32#include "ns3/traffic-control-module.h"
40std::string
dir =
"results/";
51 uint32_t qSize = queue->GetCurrentSize().GetValue();
77 "/$ns3::TcpL4Protocol/SocketList/" +
78 std::to_string(cwndWindow) +
"/CongestionWindow",
87 std::string socketFactory,
111main(
int argc,
char* argv[])
114 std::string socketFactory =
"ns3::TcpSocketFactory";
115 std::string tcpTypeId =
"ns3::TcpLinuxReno";
116 std::string qdiscTypeId =
"ns3::FifoQueueDisc";
119 std::string recovery =
"ns3::TcpClassicRecovery";
122 cmd.AddValue(
"tcpTypeId",
123 "TCP variant to use (e.g., ns3::TcpNewReno, ns3::TcpLinuxReno, etc.)",
125 cmd.AddValue(
"qdiscTypeId",
"Queue disc for gateway (e.g., ns3::CoDelQueueDisc)", qdiscTypeId);
126 cmd.AddValue(
"segmentSize",
"TCP segment size (bytes)",
segmentSize);
127 cmd.AddValue(
"delAckCount",
"Delayed ack count", delAckCount);
128 cmd.AddValue(
"enableSack",
"Flag to enable/disable sack in TCP", isSack);
129 cmd.AddValue(
"stopTime",
130 "Stop time for applications / simulation time will be stopTime",
132 cmd.AddValue(
"recovery",
"Recovery algorithm type to use (e.g., ns3::TcpPrrRecovery", recovery);
133 cmd.Parse(argc, argv);
137 "TypeId " << qdiscTypeId <<
" not found");
144 "TypeId " << tcpTypeId <<
" not found");
156 std::vector<NetDeviceContainer> leftToRouter;
157 std::vector<NetDeviceContainer> routerToRight;
169 leftToRouter.push_back(pointToPointLeaf.
Install(leftNodes.
Get(0), routers.
Get(0)));
170 routerToRight.push_back(pointToPointLeaf.
Install(routers.
Get(1), rightNodes.
Get(0)));
174 internetStack.
Install(leftNodes);
175 internetStack.
Install(rightNodes);
176 internetStack.
Install(routers);
182 ipAddresses.NewNetwork();
184 std::vector<Ipv4InterfaceContainer> leftToRouterIPAddress;
185 leftToRouterIPAddress.push_back(ipAddresses.Assign(leftToRouter[0]));
186 ipAddresses.NewNetwork();
188 std::vector<Ipv4InterfaceContainer> routerToRightIPAddress;
189 routerToRightIPAddress.push_back(ipAddresses.Assign(routerToRight[0]));
211 int retVal [[maybe_unused]];
212 if ((stat(
dir.c_str(), &buffer)) == 0)
214 std::string dirToRemove =
"rm -rf " +
dir;
215 retVal = system(dirToRemove.c_str());
239 fPlotCwnd.open(
dir +
"cwndTraces/n0.dat", std::ios::out);
252 uint16_t
port = 50000;
257 routerToRightIPAddress[0].GetAddress(1),
271 std::ofstream myfile;
272 myfile.open(
dir +
"queueStats.txt", std::fstream::in | std::fstream::out | std::fstream::app);
274 myfile <<
"Stat for Queue 1";
279 myfile.open(
dir +
"config.txt", std::fstream::in | std::fstream::out | std::fstream::app);
280 myfile <<
"qdiscTypeId " << qdiscTypeId <<
"\n";
281 myfile <<
"stream " << stream <<
"\n";
283 myfile <<
"delAckCount " << delAckCount <<
"\n";
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.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
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.
Parse command-line arguments.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
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.
holds a vector of ns3::NetDevice pointers
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.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
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 SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
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)
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::QueueDisc pointers.
void Add(QueueDiscContainer other)
Append the contents of another QueueDiscContainer to the end of this container.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
const Stats & GetStats()
Retrieve all the collected statistics.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
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.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
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.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
void Uninstall(NetDeviceContainer c)
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
static void CwndTrace(Ptr< OutputStreamWrapper > stream, uint32_t oldCwnd, uint32_t newCwnd)
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)
void TraceCwnd(uint32_t node, uint32_t cwndWindow, Callback< void, uint32_t, uint32_t > CwndTrace)
void InstallPacketSink(Ptr< Node > node, uint16_t port, std::string socketFactory)
static void DropAtQueue(Ptr< OutputStreamWrapper > stream, Ptr< const QueueDiscItem > item)
void CheckQueueSize(Ptr< QueueDisc > queue)
static void CwndChange(uint32_t oldCwnd, uint32_t newCwnd)
#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 SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
void MakeDirectories(std::string path)
Create all the directories leading to path.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< PacketSink > sink
Pointer to the packet sink application.