18 #include "ns3/abort.h"
19 #include "ns3/boolean.h"
20 #include "ns3/config.h"
21 #include "ns3/csma-helper.h"
22 #include "ns3/data-rate.h"
23 #include "ns3/inet-socket-address.h"
24 #include "ns3/internet-stack-helper.h"
25 #include "ns3/ipv4-address-helper.h"
26 #include "ns3/ipv4-global-routing-helper.h"
28 #include "ns3/node-container.h"
29 #include "ns3/packet-sink-helper.h"
30 #include "ns3/pcap-file.h"
31 #include "ns3/point-to-point-helper.h"
32 #include "ns3/simulator.h"
33 #include "ns3/string.h"
34 #include "ns3/tcp-socket-factory.h"
36 #include "ns3/uinteger.h"
62 void DoRun()
override;
80 "Check that ns-3 TCP Nagle's algorithm works correctly and that we can turn it off."),
95 uint16_t sinkPort = 50000;
96 double sinkStopTime = 8;
97 double writerStopTime = 5;
98 double simStopTime = 10;
117 address.SetBase(
"10.1.1.0",
"255.255.255.252");
122 socketWriter->Setup(n0, sinkAddress);
124 socketWriter->SetStartTime(
Seconds(0.));
125 socketWriter->SetStopTime(writerStopTimeObj);
132 apps.
Stop(sinkStopTimeObj);
146 Simulator::Schedule(
Seconds(2), &SocketWriter::Write, socketWriter, 2680);
155 Simulator::Schedule(
Seconds(2.010), &SocketWriter::Write, socketWriter, 1);
165 Simulator::Schedule(
Seconds(2.012), &SocketWriter::Write, socketWriter, 535);
179 Simulator::Schedule(writerStopTimeObj, &SocketWriter::Close, socketWriter);
183 std::ostringstream oss;
186 oss <<
"tcp-no-delay-on-test-case";
191 oss <<
"tcp-no-delay-off-test-case";
196 Simulator::Stop(simStopTimeObj);
198 Simulator::Destroy();
203 "Incorrect number of expected receive events");
210 "Mismatch: expected " << in <<
" bytes, got " << out <<
" bytes");
Tests of Nagle's algorithm and the TCP no delay option.
Ns3TcpNoDelayTestCase(bool noDelay)
Constructor.
bool m_noDelay
Enable or disable TCP no delay option.
void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
Receive a TCP packet.
~Ns3TcpNoDelayTestCase() override
TestVectors< uint32_t > m_responses
Received packets test vector.
void DoRun() override
Implementation to actually run this TestCase.
bool m_writeResults
True if write PCAP files.
TestVectors< uint32_t > m_inputs
Sent packets test vector.
TCP Nagle's algorithm and the TCP no delay option TestSuite.
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
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
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
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.
Build a set of PointToPointNetDevice objects.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
T Get(std::size_t i) const
Get the i'th test vector.
std::size_t GetN() const
Get the total number of test vectors.
std::size_t Add(T vector)
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
static void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
Rx sink.
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static Ns3TcpNoDelayTestSuite g_ns3TcpNoDelayTestSuite
Do not forget to allocate an instance of this TestSuite.
Ptr< PacketSink > sink
Pointer to the packet sink application.