18 #include "ns3/abort.h"
20 #include "ns3/pcap-file.h"
21 #include "ns3/config.h"
22 #include "ns3/string.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/boolean.h"
25 #include "ns3/data-rate.h"
26 #include "ns3/inet-socket-address.h"
27 #include "ns3/point-to-point-helper.h"
28 #include "ns3/csma-helper.h"
29 #include "ns3/internet-stack-helper.h"
30 #include "ns3/ipv4-global-routing-helper.h"
31 #include "ns3/ipv4-address-helper.h"
32 #include "ns3/packet-sink-helper.h"
33 #include "ns3/tcp-socket-factory.h"
34 #include "ns3/node-container.h"
35 #include "ns3/simulator.h"
54 virtual void DoRun (
void);
65 :
TestCase (
"Check that ns-3 TCP Nagle's algorithm works correctly and that we can turn it off."),
67 m_writeResults (false)
80 uint16_t sinkPort = 50000;
81 double sinkStopTime = 8;
82 double writerStopTime = 5;
83 double simStopTime = 10;
92 pointToPoint.SetDeviceAttribute (
"DataRate",
StringValue (
"5Mbps"));
93 pointToPoint.SetChannelAttribute (
"Delay",
StringValue (
"2ms"));
96 devices = pointToPoint.Install (n0, n1);
102 address.
SetBase (
"10.1.1.0",
"255.255.255.252");
107 socketWriter->
Setup (n0, sinkAddress);
117 apps.
Stop (sinkStopTimeObj);
129 Simulator::Schedule (
Seconds (2), &SocketWriter::Write, socketWriter, 2680);
138 Simulator::Schedule (
Seconds (2.010), &SocketWriter::Write, socketWriter, 1);
148 Simulator::Schedule (
Seconds (2.012), &SocketWriter::Write, socketWriter, 535);
162 Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter);
166 std::ostringstream oss;
169 oss <<
"tcp-no-delay-on-test-case";
170 pointToPoint.EnablePcapAll (oss.str ());
174 oss <<
"tcp-no-delay-off-test-case";
175 pointToPoint.EnablePcapAll (oss.str ());
179 Simulator::Stop (simStopTimeObj);
181 Simulator::Destroy ();
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void SetStopTime(Time stop)
Specify application stop time.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Boolean.
holds a vector of std::pair of Ptr and interface index.
T Get(uint32_t i) const
Get the i'th test vector.
Hold variables of type string.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t GetSize(void) 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.
uint32_t GetN(void) const
a polymophic address class
void Setup(Ptr< Node > node, Address peer)
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
#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.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
void Connect(std::string path, const CallbackBase &cb)
TestVectors< uint32_t > m_inputs
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ns3TcpNoDelayTestCase(bool noDelay)
virtual void DoRun(void)
Implementation to actually run this TestCase.
static Ns3TcpNoDelayTestSuite ns3TcpNoDelayTestSuite
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...
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
TestVectors< uint32_t > m_responses
void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
static void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
virtual ~Ns3TcpNoDelayTestCase()
void SetStartTime(Time start)
Specify application start time.
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