93#include "ns3/applications-module.h" 
   94#include "ns3/core-module.h" 
   95#include "ns3/internet-module.h" 
   96#include "ns3/network-module.h" 
   97#include "ns3/point-to-point-module.h" 
   98#include "ns3/traffic-control-module.h" 
  120    std::cout << 
"Progress to " << std::fixed << std::setprecision(1)
 
  146    for (std::size_t i = 0; i < 10; i++)
 
  150    for (std::size_t i = 0; i < 20; i++)
 
  154    for (std::size_t i = 0; i < 10; i++)
 
  163    for (std::size_t i = 0; i < 10; i++)
 
  169    for (std::size_t i = 0; i < 20; i++)
 
  175    for (std::size_t i = 0; i < 10; i++)
 
  188    uint64_t sumSquares = 0;
 
  191    for (std::size_t i = 0; i < 10; i++)
 
  196    average = ((sum / 10) * 8 / measurementWindow.
GetSeconds()) / 1e6;
 
  197    fairness = 
static_cast<double>(sum * sum) / (10 * sumSquares);
 
  198    fairnessIndex << 
"Average throughput for S1-R1 flows: " << std::fixed << std::setprecision(2)
 
  199                  << average << 
" Mbps; fairness: " << std::fixed << std::setprecision(3)
 
  200                  << fairness << std::endl;
 
  205    for (std::size_t i = 0; i < 20; i++)
 
  210    average = ((sum / 20) * 8 / measurementWindow.
GetSeconds()) / 1e6;
 
  211    fairness = 
static_cast<double>(sum * sum) / (20 * sumSquares);
 
  212    fairnessIndex << 
"Average throughput for S2-R2 flows: " << std::fixed << std::setprecision(2)
 
  213                  << average << 
" Mbps; fairness: " << std::fixed << std::setprecision(3)
 
  214                  << fairness << std::endl;
 
  219    for (std::size_t i = 0; i < 10; i++)
 
  224    average = ((sum / 10) * 8 / measurementWindow.
GetSeconds()) / 1e6;
 
  225    fairness = 
static_cast<double>(sum * sum) / (10 * sumSquares);
 
  226    fairnessIndex << 
"Average throughput for S3-R1 flows: " << std::fixed << std::setprecision(2)
 
  227                  << average << 
" Mbps; fairness: " << std::fixed << std::setprecision(3)
 
  228                  << fairness << std::endl;
 
  230    for (std::size_t i = 0; i < 10; i++)
 
  234    for (std::size_t i = 0; i < 20; i++)
 
  238    fairnessIndex << 
"Aggregate user-level throughput for flows through T1: " 
  239                  << 
static_cast<double>(sum * 8) / 1e9 << 
" Gbps" << std::endl;
 
  241    for (std::size_t i = 0; i < 10; i++)
 
  245    for (std::size_t i = 0; i < 10; i++)
 
  249    fairnessIndex << 
"Aggregate user-level throughput for flows to R1: " 
  250                  << 
static_cast<double>(sum * 8) / 1e9 << 
" Gbps" << std::endl;
 
  258    Time backlog = 
Seconds(
static_cast<double>(qSize * 1500 * 8) / 1e10); 
 
  270    Time backlog = 
Seconds(
static_cast<double>(qSize * 1500 * 8) / 1e9); 
 
  279main(
int argc, 
char* argv[])
 
  281    std::string outputFilePath = 
".";
 
  282    std::string tcpTypeId = 
"TcpDctcp";
 
  286    bool enableSwitchEcn = 
