A Discrete-Event Network Simulator
API
udp-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  *
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  * Author: Raj Bhattacharjea <raj.b@gatech.edu>
19  */
25 #include "ns3/test.h"
26 #include "ns3/socket-factory.h"
27 #include "ns3/udp-socket-factory.h"
28 #include "ns3/simulator.h"
29 #include "ns3/simple-channel.h"
30 #include "ns3/simple-net-device.h"
31 #include "ns3/simple-net-device-helper.h"
32 #include "ns3/drop-tail-queue.h"
33 #include "ns3/socket.h"
34 
35 #include "ns3/boolean.h"
36 #include "ns3/log.h"
37 #include "ns3/node.h"
38 #include "ns3/inet-socket-address.h"
39 #include "ns3/inet6-socket-address.h"
40 #include "ns3/internet-stack-helper.h"
41 
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 #include "ns3/ipv4-list-routing.h"
50 #include "ns3/ipv4-static-routing.h"
51 #include "ns3/ipv6-list-routing.h"
52 #include "ns3/ipv6-static-routing.h"
53 #include "ns3/ipv6-address-helper.h"
54 
55 #include <string>
56 #include <limits>
57 
58 using namespace ns3;
59 
60 
62 {
63 public:
65  virtual void DoRun (void);
66 
67  void ReceivePkt (Ptr<Socket> socket);
69 };
70 
72  : TestCase ("UDP loopback test")
73 {
74 }
75 
77 {
78  uint32_t availableData;
79  availableData = socket->GetRxAvailable ();
81  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
82 }
83 
84 void
86 {
87  Ptr<Node> rxNode = CreateObject<Node> ();
88  InternetStackHelper internet;
89  internet.Install (rxNode);
90 
91  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
92  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
93  rxSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 80));
94  rxSocket->SetRecvCallback (MakeCallback (&UdpSocketLoopbackTest::ReceivePkt, this));
95 
96  Ptr<Socket> txSocket = rxSocketFactory->CreateSocket ();
97  txSocket->SendTo (Create<Packet> (246), 0, InetSocketAddress ("127.0.0.1", 80));
98  Simulator::Run ();
99  Simulator::Destroy ();
100  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 246, "first socket should not receive it (it is bound specifically to the second interface's address");
101 }
102 
104 {
105 public:
107  virtual void DoRun (void);
108 
109  void ReceivePkt (Ptr<Socket> socket);
111 };
112 
114  : TestCase ("UDP6 loopback test")
115 {
116 }
117 
119 {
120  uint32_t availableData;
121  availableData = socket->GetRxAvailable ();
123  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
124  //cast availableData to void, to suppress 'availableData' set but not used
125  //compiler warning
126  (void) availableData;
127 }
128 
129 void
131 {
132  Ptr<Node> rxNode = CreateObject<Node> ();
133  InternetStackHelper internet;
134  internet.Install (rxNode);
135 
136  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
137  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
138  rxSocket->Bind (Inet6SocketAddress (Ipv6Address::GetAny (), 80));
139  rxSocket->SetRecvCallback (MakeCallback (&Udp6SocketLoopbackTest::ReceivePkt, this));
140 
141  Ptr<Socket> txSocket = rxSocketFactory->CreateSocket ();
142  txSocket->SendTo (Create<Packet> (246), 0, Inet6SocketAddress ("::1", 80));
143  Simulator::Run ();
144  Simulator::Destroy ();
145  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 246, "first socket should not receive it (it is bound specifically to the second interface's address");
146 }
147 
149 {
152  void DoSendData (Ptr<Socket> socket, std::string to);
153  void SendData (Ptr<Socket> socket, std::string to);
154 
155 public:
156  virtual void DoRun (void);
158 
159  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
160  void ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
161  void ReceivePkt (Ptr<Socket> socket);
162  void ReceivePkt2 (Ptr<Socket> socket);
163 };
164 
166  : TestCase ("UDP socket implementation")
167 {
168 }
169 
171 {
172  m_receivedPacket = packet;
173 }
174 
176 {
177  m_receivedPacket2 = packet;
178 }
179 
181 {
182  uint32_t availableData;
183  availableData = socket->GetRxAvailable ();
185  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
186 }
187 
189 {
190  uint32_t availableData;
191  availableData = socket->GetRxAvailable ();
193  NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
194 }
195 
196 void
198 {
199  Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 1234);
200  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo),
201  123, "100");
202 }
203 
204 void
205 UdpSocketImplTest::SendData (Ptr<Socket> socket, std::string to)
206 {
207  m_receivedPacket = Create<Packet> ();
208  m_receivedPacket2 = Create<Packet> ();
209  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
210  &UdpSocketImplTest::DoSendData, this, socket, to);
211  Simulator::Run ();
212 }
213 
214 void
216 {
217  // Create topology
218 
219  // Receiver Node
220  Ptr<Node> rxNode = CreateObject<Node> ();
221  // Sender Node
222  Ptr<Node> txNode = CreateObject<Node> ();
223 
224  NodeContainer nodes (rxNode, txNode);
225 
226  SimpleNetDeviceHelper helperChannel1;
227  helperChannel1.SetNetDevicePointToPointMode (true);
228  NetDeviceContainer net1 = helperChannel1.Install (nodes);
229 
230  SimpleNetDeviceHelper helperChannel2;
231  helperChannel2.SetNetDevicePointToPointMode (true);
232  NetDeviceContainer net2 = helperChannel2.Install (nodes);
233 
234  InternetStackHelper internet;
235  internet.Install (nodes);
236 
237  Ptr<Ipv4> ipv4;
238  uint32_t netdev_idx;
239  Ipv4InterfaceAddress ipv4Addr;
240 
241  // Receiver Node
242  ipv4 = rxNode->GetObject<Ipv4> ();
243  netdev_idx = ipv4->AddInterface (net1.Get (0));
244  ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
245  ipv4->AddAddress (netdev_idx, ipv4Addr);
246  ipv4->SetUp (netdev_idx);
247 
248  netdev_idx = ipv4->AddInterface (net2.Get (0));
249  ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U));
250  ipv4->AddAddress (netdev_idx, ipv4Addr);
251  ipv4->SetUp (netdev_idx);
252 
253  // Sender Node
254  ipv4 = txNode->GetObject<Ipv4> ();
255  netdev_idx = ipv4->AddInterface (net1.Get (1));
256  ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
257  ipv4->AddAddress (netdev_idx, ipv4Addr);
258  ipv4->SetUp (netdev_idx);
259 
260  netdev_idx = ipv4->AddInterface (net2.Get (1));
261  ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U));
262  ipv4->AddAddress (netdev_idx, ipv4Addr);
263  ipv4->SetUp (netdev_idx);
264 
265  // Create the UDP sockets
266  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
267  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
268  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0, "trivial");
269  rxSocket->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt, this));
270 
271  Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
273  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0, "trivial");
274 
275  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory> ();
276  Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
277  txSocket->SetAllowBroadcast (true);
278 
279  // ------ Now the tests ------------
280 
281  // Unicast test
282  SendData (txSocket, "10.0.0.1");
283  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial");
284  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should receive it");
285 
288 
289  // Simple broadcast test
290 
291  SendData (txSocket, "255.255.255.255");
292  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial");
293  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address");
294 
297 
298  // Broadcast test with multiple receiving sockets
299 
300  // When receiving broadcast packets, all sockets sockets bound to
301  // the address/port should receive a copy of the same packet -- if
302  // the socket address matches.
303  rxSocket2->Dispose ();
304  rxSocket2 = rxSocketFactory->CreateSocket ();
306  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 1234)), 0, "trivial");
307 
308  SendData (txSocket, "255.255.255.255");
309  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial");
310  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "trivial");
311 
312  m_receivedPacket = 0;
313  m_receivedPacket2 = 0;
314 
315  // Simple Link-local multicast test
316 
317  txSocket->BindToNetDevice (net1.Get (1));
318  SendData (txSocket, "224.0.0.9");
319  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address");
320  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: 224.0.0.9");
321 
322  m_receivedPacket->RemoveAllByteTags ();
324 
325  // Simple getpeername tests
326 
327  Address peerAddress;
328  int err = txSocket->GetPeerName (peerAddress);
329  NS_TEST_EXPECT_MSG_EQ (err, -1, "socket GetPeerName() should fail when socket is not connected");
330  NS_TEST_EXPECT_MSG_EQ (txSocket->GetErrno (), Socket::ERROR_NOTCONN, "socket error code should be ERROR_NOTCONN");
331 
332  InetSocketAddress peer ("10.0.0.1", 1234);
333  err = txSocket->Connect (peer);
334  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket Connect() should succeed");
335 
336  err = txSocket->GetPeerName (peerAddress);
337  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket GetPeerName() should succeed when socket is connected");
338  NS_TEST_EXPECT_MSG_EQ (peerAddress, peer, "address from socket GetPeerName() should equal the connected address");
339 
340  Simulator::Destroy ();
341 
342 }
343 
345 {
348  void DoSendData (Ptr<Socket> socket, std::string to);
349  void SendData (Ptr<Socket> socket, std::string to);
350 
351 public:
352  virtual void DoRun (void);
354 
355  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
356  void ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
357  void ReceivePkt (Ptr<Socket> socket);
358  void ReceivePkt2 (Ptr<Socket> socket);
359 };
360 
362  : TestCase ("UDP6 socket implementation")
363 {
364 }
365 
367 {
368  m_receivedPacket = packet;
369 }
370 
372 {
373  m_receivedPacket2 = packet;
374 }
375 
377 {
378  uint32_t availableData;
379  availableData = socket->GetRxAvailable ();
381  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
382  //cast availableData to void, to suppress 'availableData' set but not used
383  //compiler warning
384  (void) availableData;
385 }
386 
388 {
389  uint32_t availableData;
390  availableData = socket->GetRxAvailable ();
392  NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
393  //cast availableData to void, to suppress 'availableData' set but not used
394  //compiler warning
395  (void) availableData;
396 }
397 
398 void
400 {
401  Address realTo = Inet6SocketAddress (Ipv6Address (to.c_str ()), 1234);
402  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo),
403  123, "200");
404 }
405 
406 void
408 {
409  m_receivedPacket = Create<Packet> ();
410  m_receivedPacket2 = Create<Packet> ();
411  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
412  &Udp6SocketImplTest::DoSendData, this, socket, to);
413  Simulator::Run ();
414 }
415 
416 void
418 {
419  // Create topology
420 
421  // Receiver Node
422  Ptr<Node> rxNode = CreateObject<Node> ();
423  // Sender Node
424  Ptr<Node> txNode = CreateObject<Node> ();
425 
426  NodeContainer nodes (rxNode, txNode);
427 
428  SimpleNetDeviceHelper helperChannel1;
429  helperChannel1.SetNetDevicePointToPointMode (true);
430  NetDeviceContainer net1 = helperChannel1.Install (nodes);
431 
432  SimpleNetDeviceHelper helperChannel2;
433  helperChannel2.SetNetDevicePointToPointMode (true);
434  NetDeviceContainer net2 = helperChannel2.Install (nodes);
435 
436  InternetStackHelper internetv6;
437  internetv6.Install (nodes);
438 
439  txNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
440  rxNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
441 
442  Ipv6AddressHelper ipv6helper;
443  Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress (net1);
444  Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress (net2);
445 
446  Ptr<NetDevice> device;
447  Ptr<Ipv6> ipv6;
448  int32_t ifIndex;
449  Ipv6InterfaceAddress ipv6Addr;
450 
451  ipv6 = rxNode->GetObject<Ipv6> ();
452  device = net1.Get (0);
453  ifIndex = ipv6->GetInterfaceForDevice (device);
454  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::1"), Ipv6Prefix (64));
455  ipv6->AddAddress (ifIndex, ipv6Addr);
456  ipv6->SetUp (ifIndex);
457 
458  device = net2.Get (0);
459  ifIndex = ipv6->GetInterfaceForDevice (device);
460  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::1"), Ipv6Prefix (64));
461  ipv6->AddAddress (ifIndex, ipv6Addr);
462  ipv6->SetUp (ifIndex);
463 
464  ipv6 = txNode->GetObject<Ipv6> ();
465  device = net1.Get (1);
466  ifIndex = ipv6->GetInterfaceForDevice (device);
467  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::2"), Ipv6Prefix (64));
468  ipv6->AddAddress (ifIndex, ipv6Addr);
469  ipv6->SetUp (ifIndex);
470 
471  device = net2.Get (1);
472  ifIndex = ipv6->GetInterfaceForDevice (device);
473  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::2"), Ipv6Prefix (64));
474  ipv6->AddAddress (ifIndex, ipv6Addr);
475  ipv6->SetUp (ifIndex);
476 
477  // Create the UDP sockets
478  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
479  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
480  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (Inet6SocketAddress (Ipv6Address ("2001:0100::1"), 1234)), 0, "trivial");
481  rxSocket->SetRecvCallback (MakeCallback (&Udp6SocketImplTest::ReceivePkt, this));
482 
483  Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
485  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("2001:0100:1::1"), 1234)), 0, "trivial");
486 
487  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory> ();
488  Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
489  txSocket->SetAllowBroadcast (true);
490  // ------ Now the tests ------------
491 
492  // Unicast test
493  SendData (txSocket, "2001:0100::1");
494  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial");
495  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should receive it");
496 
499 
500  // Simple Link-local multicast test
501 
502  // When receiving broadcast packets, all sockets sockets bound to
503  // the address/port should receive a copy of the same packet -- if
504  // the socket address matches.
505  rxSocket2->Dispose ();
506  rxSocket2 = rxSocketFactory->CreateSocket ();
508  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("::"), 1234)), 0, "trivial");
509 
510  txSocket->BindToNetDevice (net1.Get (1));
511  SendData (txSocket, "ff02::1");
512  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address");
513  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: ff02::1");
514 
517 
518  // Simple getpeername tests
519  Address peerAddress;
520  int err = txSocket->GetPeerName (peerAddress);
521  NS_TEST_EXPECT_MSG_EQ (err, -1, "socket GetPeerName() should fail when socket is not connected");
522  NS_TEST_EXPECT_MSG_EQ (txSocket->GetErrno (), Socket::ERROR_NOTCONN, "socket error code should be ERROR_NOTCONN");
523 
524  Inet6SocketAddress peer ("2001:0100::1", 1234);
525  err = txSocket->Connect (peer);
526  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket Connect() should succeed");
527 
528  err = txSocket->GetPeerName (peerAddress);
529  NS_TEST_EXPECT_MSG_EQ (err, 0, "socket GetPeerName() should succeed when socket is connected");
530  NS_TEST_EXPECT_MSG_EQ (peerAddress, peer, "address from socket GetPeerName() should equal the connected address");
531 
532  Simulator::Destroy ();
533 
534 }
535 
536 
537 //-----------------------------------------------------------------------------
538 class UdpTestSuite : public TestSuite
539 {
540 public:
542  {
543  AddTestCase (new UdpSocketImplTest, TestCase::QUICK);
544  AddTestCase (new UdpSocketLoopbackTest, TestCase::QUICK);
545  AddTestCase (new Udp6SocketImplTest, TestCase::QUICK);
546  AddTestCase (new Udp6SocketLoopbackTest, TestCase::QUICK);
547  }
void Dispose(void)
Dispose of this Object.
Definition: object.cc:208
void ReceivePkt(Ptr< Socket > socket)
Definition: udp-test.cc:118
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
an Inet address class
AttributeValue implementation for Boolean.
Definition: boolean.h:34
Keep track of a set of IPv6 interfaces.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: udp-test.cc:130
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
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:234
A suite of tests to run.
Definition: test.h:1333
#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
IPv6 address associated with an interface.
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
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: udp-test.cc:215
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
virtual Ptr< Socket > CreateSocket(void)=0
encapsulates test code
Definition: test.h:1147
This test suite implements a Unit Test.
Definition: test.h:1343
Ptr< Packet > m_receivedPacket2
Definition: udp-test.cc:151
a polymophic address class
Definition: address.h:90
tuple nodes
Definition: first.py:25
void DoSendData(Ptr< Socket > socket, std::string to)
Definition: udp-test.cc:197
void SendData(Ptr< Socket > socket, std::string to)
Definition: udp-test.cc:205
void ReceivePkt(Ptr< Socket > socket)
Definition: udp-test.cc:76
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Definition: udp-test.cc:371
#define max(a, b)
Definition: 80211b.c:45
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:68
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:110
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
holds a vector of ns3::NetDevice pointers
An Inet6 address class.
An implementation of the ICMPv6 protocol.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Definition: udp-test.cc:170
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
void ReceivePkt2(Ptr< Socket > socket)
Definition: udp-test.cc:387
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
void ReceivePkt2(Ptr< Socket > socket)
Definition: udp-test.cc:188
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.
void DoSendData(Ptr< Socket > socket, std::string to)
Definition: udp-test.cc:399
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Definition: udp-test.cc:175
void ReceivePkt(Ptr< Socket > socket)
Definition: udp-test.cc:376
Helper class to auto-assign global IPv6 unicast addresses.
UdpTestSuite g_udpTestSuite
Ptr< Packet > m_receivedPacket2
Definition: udp-test.cc:347
void SendData(Ptr< Socket > socket, std::string to)
Definition: udp-test.cc:407
Describes an IPv6 address.
Definition: ipv6-address.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
uint32_t GetId(void) const
Definition: node.cc:107
a class to store IPv4 address information on an interface
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void ReceivePkt(Ptr< Socket > socket)
Definition: udp-test.cc:180
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
Definition: packet.cc:349
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:346
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:150
Describes an IPv6 prefix.
Definition: ipv6-address.h:393
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.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Definition: udp-test.cc:366
API to create UDP socket instances.
build a set of SimpleNetDevice objects
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: udp-test.cc:417
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
Get the interface index of the specified NetDevice.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: udp-test.cc:85
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.