A Discrete-Event Network Simulator
API
ns3tcp-loss-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #include <iomanip>
20 
21 #include "ns3/log.h"
22 #include "ns3/abort.h"
23 #include "ns3/test.h"
24 #include "ns3/pcap-file.h"
25 #include "ns3/config.h"
26 #include "ns3/string.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/data-rate.h"
29 #include "ns3/inet-socket-address.h"
30 #include "ns3/point-to-point-helper.h"
31 #include "ns3/internet-stack-helper.h"
32 #include "ns3/ipv4-global-routing-helper.h"
33 #include "ns3/ipv4-address-helper.h"
34 #include "ns3/packet-sink-helper.h"
35 #include "ns3/tcp-socket-factory.h"
36 #include "ns3/node-container.h"
37 #include "ns3/simulator.h"
38 #include "ns3/error-model.h"
39 #include "ns3/pointer.h"
40 #include "ns3tcp-socket-writer.h"
41 #include "ns3/tcp-westwood.h"
42 #include "ns3/tcp-header.h"
43 
44 using namespace ns3;
45 
46 NS_LOG_COMPONENT_DEFINE ("Ns3TcpLossTest");
47 
48 // The below boolean constants should only be changed to 'true'
49 // during test debugging (i.e. do not commit the value 'true')
50 
51 // set to 'true' to have the test suite overwrite the response vectors
52 // stored in the test directory. This should only be done if you are
53 // convinced through other means (e.g. pcap tracing or logging) that the
54 // revised vectors are the correct ones. In other words, don't simply
55 // enable this to true to clear a failing test without looking at the
56 // results closely.
57 const bool WRITE_VECTORS = false; // set to true to write response vectors
58 const bool WRITE_PCAP = false; // set to true to write out pcap
59 const bool WRITE_LOGGING = false; // set to true to write logging
60 const uint32_t PCAP_LINK_TYPE = 1187373557; // Some large random number -- we use to verify data was written by this program
61 const uint32_t PCAP_SNAPLEN = 64; // Don't bother to save much data
62 
63 // ===========================================================================
64 // Tests of TCP implementation loss behavior
65 // ===========================================================================
66 //
67 
69 {
70 public:
72  Ns3TcpLossTestCase (std::string tcpModel, uint32_t testCase);
74  {
75  }
76 
77 private:
78  virtual void DoSetup (void);
79  virtual void DoRun (void);
80  virtual void DoTeardown (void);
81 
83  std::string m_pcapFilename;
85  uint32_t m_testCase;
86  uint32_t m_totalTxBytes;
87  uint32_t m_currentTxBytes;
92  std::string m_tcpModel;
93 
94  void Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
95  void CwndTracer (uint32_t oldval, uint32_t newval);
96  void WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace);
97  void StartFlow (Ptr<Socket> localSocket,
98  Ipv4Address servAddress,
99  uint16_t servPort);
100 
101 };
102 
104  : TestCase ("Check the operation of the TCP state machine for several cases"),
105  m_testCase (0),
106  m_totalTxBytes (200000),
107  m_currentTxBytes (0),
108  m_writeVectors (WRITE_VECTORS),
109  m_writeResults (WRITE_PCAP),
110  m_writeLogging (WRITE_LOGGING),
111  m_needToClose (true),
112  m_tcpModel ("ns3::TcpWestwood")
113 {
114 }
115 
116 Ns3TcpLossTestCase::Ns3TcpLossTestCase (std::string tcpModel, uint32_t testCase)
117  : TestCase ("Check the behaviour of TCP upon packet losses"),
118  m_testCase (testCase),
119  m_totalTxBytes (200000),
120  m_currentTxBytes (0),
121  m_writeVectors (WRITE_VECTORS),
122  m_writeResults (WRITE_PCAP),
123  m_writeLogging (WRITE_LOGGING),
124  m_needToClose (true),
125  m_tcpModel (tcpModel)
126 {
127 }
128 
129 void
131 {
132  // This test was written before SACK was added to ns-3
133  Config::SetDefault ("ns3::TcpSocketBase::Sack", BooleanValue (false));
134 
135  //
136  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
137  // the data directory
138  //
139  std::ostringstream oss;
140  oss << "ns3tcp-loss-" << m_tcpModel << m_testCase << "-response-vectors.pcap";
141  m_pcapFilename = CreateDataDirFilename (oss.str ());
142 
143  if (m_writeVectors)
144  {
145  m_pcapFile.Open (m_pcapFilename, std::ios::out | std::ios::binary);
147  }
148  else
149  {
150  m_pcapFile.Open (m_pcapFilename, std::ios::in | std::ios::binary);
152  "Wrong response vectors in directory: opening " <<
154  }
155 }
156 
157 void
159 {
160  m_pcapFile.Close ();
161 }
162 
163 void
164 Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface)
165 {
166  //
167  // We're not testing IP so remove and toss the header. In order to do this,
168  // though, we need to copy the packet since we have a const version.
169  //
170  Ptr<Packet> received = packet->Copy ();
171  Ipv4Header ipHeader;
172  received->RemoveHeader (ipHeader);
173 
174  //
175  // What is left is the TCP header and any data that may be sent. We aren't
176  // sending any TCP data, so we expect what remains is only TCP header, which
177  // is a small thing to save.
178  //
179  if (m_writeVectors)
180  {
181  //
182  // Save the TCP under test response for later testing.
183  //
184  Time tNow = Simulator::Now ();
185  int64_t tMicroSeconds = tNow.GetMicroSeconds ();
186 
187 
188  m_pcapFile.Write (uint32_t (tMicroSeconds / 1000000),
189  uint32_t (tMicroSeconds % 1000000),
190  received);
191  }
192  else
193  {
194  //
195  // Read the TCP under test expected response from the expected vector
196  // file and see if it still does the right thing.
197  //
198  uint8_t expectedBuffer[PCAP_SNAPLEN];
199  uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
200  m_pcapFile.Read (expectedBuffer, sizeof(expectedBuffer), tsSec, tsUsec, inclLen, origLen, readLen);
201 
202  NS_LOG_INFO ("read " << readLen << " bytes");
203 
204  uint8_t *actual = new uint8_t[readLen];
205  received->CopyData (actual, readLen);
206 
207  int result = memcmp (actual, expectedBuffer, readLen);
208 
209  TcpHeader expectedHeader, receivedHeader;
210  Ptr<Packet> expected = Create<Packet> (expectedBuffer, readLen);
211 
212  expected->RemoveHeader (expectedHeader);
213  received->RemoveHeader (receivedHeader);
214 
215  NS_LOG_DEBUG ("Expected " << expectedHeader << " received: " << receivedHeader);
216 
217  delete [] actual;
218 
219  //
220  // Avoid streams of errors -- only report the first.
221  //
222  if (IsStatusSuccess ())
223  {
224  NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error: " << m_tcpModel << "-" << m_testCase);
225  }
226  }
227 }
228 
229 void
230 Ns3TcpLossTestCase::CwndTracer (uint32_t oldval, uint32_t newval)
231 {
232  if (m_writeLogging)
233  {
234  *(m_osw->GetStream ()) << "Moving cwnd from " << oldval << " to " << newval
235  << " at time " << Simulator::Now ().GetSeconds ()
236  << " seconds" << std::endl;
237  }
238 }
239 
241 // Implementing an "application" to send bytes over a TCP connection
242 void
244 {
246  {
247  uint32_t left = m_totalTxBytes - m_currentTxBytes;
248  uint32_t dataOffset = m_currentTxBytes % 1040;
249  uint32_t toWrite = 1040 - dataOffset;
250  uint32_t txAvail = localSocket->GetTxAvailable ();
251  toWrite = std::min (toWrite, left);
252  toWrite = std::min (toWrite, txAvail);
253  if (txAvail == 0)
254  {
255  return;
256  }
257  if (m_writeLogging)
258  {
259  std::clog << "Submitting " << toWrite
260  << " bytes to TCP socket" << std::endl;
261  }
262  int amountSent = localSocket->Send (0, toWrite, 0);
263  NS_ASSERT (amountSent > 0); // Given GetTxAvailable() non-zero, amountSent should not be zero
264  m_currentTxBytes += amountSent;
265  }
266  if (m_needToClose)
267  {
268  if (m_writeLogging)
269  {
270  std::clog << "Close socket at "
271  << Simulator::Now ().GetSeconds () << std::endl;
272  }
273  localSocket->Close ();
274  m_needToClose = false;
275  }
276 }
277 
278 void
280  Ipv4Address servAddress,
281  uint16_t servPort)
282 {
283  if (m_writeLogging)
284  {
285  std::clog << "Starting flow at time "
286  << Simulator::Now ().GetSeconds () << std::endl;
287  }
288  localSocket->Connect (InetSocketAddress (servAddress, servPort)); // connect
289 
290  // tell the tcp implementation to call WriteUntilBufferFull again
291  // if we blocked and new tx buffer space becomes available
292  localSocket->SetSendCallback (MakeCallback
294  this));
295  WriteUntilBufferFull (localSocket, localSocket->GetTxAvailable ());
296 }
297 
298 void
300 {
301  // Network topology
302  //
303  // 8Mb/s, 0.1ms 0.8Mb/s, 100ms
304  // s1-----------------r1-----------------k1
305  //
306  // Example corresponding to simulations in the paper "Simulation-based
307  // Comparisons of Tahoe, Reno, and SACK TCP
308 
309  Config::SetDefault ("ns3::TcpSocketBase::Sack", BooleanValue (false));
310 
311  std::ostringstream tcpModel;
312  tcpModel << "ns3::Tcp" << m_tcpModel;
313  if (m_tcpModel.compare ("WestwoodPlus") == 0)
314  {
315  Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
316  TypeIdValue (TcpWestwood::GetTypeId ()));
317  Config::SetDefault ("ns3::TcpWestwood::ProtocolType",
318  EnumValue (TcpWestwood::WESTWOODPLUS));
319  }
320  else
321  {
322  Config::SetDefault ("ns3::TcpL4Protocol::SocketType",
323  StringValue (tcpModel.str ()));
324  }
325 
326  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
327  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
328  Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (false));
329 
330  if (m_writeLogging)
331  {
333  LogComponentEnable ("Ns3TcpLossTest", LOG_LEVEL_ALL);
334  LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
335  LogComponentEnable ("TcpWestwood", LOG_LEVEL_ALL);
336  LogComponentEnable ("TcpCongestionOps", LOG_LEVEL_INFO);
337  LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
338  }
339 
341  // Topology construction
342  //
343 
344  // Create three nodes: s1, r1, and k1
345  NodeContainer s1r1;
346  s1r1.Create (2);
347 
348  NodeContainer r1k1;
349  r1k1.Add (s1r1.Get (1));
350  r1k1.Create (1);
351 
352  // Set up TCP/IP stack to all nodes (and create loopback device at device 0)
353  InternetStackHelper internet;
354  internet.InstallAll ();
355 
356  // Connect the nodes
357  PointToPointHelper p2p;
358  p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (8000000)));
359  p2p.SetChannelAttribute ("Delay", TimeValue (Seconds (0.0001)));
360  NetDeviceContainer dev0 = p2p.Install (s1r1);
361  p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (800000)));
362  p2p.SetChannelAttribute ("Delay", TimeValue (Seconds (0.1)));
363  NetDeviceContainer dev1 = p2p.Install (r1k1);
364 
365  // Add IP addresses to each network interfaces
366  Ipv4AddressHelper ipv4;
367  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
368  ipv4.Assign (dev0);
369  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
370  Ipv4InterfaceContainer ipInterfs = ipv4.Assign (dev1);
371 
372  // Set up routes to all nodes
373  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
374 
376  // Send 20000 (totalTxBytes) bytes from node s1 to node k1
377  //
378 
379  // Create a packet sink to receive packets on node k1
380  uint16_t servPort = 50000; // Destination port number
381  PacketSinkHelper sink ("ns3::TcpSocketFactory",
382  InetSocketAddress (Ipv4Address::GetAny (), servPort));
383  ApplicationContainer apps = sink.Install (r1k1.Get (1));
384  apps.Start (Seconds (0.0));
385  apps.Stop (Seconds (100.0));
386 
387  // Create a data source to send packets on node s0.
388  // Instead of full application, here use the socket directly by
389  // registering callbacks in function StarFlow().
390  Ptr<Socket> localSocket = Socket::CreateSocket (s1r1.Get (0), TcpSocketFactory::GetTypeId ());
391  localSocket->Bind ();
392  Simulator::ScheduleNow (&Ns3TcpLossTestCase::StartFlow,
393  this,
394  localSocket,
395  ipInterfs.GetAddress (1),
396  servPort);
397 
398  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
400 
402  ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
404 
406  // Set up loss model at node k1
407  //
408  std::list<uint32_t> sampleList;
409  switch (m_testCase)
410  {
411  case 0:
412  break;
413  case 1:
414  // Force a loss for 15th data packet. TCP cwnd will be at 14 segments
415  // (14000 bytes) when duplicate acknowledgments start to come.
416  sampleList.push_back (16);
417  break;
418  case 2:
419  sampleList.push_back (16);
420  sampleList.push_back (17);
421  break;
422  case 3:
423  sampleList.push_back (16);
424  sampleList.push_back (17);
425  sampleList.push_back (18);
426  break;
427  case 4:
428  sampleList.push_back (16);
429  sampleList.push_back (17);
430  sampleList.push_back (18);
431  sampleList.push_back (19);
432  break;
433  default:
434  NS_FATAL_ERROR ("Program fatal error: loss value " << m_testCase << " not supported.");
435  break;
436  }
437 
438  Ptr<ReceiveListErrorModel> pem = CreateObject<ReceiveListErrorModel> ();
439  pem->SetList (sampleList);
440  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
441 
442  // One can toggle the comment for the following line on or off to see the
443  // effects of finite send buffer modelling. One can also change the size of
444  // that buffer.
445  // localSocket->SetAttribute("SndBufSize", UintegerValue(4096));
446 
447  std::ostringstream oss;
448  oss << "tcp-loss-" << m_tcpModel << m_testCase << "-test-case";
449  if (m_writeResults)
450  {
451  p2p.EnablePcapAll (oss.str ());
452  p2p.EnableAsciiAll (oss.str ());
453  }
454 
455  std::ostringstream oss2;
456  oss2 << "src/test/ns3tcp/Tcp" << m_tcpModel << "." << m_testCase << ".log";
457  AsciiTraceHelper ascii;
458  if (m_writeLogging)
459  {
460  m_osw = ascii.CreateFileStream (oss2.str ());
461  *(m_osw->GetStream ()) << std::setprecision (9) << std::fixed;
462  p2p.EnableAsciiAll (m_osw);
463  }
464 
465  // Finally, set up the simulator to run. The 1000 second hard limit is a
466  // failsafe in case some change above causes the simulation to never end
467  Simulator::Stop (Seconds (1000));
468  Simulator::Run ();
469  Simulator::Destroy ();
470 }
471 
473 {
474 public:
476 };
477 
479  : TestSuite ("ns3-tcp-loss", SYSTEM)
480 {
481  // We can't use NS_TEST_SOURCEDIR variable here because we use subdirectories
482  SetDataDir ("src/test/ns3tcp/response-vectors");
483  Packet::EnablePrinting (); // Enable packet metadata for all test cases
484 
485  AddTestCase (new Ns3TcpLossTestCase ("NewReno", 0), TestCase::QUICK);
486  AddTestCase (new Ns3TcpLossTestCase ("NewReno", 1), TestCase::QUICK);
487  AddTestCase (new Ns3TcpLossTestCase ("NewReno", 2), TestCase::QUICK);
488  AddTestCase (new Ns3TcpLossTestCase ("NewReno", 3), TestCase::QUICK);
489  AddTestCase (new Ns3TcpLossTestCase ("NewReno", 4), TestCase::QUICK);
490 
491  AddTestCase (new Ns3TcpLossTestCase ("Westwood", 0), TestCase::QUICK);
492  AddTestCase (new Ns3TcpLossTestCase ("Westwood", 1), TestCase::QUICK);
493  AddTestCase (new Ns3TcpLossTestCase ("Westwood", 2), TestCase::QUICK);
494  AddTestCase (new Ns3TcpLossTestCase ("Westwood", 3), TestCase::QUICK);
495  AddTestCase (new Ns3TcpLossTestCase ("Westwood", 4), TestCase::QUICK);
496 
497  AddTestCase (new Ns3TcpLossTestCase ("WestwoodPlus", 0), TestCase::QUICK);
498  AddTestCase (new Ns3TcpLossTestCase ("WestwoodPlus", 1), TestCase::QUICK);
499  AddTestCase (new Ns3TcpLossTestCase ("WestwoodPlus", 2), TestCase::QUICK);
500  AddTestCase (new Ns3TcpLossTestCase ("WestwoodPlus", 3), TestCase::QUICK);
501  AddTestCase (new Ns3TcpLossTestCase ("WestwoodPlus", 4), TestCase::QUICK);
502 
503 }
504 
506 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:56
holds a vector of ns3::Application pointers.
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.
Definition: nstime.h:102
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
an Inet address class
const bool WRITE_PCAP
AttributeValue implementation for Boolean.
Definition: boolean.h:36
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void Ipv4L3Tx(std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Hold variables of type string.
Definition: string.h:41
#define min(a, b)
Definition: 80211b.c:42
NetDeviceContainer Install(NodeContainer c)
A suite of tests to run.
Definition: test.h:1343
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:361
void StartFlow(Ptr< Socket > localSocket, Ipv4Address servAddress, uint16_t servPort)
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:345
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
aggregate IP/TCP/UDP functionality to existing Nodes.
#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:283
const bool WRITE_VECTORS
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we&#39;ll use to write the traced bits. ...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:1153
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void StartFlow(Ptr< Socket >, Ipv4Address, uint16_t)
bool IsStatusSuccess(void) const
Check if all tests passed.
Definition: test.cc:458
Class for representing data rates.
Definition: data-rate.h:88
Packet header for IPv4.
Definition: ipv4-header.h:33
virtual void DoRun(void)
Implementation to actually run this TestCase.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:370
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 ...
Hold variables of type enum.
Definition: enum.h:54
static void CwndTracer(uint32_t oldval, uint32_t newval)
void CwndTracer(uint32_t oldval, uint32_t newval)
AttributeValue implementation for Time.
Definition: nstime.h:1132
A class representing a pcap file.
Definition: pcap-file.h:42
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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:469
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< OutputStreamWrapper > m_osw
static Ns3TcpLossTestSuite ns3TcpLossTestSuite
LOG_INFO and above.
Definition: log.h:107
holds a vector of ns3::NetDevice pointers
AttributeValue implementation for TypeId.
Definition: type-id.h:611
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1610
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:862
const bool WRITE_LOGGING
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)
Definition: config.cc:873
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
const uint32_t PCAP_LINK_TYPE
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:369
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:394
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteUntilBufferFull(Ptr< Socket > localSocket, uint32_t txSpace)
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
std::string CreateDataDirFilename(std::string filename)
Construct the full path to a file in the data directory.
Definition: test.cc:412
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
void WriteUntilBufferFull(Ptr< Socket >, uint32_t)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
void Close(void)
Close the underlying file.
Definition: pcap-file.cc:88
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
Definition: socket.cc:121
void Open(std::string const &filename, std::ios::openmode mode)
Create a new pcap file or open an existing pcap file.
Definition: pcap-file.cc:325
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
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...
LOG_DEBUG and above.
Definition: log.h:104
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
Prefix all trace prints with function.
Definition: log.h:118
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:378
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:812
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found.
Definition: test.cc:465
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Print everything.
Definition: log.h:116
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint32_t GetDataLinkType(void)
Returns the data link type field of the pcap file as defined by the network field in the pcap global ...
Definition: pcap-file.cc:137
void Write(uint32_t tsSec, uint32_t tsUsec, uint8_t const *const data, uint32_t totalLen)
Write next packet to file.
Definition: pcap-file.cc:434
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
const uint32_t PCAP_SNAPLEN
virtual uint32_t GetTxAvailable(void) const =0
Returns the number of bytes which can be sent in a single call to Send.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.