39 #include "ns3/core-module.h"
40 #include "ns3/network-module.h"
41 #include "ns3/internet-module.h"
42 #include "ns3/point-to-point-module.h"
43 #include "ns3/applications-module.h"
44 #include "ns3/error-model.h"
45 #include "ns3/tcp-header.h"
46 #include "ns3/udp-header.h"
48 #include "ns3/event-id.h"
49 #include "ns3/ipv4-global-routing-helper.h"
58 *stream->
GetStream () << oldval <<
" " << newval << std::endl;
65 if (cwndTrFileName.compare (
"") == 0)
77 int main (
int argc,
char *argv[])
79 std::string bottleneckBandwidth =
"5Mbps";
80 std::string bottleneckDelay =
"5ms";
81 std::string accessBandwidth =
"100Mbps";
82 std::string accessDelay =
"0.1ms";
84 std::string queueType =
"DropTail";
85 uint32_t queueSize = 1000;
86 uint32_t pktSize = 1458;
88 float simDuration = 60;
90 bool isPcapEnabled =
true;
91 std::string pcapFileName =
"pcapFileDropTail.pcap";
92 std::string cwndTrFileName =
"cwndDropTail.tr";
96 cmd.
AddValue (
"bottleneckBandwidth",
"Bottleneck bandwidth", bottleneckBandwidth);
97 cmd.
AddValue (
"bottleneckDelay",
"Bottleneck delay", bottleneckDelay);
98 cmd.
AddValue (
"accessBandwidth",
"Access link bandwidth", accessBandwidth);
99 cmd.
AddValue (
"accessDelay",
"Access link delay", accessDelay);
100 cmd.
AddValue (
"queueType",
"Queue type: DropTail, CoDel", queueType);
101 cmd.
AddValue (
"queueSize",
"Queue size in packets", queueSize);
102 cmd.
AddValue (
"pktSize",
"Packet size in bytes", pktSize);
103 cmd.
AddValue (
"startTime",
"Simulation start time", startTime);
104 cmd.
AddValue (
"simDuration",
"Simulation duration in seconds", simDuration);
105 cmd.
AddValue (
"isPcapEnabled",
"Flag to enable/disable pcap", isPcapEnabled);
106 cmd.
AddValue (
"pcapFileName",
"Name of pcap file", pcapFileName);
107 cmd.
AddValue (
"cwndTrFileName",
"Name of cwnd trace file", cwndTrFileName);
108 cmd.
AddValue (
"logging",
"Flag to enable/disable logging", logging);
109 cmd.
Parse (argc, argv);
111 float stopTime = startTime + simDuration;
145 if (queueType.compare (
"DropTail") == 0)
147 bottleneckLink.
SetQueue (
"ns3::DropTailQueue",
151 else if (queueType.compare (
"CoDel") == 0)
153 bottleneckLink.
SetQueue (
"ns3::CoDelQueue",
167 address.
SetBase (
"10.0.0.0",
"255.255.255.0");
174 devices = accessLink.
Install (source.
Get (0), gateway.
Get (0));
177 devices = bottleneckLink.
Install (gateway.
Get (0), sink.
Get (0));
179 interfaces = address.
Assign (devices);
181 sinkInterface.
Add (interfaces.
Get (1));
186 uint16_t
port = 50000;
211 accessLink.
EnablePcap (pcapFileName,source,
true);
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr and interface stored at the location specified by the index...
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
NetDeviceContainer Install(NodeContainer c)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
void SetQueue(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue())
Each point to point net device must have a queue to pass packets through.
static void Run(void)
Run the simulation until one of:
#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.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
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
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
static void TraceCwnd(std::string cwndTrFileName)
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
hold objects of type ns3::TypeId
static void Bind(std::string name, const AttributeValue &value)
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 Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
static TypeId GetTypeId(void)
Get the type ID.
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
int main(int argc, char *argv[])
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
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)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
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.
static void CwndTracer(Ptr< OutputStreamWrapper >stream, uint32_t oldval, uint32_t newval)
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
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 Add(Ipv4InterfaceContainer other)
Concatenate the entries in the other container with ours.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes...
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
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.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const