31 #include "ns3/core-module.h"
32 #include "ns3/point-to-point-module.h"
33 #include "ns3/internet-module.h"
34 #include "ns3/applications-module.h"
35 #include "ns3/network-module.h"
36 #include "ns3/packet-sink.h"
37 #include "ns3/flow-monitor-module.h"
44 main (
int argc,
char *argv[])
48 uint32_t maxBytes = 0;
49 uint32_t TCPFlows = 1;
50 bool isPacingEnabled =
true;
51 std::string pacingRate =
"4Gbps";
53 uint32_t maxPackets = 0;
56 cmd.
AddValue (
"tracing",
"Flag to enable/disable tracing", tracing);
58 "Total number of bytes for application to send", maxBytes);
60 "Total number of bytes for application to send", maxPackets);
61 cmd.
AddValue (
"TCPFlows",
"Number of application flows between sender and receiver", TCPFlows);
62 cmd.
AddValue (
"Pacing",
"Flag to enable/disable pacing in TCP", isPacingEnabled);
63 cmd.
AddValue (
"Sack",
"Flag to enable/disable sack in TCP", isSack);
64 cmd.
AddValue (
"PacingRate",
"Max Pacing Rate in bps", pacingRate);
65 cmd.
Parse (argc, argv);
69 maxBytes = 500 * maxPackets;
86 devices = pointToPoint.
Install (nodes);
93 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
100 for (uint32_t iterator = 0; iterator < TCPFlows; iterator++)
102 uint16_t
port = 10000 + iterator;
108 sourceApps.
Add (source.Install (nodes.
Get (0)));
137 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
145 std::cout <<
" Tx Packets: " << i->second.txPackets <<
"\n";
146 std::cout <<
" Tx Bytes: " << i->second.txBytes <<
"\n";
147 std::cout <<
" TxOffered: " << i->second.txBytes * 8.0 / 9.0 / 1000 / 1000 <<
" Mbps\n";
148 std::cout <<
" Rx Packets: " << i->second.rxPackets <<
"\n";
149 std::cout <<
" Rx Bytes: " << i->second.rxBytes <<
"\n";
150 std::cout <<
" Throughput: " << i->second.rxBytes * 8.0 / 9.0 / 1000 / 1000 <<
" Mbps\n";
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
const FlowStatsContainer & GetFlowStats() const
Retrieve all collected the flow statistics.
static Ipv4Address GetAny(void)
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
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.
Hold variables of type string.
void CheckForLostPackets()
Check right now for packets that appear to be lost.
NetDeviceContainer Install(NodeContainer c)
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Ipv4Address destinationAddress
Destination address.
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.
std::map< FlowId, FlowStats > FlowStatsContainer
Container: FlowId, FlowStats.
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 ...
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
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)
Execute the events scheduled with ScheduleDestroy().
Ptr< FlowClassifier > GetClassifier()
Retrieve the FlowClassifier object for IPv4 created by the Install* methods.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Helper to enable IP flow monitoring on a set of Nodes.
Structure to classify a packet.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
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)
Tell the Simulator the calling event should be the last one executed.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
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 EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ipv4Address sourceAddress
Source address.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const