A Discrete-Event Network Simulator
API
ns3tcp-state-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 #include <string>
21 
22 #include "ns3/log.h"
23 #include "ns3/abort.h"
24 #include "ns3/test.h"
25 #include "ns3/pcap-file.h"
26 #include "ns3/config.h"
27 #include "ns3/string.h"
28 #include "ns3/uinteger.h"
29 #include "ns3/boolean.h"
30 #include "ns3/data-rate.h"
31 #include "ns3/inet-socket-address.h"
32 #include "ns3/point-to-point-helper.h"
33 #include "ns3/internet-stack-helper.h"
34 #include "ns3/ipv4-global-routing-helper.h"
35 #include "ns3/ipv4-address-helper.h"
36 #include "ns3/packet-sink-helper.h"
37 #include "ns3/tcp-socket-factory.h"
38 #include "ns3/node-container.h"
39 #include "ns3/simulator.h"
40 #include "ns3/error-model.h"
41 #include "ns3/pointer.h"
42 #include "ns3tcp-socket-writer.h"
43 #include "ns3/tcp-header.h"
44 
45 using namespace ns3;
46 
47 NS_LOG_COMPONENT_DEFINE ("Ns3TcpStateTest");
48 
49 // The below boolean constants should only be changed to 'true'
50 // during test debugging (i.e. do not commit the value 'true')
51 
52 // set to 'true' to have the test suite overwrite the response vectors
53 // stored in the test directory. This should only be done if you are
54 // convinced through other means (e.g. pcap tracing or logging) that the
55 // revised vectors are the correct ones. In other words, don't simply
56 // enable this to true to clear a failing test without looking at the
57 // results closely.
58 const bool WRITE_VECTORS = false; // set to true to write response vectors
59 const bool WRITE_PCAP = false; // set to true to write out pcap
60 const bool WRITE_LOGGING = false; // set to true to write logging
61 const uint32_t PCAP_LINK_TYPE = 1187373554; // Some large random number -- we use to verify data was written by this program
62 const uint32_t PCAP_SNAPLEN = 64; // Don't bother to save much data
63 
64 // ===========================================================================
65 // Tests of TCP implementation state machine behavior
66 // ===========================================================================
67 //
68 
70 {
71 public:
73  Ns3TcpStateTestCase (uint32_t testCase);
74  virtual ~Ns3TcpStateTestCase () {}
75 
76 private:
77  virtual void DoSetup (void);
78  virtual void DoRun (void);
79  virtual void DoTeardown (void);
80 
81  std::string m_pcapFilename;
83  uint32_t m_testCase;
84  uint32_t m_totalTxBytes;
85  uint32_t m_currentTxBytes;
90 
91  void Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
92  void WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace);
93  void StartFlow (Ptr<Socket> localSocket,
94  Ipv4Address servAddress,
95  uint16_t servPort);
96 
97 };
98 
100  : TestCase ("Check the operation of the TCP state machine for several cases"),
101  m_testCase (0),
102  m_totalTxBytes (20000),
103  m_currentTxBytes (0),
104  m_writeVectors (WRITE_VECTORS),
105  m_writeResults (WRITE_PCAP),
106  m_writeLogging (WRITE_LOGGING),
107  m_needToClose (true)
108 {
109 }
110 
112  : TestCase ("Check the operation of the TCP state machine for several cases"),
113  m_testCase (testCase),
114  m_totalTxBytes (20000),
115  m_currentTxBytes (0),
116  m_writeVectors (WRITE_VECTORS),
117  m_writeResults (WRITE_PCAP),
118  m_writeLogging (WRITE_LOGGING),
119  m_needToClose (true)
120 {
121 }
122 
123 void
125 {
126  //
127  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
128  // the data directory
129  //
130  std::ostringstream oss;
131  oss << "ns3tcp-state" << m_testCase << "-response-vectors.pcap";
132  m_pcapFilename = CreateDataDirFilename (oss.str ());
133  std::cout << "m_pcapFilename=" << m_pcapFilename << std::endl;
134 
135  if (m_writeVectors)
136  {
137  m_pcapFile.Open (m_pcapFilename, std::ios::out|std::ios::binary);
139  }
140  else
141  {
142  m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
144  "Wrong response vectors in directory: opening " <<
146  }
147 }
148 
149 void
151 {
152  m_pcapFile.Close ();
153 }
154 
155 void
156 Ns3TcpStateTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface)
157 {
158  //
159  // We're not testing IP so remove and toss the header. In order to do this,
160  // though, we need to copy the packet since we have a const version.
161  //
162  Ptr<Packet> p = packet->Copy ();
163  Ipv4Header ipHeader;
164  p->RemoveHeader (ipHeader);
165 
166  if (g_log.IsEnabled (ns3::LOG_DEBUG))
167  {
168  TcpHeader th;
169  p->PeekHeader (th);
170  std::clog << Simulator::Now ().GetSeconds () << " TCP header " << th << std::endl;
171  }
172 
173  //
174  // What is left is the TCP header and any data that may be sent. We aren't
175  // sending any TCP data, so we expect what remains is only TCP header, which
176  // is a small thing to save.
177  //
178  if (m_writeVectors)
179  {
180  //
181  // Save the TCP under test response for later testing.
182  //
183  Time tNow = Simulator::Now ();
184  int64_t tMicroSeconds = tNow.GetMicroSeconds ();
185 
186  m_pcapFile.Write (uint32_t (tMicroSeconds / 1000000),
187  uint32_t (tMicroSeconds % 1000000),
188  p);
189  }
190  else
191  {
192  //
193  // Read the TCP under test expected response from the expected vector
194  // file and see if it still does the right thing.
195  //
196  uint8_t expected[PCAP_SNAPLEN];
197  uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
198  m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
199 
200  uint8_t *actual = new uint8_t[readLen];
201  p->CopyData (actual, readLen);
202 
203  uint32_t result = memcmp (actual, expected, readLen);
204 
205  delete [] actual;
206 
207  //
208  // Avoid streams of errors -- only report the first.
209  //
210  if (IsStatusSuccess ())
211  {
212  NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
213  }
214  }
215 }
216 
218 // Implementing an "application" to send bytes over a TCP connection
219 void
221 {
223  {
224  uint32_t left = m_totalTxBytes - m_currentTxBytes;
225  uint32_t dataOffset = m_currentTxBytes % 1040;
226  uint32_t toWrite = 1040 - dataOffset;
227  uint32_t txAvail = localSocket->GetTxAvailable ();
228  toWrite = std::min (toWrite, left);
229  toWrite = std::min (toWrite, txAvail);
230  if (txAvail == 0)
231  {
232  return;
233  };
234  if (m_writeLogging)
235  {
236  std::clog << "Submitting "
237  << toWrite << " bytes to TCP socket" << std::endl;
238  }
239  int amountSent = localSocket->Send (0, toWrite, 0);
240  NS_ASSERT (amountSent > 0); // Given GetTxAvailable() non-zero, amountSent should not be zero
241  m_currentTxBytes += amountSent;
242  }
243  if (m_needToClose)
244  {
245  if (m_writeLogging)
246  {
247  std::clog << "Close socket at "
248  << Simulator::Now ().GetSeconds ()
249  << std::endl;
250  }
251  localSocket->Close ();
252  m_needToClose = false;
253  }
254 }
255 
256 void
258  Ipv4Address servAddress,
259  uint16_t servPort)
260 {
261  if (m_writeLogging)
262  {
263  std::clog << "Starting flow at time "
264  << Simulator::Now ().GetSeconds ()
265  << std::endl;
266  }
267 
268  localSocket->Connect (InetSocketAddress (servAddress, servPort)); // connect
269 
270  // tell the tcp implementation to call WriteUntilBufferFull again
271  // if we blocked and new tx buffer space becomes available
272  localSocket->SetSendCallback (MakeCallback
274  this));
275  WriteUntilBufferFull (localSocket, localSocket->GetTxAvailable ());
276 }
277 
278 void
280 {
281  // Network topology
282  //
283  // 10Mb/s, 0.1ms 10Mb/s, 0.1ms
284  // n0-----------------n1-----------------n2
285 
286  std::string tcpModel ("ns3::TcpNewReno");
287 
288  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
289  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
290  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
291  Config::SetDefault ("ns3::Queue::MaxPackets", UintegerValue (20));
292  Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (false));
293 
294  if (m_writeLogging)
295  {
297  LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
298  LogComponentEnable ("Ns3TcpStateTest", LOG_LEVEL_DEBUG);
299  LogComponentEnable ("TcpCongestionOps", LOG_LEVEL_INFO);
300  LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
301  }
302 
304  // Topology construction
305  //
306 
307  // Create three nodes
308  NodeContainer n0n1;
309  n0n1.Create (2);
310 
312  n1n2.Add (n0n1.Get (1));
313  n1n2.Create (1);
314 
315  // Set up TCP/IP stack to all nodes (and create loopback device at device 0)
316  InternetStackHelper internet;
317  internet.InstallAll ();
318 
319  // Connect the nodes
320  PointToPointHelper p2p;
321  p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (1000000)));
322  p2p.SetChannelAttribute ("Delay", TimeValue (Seconds (0.0001)));
323  NetDeviceContainer dev0 = p2p.Install (n0n1);
324  NetDeviceContainer dev1 = p2p.Install (n1n2);
325 
326  // Add IP addresses to each network interfaces
327  Ipv4AddressHelper ipv4;
328  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
329  ipv4.Assign (dev0);
330  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
331  Ipv4InterfaceContainer ipInterfs = ipv4.Assign (dev1);
332 
333  // Set up routes to all nodes
334  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
335 
337  // A flow from node n0 to node n2
338  //
339 
340  // Create a packet sink to receive packets on node n2
341  uint16_t servPort = 50000; // Destination port number
342  PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), servPort));
343  ApplicationContainer sinkApps = sink.Install (n1n2.Get (1));
344  sinkApps.Start (Seconds (0.0));
345  sinkApps.Stop (Seconds (100.0));
346 
347  // Create a data source to send packets on node n0
348  // Instead of full application, here use the socket directly by
349  // registering callbacks in function StarFlow().
350  Ptr<Socket> localSocket = Socket::CreateSocket (n0n1.Get (0),
351  TcpSocketFactory::GetTypeId ());
352  localSocket->Bind ();
353  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this,
354  localSocket, ipInterfs.GetAddress (1), servPort);
355 
356  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
358 
360  // Set up different test cases: Lost model at node n1, different file size
361  //
362 
363  std::list<uint32_t> dropListN0;
364  std::list<uint32_t> dropListN1;
365  std::string caseDescription;
366  switch (m_testCase)
367  {
368  case 0:
369  m_totalTxBytes = 1000;
370  caseDescription = "Verify connection establishment";
371  break;
372  case 1:
373  m_totalTxBytes = 100*1000;
374  caseDescription = "Verify a bigger (100 pkts) transfer: Sliding window operation, etc.";
375  break;
376  case 2:
377  m_totalTxBytes = 1000;
378  caseDescription = "Survive a SYN lost";
379  dropListN0.push_back (0);
380  break;
381  case 3:
382  m_totalTxBytes = 2000;
383  caseDescription = "Survive a SYN+ACK lost";
384  dropListN1.push_back (0);
385  break;
386  case 4:
387  m_totalTxBytes = 2000;
388  caseDescription = "Survive a ACK (last packet in 3-way handshake) lost";
389  dropListN0.push_back (1);
390  break;
391  case 5:
392  m_totalTxBytes = 0;
393  caseDescription = "Immediate FIN upon SYN_RCVD";
394  m_needToClose = false;
395  dropListN0.push_back (1); // Hide the ACK in 3WHS
396  Simulator::Schedule (Seconds (0.002), &Socket::Close, localSocket);
397  break;
398  case 6:
399  m_totalTxBytes = 5000;
400  caseDescription = "Simulated simultaneous close";
401  dropListN1.push_back (5); // Hide the ACK-to-FIN from n2
402  break;
403  case 7:
404  m_totalTxBytes = 5000;
405  caseDescription = "FIN check 1: Loss of initiator's FIN. Wait until app close";
406  m_needToClose = false;
407  dropListN0.push_back (7); // Hide the FIN from n0
408  Simulator::Schedule (Seconds (0.04), &Socket::Close, localSocket);
409  break;
410  case 8:
411  m_totalTxBytes = 5000;
412  caseDescription = "FIN check 2: Loss responder's FIN. FIN will be resent after last ack timeout";
413  dropListN1.push_back (6); // Hide the FIN from n2
414  break;
415  default:
416  NS_FATAL_ERROR ("Program fatal error: specified test case not supported: "
417  << m_testCase);
418  break;
419  }
420 
421  Ptr<ReceiveListErrorModel> errN0 = CreateObject<ReceiveListErrorModel> ();
422  errN0->SetList (dropListN0);
423  dev0.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (errN0));
424 
425  Ptr<ReceiveListErrorModel> errN1 = CreateObject<ReceiveListErrorModel> ();
426  errN1->SetList (dropListN1);
427  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
428 
429  std::ostringstream oss;
430  oss << "tcp-state" << m_testCase << "-test-case";
431  if (m_writeResults)
432  {
433  p2p.EnablePcapAll (oss.str ());
434  p2p.EnableAsciiAll (oss.str ());
435  }
436 
437  if (m_writeLogging)
438  {
439  Ptr<OutputStreamWrapper> osw = Create<OutputStreamWrapper> (&std::clog);
440  *(osw->GetStream ()) << std::setprecision (9) << std::fixed;
441  p2p.EnableAsciiAll (osw);
442 
443  std::clog << std::endl << "Running TCP test-case " << m_testCase << ": "
444  << caseDescription << std::endl;
445  }
446 
447  // Finally, set up the simulator to run. The 1000 second hard limit is a
448  // failsafe in case some change above causes the simulation to never end
449  Simulator::Stop (Seconds (1000));
450  Simulator::Run ();
451  Simulator::Destroy ();
452 
453 
454 }
455 
457 {
458 public:
460 };
461 
463  : TestSuite ("ns3-tcp-state", SYSTEM)
464 {
465  // We can't use NS_TEST_SOURCEDIR variable here because we use subdirectories
466  SetDataDir ("src/test/ns3tcp/response-vectors");
467  Packet::EnablePrinting (); // Enable packet metadata for all test cases
468 
469  AddTestCase (new Ns3TcpStateTestCase (0), TestCase::QUICK);
470  AddTestCase (new Ns3TcpStateTestCase (1), TestCase::QUICK);
471  AddTestCase (new Ns3TcpStateTestCase (2), TestCase::QUICK);
472  AddTestCase (new Ns3TcpStateTestCase (3), TestCase::QUICK);
473  AddTestCase (new Ns3TcpStateTestCase (4), TestCase::QUICK);
474  AddTestCase (new Ns3TcpStateTestCase (5), TestCase::QUICK);
475  AddTestCase (new Ns3TcpStateTestCase (6), TestCase::QUICK);
476  AddTestCase (new Ns3TcpStateTestCase (7), TestCase::QUICK);
477  AddTestCase (new Ns3TcpStateTestCase (8), TestCase::QUICK);
478 }
479 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:47
holds a vector of ns3::Application pointers.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
AttributeValue implementation for Boolean.
Definition: boolean.h:34
holds a vector of std::pair of Ptr and interface index.
Hold variables of type string.
Definition: string.h:41
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#define min(a, b)
Definition: 80211b.c:44
NetDeviceContainer Install(NodeContainer c)
A suite of tests to run.
Definition: test.h:1333
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
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:278
LOG_INFO and above.
Definition: log.h:103
#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...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:1147
void StartFlow(Ptr< Socket > localSocket, Ipv4Address servAddress, uint16_t servPort)
Rare ad-hoc debug messages.
Definition: log.h:99
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)
void WriteUntilBufferFull(Ptr< Socket > localSocket, uint32_t txSpace)
Class for representing data rates.
Definition: data-rate.h:88
Packet header for IPv4.
Definition: ipv4-header.h:33
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
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 ...
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:349
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.
Definition: test.cc:298
AttributeValue implementation for Time.
Definition: nstime.h:957
A class representing a pcap file.
Definition: pcap-file.h:42
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
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
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:835
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:278
LOG_DEBUG and above.
Definition: log.h:100
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:375
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.
keep track of a set of node pointers.
Hold objects of type Ptr.
Definition: pointer.h:36
std::string CreateDataDirFilename(std::string filename)
Construct the full path to a file in the data directory.
Definition: test.cc:411
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
void WriteUntilBufferFull(Ptr< Socket >, uint32_t)
Prefix all trace prints with function.
Definition: log.h:114
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
const uint32_t PCAP_LINK_TYPE
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
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
static Ns3TcpStateTestSuite ns3TcpLossTestSuite
bool IsStatusSuccess(void) const
Check if all tests passed.
Definition: test.cc:457
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
const bool WRITE_LOGGING
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:40
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...
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
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found.
Definition: test.cc:464
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:356
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.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
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
const bool WRITE_PCAP
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.
virtual uint32_t GetTxAvailable(void) const =0
Returns the number of bytes which can be sent in a single call to Send.
void Ipv4L3Tx(std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
NodeContainer n1n2
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.
const bool WRITE_VECTORS
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
const uint32_t PCAP_SNAPLEN