true;
 
  290    cmd.AddValue(
"tcpTypeId", 
"ns-3 TCP TypeId", tcpTypeId);
 
  291    cmd.AddValue(
"flowStartupWindow",
 
  292                 "startup time window (TCP staggered starts)",
 
  294    cmd.AddValue(
"convergenceTime", 
"convergence time", convergenceTime);
 
  295    cmd.AddValue(
"measurementWindow", 
"measurement window", measurementWindow);
 
  296    cmd.AddValue(
"enableSwitchEcn", 
"enable ECN at switches", enableSwitchEcn);
 
  297    cmd.Parse(argc, argv);
 
  302    Time stopTime = flowStartupWindow + convergenceTime + measurementWindow;
 
  304    Time clientStartTime = startTime;
 
  324    GlobalValue::Bind(
"ChecksumEnabled", 
BooleanValue(
false));
 
  351    std::vector<NetDeviceContainer> S1T1;
 
  353    std::vector<NetDeviceContainer> S2T1;
 
  355    std::vector<NetDeviceContainer> S3T2;
 
  357    std::vector<NetDeviceContainer> R2T2;
 
  362    for (std::size_t i = 0; i < 10; i++)
 
  365        S1T1.push_back(pointToPointSR.
Install(n, T1));
 
  367    for (std::size_t i = 0; i < 20; i++)
 
  370        S2T1.push_back(pointToPointSR.
Install(n, T1));
 
  372    for (std::size_t i = 0; i < 10; i++)
 
  375        S3T2.push_back(pointToPointSR.
Install(n, T2));
 
  377    for (std::size_t i = 0; i < 20; i++)
 
  380        R2T2.push_back(pointToPointSR.
Install(n, T2));
 
  413    for (std::size_t i = 0; i < 10; i++)
 
  415        tchRed1.
Install(S1T1[i].Get(1));
 
  417    for (std::size_t i = 0; i < 20; i++)
 
  419        tchRed1.
Install(S2T1[i].Get(1));
 
  421    for (std::size_t i = 0; i < 10; i++)
 
  423        tchRed1.
Install(S3T2[i].Get(1));
 
  425    for (std::size_t i = 0; i < 20; i++)
 
  427        tchRed1.
Install(R2T2[i].Get(1));
 
  431    std::vector<Ipv4InterfaceContainer> ipS1T1;
 
  433    std::vector<Ipv4InterfaceContainer> ipS2T1;
 
  435    std::vector<Ipv4InterfaceContainer> ipS3T2;
 
  437    std::vector<Ipv4InterfaceContainer> ipR2T2;
 
  439    address.SetBase(
"172.16.1.0", 
"255.255.255.0");
 
  441    address.SetBase(
"192.168.0.0", 
"255.255.255.0");
 
  443    address.SetBase(
"10.1.1.0", 
"255.255.255.0");
 
  444    for (std::size_t i = 0; i < 10; i++)
 
  446        ipS1T1.push_back(
address.Assign(S1T1[i]));
 
  449    address.SetBase(
"10.2.1.0", 
"255.255.255.0");
 
  450    for (std::size_t i = 0; i < 20; i++)
 
  452        ipS2T1.push_back(
address.Assign(S2T1[i]));
 
  455    address.SetBase(
"10.3.1.0", 
"255.255.255.0");
 
  456    for (std::size_t i = 0; i < 10; i++)
 
  458        ipS3T2.push_back(
address.Assign(S3T2[i]));
 
  461    address.SetBase(
"10.4.1.0", 
"255.255.255.0");
 
  462    for (std::size_t i = 0; i < 20; i++)
 
  464        ipR2T2.push_back(
address.Assign(R2T2[i]));
 
  468    Ipv4GlobalRoutingHelper::PopulateRoutingTables();
 
  471    std::vector<Ptr<PacketSink>> r2Sinks;
 
  473    for (std::size_t i = 0; i < 20; i++)
 
  475        uint16_t 
port = 50000 + i;
 
  480        r2Sinks.push_back(packetSink);
 
  481        sinkApp.
Start(startTime);
 
  485        clientHelper1.SetAttribute(
"OnTime",
 
  486                                   StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
 
  487        clientHelper1.SetAttribute(
"OffTime",
 
  488                                   StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
 
  490        clientHelper1.SetAttribute(
"PacketSize", 
UintegerValue(1000));
 
  494        clientHelper1.SetAttribute(
"Remote", remoteAddress);
 
  495        clientApps1.
Add(clientHelper1.Install(S2.
Get(i)));
 
  496        clientApps1.
Start(i * flowStartupWindow / 20 + clientStartTime + 
MilliSeconds(i * 5));
 
  501    std::vector<Ptr<PacketSink>> s1r1Sinks;
 
  502    std::vector<Ptr<PacketSink>> s3r1Sinks;
 
  503    s1r1Sinks.reserve(10);
 
  504    s3r1Sinks.reserve(10);
 
  505    for (std::size_t i = 0; i < 20; i++)
 
  507        uint16_t 
port = 50000 + i;
 
  514            s1r1Sinks.push_back(packetSink);
 
  518            s3r1Sinks.push_back(packetSink);
 
  520        sinkApp.
Start(startTime);
 
  524        clientHelper1.SetAttribute(
"OnTime",
 
  525                                   StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
 
  526        clientHelper1.SetAttribute(
"OffTime",
 
  527                                   StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
 
  529        clientHelper1.SetAttribute(
"PacketSize", 
UintegerValue(1000));
 
  533        clientHelper1.SetAttribute(
"Remote", remoteAddress);
 
  536            clientApps1.
Add(clientHelper1.Install(S1.
Get(i)));
 
  537            clientApps1.
Start(i * flowStartupWindow / 10 + clientStartTime + 
MilliSeconds(i * 5));
 
  541            clientApps1.
Add(clientHelper1.Install(S3.
Get(i - 10)));
 
  542            clientApps1.
Start((i - 10) * flowStartupWindow / 10 + clientStartTime +
 
  555    fairnessIndex.open(
"dctcp-example-fairness.dat", std::ios::out);
 
  556    t1QueueLength.open(
"dctcp-example-t1-length.dat", std::ios::out);
 
  557    t1QueueLength << 
"#Time(s) qlen(pkts) qlen(us)" << std::endl;
 
  558    t2QueueLength.open(
"dctcp-example-t2-length.dat", std::ios::out);
 
  559    t2QueueLength << 
"#Time(s) qlen(pkts) qlen(us)" << std::endl;
 
  560    for (std::size_t i = 0; i < 10; i++)
 
  564    for (std::size_t i = 0; i < 20; i++)
 
  568    for (std::size_t i = 0; i < 10; i++)
 
  573    Simulator::Schedule(flowStartupWindow + convergenceTime + measurementWindow,
 
  576    Simulator::Schedule(flowStartupWindow + convergenceTime + measurementWindow,
 
  579    Simulator::Schedule(progressInterval, &
PrintProgress, progressInterval);
 
  580    Simulator::Schedule(flowStartupWindow + convergenceTime, &
CheckT1QueueSize, queueDiscs1.
Get(0));
 
  581    Simulator::Schedule(flowStartupWindow + convergenceTime, &
CheckT2QueueSize, queueDiscs2.
Get(0));
 
  592    Simulator::Destroy();
 
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
Parse command-line arguments.
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Receive and consume traffic generated to an IP address and port.
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)
Holds a vector of ns3::QueueDisc pointers.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
uint32_t GetNPackets() const
Get the number of packets stored by the queue disc.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time TimeStep(uint64_t ts)
Scheduler interface.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
void TraceS1R1Sink(std::size_t index, Ptr< const Packet > p, const Address &a)
std::ofstream rxS3R1Throughput
std::ofstream fairnessIndex
std::ofstream t1QueueLength
std::vector< uint64_t > rxS3R1Bytes
std::stringstream filePlotQueue1
void PrintFairness(Time measurementWindow)
void InitializeCounters()
void TraceS2R2Sink(std::size_t index, Ptr< const Packet > p, const Address &a)
std::vector< uint64_t > rxS2R2Bytes
void PrintThroughput(Time measurementWindow)
void CheckT1QueueSize(Ptr< QueueDisc > queue)
void PrintProgress(Time interval)
std::stringstream filePlotQueue2
std::ofstream rxS2R2Throughput
void TraceS3R1Sink(std::size_t index, Ptr< const Packet > p, const Address &a)
std::vector< uint64_t > rxS1R1Bytes
std::ofstream rxS1R1Throughput
std::ofstream t2QueueLength
void CheckT2QueueSize(Ptr< QueueDisc > queue)
void SetDefault(std::string name, const AttributeValue &value)
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.