|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
20 #include "ns3/abort.h"
22 #include "ns3/pcap-file.h"
23 #include "ns3/config.h"
24 #include "ns3/string.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/data-rate.h"
27 #include "ns3/inet-socket-address.h"
28 #include "ns3/point-to-point-helper.h"
29 #include "ns3/csma-helper.h"
30 #include "ns3/internet-stack-helper.h"
31 #include "ns3/ipv4-global-routing-helper.h"
32 #include "ns3/ipv4-address-helper.h"
33 #include "ns3/packet-sink-helper.h"
34 #include "ns3/tcp-socket-factory.h"
35 #include "ns3/node-container.h"
36 #include "ns3/simulator.h"
55 virtual void DoRun (
void);
65 :
TestCase (
"Check that ns-3 TCP successfully transfers an application data write of various sizes (point-to-point)"),
66 m_writeResults (false)
79 uint16_t sinkPort = 50000;
80 double sinkStopTime = 40;
81 double writerStopTime = 30;
82 double simStopTime = 60;
101 address.SetBase (
"10.1.1.0",
"255.255.255.252");
106 socketWriter->
Setup (n0, sinkAddress);
116 apps.
Stop (sinkStopTimeObj);
123 Simulator::Schedule (
Seconds (10), &SocketWriter::Write, socketWriter, 1);
125 Simulator::Schedule (
Seconds (12), &SocketWriter::Write, socketWriter, 10);
127 Simulator::Schedule (
Seconds (14), &SocketWriter::Write, socketWriter, 100);
129 Simulator::Schedule (
Seconds (16), &SocketWriter::Write, socketWriter, 1000);
132 Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter);
139 Simulator::Stop (simStopTimeObj);
141 Simulator::Destroy ();
160 virtual void DoRun (
void);
170 :
TestCase (
"Check to see that ns-3 TCP successfully transfers an application data write of various sizes (CSMA)"),
171 m_writeResults (false)
184 uint16_t sinkPort = 50000;
185 double sinkStopTime = 40;
186 double writerStopTime = 30;
187 double simStopTime = 60;
210 address.SetBase (
"10.1.1.0",
"255.255.255.252");
215 socketWriter->
Setup (n0, sinkAddress);
225 apps.
Stop (sinkStopTimeObj);
233 Simulator::Schedule (
Seconds (10), &SocketWriter::Write, socketWriter, 1);
235 Simulator::Schedule (
Seconds (12), &SocketWriter::Write, socketWriter, 10);
237 Simulator::Schedule (
Seconds (14), &SocketWriter::Write, socketWriter, 100);
239 Simulator::Schedule (
Seconds (16), &SocketWriter::Write, socketWriter, 1000);
242 Simulator::Schedule (
Seconds (16), &SocketWriter::Write, socketWriter, 1001);
245 Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter);
249 csma.EnablePcapAll (
"tcp-socket-test-case-2",
false);
251 Simulator::Stop (simStopTimeObj);
253 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
TestVectors< uint32_t > m_responses
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
static Ns3TcpSocketTestSuite ns3TcpSocketTestSuite
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
TestVectors< uint32_t > m_responses
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
build a set of CsmaNetDevice objects
void SetStopTime(Time stop)
Specify application stop time.
void SetStartTime(Time start)
Specify application start time.
void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)
a polymophic address class
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
virtual ~Ns3TcpSocketTestCase2()
Simulation virtual time values and global simulation resolution.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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...
Hold variables of type string.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
#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.
void Connect(std::string path, const CallbackBase &cb)
T Get(std::size_t i) const
Get the i'th test vector.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
holds a vector of ns3::Application pointers.
Build a set of PointToPointNetDevice objects.
keep track of a set of node pointers.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
virtual ~Ns3TcpSocketTestCase1()
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
std::size_t GetN(void) const
Get the total number of test vectors.
TestVectors< uint32_t > m_inputs
void Setup(Ptr< Node > node, Address peer)
TestVectors< uint32_t > m_inputs
aggregate IP/TCP/UDP functionality to existing Nodes.
std::size_t Add(T vector)
static void SinkRx(std::string path, Ptr< const Packet > p, const Address &address)