36 #include "ns3/applications-module.h"
37 #include "ns3/core-module.h"
39 #include "ns3/error-model.h"
40 #include "ns3/event-id.h"
41 #include "ns3/internet-module.h"
42 #include "ns3/ipv4-global-routing-helper.h"
43 #include "ns3/network-module.h"
44 #include "ns3/point-to-point-module.h"
45 #include "ns3/tcp-header.h"
46 #include "ns3/traffic-control-module.h"
47 #include "ns3/udp-header.h"
67 *stream->
GetStream() << oldval <<
" " << newval << std::endl;
81 if (cwndTrFileName.empty())
90 "/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
96 main(
int argc,
char* argv[])
98 std::string bottleneckBandwidth =
"5Mbps";
99 std::string bottleneckDelay =
"5ms";
100 std::string accessBandwidth =
"100Mbps";
101 std::string accessDelay =
"0.1ms";
103 std::string queueDiscType =
"PfifoFast";
104 uint32_t queueDiscSize = 1000;
107 float startTime = 0.1F;
108 float simDuration = 60;
110 bool isPcapEnabled =
true;
111 std::string pcapFileName =
"pcapFilePfifoFast.pcap";
112 std::string cwndTrFileName =
"cwndPfifoFast.tr";
113 bool logging =
false;
116 cmd.AddValue(
"bottleneckBandwidth",
"Bottleneck bandwidth", bottleneckBandwidth);
117 cmd.AddValue(
"bottleneckDelay",
"Bottleneck delay", bottleneckDelay);
118 cmd.AddValue(
"accessBandwidth",
"Access link bandwidth", accessBandwidth);
119 cmd.AddValue(
"accessDelay",
"Access link delay", accessDelay);
120 cmd.AddValue(
"queueDiscType",
"Bottleneck queue disc type: PfifoFast, CoDel", queueDiscType);
121 cmd.AddValue(
"queueDiscSize",
"Bottleneck queue disc size in packets", queueDiscSize);
122 cmd.AddValue(
"queueSize",
"Devices queue size in packets",
queueSize);
123 cmd.AddValue(
"pktSize",
"Packet size in bytes",
pktSize);
124 cmd.AddValue(
"startTime",
"Simulation start time", startTime);
125 cmd.AddValue(
"simDuration",
"Simulation duration in seconds", simDuration);
126 cmd.AddValue(
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
127 cmd.AddValue(
"pcapFileName",
"Name of pcap file", pcapFileName);
128 cmd.AddValue(
"cwndTrFileName",
"Name of cwnd trace file", cwndTrFileName);
129 cmd.AddValue(
"logging",
"Flag to enable/disable logging", logging);
130 cmd.Parse(argc, argv);
132 float stopTime = startTime + simDuration;
188 address.SetBase(
"10.0.0.0",
"255.255.255.0");
197 devicesAccessLink = accessLink.
Install(source.
Get(0), gateway.
Get(0));
198 tchPfifoFastAccess.
Install(devicesAccessLink);
202 devicesBottleneckLink = bottleneckLink.
Install(gateway.
Get(0),
sink.Get(0));
205 if (queueDiscType ==
"PfifoFast")
207 tchPfifo.
Install(devicesBottleneckLink);
209 else if (queueDiscType ==
"CoDel")
211 tchCoDel.
Install(devicesBottleneckLink);
216 "Invalid queue disc type: Use --queueDiscType=PfifoFast or --queueDiscType=CoDel");
225 uint16_t
port = 50000;
250 accessLink.
EnablePcap(pcapFileName, source,
true);
a polymophic address class
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.
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.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
Parse command-line arguments.
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.
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.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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.
std::ostream * GetStream()
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 EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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)
Class for representing queue sizes.
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 void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
static TypeId GetTypeId()
Get the type ID.
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 TraceCwnd(std::string cwndTrFileName)
Function to enable the Congestion window tracing.
static void CwndTracer(Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
Function called when Congestion Window is changed.
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#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.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
@ PACKETS
Use number of packets for queue size.
Time Seconds(double value)
Construct a Time in the indicated unit.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_LEVEL_INFO
LOG_INFO and above.
uint32_t pktSize
packet size used for the simulation (in bytes)
Ptr< PacketSink > sink
Pointer to the packet sink application.