|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
86 #include "ns3/core-module.h"
87 #include "ns3/point-to-point-module.h"
88 #include "ns3/internet-module.h"
89 #include "ns3/applications-module.h"
90 #include "ns3/network-module.h"
91 #include "ns3/packet-sink.h"
92 #include "ns3/flow-monitor-module.h"
93 #include "ns3/ipv4-global-routing-helper.h"
94 #include "ns3/traffic-control-module.h"
146 main (
int argc,
char *argv[])
150 uint32_t maxBytes = 0;
151 std::string transportProtocol =
"ns3::TcpCubic";
154 DataRate bottleneckBandwidth (
"10Mbps");
156 DataRate regLinkBandwidth =
DataRate (4 * bottleneckBandwidth.GetBitRate ());
160 bool isPacingEnabled =
true;
162 bool useQueueDisc =
true;
163 bool shouldPaceInitialWindow =
true;
171 cmd.AddValue (
"tracing",
"Flag to enable/disable Ascii and Pcap tracing",
tracing);
172 cmd.AddValue (
"maxBytes",
"Total number of bytes for application to send", maxBytes);
173 cmd.AddValue (
"isPacingEnabled",
"Flag to enable/disable pacing in TCP", isPacingEnabled);
174 cmd.AddValue (
"maxPacingRate",
"Max Pacing Rate", maxPacingRate);
175 cmd.AddValue (
"useEcn",
"Flag to enable/disable ECN", useEcn);
176 cmd.AddValue (
"useQueueDisc",
"Flag to enable/disable queue disc on bottleneck", useQueueDisc);
177 cmd.AddValue (
"shouldPaceInitialWindow",
"Flag to enable/disable pacing of TCP initial window", shouldPaceInitialWindow);
178 cmd.AddValue (
"simulationEndTime",
"Simulation end time", simulationEndTime);
179 cmd.Parse (argc, argv);
230 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
233 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
236 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
239 ipv4.
SetBase (
"10.1.4.0",
"255.255.255.0");
242 ipv4.
SetBase (
"10.1.5.0",
"255.255.255.0");
250 uint16_t sinkPort = 8080;
258 sinkApps4.
Stop (simulationEndTime);
260 sinkApps5.
Stop (simulationEndTime);
276 sourceApps0.
Stop (simulationEndTime);
278 sourceApps1.
Stop (simulationEndTime);
287 cwndStream.open (
"tcp-dynamic-pacing-cwnd.dat", std::ios::out);
288 cwndStream <<
"#Time(s) Congestion Window (B)" << std::endl;
290 pacingRateStream.open (
"tcp-dynamic-pacing-pacing-rate.dat", std::ios::out);
293 ssThreshStream.open (
"tcp-dynamic-pacing-ssthresh.dat", std::ios::out);
294 ssThreshStream <<
"#Time(s) Slow Start threshold (B)" << std::endl;
311 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
316 std::cout <<
" Tx Packets: " << i->second.txPackets <<
"\n";
317 std::cout <<
" Tx Bytes: " << i->second.txBytes <<
"\n";
318 std::cout <<
" TxOffered: " << i->second.txBytes * 8.0 / simulationEndTime.
GetSeconds () / 1000 / 1000 <<
" Mbps\n";
319 std::cout <<
" Rx Packets: " << i->second.rxPackets <<
"\n";
320 std::cout <<
" Rx Bytes: " << i->second.rxBytes <<
"\n";
321 std::cout <<
" Throughput: " << i->second.rxBytes * 8.0 / simulationEndTime.
GetSeconds () / 1000 / 1000 <<
" Mbps\n";
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Parse command-line arguments.
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
AttributeValue implementation for Boolean.
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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static Time Now(void)
Return the current simulation virtual time.
bool tracing
Flag to enable/disable generation of tracing files.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ipv4Address sourceAddress
Source address.
static void CwndTracer(uint32_t oldval, uint32_t newval)
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
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 ...
static void TxTracer(Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interface)
NetDeviceContainer Install(NodeContainer c)
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Structure to classify a packet.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Hold variables of type enum.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Class for representing data rates.
static void RxTracer(Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interface)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Helper to enable IP flow monitoring on a set of Nodes.
Ipv4Address destinationAddress
Destination address.
std::map< FlowId, FlowStats > FlowStatsContainer
Container: FlowId, FlowStats.
AttributeValue implementation for TypeId.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
QueueDiscContainer Install(NetDeviceContainer c)
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
a polymophic address class
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
std::ofstream ssThreshStream
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Ptr< FlowClassifier > GetClassifier()
Retrieve the FlowClassifier object for IPv4 created by the Install* methods.
static void SsThreshTracer(uint32_t oldval, uint32_t newval)
uint64_t GetBitRate() const
Get the underlying bitrate.
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...
static void Run(void)
Run the simulation.
static void PacingRateTracer(DataRate oldval, DataRate newval)
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Manage ASCII trace files for device models.
std::ofstream pacingRateStream
std::ofstream packetTraceStream
static Ipv4Address GetAny(void)
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
Build a set of QueueDisc objects.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
holds a vector of ns3::Application pointers.
AttributeValue implementation for Time.
Build a set of PointToPointNetDevice objects.
keep track of a set of node pointers.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
const FlowStatsContainer & GetFlowStats() const
Retrieve all collected the flow statistics.
aggregate IP/TCP/UDP functionality to existing Nodes.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
void CheckForLostPackets()
Check right now for packets that appear to be lost.
void ConnectSocketTraces(void)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.