A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3tcp-state-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
19
20#include "ns3/abort.h"
21#include "ns3/boolean.h"
22#include "ns3/config.h"
23#include "ns3/data-rate.h"
24#include "ns3/error-model.h"
25#include "ns3/inet-socket-address.h"
26#include "ns3/internet-stack-helper.h"
27#include "ns3/ipv4-address-helper.h"
28#include "ns3/ipv4-global-routing-helper.h"
29#include "ns3/log.h"
30#include "ns3/node-container.h"
31#include "ns3/packet-sink-helper.h"
32#include "ns3/pcap-file.h"
33#include "ns3/point-to-point-helper.h"
34#include "ns3/pointer.h"
35#include "ns3/simulator.h"
36#include "ns3/string.h"
37#include "ns3/tcp-header.h"
38#include "ns3/tcp-socket-factory.h"
39#include "ns3/test.h"
40#include "ns3/traffic-control-helper.h"
41#include "ns3/uinteger.h"
42
43#include <iomanip>
44#include <string>
45
46using namespace ns3;
47
48NS_LOG_COMPONENT_DEFINE("Ns3TcpStateTest");
49
50// The below boolean constants should only be changed to 'true'
51// during test debugging (i.e. do not commit the value 'true')
52
53// set to 'true' to have the test suite overwrite the response vectors
54// stored in the test directory. This should only be done if you are
55// convinced through other means (e.g. pcap tracing or logging) that the
56// revised vectors are the correct ones. In other words, don't simply
57// enable this to true to clear a failing test without looking at the
58// results closely.
59const bool WRITE_VECTORS = false; //!< Set to true to write response vectors.
60const bool WRITE_PCAP = false; //!< Set to true to write out pcap.
61const bool WRITE_LOGGING = false; //!< Set to true to write logging.
63 1187373554; //!< Some large random number -- we use to verify data was written by this program.
64const uint32_t PCAP_SNAPLEN = 64; //!< Don't bother to save much data.
65
66/**
67 * \ingroup system-tests-tcp
68 *
69 * \brief Tests of TCP implementation state machine behavior
70 */
72{
73 public:
75 /**
76 * Constructor.
77 * \param testCase Testcase number.
78 */
80
82 {
83 }
84
85 private:
86 void DoSetup() override;
87 void DoRun() override;
88 void DoTeardown() override;
89
90 std::string m_pcapFilename; //!< The PCAP filename.
91 PcapFile m_pcapFile; //!< The PCAP ffile.
92 uint32_t m_testCase; //!< Testcase number.
93 uint32_t m_totalTxBytes; //!< Total number of bytes to send.
94 uint32_t m_currentTxBytes; //!< Current number of bytes sent.
95 bool m_writeVectors; //!< True if response vectors have to be written (and not read).
96 bool m_writeResults; //!< True if write PCAP files.
97 bool m_writeLogging; //!< True if write logging.
98 bool m_needToClose; //!< Check if the sending socket need to be closed.
99
100 /**
101 * Check that the transmitted packets are consistent with the trace.
102 * This callback is hooked to ns3::Ipv4L3Protocol/Tx.
103 *
104 * \param context The callback context (unused).
105 * \param packet The transmitted packet.
106 * \param ipv4 The IPv4 object that did send the packet (unused).
107 * \param interface The IPv4 interface that did send the packet (unused).
108 */
109 void Ipv4L3Tx(std::string context,
110 Ptr<const Packet> packet,
111 Ptr<Ipv4> ipv4,
112 uint32_t interface);
113 /**
114 * Check that the received packets are consistent with the trace.
115 * This callback is hooked to ns3::Ipv4L3Protocol/Tx.
116 *
117 * \param context The callback context (unused).
118 * \param packet The transmitted packet.
119 * \param ipv4 The IPv4 object that did send the packet (unused).
120 * \param interface The IPv4 interface that did send the packet (unused).
121 */
122 void Ipv4L3Rx(std::string context,
123 Ptr<const Packet> packet,
124 Ptr<Ipv4> ipv4,
125 uint32_t interface);
126 /**
127 * Write to the socket until the buffer is full.
128 *
129 * \param localSocket The output socket.
130 * \param txSpace The space left on the socket (unused).
131 */
132 void WriteUntilBufferFull(Ptr<Socket> localSocket, uint32_t txSpace);
133 /**
134 * Start transmitting a TCP flow.
135 *
136 * \param localSocket The sending socket.
137 * \param servAddress The IPv4 address of the server (i.e., the destination address).
138 * \param servPort The TCP port of the server (i.e., the destination port).
139 */
140 void StartFlow(Ptr<Socket> localSocket, Ipv4Address servAddress, uint16_t servPort);
141};
142
144 : TestCase("Check the operation of the TCP state machine for several cases"),
145 m_testCase(0),
146 m_totalTxBytes(20000),
147 m_currentTxBytes(0),
148 m_writeVectors(WRITE_VECTORS),
149 m_writeResults(WRITE_PCAP),
150 m_writeLogging(WRITE_LOGGING),
151 m_needToClose(true)
152{
153}
154
156 : TestCase("Check the operation of the TCP state machine for several cases"),
157 m_testCase(testCase),
158 m_totalTxBytes(20000),
159 m_currentTxBytes(0),
160 m_writeVectors(WRITE_VECTORS),
161 m_writeResults(WRITE_PCAP),
162 m_writeLogging(WRITE_LOGGING),
163 m_needToClose(true)
164{
165}
166
167void
169{
170 //
171 // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
172 // the data directory
173 //
174 std::ostringstream oss;
175 oss << "ns3tcp-state" << m_testCase << "-response-vectors.pcap";
177 NS_LOG_INFO("m_pcapFilename=" << m_pcapFilename);
178
179 if (m_writeVectors)
180 {
181 m_pcapFile.Open(m_pcapFilename, std::ios::out | std::ios::binary);
183 }
184 else
185 {
186 m_pcapFile.Open(m_pcapFilename, std::ios::in | std::ios::binary);
188 "Wrong response vectors in directory: opening " << m_pcapFilename);
189 }
190}
191
192void
194{
196}
197
198void
200{
201 Ptr<Packet> received = packet->Copy();
202 Ipv4Header ipHeader;
203 TcpHeader tcpHeader;
204 received->RemoveHeader(ipHeader);
205 received->RemoveHeader(tcpHeader);
206
207 NS_LOG_DEBUG("Received: " << tcpHeader);
208}
209
210void
212{
213 //
214 // We're not testing IP so remove and toss the header. In order to do this,
215 // though, we need to copy the packet since we have a const version.
216 //
217 Ptr<Packet> received = packet->Copy();
218 Ipv4Header ipHeader;
219 received->RemoveHeader(ipHeader);
220
221 //
222 // What is left is the TCP header and any data that may be sent. We aren't
223 // sending any TCP data, so we expect what remains is only TCP header, which
224 // is a small thing to save.
225 //
226 if (m_writeVectors)
227 {
228 //
229 // Save the TCP under test response for later testing.
230 //
231 Time tNow = Simulator::Now();
232 int64_t tMicroSeconds = tNow.GetMicroSeconds();
233
234 m_pcapFile.Write(uint32_t(tMicroSeconds / 1000000),
235 uint32_t(tMicroSeconds % 1000000),
236 received);
237 }
238 else
239 {
240 //
241 // Read the TCP under test expected response from the expected vector
242 // file and see if it still does the right thing.
243 //
244 uint8_t expectedBuffer[PCAP_SNAPLEN];
245 uint32_t tsSec;
246 uint32_t tsUsec;
247 uint32_t inclLen;
248 uint32_t origLen;
249 uint32_t readLen;
251 .Read(expectedBuffer, sizeof(expectedBuffer), tsSec, tsUsec, inclLen, origLen, readLen);
252
253 NS_LOG_INFO("read " << readLen << " bytes");
254
255 auto actual = new uint8_t[readLen];
256 received->CopyData(actual, readLen);
257
258 int result = memcmp(actual, expectedBuffer, readLen);
259
260 TcpHeader expectedHeader;
261 TcpHeader receivedHeader;
262 Ptr<Packet> expected = Create<Packet>(expectedBuffer, readLen);
263
264 expected->RemoveHeader(expectedHeader);
265 received->RemoveHeader(receivedHeader);
266
267 NS_LOG_DEBUG("Expected " << expectedHeader << " received: " << receivedHeader);
268
269 delete[] actual;
270
271 //
272 // Avoid streams of errors -- only report the first.
273 //
274 if (IsStatusSuccess())
275 {
276 NS_TEST_EXPECT_MSG_EQ(result, 0, "Expected data comparison error");
277 }
278 }
279}
280
281////////////////////////////////////////////////////////////////////
282// Implementing an "application" to send bytes over a TCP connection
283void
285{
287 {
289 uint32_t dataOffset = m_currentTxBytes % 1040;
290 uint32_t toWrite = 1040 - dataOffset;
291 uint32_t txAvail = localSocket->GetTxAvailable();
292 toWrite = std::min(toWrite, left);
293 toWrite = std::min(toWrite, txAvail);
294 if (txAvail == 0)
295 {
296 return;
297 }
298 if (m_writeLogging)
299 {
300 std::clog << "Submitting " << toWrite << " bytes to TCP socket" << std::endl;
301 }
302 int amountSent = localSocket->Send(nullptr, toWrite, 0);
303 NS_ASSERT(amountSent > 0); // Given GetTxAvailable() non-zero, amountSent should not be zero
304 m_currentTxBytes += amountSent;
305 }
306 if (m_needToClose)
307 {
308 if (m_writeLogging)
309 {
310 std::clog << "Close socket at " << Simulator::Now().GetSeconds() << std::endl;
311 }
312 localSocket->Close();
313 m_needToClose = false;
314 }
315}
316
317void
318Ns3TcpStateTestCase::StartFlow(Ptr<Socket> localSocket, Ipv4Address servAddress, uint16_t servPort)
319{
320 if (m_writeLogging)
321 {
322 std::clog << "Starting flow at time " << Simulator::Now().GetSeconds() << std::endl;
323 }
324
325 localSocket->Connect(InetSocketAddress(servAddress, servPort)); // connect
326
327 // tell the tcp implementation to call WriteUntilBufferFull again
328 // if we blocked and new tx buffer space becomes available
329 localSocket->SetSendCallback(MakeCallback(&Ns3TcpStateTestCase::WriteUntilBufferFull, this));
330 WriteUntilBufferFull(localSocket, localSocket->GetTxAvailable());
331}
332
333void
335{
336 // Network topology
337 //
338 // 10Mb/s, 0.1ms 10Mb/s, 0.1ms
339 // n0-----------------n1-----------------n2
340
341 std::string tcpModel("ns3::TcpNewReno");
342
343 Config::SetDefault("ns3::TcpSocketBase::Sack", BooleanValue(false));
344 Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue(tcpModel));
345 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1000));
346 Config::SetDefault("ns3::TcpSocket::DelAckCount", UintegerValue(1));
347 Config::SetDefault("ns3::DropTailQueue<Packet>::MaxSize", StringValue("20p"));
348 Config::SetDefault("ns3::TcpSocketBase::Timestamp", BooleanValue(false));
349
350 if (m_writeLogging)
351 {
353 LogComponentEnable("ErrorModel", LOG_LEVEL_DEBUG);
354 LogComponentEnable("Ns3TcpStateTest", LOG_LEVEL_DEBUG);
355 LogComponentEnable("TcpCongestionOps", LOG_LEVEL_INFO);
356 LogComponentEnable("TcpSocketBase", LOG_LEVEL_INFO);
357 }
358
359 ////////////////////////////////////////////////////////
360 // Topology construction
361 //
362
363 // Create three nodes
364 NodeContainer n0n1;
365 n0n1.Create(2);
366
368 n1n2.Add(n0n1.Get(1));
369 n1n2.Create(1);
370
371 // Set up TCP/IP stack to all nodes (and create loopback device at device 0)
372 InternetStackHelper internet;
373 internet.InstallAll();
374
375 // Connect the nodes
377 p2p.SetDeviceAttribute("DataRate", DataRateValue(DataRate(1000000)));
378 p2p.SetChannelAttribute("Delay", TimeValue(Seconds(0.0001)));
379 NetDeviceContainer dev0 = p2p.Install(n0n1);
380 NetDeviceContainer dev1 = p2p.Install(n1n2);
381
382 // Use PfifoFast queue disc
384 tch.SetRootQueueDisc("ns3::PfifoFastQueueDisc");
385 tch.Install(dev0);
386 tch.Install(dev1);
387
388 // Add IP addresses to each network interfaces
390 ipv4.SetBase("10.1.3.0", "255.255.255.0");
391 ipv4.Assign(dev0);
392 ipv4.SetBase("10.1.2.0", "255.255.255.0");
393 Ipv4InterfaceContainer ipInterfs = ipv4.Assign(dev1);
394
395 // Set up routes to all nodes
397
398 ////////////////////////////////////////////////////////
399 // A flow from node n0 to node n2
400 //
401
402 // Create a packet sink to receive packets on node n2
403 uint16_t servPort = 50000; // Destination port number
404 PacketSinkHelper sink("ns3::TcpSocketFactory",
406 ApplicationContainer sinkApps = sink.Install(n1n2.Get(1));
407 sinkApps.Start(Seconds(0.0));
408 sinkApps.Stop(Seconds(100.0));
409
410 // Create a data source to send packets on node n0
411 // Instead of full application, here use the socket directly by
412 // registering callbacks in function StarFlow().
414 localSocket->Bind();
416 this,
417 localSocket,
418 ipInterfs.GetAddress(1),
419 servPort);
420
421 Config::Connect("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
423
424 Config::Connect("/NodeList/0/$ns3::Ipv4L3Protocol/Rx",
426
427 ////////////////////////////////////////////////////////
428 // Set up different test cases: Lost model at node n1, different file size
429 //
430
431 std::list<uint32_t> dropListN0;
432 std::list<uint32_t> dropListN1;
433 std::string caseDescription;
434 switch (m_testCase)
435 {
436 case 0:
437 m_totalTxBytes = 1000;
438 caseDescription = "Verify connection establishment";
439 break;
440 case 1:
441 m_totalTxBytes = 100 * 1000;
442 caseDescription = "Verify a bigger (100 pkts) transfer: Sliding window operation, etc.";
443 break;
444 case 2:
445 m_totalTxBytes = 1000;
446 caseDescription = "Survive a SYN lost";
447 dropListN0.push_back(0);
448 break;
449 case 3:
450 m_totalTxBytes = 2000;
451 caseDescription = "Survive a SYN+ACK lost";
452 dropListN1.push_back(0);
453 break;
454 case 4:
455 m_totalTxBytes = 2000;
456 caseDescription = "Survive a ACK (last packet in 3-way handshake) lost";
457 dropListN0.push_back(1);
458 break;
459 case 5:
460 m_totalTxBytes = 0;
461 caseDescription = "Immediate FIN upon SYN_RCVD";
462 m_needToClose = false;
463 dropListN0.push_back(1); // Hide the ACK in 3WHS
464 Simulator::Schedule(Seconds(0.002), &Socket::Close, localSocket);
465 break;
466 case 6:
467 m_totalTxBytes = 5000;
468 caseDescription = "Simulated simultaneous close";
469 dropListN1.push_back(5); // Hide the ACK-to-FIN from n2
470 break;
471 case 7:
472 m_totalTxBytes = 5000;
473 caseDescription = "FIN check 1: Loss of initiator's FIN. Wait until app close";
474 m_needToClose = false;
475 dropListN0.push_back(7); // Hide the FIN from n0
476 Simulator::Schedule(Seconds(0.04), &Socket::Close, localSocket);
477 break;
478 case 8:
479 m_totalTxBytes = 5000;
480 caseDescription =
481 "FIN check 2: Loss responder's FIN. FIN will be resent after last ack timeout";
482 dropListN1.push_back(6); // Hide the FIN from n2
483 break;
484 default:
485 NS_FATAL_ERROR("Program fatal error: specified test case not supported: " << m_testCase);
486 break;
487 }
488
489 Ptr<ReceiveListErrorModel> errN0 = CreateObject<ReceiveListErrorModel>();
490 errN0->SetList(dropListN0);
491 dev0.Get(1)->SetAttribute("ReceiveErrorModel", PointerValue(errN0));
492
493 Ptr<ReceiveListErrorModel> errN1 = CreateObject<ReceiveListErrorModel>();
494 errN1->SetList(dropListN1);
495 dev1.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(errN1));
496
497 std::ostringstream oss;
498 oss << "tcp-state" << m_testCase << "-test-case";
499 if (m_writeResults)
500 {
501 p2p.EnablePcapAll(oss.str());
502 p2p.EnableAsciiAll(oss.str());
503 }
504
505 if (m_writeLogging)
506 {
507 Ptr<OutputStreamWrapper> osw = Create<OutputStreamWrapper>(&std::clog);
508 *(osw->GetStream()) << std::setprecision(9) << std::fixed;
509 p2p.EnableAsciiAll(osw);
510
511 std::clog << std::endl
512 << "Running TCP test-case " << m_testCase << ": " << caseDescription << std::endl;
513 }
514
515 // Finally, set up the simulator to run. The 1000 second hard limit is a
516 // failsafe in case some change above causes the simulation to never end
520}
521
522/**
523 * \ingroup system-tests-tcp
524 *
525 * TCP implementation state machine behavior TestSuite.
526 */
528{
529 public:
531};
532
534 : TestSuite("ns3-tcp-state", Type::SYSTEM)
535{
536 // We can't use NS_TEST_SOURCEDIR variable here because we use subdirectories
537 SetDataDir("src/test/ns3tcp/response-vectors");
538 Packet::EnablePrinting(); // Enable packet metadata for all test cases
539
540 AddTestCase(new Ns3TcpStateTestCase(0), TestCase::Duration::QUICK);
541 AddTestCase(new Ns3TcpStateTestCase(1), TestCase::Duration::QUICK);
542 AddTestCase(new Ns3TcpStateTestCase(2), TestCase::Duration::QUICK);
543 AddTestCase(new Ns3TcpStateTestCase(3), TestCase::Duration::QUICK);
544 AddTestCase(new Ns3TcpStateTestCase(4), TestCase::Duration::QUICK);
545 AddTestCase(new Ns3TcpStateTestCase(5), TestCase::Duration::QUICK);
546 AddTestCase(new Ns3TcpStateTestCase(6), TestCase::Duration::QUICK);
547 AddTestCase(new Ns3TcpStateTestCase(7), TestCase::Duration::QUICK);
548 AddTestCase(new Ns3TcpStateTestCase(8), TestCase::Duration::QUICK);
549}
550
551/// Do not forget to allocate an instance of this TestSuite.
NodeContainer n1n2
Nodecontainer n1 + n2.
Tests of TCP implementation state machine behavior.
bool m_writeVectors
True if response vectors have to be written (and not read).
void StartFlow(Ptr< Socket > localSocket, Ipv4Address servAddress, uint16_t servPort)
Start transmitting a TCP flow.
void Ipv4L3Tx(std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Check that the transmitted packets are consistent with the trace.
uint32_t m_totalTxBytes
Total number of bytes to send.
uint32_t m_currentTxBytes
Current number of bytes sent.
std::string m_pcapFilename
The PCAP filename.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
bool m_writeLogging
True if write logging.
void Ipv4L3Rx(std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Check that the received packets are consistent with the trace.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
void WriteUntilBufferFull(Ptr< Socket > localSocket, uint32_t txSpace)
Write to the socket until the buffer is full.
PcapFile m_pcapFile
The PCAP ffile.
bool m_needToClose
Check if the sending socket need to be closed.
bool m_writeResults
True if write PCAP files.
uint32_t m_testCase
Testcase number.
TCP implementation state machine behavior TestSuite.
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.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
Definition: data-rate.h:296
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Packet header for IPv4.
Definition: ipv4-header.h:34
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
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
static void EnablePrinting()
Enable printing packets metadata.
Definition: packet.cc:596
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
A class representing a pcap file.
Definition: pcap-file.h:43
void Close()
Close the underlying file.
Definition: pcap-file.cc:92
void Open(const std::string &filename, std::ios::openmode mode)
Create a new pcap file or open an existing pcap file.
Definition: pcap-file.cc:331
uint32_t GetDataLinkType()
Returns the data link type field of the pcap file as defined by the network field in the pcap global ...
Definition: pcap-file.cc:141
void Read(uint8_t *const data, uint32_t maxBytes, uint32_t &tsSec, uint32_t &tsUsec, uint32_t &inclLen, uint32_t &origLen, uint32_t &readLen)
Read next packet from file.
Definition: pcap-file.cc:479
void Init(uint32_t dataLinkType, uint32_t snapLen=SNAPLEN_DEFAULT, int32_t timeZoneCorrection=ZONE_DEFAULT, bool swapMode=false, bool nanosecMode=false)
Initialize the pcap file associated with this object.
Definition: pcap-file.cc:351
void Write(uint32_t tsSec, uint32_t tsUsec, const uint8_t *const data, uint32_t totalLen)
Write next packet to file.
Definition: pcap-file.cc:444
Build a set of PointToPointNetDevice objects.
AttributeValue implementation for Pointer.
Definition: pointer.h:48
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:605
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:72
virtual int Close()=0
Close a socket.
Hold variables of type string.
Definition: string.h:56
Header for the Transmission Control Protocol.
Definition: tcp-header.h:47
static TypeId GetTypeId()
Get the type ID.
encapsulates test code
Definition: test.h:1061
std::string CreateDataDirFilename(std::string filename)
Construct the full path to a file in the data directory.
Definition: test.cc:419
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
bool IsStatusSuccess() const
Check if all tests passed.
Definition: test.cc:471
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found.
Definition: test.cc:478
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:413
AttributeValue implementation for Time.
Definition: nstime.h:1406
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
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.
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:978
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:252
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
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...
Definition: callback.h:706
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition: log.h:113
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:104
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:320
const uint32_t PCAP_LINK_TYPE
Some large random number – we use to verify data was written by this program.
const bool WRITE_VECTORS
Set to true to write response vectors.
static Ns3TcpStateTestSuite g_ns3TcpLossTestSuite
Do not forget to allocate an instance of this TestSuite.
const bool WRITE_PCAP
Set to true to write out pcap.
const bool WRITE_LOGGING
Set to true to write logging.
const uint32_t PCAP_SNAPLEN
Don't bother to save much data.
Ptr< PacketSink > sink
Pointer to the packet sink application.
Definition: wifi-tcp.cc:55