A Discrete-Event Network Simulator
API
tcp-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 Georgia Tech Research Corporation
4  * Copyright (c) 2009 INRIA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Raj Bhattacharjea <raj.b@gatech.edu>
21  */
22 
23 #include "ns3/test.h"
24 #include "ns3/socket-factory.h"
25 #include "ns3/tcp-socket-factory.h"
26 #include "ns3/simulator.h"
27 #include "ns3/simple-channel.h"
28 #include "ns3/simple-net-device.h"
29 #include "ns3/drop-tail-queue.h"
30 #include "ns3/config.h"
31 #include "ns3/ipv4-static-routing.h"
32 #include "ns3/ipv4-list-routing.h"
33 #include "ns3/ipv6-static-routing.h"
34 #include "ns3/ipv6-list-routing.h"
35 #include "ns3/node.h"
36 #include "ns3/inet-socket-address.h"
37 #include "ns3/inet6-socket-address.h"
38 #include "ns3/uinteger.h"
39 #include "ns3/log.h"
40 
41 #include "ns3/arp-l3-protocol.h"
42 #include "ns3/ipv4-l3-protocol.h"
43 #include "ns3/ipv6-l3-protocol.h"
44 #include "ns3/icmpv4-l4-protocol.h"
45 #include "ns3/icmpv6-l4-protocol.h"
46 #include "ns3/udp-l4-protocol.h"
47 #include "ns3/tcp-l4-protocol.h"
48 #include "ns3/traffic-control-layer.h"
49 
50 #include <string>
51 
52 using namespace ns3;
53 
54 NS_LOG_COMPONENT_DEFINE ("TcpTestSuite");
55 
56 class TcpTestCase : public TestCase
57 {
58 public:
59  TcpTestCase (uint32_t totalStreamSize,
60  uint32_t sourceWriteSize,
61  uint32_t sourceReadSize,
62  uint32_t serverWriteSize,
63  uint32_t serverReadSize,
64  bool useIpv6);
65 private:
66  virtual void DoRun (void);
67  virtual void DoTeardown (void);
68  void SetupDefaultSim (void);
69  void SetupDefaultSim6 (void);
70 
71  Ptr<Node> CreateInternetNode (void);
72  Ptr<Node> CreateInternetNode6 (void);
73  Ptr<SimpleNetDevice> AddSimpleNetDevice (Ptr<Node> node, const char* ipaddr, const char* netmask);
74  Ptr<SimpleNetDevice> AddSimpleNetDevice6 (Ptr<Node> node, Ipv6Address ipaddr, Ipv6Prefix prefix);
75  void ServerHandleConnectionCreated (Ptr<Socket> s, const Address & addr);
76  void ServerHandleRecv (Ptr<Socket> sock);
77  void ServerHandleSend (Ptr<Socket> sock, uint32_t available);
78  void SourceHandleSend (Ptr<Socket> sock, uint32_t available);
79  void SourceHandleRecv (Ptr<Socket> sock);
80 
81  uint32_t m_totalBytes;
83  uint32_t m_sourceReadSize;
85  uint32_t m_serverReadSize;
93 
94  bool m_useIpv6;
95 };
96 
97 static std::string Name (std::string str, uint32_t totalStreamSize,
98  uint32_t sourceWriteSize,
99  uint32_t serverReadSize,
100  uint32_t serverWriteSize,
101  uint32_t sourceReadSize,
102  bool useIpv6)
103 {
104  std::ostringstream oss;
105  oss << str << " total=" << totalStreamSize << " sourceWrite=" << sourceWriteSize
106  << " sourceRead=" << sourceReadSize << " serverRead=" << serverReadSize
107  << " serverWrite=" << serverWriteSize << " useIpv6=" << useIpv6;
108  return oss.str ();
109 }
110 
111 static inline std::string GetString (Ptr<Packet> p)
112 {
113  std::ostringstream oss;
114  p->CopyData (&oss, p->GetSize ());
115  return oss.str ();
116 }
117 
118 TcpTestCase::TcpTestCase (uint32_t totalStreamSize,
119  uint32_t sourceWriteSize,
120  uint32_t sourceReadSize,
121  uint32_t serverWriteSize,
122  uint32_t serverReadSize,
123  bool useIpv6)
124  : TestCase (Name ("Send string data from client to server and back",
125  totalStreamSize,
126  sourceWriteSize,
127  serverReadSize,
128  serverWriteSize,
129  sourceReadSize,
130  useIpv6)),
131  m_totalBytes (totalStreamSize),
132  m_sourceWriteSize (sourceWriteSize),
133  m_sourceReadSize (sourceReadSize),
134  m_serverWriteSize (serverWriteSize),
135  m_serverReadSize (serverReadSize),
136  m_useIpv6 (useIpv6)
137 {
138 }
139 
140 void
142 {
147  m_sourceTxPayload = new uint8_t [m_totalBytes];
148  m_sourceRxPayload = new uint8_t [m_totalBytes];
149  m_serverRxPayload = new uint8_t [m_totalBytes];
150  for(uint32_t i = 0; i < m_totalBytes; ++i)
151  {
152  uint8_t m = (uint8_t)(97 + (i % 26));
153  m_sourceTxPayload[i] = m;
154  }
155  memset (m_sourceRxPayload, 0, m_totalBytes);
156  memset (m_serverRxPayload, 0, m_totalBytes);
157 
158  if (m_useIpv6 == true)
159  {
160  SetupDefaultSim6 ();
161  }
162  else
163  {
164  SetupDefaultSim ();
165  }
166 
167  Simulator::Run ();
168 
169  NS_TEST_EXPECT_MSG_EQ (m_currentSourceTxBytes, m_totalBytes, "Source sent all bytes");
170  NS_TEST_EXPECT_MSG_EQ (m_currentServerRxBytes, m_totalBytes, "Server received all bytes");
171  NS_TEST_EXPECT_MSG_EQ (m_currentSourceRxBytes, m_totalBytes, "Source received all bytes");
172  NS_TEST_EXPECT_MSG_EQ (memcmp (m_sourceTxPayload, m_serverRxPayload, m_totalBytes), 0,
173  "Server received expected data buffers");
174  NS_TEST_EXPECT_MSG_EQ (memcmp (m_sourceTxPayload, m_sourceRxPayload, m_totalBytes), 0,
175  "Source received back expected data buffers");
176 }
177 void
179 {
180  delete [] m_sourceTxPayload;
181  delete [] m_sourceRxPayload;
182  delete [] m_serverRxPayload;
183  Simulator::Destroy ();
184 }
185 
186 void
188 {
191 }
192 
193 void
195 {
196  while (sock->GetRxAvailable () > 0)
197  {
198  uint32_t toRead = std::min (m_serverReadSize, sock->GetRxAvailable ());
199  Ptr<Packet> p = sock->Recv (toRead, 0);
200  if (p == 0 && sock->GetErrno () != Socket::ERROR_NOTERROR)
201  {
202  NS_FATAL_ERROR ("Server could not read stream at byte " << m_currentServerRxBytes);
203  }
204  NS_TEST_EXPECT_MSG_EQ ((m_currentServerRxBytes + p->GetSize () <= m_totalBytes), true,
205  "Server received too many bytes");
206  NS_LOG_DEBUG ("Server recv data=\"" << GetString (p) << "\"");
207  p->CopyData (&m_serverRxPayload[m_currentServerRxBytes], p->GetSize ());
208  m_currentServerRxBytes += p->GetSize ();
209  ServerHandleSend (sock, sock->GetTxAvailable ());
210  }
211 }
212 
213 void
214 TcpTestCase::ServerHandleSend (Ptr<Socket> sock, uint32_t available)
215 {
217  {
219  uint32_t toSend = std::min (left, sock->GetTxAvailable ());
220  toSend = std::min (toSend, m_serverWriteSize);
221  Ptr<Packet> p = Create<Packet> (&m_serverRxPayload[m_currentServerTxBytes], toSend);
222  NS_LOG_DEBUG ("Server send data=\"" << GetString (p) << "\"");
223  int sent = sock->Send (p);
224  NS_TEST_EXPECT_MSG_EQ ((sent != -1), true, "Server error during send ?");
225  m_currentServerTxBytes += sent;
226  }
228  {
229  sock->Close ();
230  }
231 }
232 
233 void
234 TcpTestCase::SourceHandleSend (Ptr<Socket> sock, uint32_t available)
235 {
236  while (sock->GetTxAvailable () > 0 && m_currentSourceTxBytes < m_totalBytes)
237  {
238  uint32_t left = m_totalBytes - m_currentSourceTxBytes;
239  uint32_t toSend = std::min (left, sock->GetTxAvailable ());
240  toSend = std::min (toSend, m_sourceWriteSize);
241  Ptr<Packet> p = Create<Packet> (&m_sourceTxPayload[m_currentSourceTxBytes], toSend);
242  NS_LOG_DEBUG ("Source send data=\"" << GetString (p) << "\"");
243  int sent = sock->Send (p);
244  NS_TEST_EXPECT_MSG_EQ ((sent != -1), true, "Error during send ?");
245  m_currentSourceTxBytes += sent;
246  }
247 }
248 
249 void
251 {
252  while (sock->GetRxAvailable () > 0 && m_currentSourceRxBytes < m_totalBytes)
253  {
254  uint32_t toRead = std::min (m_sourceReadSize, sock->GetRxAvailable ());
255  Ptr<Packet> p = sock->Recv (toRead, 0);
256  if (p == 0 && sock->GetErrno () != Socket::ERROR_NOTERROR)
257  {
258  NS_FATAL_ERROR ("Source could not read stream at byte " << m_currentSourceRxBytes);
259  }
260  NS_TEST_EXPECT_MSG_EQ ((m_currentSourceRxBytes + p->GetSize () <= m_totalBytes), true,
261  "Source received too many bytes");
262  NS_LOG_DEBUG ("Source recv data=\"" << GetString (p) << "\"");
263  p->CopyData (&m_sourceRxPayload[m_currentSourceRxBytes], p->GetSize ());
264  m_currentSourceRxBytes += p->GetSize ();
265  }
267  {
268  sock->Close ();
269  }
270 }
271 
272 Ptr<Node>
274 {
275  Ptr<Node> node = CreateObject<Node> ();
276  //ARP
277  Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
278  node->AggregateObject (arp);
279  //IPV4
280  Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
281  //Routing for Ipv4
282  Ptr<Ipv4ListRouting> ipv4Routing = CreateObject<Ipv4ListRouting> ();
283  ipv4->SetRoutingProtocol (ipv4Routing);
284  Ptr<Ipv4StaticRouting> ipv4staticRouting = CreateObject<Ipv4StaticRouting> ();
285  ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
286  node->AggregateObject (ipv4);
287  //ICMP
288  Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
289  node->AggregateObject (icmp);
290  //UDP
291  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
292  node->AggregateObject (udp);
293  //TCP
294  Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
295  node->AggregateObject (tcp);
296  // Traffic Control
297  Ptr<TrafficControlLayer> tc = CreateObject<TrafficControlLayer> ();
298  node->AggregateObject (tc);
299  return node;
300 }
301 
303 TcpTestCase::AddSimpleNetDevice (Ptr<Node> node, const char* ipaddr, const char* netmask)
304 {
305  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
306  dev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
307  node->AddDevice (dev);
308  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
309  uint32_t ndid = ipv4->AddInterface (dev);
310  Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address (ipaddr), Ipv4Mask (netmask));
311  ipv4->AddAddress (ndid, ipv4Addr);
312  ipv4->SetUp (ndid);
313  return dev;
314 }
315 
316 void
318 {
319  const char* netmask = "255.255.255.0";
320  const char* ipaddr0 = "192.168.1.1";
321  const char* ipaddr1 = "192.168.1.2";
322  Ptr<Node> node0 = CreateInternetNode ();
323  Ptr<Node> node1 = CreateInternetNode ();
324  Ptr<SimpleNetDevice> dev0 = AddSimpleNetDevice (node0, ipaddr0, netmask);
325  Ptr<SimpleNetDevice> dev1 = AddSimpleNetDevice (node1, ipaddr1, netmask);
326 
327  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel> ();
328  dev0->SetChannel (channel);
329  dev1->SetChannel (channel);
330 
331  Ptr<SocketFactory> sockFactory0 = node0->GetObject<TcpSocketFactory> ();
332  Ptr<SocketFactory> sockFactory1 = node1->GetObject<TcpSocketFactory> ();
333 
334  Ptr<Socket> server = sockFactory0->CreateSocket ();
335  Ptr<Socket> source = sockFactory1->CreateSocket ();
336 
337  uint16_t port = 50000;
338  InetSocketAddress serverlocaladdr (Ipv4Address::GetAny (), port);
339  InetSocketAddress serverremoteaddr (Ipv4Address (ipaddr0), port);
340 
341  server->Bind (serverlocaladdr);
342  server->Listen ();
343  server->SetAcceptCallback (MakeNullCallback<bool, Ptr< Socket >, const Address &> (),
345 
348 
349  Address peerAddress;
350  int err = source->GetPeerName (peerAddress);
351  NS_TEST_EXPECT_MSG_EQ (err, -1, "socket GetPeerName() should fail when socket is not connected");
352  NS_TEST_EXPECT_MSG_EQ (source->GetErrno (), Socket::ERROR_NOTCONN, "socket error code should be ERROR_NOTCONN");
353 
354  err = source->Connect (serverremoteaddr);
355  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket Connect() should succeed");
356 
357  err = source->GetPeerName (peerAddress);
358  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket GetPeerName() should succeed when socket is connected");
359  NS_TEST_EXPECT_MSG_EQ (peerAddress, serverremoteaddr, "address from socket GetPeerName() should equal the connected address");
360 }
361 
362 void
364 {
365  Ipv6Prefix prefix = Ipv6Prefix(64);
366  Ipv6Address ipaddr0 = Ipv6Address("2001:0100:f00d:cafe::1");
367  Ipv6Address ipaddr1 = Ipv6Address("2001:0100:f00d:cafe::2");
368  Ptr<Node> node0 = CreateInternetNode6 ();
369  Ptr<Node> node1 = CreateInternetNode6 ();
370  Ptr<SimpleNetDevice> dev0 = AddSimpleNetDevice6 (node0, ipaddr0, prefix);
371  Ptr<SimpleNetDevice> dev1 = AddSimpleNetDevice6 (node1, ipaddr1, prefix);
372 
373  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel> ();
374  dev0->SetChannel (channel);
375  dev1->SetChannel (channel);
376 
377  Ptr<SocketFactory> sockFactory0 = node0->GetObject<TcpSocketFactory> ();
378  Ptr<SocketFactory> sockFactory1 = node1->GetObject<TcpSocketFactory> ();
379 
380  Ptr<Socket> server = sockFactory0->CreateSocket ();
381  Ptr<Socket> source = sockFactory1->CreateSocket ();
382 
383  uint16_t port = 50000;
384  Inet6SocketAddress serverlocaladdr (Ipv6Address::GetAny (), port);
385  Inet6SocketAddress serverremoteaddr (ipaddr0, port);
386 
387  server->Bind (serverlocaladdr);
388  server->Listen ();
389  server->SetAcceptCallback (MakeNullCallback<bool, Ptr< Socket >, const Address &> (),
391 
394 
395  Address peerAddress;
396  int err = source->GetPeerName (peerAddress);
397  NS_TEST_EXPECT_MSG_EQ (err, -1, "socket GetPeerName() should fail when socket is not connected");
398  NS_TEST_EXPECT_MSG_EQ (source->GetErrno (), Socket::ERROR_NOTCONN, "socket error code should be ERROR_NOTCONN");
399 
400  err = source->Connect (serverremoteaddr);
401  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket Connect() should succeed");
402 
403  err = source->GetPeerName (peerAddress);
404  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket GetPeerName() should succeed when socket is connected");
405  NS_TEST_EXPECT_MSG_EQ (peerAddress, serverremoteaddr, "address from socket GetPeerName() should equal the connected address");
406 }
407 
408 Ptr<Node>
410 {
411  Ptr<Node> node = CreateObject<Node> ();
412  //IPV6
413  Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
414  //Routing for Ipv6
415  Ptr<Ipv6ListRouting> ipv6Routing = CreateObject<Ipv6ListRouting> ();
416  ipv6->SetRoutingProtocol (ipv6Routing);
417  Ptr<Ipv6StaticRouting> ipv6staticRouting = CreateObject<Ipv6StaticRouting> ();
418  ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
419  node->AggregateObject (ipv6);
420  //ICMP
421  Ptr<Icmpv6L4Protocol> icmp = CreateObject<Icmpv6L4Protocol> ();
422  node->AggregateObject (icmp);
423  //Ipv6 Extensions
424  ipv6->RegisterExtensions ();
425  ipv6->RegisterOptions ();
426  //UDP
427  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
428  node->AggregateObject (udp);
429  //TCP
430  Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
431  node->AggregateObject (tcp);
432  // Traffic Control
433  Ptr<TrafficControlLayer> tc = CreateObject<TrafficControlLayer> ();
434  node->AggregateObject (tc);
435  return node;
436 }
437 
440 {
441  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
442  dev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
443  node->AddDevice (dev);
444  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
445  uint32_t ndid = ipv6->AddInterface (dev);
446  Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (ipaddr, prefix);
447  ipv6->AddAddress (ndid, ipv6Addr);
448  ipv6->SetUp (ndid);
449  return dev;
450 }
451 
452 static class TcpTestSuite : public TestSuite
453 {
454 public:
456  : TestSuite ("tcp", UNIT)
457  {
458  // Arguments to these test cases are 1) totalStreamSize,
459  // 2) source write size, 3) source read size
460  // 4) server write size, and 5) server read size
461  // with units of bytes
462  AddTestCase (new TcpTestCase (13, 200, 200, 200, 200, false), TestCase::QUICK);
463  AddTestCase (new TcpTestCase (13, 1, 1, 1, 1, false), TestCase::QUICK);
464  AddTestCase (new TcpTestCase (100000, 100, 50, 100, 20, false), TestCase::QUICK);
465 
466  AddTestCase (new TcpTestCase (13, 200, 200, 200, 200, true), TestCase::QUICK);
467  AddTestCase (new TcpTestCase (13, 1, 1, 1, 1, true), TestCase::QUICK);
468  AddTestCase (new TcpTestCase (100000, 100, 50, 100, 20, true), TestCase::QUICK);
469  }
470 
tuple channel
Definition: third.py:85
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
an Inet address class
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:81
#define min(a, b)
Definition: 80211b.c:44
uint32_t m_currentServerTxBytes
Definition: tcp-test.cc:89
Ptr< SimpleNetDevice > AddSimpleNetDevice(Ptr< Node > node, Ipv4Address v4Addr, Ipv4Mask v4Mask, Ipv6Address v6Addr, Ipv6Prefix v6Prefix)
API to create TCP socket instances.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:234
A suite of tests to run.
Definition: test.h:1333
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:246
uint32_t m_sourceReadSize
Definition: tcp-test.cc:83
uint32_t m_currentServerRxBytes
Definition: tcp-test.cc:88
uint8_t * m_serverRxPayload
Definition: tcp-test.cc:92
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Definition: tcp-test.cc:178
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: tcp-test.cc:141
bool m_useIpv6
Definition: tcp-test.cc:94
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
IPv6 address associated with an interface.
#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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
TcpTestSuite g_tcpTestSuite
virtual Ptr< Socket > CreateSocket(void)=0
void SourceHandleRecv(Ptr< Socket > sock)
Definition: tcp-test.cc:250
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:145
Callback< R > MakeNullCallback(void)
Definition: callback.h:1626
encapsulates test code
Definition: test.h:1147
This test suite implements a Unit Test.
Definition: test.h:1343
uint32_t m_serverWriteSize
Definition: tcp-test.cc:84
uint32_t m_serverReadSize
Definition: tcp-test.cc:85
void SetupDefaultSim(void)
Definition: tcp-test.cc:317
virtual enum Socket::SocketErrno GetErrno(void) const =0
Get last error number.
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
TcpTestCase(uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t sourceReadSize, uint32_t serverWriteSize, uint32_t serverReadSize, bool useIpv6)
Definition: tcp-test.cc:118
uint8_t * m_sourceTxPayload
Definition: tcp-test.cc:90
void SourceHandleSend(Ptr< Socket > sock, uint32_t available)
Definition: tcp-test.cc:234
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)
Definition: tcp-test.cc:97
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:297
virtual void SetUp(uint32_t interface)=0
An Inet6 address class.
uint32_t m_currentSourceTxBytes
Definition: tcp-test.cc:86
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1480
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
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:71
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_sourceWriteSize
Definition: tcp-test.cc:82
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
uint8_t * m_sourceRxPayload
Definition: tcp-test.cc:91
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
Definition: socket.cc:121
Ptr< Node > CreateInternetNode6(void)
Definition: tcp-test.cc:409
Ptr< SimpleNetDevice > AddSimpleNetDevice(Ptr< Node > node, const char *ipaddr, const char *netmask)
Definition: tcp-test.cc:303
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
void ServerHandleRecv(Ptr< Socket > sock)
Definition: tcp-test.cc:194
static std::string GetString(Ptr< Packet > p)
Definition: tcp-test.cc:111
Describes an IPv6 address.
Definition: ipv6-address.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ptr< SimpleNetDevice > AddSimpleNetDevice6(Ptr< Node > node, Ipv6Address ipaddr, Ipv6Prefix prefix)
Definition: tcp-test.cc:439
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
a class to store IPv4 address information on an interface
void SetupDefaultSim6(void)
Definition: tcp-test.cc:363
virtual void SetAddress(Address address)
Set the address of this interface.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
Describes an IPv6 prefix.
Definition: ipv6-address.h:393
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
void ServerHandleConnectionCreated(Ptr< Socket > s, const Address &addr)
Definition: tcp-test.cc:187
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:356
virtual int GetPeerName(Address &address) const =0
Get the peer address of a connected socket.
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 SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
uint32_t m_totalBytes
Definition: tcp-test.cc:81
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
void ServerHandleSend(Ptr< Socket > sock, uint32_t available)
Definition: tcp-test.cc:214
uint32_t m_currentSourceRxBytes
Definition: tcp-test.cc:87
Ptr< Node > CreateInternetNode(void)
Definition: tcp-test.cc:273
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.