40 #include "ns3/core-module.h" 41 #include "ns3/network-module.h" 42 #include "ns3/internet-module.h" 43 #include "ns3/point-to-point-module.h" 44 #include "ns3/applications-module.h" 45 #include "ns3/error-model.h" 46 #include "ns3/tcp-header.h" 47 #include "ns3/udp-header.h" 49 #include "ns3/event-id.h" 50 #include "ns3/ipv4-global-routing-helper.h" 51 #include "ns3/traffic-control-module.h" 60 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
67 if (cwndTrFileName.compare (
"") == 0)
79 int main (
int argc,
char *argv[])
81 std::string bottleneckBandwidth =
"5Mbps";
82 std::string bottleneckDelay =
"5ms";
83 std::string accessBandwidth =
"100Mbps";
84 std::string accessDelay =
"0.1ms";
86 std::string queueDiscType =
"PfifoFast";
87 uint32_t queueDiscSize = 1000;
88 uint32_t queueSize = 10;
89 uint32_t pktSize = 1458;
91 float simDuration = 60;
93 bool isPcapEnabled =
true;
94 std::string pcapFileName =
"pcapFilePfifoFast.pcap";
95 std::string cwndTrFileName =
"cwndPfifoFast.tr";
99 cmd.AddValue (
"bottleneckBandwidth",
"Bottleneck bandwidth", bottleneckBandwidth);
100 cmd.AddValue (
"bottleneckDelay",
"Bottleneck delay", bottleneckDelay);
101 cmd.AddValue (
"accessBandwidth",
"Access link bandwidth", accessBandwidth);
102 cmd.AddValue (
"accessDelay",
"Access link delay", accessDelay);
103 cmd.AddValue (
"queueDiscType",
"Bottleneck queue disc type: PfifoFast, CoDel", queueDiscType);
104 cmd.AddValue (
"queueDiscSize",
"Bottleneck queue disc size in packets", queueDiscSize);
105 cmd.AddValue (
"queueSize",
"Devices queue size in packets", queueSize);
106 cmd.AddValue (
"pktSize",
"Packet size in bytes", pktSize);
107 cmd.AddValue (
"startTime",
"Simulation start time",
startTime);
108 cmd.AddValue (
"simDuration",
"Simulation duration in seconds", simDuration);
109 cmd.AddValue (
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
110 cmd.AddValue (
"pcapFileName",
"Name of pcap file", pcapFileName);
111 cmd.AddValue (
"cwndTrFileName",
"Name of cwnd trace file", cwndTrFileName);
112 cmd.AddValue (
"logging",
"Flag to enable/disable logging", logging);
113 cmd.Parse (argc, argv);
162 StringValue (std::to_string(queueDiscSize) +
"p"));
169 address.SetBase (
"10.0.0.0",
"255.255.255.0");
177 devicesAccessLink = accessLink.
Install (source.
Get (0), gateway.
Get (0));
178 tchPfifoFastAccess.
Install (devicesAccessLink);
182 devicesBottleneckLink = bottleneckLink.
Install (gateway.
Get (0),
sink.Get (0));
185 if (queueDiscType.compare (
"PfifoFast") == 0)
187 tchPfifo.
Install (devicesBottleneckLink);
189 else if (queueDiscType.compare (
"CoDel") == 0)
191 tchCoDel.
Install (devicesBottleneckLink);
195 NS_ABORT_MSG (
"Invalid queue disc type: Use --queueDiscType=PfifoFast or --queueDiscType=CoDel");
204 uint16_t
port = 50000;
212 ftp.SetAttribute (
"Remote", remoteAddress);
229 accessLink.
EnablePcap (pcapFileName,source,
true);
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
Class for representing queue sizes.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
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.
NetDeviceContainer Install(NodeContainer c)
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
static void TraceCwnd(std::string cwndTrFileName)
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.
#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...
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.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
a polymophic address class
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
Use number of packets for queue size.
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.
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...
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().
static TypeId GetTypeId(void)
Get the type ID.
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...
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
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...
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
#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)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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 EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.