147 #include "ns3/core-module.h" 148 #include "ns3/network-module.h" 149 #include "ns3/applications-module.h" 150 #include "ns3/traffic-control-module.h" 151 #include "ns3/internet-module.h" 152 #include "ns3/internet-apps-module.h" 153 #include "ns3/point-to-point-module.h" 181 double cwnd =
static_cast<double> (newCwnd) / 1448;
182 if ((now > 5.43) && (now < 5.465) && (cwnd < 500))
186 else if ((now > 5.795) && (now < 6) && (cwnd > 190))
190 else if ((now > 14) && (now < 14.328) && (cwnd < 225))
194 else if ((now > 17) && (now < 18.2) && (cwnd < 225))
212 if ((now < 7.5) && (
alpha < 0.1))
216 else if ((now > 11) && (now < 30) && (
alpha > 0.01))
220 else if ((now > 34) && (
alpha < 0.015) && (
alpha > 0.025))
228 if ((now > 5.6) && (
alpha > 0.1))
232 if ((now > 7) && ((
alpha > 0.09) || (
alpha < 0.055)))
352 if ((now < 14) && (throughput > 20))
356 if ((now < 30) && (throughput > 48))
360 if ((now > 32) && ((throughput < 47.5) || (throughput > 48.5)))
368 if ((now > 5.6) && ((throughput < 48) || (throughput > 49)))
435 main (
int argc,
char *argv[])
440 uint32_t pingSize = 100;
441 bool enableSecondTcp =
false;
442 bool enableLogging =
false;
446 std::string pingTraceFile =
"tcp-validation-ping.dat";
447 std::string firstTcpRttTraceFile =
"tcp-validation-first-tcp-rtt.dat";
448 std::string firstTcpCwndTraceFile =
"tcp-validation-first-tcp-cwnd.dat";
449 std::string firstDctcpTraceFile =
"tcp-validation-first-dctcp-alpha.dat";
450 std::string firstTcpThroughputTraceFile =
"tcp-validation-first-tcp-throughput.dat";
451 std::string secondTcpRttTraceFile =
"tcp-validation-second-tcp-rtt.dat";
452 std::string secondTcpCwndTraceFile =
"tcp-validation-second-tcp-cwnd.dat";
453 std::string secondTcpThroughputTraceFile =
"tcp-validation-second-tcp-throughput.dat";
454 std::string secondDctcpTraceFile =
"tcp-validation-second-dctcp-alpha.dat";
455 std::string queueMarkTraceFile =
"tcp-validation-queue-mark.dat";
456 std::string queueDropTraceFile =
"tcp-validation-queue-drop.dat";
457 std::string queueMarksFrequencyTraceFile =
"tcp-validation-queue-marks-frequency.dat";
458 std::string queueLengthTraceFile =
"tcp-validation-queue-length.dat";
463 std::string firstTcpType =
"cubic";
464 std::string secondTcpType =
"";
465 std::string queueType =
"codel";
469 bool queueUseEcn =
false;
489 cmd.AddValue (
"firstTcpType",
"first TCP type (cubic, dctcp, or reno)", firstTcpType);
490 cmd.AddValue (
"secondTcpType",
"second TCP type (cubic, dctcp, or reno)", secondTcpType);
491 cmd.AddValue (
"queueType",
"bottleneck queue type (fq, codel, pie, or red)", queueType);
492 cmd.AddValue (
"baseRtt",
"base RTT", baseRtt);
493 cmd.AddValue (
"ceThreshold",
"CoDel CE threshold (for DCTCP)", ceThreshold);
494 cmd.AddValue (
"linkRate",
"data rate of bottleneck link", linkRate);
495 cmd.AddValue (
"stopTime",
"simulation stop time",
stopTime);
496 cmd.AddValue (
"queueUseEcn",
"use ECN on queue", queueUseEcn);
498 cmd.AddValue (
"validate",
"validation case to run",
g_validate);
499 cmd.Parse (argc, argv);
507 ||
g_validate ==
"cubic-50ms-ecn",
"Unknown test");
548 Time oneWayDelay = baseRtt / 2;
551 if (firstTcpType ==
"reno")
555 else if (firstTcpType ==
"cubic")
559 else if (firstTcpType ==
"dctcp")
564 if (queueUseEcn ==
false)
566 std::cout <<
"Warning: using DCTCP with queue ECN disabled" << std::endl;
574 if (secondTcpType ==
"reno")
576 enableSecondTcp =
true;
579 else if (secondTcpType ==
"cubic")
581 enableSecondTcp =
true;
584 else if (secondTcpType ==
"dctcp")
586 enableSecondTcp =
true;
589 else if (secondTcpType ==
"")
591 enableSecondTcp =
false;
599 if (queueType ==
"fq")
603 else if (queueType ==
"codel")
607 else if (queueType ==
"pie")
611 else if (queueType ==
"red")
631 NS_LOG_DEBUG (
"first TCP: " << firstTcpTypeId.
GetName () <<
"; second TCP: " << secondTcpTypeId.
GetName () <<
"; queue: " << queueTypeId.
GetName () <<
"; ceThreshold: " << ceThreshold.
GetSeconds () * 1000 <<
"ms");
634 std::ofstream pingOfStream;
635 std::ofstream firstTcpRttOfStream;
636 std::ofstream firstTcpCwndOfStream;
637 std::ofstream firstTcpThroughputOfStream;
638 std::ofstream firstTcpDctcpOfStream;
639 std::ofstream secondTcpRttOfStream;
640 std::ofstream secondTcpCwndOfStream;
641 std::ofstream secondTcpThroughputOfStream;
642 std::ofstream secondTcpDctcpOfStream;
643 std::ofstream queueDropOfStream;
644 std::ofstream queueMarkOfStream;
645 std::ofstream queueMarksFrequencyOfStream;
646 std::ofstream queueLengthOfStream;
649 pingOfStream.open (pingTraceFile.c_str (), std::ofstream::out);
650 firstTcpRttOfStream.open (firstTcpRttTraceFile.c_str (), std::ofstream::out);
651 firstTcpCwndOfStream.open (firstTcpCwndTraceFile.c_str (), std::ofstream::out);
652 firstTcpThroughputOfStream.open (firstTcpThroughputTraceFile.c_str (), std::ofstream::out);
653 if (firstTcpType ==
"dctcp")
655 firstTcpDctcpOfStream.open (firstDctcpTraceFile.c_str (), std::ofstream::out);
659 secondTcpRttOfStream.open (secondTcpRttTraceFile.c_str (), std::ofstream::out);
660 secondTcpCwndOfStream.open (secondTcpCwndTraceFile.c_str (), std::ofstream::out);
661 secondTcpThroughputOfStream.open (secondTcpThroughputTraceFile.c_str (), std::ofstream::out);
662 if (secondTcpType ==
"dctcp")
664 secondTcpDctcpOfStream.open (secondDctcpTraceFile.c_str (), std::ofstream::out);
667 queueDropOfStream.open (queueDropTraceFile.c_str (), std::ofstream::out);
668 queueMarkOfStream.open (queueMarkTraceFile.c_str (), std::ofstream::out);
669 queueMarksFrequencyOfStream.open (queueMarksFrequencyTraceFile.c_str (), std::ofstream::out);
670 queueLengthOfStream.open (queueLengthTraceFile.c_str (), std::ofstream::out);
676 Ptr<Node> pingServer = CreateObject<Node> ();
677 Ptr<Node> firstServer = CreateObject<Node> ();
678 Ptr<Node> secondServer = CreateObject<Node> ();
679 Ptr<Node> wanRouter = CreateObject<Node> ();
680 Ptr<Node> lanRouter = CreateObject<Node> ();
681 Ptr<Node> pingClient = CreateObject<Node> ();
682 Ptr<Node> firstClient = CreateObject<Node> ();
683 Ptr<Node> secondClient = CreateObject<Node> ();
699 pingServerDevices = p2p.
Install (wanRouter, pingServer);
700 firstServerDevices = p2p.
Install (wanRouter, firstServer);
701 secondServerDevices = p2p.
Install (wanRouter, secondServer);
703 wanLanDevices = p2p.
Install (wanRouter, lanRouter);
706 pingClientDevices = p2p.
Install (lanRouter, pingClient);
707 firstClientDevices = p2p.
Install (lanRouter, firstClient);
708 secondClientDevices = p2p.
Install (lanRouter, secondClient);
715 stackHelper.
Install (pingServer);
717 stackHelper.
Install (firstServer);
720 stackHelper.
Install (secondServer);
721 stackHelper.
Install (wanRouter);
722 stackHelper.
Install (lanRouter);
723 stackHelper.
Install (pingClient);
725 stackHelper.
Install (firstClient);
729 stackHelper.
Install (secondClient);
747 tchFq.
Install (pingServerDevices);
748 tchFq.
Install (firstServerDevices);
749 tchFq.
Install (secondServerDevices);
751 tchFq.
Install (pingClientDevices);
752 tchFq.
Install (firstClientDevices);
753 tchFq.
Install (secondClientDevices);
758 tchBottleneck.
Install (wanLanDevices.
Get (0));
761 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
763 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
765 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
767 ipv4.
SetBase (
"172.16.1.0",
"255.255.255.0");
769 ipv4.
SetBase (
"192.168.1.0",
"255.255.255.0");
771 ipv4.
SetBase (
"192.168.2.0",
"255.255.255.0");
773 ipv4.
SetBase (
"192.168.3.0",
"255.255.255.0");
782 pingHelper.SetAttribute (
"Interval",
TimeValue (pingInterval));
791 uint16_t firstPort = 5000;
797 tcp.SetAttribute (
"Remote",
AddressValue (firstDestAddress));
798 firstApp = tcp.Install (firstServer);
804 PacketSinkHelper firstSinkHelper (
"ns3::TcpSocketFactory", firstSinkAddress);
805 firstSinkApp = firstSinkHelper.Install (firstClient);
813 uint16_t secondPort = 5000;
816 tcp.SetAttribute (
"Remote",
AddressValue (secondDestAddress));
817 secondApp = tcp.Install (secondServer);
822 PacketSinkHelper secondSinkHelper (
"ns3::TcpSocketFactory", secondSinkAddress);
824 secondSinkApp = secondSinkHelper.Install (secondClient);
843 if (firstTcpType ==
"dctcp")
855 if (secondTcpType ==
"dctcp")
873 pingOfStream.close ();
874 firstTcpCwndOfStream.close ();
875 firstTcpRttOfStream.close ();
876 if (firstTcpType ==
"dctcp")
878 firstTcpDctcpOfStream.close ();
880 firstTcpThroughputOfStream.close ();
883 secondTcpCwndOfStream.close ();
884 secondTcpRttOfStream.close ();
885 secondTcpThroughputOfStream.close ();
886 if (secondTcpType ==
"dctcp")
888 secondTcpDctcpOfStream.close ();
891 queueDropOfStream.close ();
892 queueMarkOfStream.close ();
893 queueMarksFrequencyOfStream.close ();
894 queueLengthOfStream.close ();
void ScheduleSecondTcpRttTraceConnection(std::ofstream *ofStream)
holds a vector of ns3::Application pointers.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
std::string GetName(void) const
Get the name.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Prefix all trace prints with simulation node.
static Ipv4Address GetAny(void)
void TraceSecondThroughput(std::ofstream *ofStream, Time throughputInterval)
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
Class for representing queue sizes.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
void TraceFirstThroughput(std::ofstream *ofStream, Time throughputInterval)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Hold variables of type string.
Introspection did not find any typical Config paths.
NetDeviceContainer Install(NodeContainer c)
void ScheduleSecondDctcpTraceConnection(std::ofstream *ofStream)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices...
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 TypeId GetTypeId(void)
Get the type ID.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void Run(void)
Run the simulation.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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.
uint64_t GetBitRate() const
Get the underlying bitrate.
a polymophic address class
TCP socket creation and multiplexing/demultiplexing.
static TypeId GetTypeId(void)
Get the type ID.
Class for representing data rates.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
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 ...
AttributeValue implementation for Time.
void TraceSecondCwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void TraceMarksFrequency(std::ofstream *ofStream, Time marksSamplingInterval)
Hold an unsigned integer type.
void ScheduleSecondTcpCwndTraceConnection(std::ofstream *ofStream)
holds a vector of ns3::NetDevice pointers
void TracePingRtt(std::ofstream *ofStream, Time rtt)
AttributeValue implementation for TypeId.
static TypeId GetTypeId(void)
Get the type ID.
A Device for a Point to Point Network Link.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Build a set of QueueDisc objects.
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
void ScheduleFirstPacketSinkConnection(void)
static TypeId GetTypeId(void)
Get the type ID.
uint32_t g_firstBytesReceived
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
void TraceFirstRx(Ptr< const Packet > packet, const Address &address)
Parse command-line arguments.
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...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void ScheduleFirstDctcpTraceConnection(std::ofstream *ofStream)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void ScheduleSecondPacketSinkConnection(void)
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
This function will attempt to find all trace sources which match the input path and will then connect...
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Prefix all trace prints with simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t g_secondBytesReceived
void ScheduleFirstTcpCwndTraceConnection(std::ofstream *ofStream)
void TraceQueueMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
static TypeId GetTypeId(void)
Get the type ID.
static Time Now(void)
Return the current simulation virtual time.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
LogLevel
Logging severity classes and levels.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
static TypeId GetTypeId(void)
Get the type ID.
AttributeValue implementation for 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...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
void TraceSecondRtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
static TypeId GetTypeId(void)
Get the type ID.
AttributeValue implementation for DataRate.
Prefix all trace prints with function.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT...
void TraceQueueDrop(std::ofstream *ofStream, Ptr< const QueueDiscItem > item)
#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.
void SetDefault(std::string name, const AttributeValue &value)
void TraceFirstDctcp(std::ofstream *ofStream, uint32_t bytesMarked, uint32_t bytesAcked, double alpha)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void ScheduleFirstTcpRttTraceConnection(std::ofstream *ofStream)
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void TraceQueueLength(std::ofstream *ofStream, DataRate queueLinkRate, uint32_t oldVal, uint32_t newVal)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
a unique identifier for an interface.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
Create a IPv4 ping application and associate it to a node.
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...
void TraceSecondDctcp(std::ofstream *ofStream, uint32_t bytesMarked, uint32_t bytesAcked, double alpha)
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void TraceFirstCwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
void TraceFirstRtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void TraceSecondRx(Ptr< const Packet > packet, const Address &address)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.