mtp: Change the code style of examples
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2020 NITK Surathkal
|
||||
*
|
||||
@@ -79,24 +78,25 @@
|
||||
// TCP Prague and ACK-filtering, which may show a stronger performance
|
||||
// impact for TCP pacing.
|
||||
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/flow-monitor-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/ipv4-global-routing-helper.h"
|
||||
#include "ns3/mtp-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/packet-sink.h"
|
||||
#include "ns3/point-to-point-module.h"
|
||||
#include "ns3/traffic-control-module.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/point-to-point-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/packet-sink.h"
|
||||
#include "ns3/flow-monitor-module.h"
|
||||
#include "ns3/ipv4-global-routing-helper.h"
|
||||
#include "ns3/traffic-control-module.h"
|
||||
#include "ns3/mtp-module.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TcpPacingExample");
|
||||
NS_LOG_COMPONENT_DEFINE("TcpPacingExample");
|
||||
|
||||
std::ofstream cwndStream;
|
||||
std::ofstream pacingRateStream;
|
||||
@@ -104,231 +104,252 @@ std::ofstream ssThreshStream;
|
||||
std::ofstream packetTraceStream;
|
||||
|
||||
static void
|
||||
CwndTracer (uint32_t oldval, uint32_t newval)
|
||||
CwndTracer(uint32_t oldval, uint32_t newval)
|
||||
{
|
||||
cwndStream << std::fixed << std::setprecision (6) << Simulator::Now ().GetSeconds () << std::setw (12) << newval << std::endl;
|
||||
cwndStream << std::fixed << std::setprecision(6) << Simulator::Now().GetSeconds()
|
||||
<< std::setw(12) << newval << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
PacingRateTracer (DataRate oldval, DataRate newval)
|
||||
PacingRateTracer(DataRate oldval, DataRate newval)
|
||||
{
|
||||
pacingRateStream << std::fixed << std::setprecision (6) << Simulator::Now ().GetSeconds () << std::setw (12) << newval.GetBitRate () / 1e6 << std::endl;
|
||||
pacingRateStream << std::fixed << std::setprecision(6) << Simulator::Now().GetSeconds()
|
||||
<< std::setw(12) << newval.GetBitRate() / 1e6 << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
SsThreshTracer (uint32_t oldval, uint32_t newval)
|
||||
SsThreshTracer(uint32_t oldval, uint32_t newval)
|
||||
{
|
||||
ssThreshStream << std::fixed << std::setprecision (6) << Simulator::Now ().GetSeconds () << std::setw (12) << newval << std::endl;
|
||||
ssThreshStream << std::fixed << std::setprecision(6) << Simulator::Now().GetSeconds()
|
||||
<< std::setw(12) << newval << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
TxTracer (Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
|
||||
TxTracer(Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
|
||||
{
|
||||
packetTraceStream << std::fixed << std::setprecision (6) << Simulator::Now ().GetSeconds () << " tx " << p->GetSize () << std::endl;
|
||||
packetTraceStream << std::fixed << std::setprecision(6) << Simulator::Now().GetSeconds()
|
||||
<< " tx " << p->GetSize() << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
RxTracer (Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
|
||||
RxTracer(Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
|
||||
{
|
||||
packetTraceStream << std::fixed << std::setprecision (6) << Simulator::Now ().GetSeconds () << " rx " << p->GetSize () << std::endl;
|
||||
packetTraceStream << std::fixed << std::setprecision(6) << Simulator::Now().GetSeconds()
|
||||
<< " rx " << p->GetSize() << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
ConnectSocketTraces (void)
|
||||
ConnectSocketTraces()
|
||||
{
|
||||
Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeCallback (&CwndTracer));
|
||||
Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/PacingRate", MakeCallback (&PacingRateTracer));
|
||||
Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold", MakeCallback (&SsThreshTracer));
|
||||
Config::ConnectWithoutContext ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx", MakeCallback (&TxTracer));
|
||||
Config::ConnectWithoutContext ("/NodeList/0/$ns3::Ipv4L3Protocol/Rx", MakeCallback (&RxTracer));
|
||||
Config::ConnectWithoutContext("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
|
||||
MakeCallback(&CwndTracer));
|
||||
Config::ConnectWithoutContext("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/PacingRate",
|
||||
MakeCallback(&PacingRateTracer));
|
||||
Config::ConnectWithoutContext("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",
|
||||
MakeCallback(&SsThreshTracer));
|
||||
Config::ConnectWithoutContext("/NodeList/0/$ns3::Ipv4L3Protocol/Tx", MakeCallback(&TxTracer));
|
||||
Config::ConnectWithoutContext("/NodeList/0/$ns3::Ipv4L3Protocol/Rx", MakeCallback(&RxTracer));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
LogComponentEnable ("LogicalProcess", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("MultithreadedSimulatorImpl", LOG_LEVEL_INFO);
|
||||
MtpInterface::Enable ();
|
||||
MtpInterface::Enable();
|
||||
bool tracing = false;
|
||||
|
||||
bool tracing = false;
|
||||
uint32_t maxBytes = 0; // value of zero corresponds to unlimited send
|
||||
std::string transportProtocol = "ns3::TcpCubic";
|
||||
|
||||
uint32_t maxBytes = 0; // value of zero corresponds to unlimited send
|
||||
std::string transportProtocol = "ns3::TcpCubic";
|
||||
Time simulationEndTime = Seconds(5);
|
||||
DataRate bottleneckBandwidth("10Mbps"); // value of x as shown in the above network topology
|
||||
Time bottleneckDelay = MilliSeconds(40);
|
||||
DataRate regLinkBandwidth = DataRate(4 * bottleneckBandwidth.GetBitRate());
|
||||
Time regLinkDelay = MilliSeconds(5);
|
||||
DataRate maxPacingRate("4Gbps");
|
||||
|
||||
Time simulationEndTime = Seconds (5);
|
||||
DataRate bottleneckBandwidth ("10Mbps"); // value of x as shown in the above network topology
|
||||
Time bottleneckDelay = MilliSeconds (40);
|
||||
DataRate regLinkBandwidth = DataRate (4 * bottleneckBandwidth.GetBitRate ());
|
||||
Time regLinkDelay = MilliSeconds (5);
|
||||
DataRate maxPacingRate ("4Gbps");
|
||||
bool isPacingEnabled = true;
|
||||
bool useEcn = true;
|
||||
bool useQueueDisc = true;
|
||||
bool shouldPaceInitialWindow = true;
|
||||
|
||||
bool isPacingEnabled = true;
|
||||
bool useEcn = true;
|
||||
bool useQueueDisc = true;
|
||||
bool shouldPaceInitialWindow = true;
|
||||
// Configure defaults that are not based on explicit command-line arguments
|
||||
// They may be overridden by general attribute configuration of command line
|
||||
Config::SetDefault("ns3::TcpL4Protocol::SocketType",
|
||||
TypeIdValue(TypeId::LookupByName(transportProtocol)));
|
||||
Config::SetDefault("ns3::TcpSocket::InitialCwnd", UintegerValue(10));
|
||||
|
||||
// Configure defaults that are not based on explicit command-line arguments
|
||||
// They may be overridden by general attribute configuration of command line
|
||||
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TypeId::LookupByName (transportProtocol)));
|
||||
Config::SetDefault ("ns3::TcpSocket::InitialCwnd", UintegerValue (10));
|
||||
CommandLine cmd(__FILE__);
|
||||
cmd.AddValue("tracing", "Flag to enable/disable Ascii and Pcap tracing", tracing);
|
||||
cmd.AddValue("maxBytes", "Total number of bytes for application to send", maxBytes);
|
||||
cmd.AddValue("isPacingEnabled", "Flag to enable/disable pacing in TCP", isPacingEnabled);
|
||||
cmd.AddValue("maxPacingRate", "Max Pacing Rate", maxPacingRate);
|
||||
cmd.AddValue("useEcn", "Flag to enable/disable ECN", useEcn);
|
||||
cmd.AddValue("useQueueDisc", "Flag to enable/disable queue disc on bottleneck", useQueueDisc);
|
||||
cmd.AddValue("shouldPaceInitialWindow",
|
||||
"Flag to enable/disable pacing of TCP initial window",
|
||||
shouldPaceInitialWindow);
|
||||
cmd.AddValue("simulationEndTime", "Simulation end time", simulationEndTime);
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
CommandLine cmd (__FILE__);
|
||||
cmd.AddValue ("tracing", "Flag to enable/disable Ascii and Pcap tracing", tracing);
|
||||
cmd.AddValue ("maxBytes", "Total number of bytes for application to send", maxBytes);
|
||||
cmd.AddValue ("isPacingEnabled", "Flag to enable/disable pacing in TCP", isPacingEnabled);
|
||||
cmd.AddValue ("maxPacingRate", "Max Pacing Rate", maxPacingRate);
|
||||
cmd.AddValue ("useEcn", "Flag to enable/disable ECN", useEcn);
|
||||
cmd.AddValue ("useQueueDisc", "Flag to enable/disable queue disc on bottleneck", useQueueDisc);
|
||||
cmd.AddValue ("shouldPaceInitialWindow", "Flag to enable/disable pacing of TCP initial window", shouldPaceInitialWindow);
|
||||
cmd.AddValue ("simulationEndTime", "Simulation end time", simulationEndTime);
|
||||
cmd.Parse (argc, argv);
|
||||
// Configure defaults based on command-line arguments
|
||||
Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(isPacingEnabled));
|
||||
Config::SetDefault("ns3::TcpSocketState::PaceInitialWindow",
|
||||
BooleanValue(shouldPaceInitialWindow));
|
||||
Config::SetDefault("ns3::TcpSocketBase::UseEcn",
|
||||
(useEcn ? EnumValue(TcpSocketState::On) : EnumValue(TcpSocketState::Off)));
|
||||
Config::SetDefault("ns3::TcpSocketState::MaxPacingRate", DataRateValue(maxPacingRate));
|
||||
|
||||
// Configure defaults based on command-line arguments
|
||||
Config::SetDefault ("ns3::TcpSocketState::EnablePacing", BooleanValue (isPacingEnabled));
|
||||
Config::SetDefault ("ns3::TcpSocketState::PaceInitialWindow", BooleanValue (shouldPaceInitialWindow));
|
||||
Config::SetDefault ("ns3::TcpSocketBase::UseEcn", (useEcn ? EnumValue (TcpSocketState::On) : EnumValue (TcpSocketState::Off)));
|
||||
Config::SetDefault ("ns3::TcpSocketState::MaxPacingRate", DataRateValue (maxPacingRate));
|
||||
NS_LOG_INFO("Create nodes.");
|
||||
NodeContainer c;
|
||||
c.Create(6);
|
||||
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
NodeContainer c;
|
||||
c.Create (6);
|
||||
NS_LOG_INFO("Create channels.");
|
||||
NodeContainer n0n2 = NodeContainer(c.Get(0), c.Get(2));
|
||||
NodeContainer n1n2 = NodeContainer(c.Get(1), c.Get(2));
|
||||
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
|
||||
NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
|
||||
NodeContainer n2n3 = NodeContainer(c.Get(2), c.Get(3));
|
||||
|
||||
NodeContainer n2n3 = NodeContainer (c.Get (2), c.Get (3));
|
||||
NodeContainer n3n4 = NodeContainer(c.Get(3), c.Get(4));
|
||||
NodeContainer n3n5 = NodeContainer(c.Get(3), c.Get(5));
|
||||
|
||||
NodeContainer n3n4 = NodeContainer (c.Get (3), c.Get (4));
|
||||
NodeContainer n3n5 = NodeContainer (c.Get (3), c.Get (5));
|
||||
// Define Node link properties
|
||||
PointToPointHelper regLink;
|
||||
regLink.SetDeviceAttribute("DataRate", DataRateValue(regLinkBandwidth));
|
||||
regLink.SetChannelAttribute("Delay", TimeValue(regLinkDelay));
|
||||
|
||||
//Define Node link properties
|
||||
PointToPointHelper regLink;
|
||||
regLink.SetDeviceAttribute ("DataRate", DataRateValue (regLinkBandwidth));
|
||||
regLink.SetChannelAttribute ("Delay", TimeValue (regLinkDelay));
|
||||
NetDeviceContainer d0d2 = regLink.Install(n0n2);
|
||||
NetDeviceContainer d1d2 = regLink.Install(n1n2);
|
||||
NetDeviceContainer d3d4 = regLink.Install(n3n4);
|
||||
NetDeviceContainer d3d5 = regLink.Install(n3n5);
|
||||
|
||||
NetDeviceContainer d0d2 = regLink.Install (n0n2);
|
||||
NetDeviceContainer d1d2 = regLink.Install (n1n2);
|
||||
NetDeviceContainer d3d4 = regLink.Install (n3n4);
|
||||
NetDeviceContainer d3d5 = regLink.Install (n3n5);
|
||||
PointToPointHelper bottleNeckLink;
|
||||
bottleNeckLink.SetDeviceAttribute("DataRate", DataRateValue(bottleneckBandwidth));
|
||||
bottleNeckLink.SetChannelAttribute("Delay", TimeValue(bottleneckDelay));
|
||||
|
||||
PointToPointHelper bottleNeckLink;
|
||||
bottleNeckLink.SetDeviceAttribute ("DataRate", DataRateValue (bottleneckBandwidth));
|
||||
bottleNeckLink.SetChannelAttribute ("Delay", TimeValue (bottleneckDelay));
|
||||
NetDeviceContainer d2d3 = bottleNeckLink.Install(n2n3);
|
||||
|
||||
NetDeviceContainer d2d3 = bottleNeckLink.Install (n2n3);
|
||||
// Install Internet stack
|
||||
InternetStackHelper stack;
|
||||
stack.Install(c);
|
||||
|
||||
//Install Internet stack
|
||||
InternetStackHelper stack;
|
||||
stack.Install (c);
|
||||
|
||||
// Install traffic control
|
||||
if (useQueueDisc)
|
||||
// Install traffic control
|
||||
if (useQueueDisc)
|
||||
{
|
||||
TrafficControlHelper tchBottleneck;
|
||||
tchBottleneck.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
|
||||
tchBottleneck.Install (d2d3);
|
||||
TrafficControlHelper tchBottleneck;
|
||||
tchBottleneck.SetRootQueueDisc("ns3::FqCoDelQueueDisc");
|
||||
tchBottleneck.Install(d2d3);
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface0 = ipv4.Assign (d0d2);
|
||||
NS_LOG_INFO("Assign IP Addresses.");
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface0 = ipv4.Assign(d0d2);
|
||||
|
||||
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface1 = ipv4.Assign (d1d2);
|
||||
ipv4.SetBase("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface1 = ipv4.Assign(d1d2);
|
||||
|
||||
ipv4.SetBase ("10.1.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer bottleneckInterface = ipv4.Assign (d2d3);
|
||||
ipv4.SetBase("10.1.3.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer bottleneckInterface = ipv4.Assign(d2d3);
|
||||
|
||||
ipv4.SetBase ("10.1.4.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface4 = ipv4.Assign (d3d4);
|
||||
ipv4.SetBase("10.1.4.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface4 = ipv4.Assign(d3d4);
|
||||
|
||||
ipv4.SetBase ("10.1.5.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface5 = ipv4.Assign (d3d5);
|
||||
ipv4.SetBase("10.1.5.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer regLinkInterface5 = ipv4.Assign(d3d5);
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
|
||||
|
||||
NS_LOG_INFO ("Create Applications.");
|
||||
NS_LOG_INFO("Create Applications.");
|
||||
|
||||
// Two Sink Applications at n4 and n5
|
||||
uint16_t sinkPort = 8080;
|
||||
Address sinkAddress4 (InetSocketAddress (regLinkInterface4.GetAddress (1), sinkPort)); // interface of n4
|
||||
Address sinkAddress5 (InetSocketAddress (regLinkInterface5.GetAddress (1), sinkPort)); // interface of n5
|
||||
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
|
||||
ApplicationContainer sinkApps4 = packetSinkHelper.Install (c.Get (4)); //n4 as sink
|
||||
ApplicationContainer sinkApps5 = packetSinkHelper.Install (c.Get (5)); //n5 as sink
|
||||
// Two Sink Applications at n4 and n5
|
||||
uint16_t sinkPort = 8080;
|
||||
Address sinkAddress4(
|
||||
InetSocketAddress(regLinkInterface4.GetAddress(1), sinkPort)); // interface of n4
|
||||
Address sinkAddress5(
|
||||
InetSocketAddress(regLinkInterface5.GetAddress(1), sinkPort)); // interface of n5
|
||||
PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory",
|
||||
InetSocketAddress(Ipv4Address::GetAny(), sinkPort));
|
||||
ApplicationContainer sinkApps4 = packetSinkHelper.Install(c.Get(4)); // n4 as sink
|
||||
ApplicationContainer sinkApps5 = packetSinkHelper.Install(c.Get(5)); // n5 as sink
|
||||
|
||||
sinkApps4.Start (Seconds (0));
|
||||
sinkApps4.Stop (simulationEndTime);
|
||||
sinkApps5.Start (Seconds (0));
|
||||
sinkApps5.Stop (simulationEndTime);
|
||||
sinkApps4.Start(Seconds(0));
|
||||
sinkApps4.Stop(simulationEndTime);
|
||||
sinkApps5.Start(Seconds(0));
|
||||
sinkApps5.Stop(simulationEndTime);
|
||||
|
||||
// Randomize the start time between 0 and 1ms
|
||||
Ptr<UniformRandomVariable> uniformRv = CreateObject<UniformRandomVariable> ();
|
||||
uniformRv->SetStream (0);
|
||||
// Randomize the start time between 0 and 1ms
|
||||
Ptr<UniformRandomVariable> uniformRv = CreateObject<UniformRandomVariable>();
|
||||
uniformRv->SetStream(0);
|
||||
|
||||
// Two Source Applications at n0 and n1
|
||||
BulkSendHelper source0 ("ns3::TcpSocketFactory", sinkAddress4);
|
||||
BulkSendHelper source1 ("ns3::TcpSocketFactory", sinkAddress5);
|
||||
// Set the amount of data to send in bytes. Zero is unlimited.
|
||||
source0.SetAttribute ("MaxBytes", UintegerValue (maxBytes));
|
||||
source1.SetAttribute ("MaxBytes", UintegerValue (maxBytes));
|
||||
ApplicationContainer sourceApps0 = source0.Install (c.Get (0));
|
||||
ApplicationContainer sourceApps1 = source1.Install (c.Get (1));
|
||||
// Two Source Applications at n0 and n1
|
||||
BulkSendHelper source0("ns3::TcpSocketFactory", sinkAddress4);
|
||||
BulkSendHelper source1("ns3::TcpSocketFactory", sinkAddress5);
|
||||
// Set the amount of data to send in bytes. Zero is unlimited.
|
||||
source0.SetAttribute("MaxBytes", UintegerValue(maxBytes));
|
||||
source1.SetAttribute("MaxBytes", UintegerValue(maxBytes));
|
||||
ApplicationContainer sourceApps0 = source0.Install(c.Get(0));
|
||||
ApplicationContainer sourceApps1 = source1.Install(c.Get(1));
|
||||
|
||||
sourceApps0.Start (MicroSeconds (uniformRv->GetInteger (0, 1000)));
|
||||
sourceApps0.Stop (simulationEndTime);
|
||||
sourceApps1.Start (MicroSeconds (uniformRv->GetInteger (0, 1000)));
|
||||
sourceApps1.Stop (simulationEndTime);
|
||||
sourceApps0.Start(MicroSeconds(uniformRv->GetInteger(0, 1000)));
|
||||
sourceApps0.Stop(simulationEndTime);
|
||||
sourceApps1.Start(MicroSeconds(uniformRv->GetInteger(0, 1000)));
|
||||
sourceApps1.Stop(simulationEndTime);
|
||||
|
||||
if (tracing)
|
||||
if (tracing)
|
||||
{
|
||||
AsciiTraceHelper ascii;
|
||||
regLink.EnableAsciiAll (ascii.CreateFileStream ("tcp-dynamic-pacing.tr"));
|
||||
regLink.EnablePcapAll ("tcp-dynamic-pacing", false);
|
||||
AsciiTraceHelper ascii;
|
||||
regLink.EnableAsciiAll(ascii.CreateFileStream("tcp-dynamic-pacing.tr"));
|
||||
regLink.EnablePcapAll("tcp-dynamic-pacing", false);
|
||||
}
|
||||
|
||||
cwndStream.open ("tcp-dynamic-pacing-cwnd.dat", std::ios::out);
|
||||
cwndStream << "#Time(s) Congestion Window (B)" << std::endl;
|
||||
cwndStream.open("tcp-dynamic-pacing-cwnd.dat", std::ios::out);
|
||||
cwndStream << "#Time(s) Congestion Window (B)" << std::endl;
|
||||
|
||||
pacingRateStream.open ("tcp-dynamic-pacing-pacing-rate.dat", std::ios::out);
|
||||
pacingRateStream << "#Time(s) Pacing Rate (Mb/s)" << std::endl;
|
||||
pacingRateStream.open("tcp-dynamic-pacing-pacing-rate.dat", std::ios::out);
|
||||
pacingRateStream << "#Time(s) Pacing Rate (Mb/s)" << std::endl;
|
||||
|
||||
ssThreshStream.open ("tcp-dynamic-pacing-ssthresh.dat", std::ios::out);
|
||||
ssThreshStream << "#Time(s) Slow Start threshold (B)" << std::endl;
|
||||
ssThreshStream.open("tcp-dynamic-pacing-ssthresh.dat", std::ios::out);
|
||||
ssThreshStream << "#Time(s) Slow Start threshold (B)" << std::endl;
|
||||
|
||||
packetTraceStream.open ("tcp-dynamic-pacing-packet-trace.dat", std::ios::out);
|
||||
packetTraceStream << "#Time(s) tx/rx size (B)" << std::endl;
|
||||
packetTraceStream.open("tcp-dynamic-pacing-packet-trace.dat", std::ios::out);
|
||||
packetTraceStream << "#Time(s) tx/rx size (B)" << std::endl;
|
||||
|
||||
Simulator::Schedule (MicroSeconds (1001), &ConnectSocketTraces);
|
||||
Simulator::Schedule(MicroSeconds(1001), &ConnectSocketTraces);
|
||||
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Stop (simulationEndTime);
|
||||
Simulator::Run ();
|
||||
NS_LOG_INFO("Run Simulation.");
|
||||
Simulator::Stop(simulationEndTime);
|
||||
Simulator::Run();
|
||||
|
||||
monitor->CheckForLostPackets ();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
|
||||
FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats ();
|
||||
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
|
||||
monitor->CheckForLostPackets();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier>(flowmon.GetClassifier());
|
||||
FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats();
|
||||
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin();
|
||||
i != stats.end();
|
||||
++i)
|
||||
{
|
||||
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);
|
||||
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
|
||||
|
||||
std::cout << "Flow " << i->first << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n";
|
||||
std::cout << " Tx Packets: " << i->second.txPackets << "\n";
|
||||
std::cout << " Tx Bytes: " << i->second.txBytes << "\n";
|
||||
std::cout << " TxOffered: " << i->second.txBytes * 8.0 / simulationEndTime.GetSeconds () / 1000 / 1000 << " Mbps\n";
|
||||
std::cout << " Rx Packets: " << i->second.rxPackets << "\n";
|
||||
std::cout << " Rx Bytes: " << i->second.rxBytes << "\n";
|
||||
std::cout << " Throughput: " << i->second.rxBytes * 8.0 / simulationEndTime.GetSeconds () / 1000 / 1000 << " Mbps\n";
|
||||
std::cout << "Flow " << i->first << " (" << t.sourceAddress << " -> "
|
||||
<< t.destinationAddress << ")\n";
|
||||
std::cout << " Tx Packets: " << i->second.txPackets << "\n";
|
||||
std::cout << " Tx Bytes: " << i->second.txBytes << "\n";
|
||||
std::cout << " TxOffered: "
|
||||
<< i->second.txBytes * 8.0 / simulationEndTime.GetSeconds() / 1000 / 1000
|
||||
<< " Mbps\n";
|
||||
std::cout << " Rx Packets: " << i->second.rxPackets << "\n";
|
||||
std::cout << " Rx Bytes: " << i->second.rxBytes << "\n";
|
||||
std::cout << " Throughput: "
|
||||
<< i->second.rxBytes * 8.0 / simulationEndTime.GetSeconds() / 1000 / 1000
|
||||
<< " Mbps\n";
|
||||
}
|
||||
|
||||
cwndStream.close();
|
||||
pacingRateStream.close();
|
||||
ssThreshStream.close();
|
||||
Simulator::Destroy();
|
||||
|
||||
cwndStream.close ();
|
||||
pacingRateStream.close ();
|
||||
ssThreshStream.close ();
|
||||
Simulator::Destroy ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user