A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tcp-test.cc
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/ipv4-end-point.h"
42 #include "ns3/arp-l3-protocol.h"
43 #include "ns3/ipv4-l3-protocol.h"
44 #include "ns3/ipv6-l3-protocol.h"
45 #include "ns3/icmpv4-l4-protocol.h"
46 #include "ns3/icmpv6-l4-protocol.h"
47 #include "ns3/udp-l4-protocol.h"
48 #include "ns3/tcp-l4-protocol.h"
49 
50 #include <string>
51 
52 NS_LOG_COMPONENT_DEFINE ("TcpTestSuite");
53 
54 using namespace ns3;
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;
82  uint32_t m_sourceWriteSize;
83  uint32_t m_sourceReadSize;
84  uint32_t m_serverWriteSize;
85  uint32_t m_serverReadSize;
86  uint32_t m_currentSourceTxBytes;
87  uint32_t m_currentSourceRxBytes;
88  uint32_t m_currentServerRxBytes;
89  uint32_t m_currentServerTxBytes;
90  uint8_t *m_sourceTxPayload;
91  uint8_t *m_sourceRxPayload;
92  uint8_t* m_serverRxPayload;
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 #ifdef NS3_LOG_ENABLE
112 static std::string GetString (Ptr<Packet> p)
113 {
114  std::ostringstream oss;
115  p->CopyData (&oss, p->GetSize ());
116  return oss.str ();
117 }
118 #endif /* NS3_LOG_ENABLE */
119 
120 TcpTestCase::TcpTestCase (uint32_t totalStreamSize,
121  uint32_t sourceWriteSize,
122  uint32_t sourceReadSize,
123  uint32_t serverWriteSize,
124  uint32_t serverReadSize,
125  bool useIpv6)
126  : TestCase (Name ("Send string data from client to server and back",
127  totalStreamSize,
128  sourceWriteSize,
129  serverReadSize,
130  serverWriteSize,
131  sourceReadSize,
132  useIpv6)),
133  m_totalBytes (totalStreamSize),
134  m_sourceWriteSize (sourceWriteSize),
135  m_sourceReadSize (sourceReadSize),
136  m_serverWriteSize (serverWriteSize),
137  m_serverReadSize (serverReadSize),
138  m_useIpv6 (useIpv6)
139 {
140 }
141 
142 void
144 {
145  m_currentSourceTxBytes = 0;
146  m_currentSourceRxBytes = 0;
147  m_currentServerRxBytes = 0;
148  m_currentServerTxBytes = 0;
149  m_sourceTxPayload = new uint8_t [m_totalBytes];
150  m_sourceRxPayload = new uint8_t [m_totalBytes];
151  m_serverRxPayload = new uint8_t [m_totalBytes];
152  for(uint32_t i = 0; i < m_totalBytes; ++i)
153  {
154  uint8_t m = (uint8_t)(97 + (i % 26));
155  m_sourceTxPayload[i] = m;
156  }
157  memset (m_sourceRxPayload, 0, m_totalBytes);
158  memset (m_serverRxPayload, 0, m_totalBytes);
159 
160  if (m_useIpv6 == true)
161  {
162  SetupDefaultSim6 ();
163  }
164  else
165  {
166  SetupDefaultSim ();
167  }
168 
169  Simulator::Run ();
170 
171  NS_TEST_EXPECT_MSG_EQ (m_currentSourceTxBytes, m_totalBytes, "Source sent all bytes");
172  NS_TEST_EXPECT_MSG_EQ (m_currentServerRxBytes, m_totalBytes, "Server received all bytes");
173  NS_TEST_EXPECT_MSG_EQ (m_currentSourceRxBytes, m_totalBytes, "Source received all bytes");
174  NS_TEST_EXPECT_MSG_EQ (memcmp (m_sourceTxPayload, m_serverRxPayload, m_totalBytes), 0,
175  "Server received expected data buffers");
176  NS_TEST_EXPECT_MSG_EQ (memcmp (m_sourceTxPayload, m_sourceRxPayload, m_totalBytes), 0,
177  "Source received back expected data buffers");
178 }
179 void
181 {
182  delete [] m_sourceTxPayload;
183  delete [] m_sourceRxPayload;
184  delete [] m_serverRxPayload;
185  Simulator::Destroy ();
186 }
187 
188 void
189 TcpTestCase::ServerHandleConnectionCreated (Ptr<Socket> s, const Address & addr)
190 {
191  s->SetRecvCallback (MakeCallback (&TcpTestCase::ServerHandleRecv, this));
192  s->SetSendCallback (MakeCallback (&TcpTestCase::ServerHandleSend, this));
193 }
194 
195 void
196 TcpTestCase::ServerHandleRecv (Ptr<Socket> sock)
197 {
198  while (sock->GetRxAvailable () > 0)
199  {
200  uint32_t toRead = std::min (m_serverReadSize, sock->GetRxAvailable ());
201  Ptr<Packet> p = sock->Recv (toRead, 0);
202  if (p == 0 && sock->GetErrno () != Socket::ERROR_NOTERROR)
203  {
204  NS_FATAL_ERROR ("Server could not read stream at byte " << m_currentServerRxBytes);
205  }
206  NS_TEST_EXPECT_MSG_EQ ((m_currentServerRxBytes + p->GetSize () <= m_totalBytes), true,
207  "Server received too many bytes");
208  NS_LOG_DEBUG ("Server recv data=\"" << GetString (p) << "\"");
209  p->CopyData (&m_serverRxPayload[m_currentServerRxBytes], p->GetSize ());
210  m_currentServerRxBytes += p->GetSize ();
211  ServerHandleSend (sock, sock->GetTxAvailable ());
212  }
213 }
214 
215 void
216 TcpTestCase::ServerHandleSend (Ptr<Socket> sock, uint32_t available)
217 {
218  while (sock->GetTxAvailable () > 0 && m_currentServerTxBytes < m_currentServerRxBytes)
219  {
220  uint32_t left = m_currentServerRxBytes - m_currentServerTxBytes;
221  uint32_t toSend = std::min (left, sock->GetTxAvailable ());
222  toSend = std::min (toSend, m_serverWriteSize);
223  Ptr<Packet> p = Create<Packet> (&m_serverRxPayload[m_currentServerTxBytes], toSend);
224  NS_LOG_DEBUG ("Server send data=\"" << GetString (p) << "\"");
225  int sent = sock->Send (p);
226  NS_TEST_EXPECT_MSG_EQ ((sent != -1), true, "Server error during send ?");
227  m_currentServerTxBytes += sent;
228  }
229  if (m_currentServerTxBytes == m_totalBytes)
230  {
231  sock->Close ();
232  }
233 }
234 
235 void
236 TcpTestCase::SourceHandleSend (Ptr<Socket> sock, uint32_t available)
237 {
238  while (sock->GetTxAvailable () > 0 && m_currentSourceTxBytes < m_totalBytes)
239  {
240  uint32_t left = m_totalBytes - m_currentSourceTxBytes;
241  uint32_t toSend = std::min (left, sock->GetTxAvailable ());
242  toSend = std::min (toSend, m_sourceWriteSize);
243  Ptr<Packet> p = Create<Packet> (&m_sourceTxPayload[m_currentSourceTxBytes], toSend);
244  NS_LOG_DEBUG ("Source send data=\"" << GetString (p) << "\"");
245  int sent = sock->Send (p);
246  NS_TEST_EXPECT_MSG_EQ ((sent != -1), true, "Error during send ?");
247  m_currentSourceTxBytes += sent;
248  }
249 }
250 
251 void
252 TcpTestCase::SourceHandleRecv (Ptr<Socket> sock)
253 {
254  while (sock->GetRxAvailable () > 0 && m_currentSourceRxBytes < m_totalBytes)
255  {
256  uint32_t toRead = std::min (m_sourceReadSize, sock->GetRxAvailable ());
257  Ptr<Packet> p = sock->Recv (toRead, 0);
258  if (p == 0 && sock->GetErrno () != Socket::ERROR_NOTERROR)
259  {
260  NS_FATAL_ERROR ("Source could not read stream at byte " << m_currentSourceRxBytes);
261  }
262  NS_TEST_EXPECT_MSG_EQ ((m_currentSourceRxBytes + p->GetSize () <= m_totalBytes), true,
263  "Source received too many bytes");
264  NS_LOG_DEBUG ("Source recv data=\"" << GetString (p) << "\"");
265  p->CopyData (&m_sourceRxPayload[m_currentSourceRxBytes], p->GetSize ());
266  m_currentSourceRxBytes += p->GetSize ();
267  }
268  if (m_currentSourceRxBytes == m_totalBytes)
269  {
270  sock->Close ();
271  }
272 }
273 
274 Ptr<Node>
275 TcpTestCase::CreateInternetNode ()
276 {
277  Ptr<Node> node = CreateObject<Node> ();
278  //ARP
279  Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
280  node->AggregateObject (arp);
281  //IPV4
282  Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
283  //Routing for Ipv4
284  Ptr<Ipv4ListRouting> ipv4Routing = CreateObject<Ipv4ListRouting> ();
285  ipv4->SetRoutingProtocol (ipv4Routing);
286  Ptr<Ipv4StaticRouting> ipv4staticRouting = CreateObject<Ipv4StaticRouting> ();
287  ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
288  node->AggregateObject (ipv4);
289  //ICMP
290  Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
291  node->AggregateObject (icmp);
292  //UDP
293  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
294  node->AggregateObject (udp);
295  //TCP
296  Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
297  node->AggregateObject (tcp);
298  return node;
299 }
300 
302 TcpTestCase::AddSimpleNetDevice (Ptr<Node> node, const char* ipaddr, const char* netmask)
303 {
304  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
305  dev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
306  node->AddDevice (dev);
307  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
308  uint32_t ndid = ipv4->AddInterface (dev);
309  Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address (ipaddr), Ipv4Mask (netmask));
310  ipv4->AddAddress (ndid, ipv4Addr);
311  ipv4->SetUp (ndid);
312  return dev;
313 }
314 
315 void
316 TcpTestCase::SetupDefaultSim (void)
317 {
318  const char* netmask = "255.255.255.0";
319  const char* ipaddr0 = "192.168.1.1";
320  const char* ipaddr1 = "192.168.1.2";
321  Ptr<Node> node0 = CreateInternetNode ();
322  Ptr<Node> node1 = CreateInternetNode ();
323  Ptr<SimpleNetDevice> dev0 = AddSimpleNetDevice (node0, ipaddr0, netmask);
324  Ptr<SimpleNetDevice> dev1 = AddSimpleNetDevice (node1, ipaddr1, netmask);
325 
326  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel> ();
327  dev0->SetChannel (channel);
328  dev1->SetChannel (channel);
329 
330  Ptr<SocketFactory> sockFactory0 = node0->GetObject<TcpSocketFactory> ();
331  Ptr<SocketFactory> sockFactory1 = node1->GetObject<TcpSocketFactory> ();
332 
333  Ptr<Socket> server = sockFactory0->CreateSocket ();
334  Ptr<Socket> source = sockFactory1->CreateSocket ();
335 
336  uint16_t port = 50000;
337  InetSocketAddress serverlocaladdr (Ipv4Address::GetAny (), port);
338  InetSocketAddress serverremoteaddr (Ipv4Address (ipaddr0), port);
339 
340  server->Bind (serverlocaladdr);
341  server->Listen ();
342  server->SetAcceptCallback (MakeNullCallback<bool, Ptr< Socket >, const Address &> (),
343  MakeCallback (&TcpTestCase::ServerHandleConnectionCreated,this));
344 
345  source->SetRecvCallback (MakeCallback (&TcpTestCase::SourceHandleRecv, this));
346  source->SetSendCallback (MakeCallback (&TcpTestCase::SourceHandleSend, this));
347 
348  source->Connect (serverremoteaddr);
349 }
350 
351 void
352 TcpTestCase::SetupDefaultSim6 (void)
353 {
354  Ipv6Prefix prefix = Ipv6Prefix(64);
355  Ipv6Address ipaddr0 = Ipv6Address("2001:0100:f00d:cafe::1");
356  Ipv6Address ipaddr1 = Ipv6Address("2001:0100:f00d:cafe::2");
357  Ptr<Node> node0 = CreateInternetNode6 ();
358  Ptr<Node> node1 = CreateInternetNode6 ();
359  Ptr<SimpleNetDevice> dev0 = AddSimpleNetDevice6 (node0, ipaddr0, prefix);
360  Ptr<SimpleNetDevice> dev1 = AddSimpleNetDevice6 (node1, ipaddr1, prefix);
361 
362  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel> ();
363  dev0->SetChannel (channel);
364  dev1->SetChannel (channel);
365 
366  Ptr<SocketFactory> sockFactory0 = node0->GetObject<TcpSocketFactory> ();
367  Ptr<SocketFactory> sockFactory1 = node1->GetObject<TcpSocketFactory> ();
368 
369  Ptr<Socket> server = sockFactory0->CreateSocket ();
370  Ptr<Socket> source = sockFactory1->CreateSocket ();
371 
372  uint16_t port = 50000;
373  Inet6SocketAddress serverlocaladdr (Ipv6Address::GetAny (), port);
374  Inet6SocketAddress serverremoteaddr (ipaddr0, port);
375 
376  server->Bind (serverlocaladdr);
377  server->Listen ();
378  server->SetAcceptCallback (MakeNullCallback<bool, Ptr< Socket >, const Address &> (),
379  MakeCallback (&TcpTestCase::ServerHandleConnectionCreated,this));
380 
381  source->SetRecvCallback (MakeCallback (&TcpTestCase::SourceHandleRecv, this));
382  source->SetSendCallback (MakeCallback (&TcpTestCase::SourceHandleSend, this));
383 
384  source->Connect (serverremoteaddr);
385 }
386 
387 Ptr<Node>
388 TcpTestCase::CreateInternetNode6 ()
389 {
390  Ptr<Node> node = CreateObject<Node> ();
391  //IPV6
392  Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
393  //Routing for Ipv6
394  Ptr<Ipv6ListRouting> ipv6Routing = CreateObject<Ipv6ListRouting> ();
395  ipv6->SetRoutingProtocol (ipv6Routing);
396  Ptr<Ipv6StaticRouting> ipv6staticRouting = CreateObject<Ipv6StaticRouting> ();
397  ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
398  node->AggregateObject (ipv6);
399  //ICMP
400  Ptr<Icmpv6L4Protocol> icmp = CreateObject<Icmpv6L4Protocol> ();
401  node->AggregateObject (icmp);
402  //Ipv6 Extensions
403  ipv6->RegisterExtensions ();
404  ipv6->RegisterOptions ();
405  //UDP
406  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
407  node->AggregateObject (udp);
408  //TCP
409  Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
410  node->AggregateObject (tcp);
411  return node;
412 }
413 
415 TcpTestCase::AddSimpleNetDevice6 (Ptr<Node> node, Ipv6Address ipaddr, Ipv6Prefix prefix)
416 {
417  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
418  dev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
419  node->AddDevice (dev);
420  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
421  uint32_t ndid = ipv6->AddInterface (dev);
422  Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (ipaddr, prefix);
423  ipv6->AddAddress (ndid, ipv6Addr);
424  ipv6->SetUp (ndid);
425  return dev;
426 }
427 
428 static class TcpTestSuite : public TestSuite
429 {
430 public:
431  TcpTestSuite ()
432  : TestSuite ("tcp", UNIT)
433  {
434  // Arguments to these test cases are 1) totalStreamSize,
435  // 2) source write size, 3) source read size
436  // 4) server write size, and 5) server read size
437  // with units of bytes
438  AddTestCase (new TcpTestCase (13, 200, 200, 200, 200, false), TestCase::QUICK);
439  AddTestCase (new TcpTestCase (13, 1, 1, 1, 1, false), TestCase::QUICK);
440  AddTestCase (new TcpTestCase (100000, 100, 50, 100, 20, false), TestCase::QUICK);
441 
442  AddTestCase (new TcpTestCase (13, 200, 200, 200, 200, true), TestCase::QUICK);
443  AddTestCase (new TcpTestCase (13, 1, 1, 1, 1, true), TestCase::QUICK);
444  AddTestCase (new TcpTestCase (100000, 100, 50, 100, 20, true), TestCase::QUICK);
445  }
446 
447 } g_tcpTestSuite;
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
an Inet address class
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:79
API to create TCP socket instances.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
A suite of tests to run.
Definition: test.h:962
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
Definition: tcp-test.cc:180
virtual void DoRun(void)
Implementation to actually run this test case.
Definition: tcp-test.cc:143
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
IPv6 address associated with an interface.
uint32_t GetSize(void) const
Definition: packet.h:620
virtual Ptr< Socket > CreateSocket(void)=0
encapsulates test code
Definition: test.h:834
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Definition: test.cc:354
virtual enum Socket::SocketErrno GetErrno(void) const =0
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
a polymophic address class
Definition: address.h:86
virtual void SetUp(uint32_t interface)=0
An Inet6 address class.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:502
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:127
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
Definition: socket.cc:70
void AggregateObject(Ptr< Object > other)
Definition: object.cc:242
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:75
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Callback< R > MakeNullCallback(void)
Definition: callback.h:781
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Definition: test.cc:172
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
Definition: socket.cc:120
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
uint32_t AddDevice(Ptr< NetDevice > device)
Definition: node.cc:119
a class to store IPv4 address information on an interface
virtual void SetAddress(Address address)
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.
Definition: ipv6-address.h:326
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
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
Definition: packet.cc:398
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.
Ptr< T > GetObject(void) const
Definition: object.h:332
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual uint32_t GetRxAvailable(void) const =0
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.