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 ();
80  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
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 ();
122  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
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 ();
184  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
185  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
186 }
187 
189 {
190  uint32_t availableData;
191  availableData = socket->GetRxAvailable ();
192  m_receivedPacket2 = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
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  Simulator::Destroy ();
326 
327 }
328 
330 {
333  void DoSendData (Ptr<Socket> socket, std::string to);
334  void SendData (Ptr<Socket> socket, std::string to);
335 
336 public:
337  virtual void DoRun (void);
339 
340  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
341  void ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
342  void ReceivePkt (Ptr<Socket> socket);
343  void ReceivePkt2 (Ptr<Socket> socket);
344 };
345 
347  : TestCase ("UDP6 socket implementation")
348 {
349 }
350 
352 {
353  m_receivedPacket = packet;
354 }
355 
357 {
358  m_receivedPacket2 = packet;
359 }
360 
362 {
363  uint32_t availableData;
364  availableData = socket->GetRxAvailable ();
365  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
366  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
367  //cast availableData to void, to suppress 'availableData' set but not used
368  //compiler warning
369  (void) availableData;
370 }
371 
373 {
374  uint32_t availableData;
375  availableData = socket->GetRxAvailable ();
376  m_receivedPacket2 = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
377  NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
378  //cast availableData to void, to suppress 'availableData' set but not used
379  //compiler warning
380  (void) availableData;
381 }
382 
383 void
385 {
386  Address realTo = Inet6SocketAddress (Ipv6Address (to.c_str ()), 1234);
387  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo),
388  123, "200");
389 }
390 
391 void
393 {
394  m_receivedPacket = Create<Packet> ();
395  m_receivedPacket2 = Create<Packet> ();
396  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
397  &Udp6SocketImplTest::DoSendData, this, socket, to);
398  Simulator::Run ();
399 }
400 
401 void
403 {
404  // Create topology
405 
406  // Receiver Node
407  Ptr<Node> rxNode = CreateObject<Node> ();
408  // Sender Node
409  Ptr<Node> txNode = CreateObject<Node> ();
410 
411  NodeContainer nodes (rxNode, txNode);
412 
413  SimpleNetDeviceHelper helperChannel1;
414  helperChannel1.SetNetDevicePointToPointMode (true);
415  NetDeviceContainer net1 = helperChannel1.Install (nodes);
416 
417  SimpleNetDeviceHelper helperChannel2;
418  helperChannel2.SetNetDevicePointToPointMode (true);
419  NetDeviceContainer net2 = helperChannel2.Install (nodes);
420 
421  InternetStackHelper internetv6;
422  internetv6.Install (nodes);
423 
424  txNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
425  rxNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
426 
427  Ipv6AddressHelper ipv6helper;
428  Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress (net1);
429  Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress (net2);
430 
431  Ptr<NetDevice> device;
432  Ptr<Ipv6> ipv6;
433  int32_t ifIndex;
434  Ipv6InterfaceAddress ipv6Addr;
435 
436  ipv6 = rxNode->GetObject<Ipv6> ();
437  device = net1.Get (0);
438  ifIndex = ipv6->GetInterfaceForDevice (device);
439  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::1"), Ipv6Prefix (64));
440  ipv6->AddAddress (ifIndex, ipv6Addr);
441  ipv6->SetUp (ifIndex);
442 
443  device = net2.Get (0);
444  ifIndex = ipv6->GetInterfaceForDevice (device);
445  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::1"), Ipv6Prefix (64));
446  ipv6->AddAddress (ifIndex, ipv6Addr);
447  ipv6->SetUp (ifIndex);
448 
449  ipv6 = txNode->GetObject<Ipv6> ();
450  device = net1.Get (1);
451  ifIndex = ipv6->GetInterfaceForDevice (device);
452  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::2"), Ipv6Prefix (64));
453  ipv6->AddAddress (ifIndex, ipv6Addr);
454  ipv6->SetUp (ifIndex);
455 
456  device = net2.Get (1);
457  ifIndex = ipv6->GetInterfaceForDevice (device);
458  ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::2"), Ipv6Prefix (64));
459  ipv6->AddAddress (ifIndex, ipv6Addr);
460  ipv6->SetUp (ifIndex);
461 
462  // Create the UDP sockets
463  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
464  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
465  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (Inet6SocketAddress (Ipv6Address ("2001:0100::1"), 1234)), 0, "trivial");
466  rxSocket->SetRecvCallback (MakeCallback (&Udp6SocketImplTest::ReceivePkt, this));
467 
468  Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
470  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("2001:0100:1::1"), 1234)), 0, "trivial");
471 
472  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory> ();
473  Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
474  txSocket->SetAllowBroadcast (true);
475  // ------ Now the tests ------------
476 
477  // Unicast test
478  SendData (txSocket, "2001:0100::1");
479  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial");
480  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should receive it");
481 
484 
485  // Simple Link-local multicast test
486 
487  // When receiving broadcast packets, all sockets sockets bound to
488  // the address/port should receive a copy of the same packet -- if
489  // the socket address matches.
490  rxSocket2->Dispose ();
491  rxSocket2 = rxSocketFactory->CreateSocket ();
493  NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("::"), 1234)), 0, "trivial");
494 
495  txSocket->BindToNetDevice (net1.Get (1));
496  SendData (txSocket, "ff02::1");
497  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");
498  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: ff02::1");
499 
502 
503  Simulator::Destroy ();
504 
505 }
506 
507 
508 //-----------------------------------------------------------------------------
509 class UdpTestSuite : public TestSuite
510 {
511 public:
513  {
514  AddTestCase (new UdpSocketImplTest, TestCase::QUICK);
515  AddTestCase (new UdpSocketLoopbackTest, TestCase::QUICK);
516  AddTestCase (new Udp6SocketImplTest, TestCase::QUICK);
517  AddTestCase (new Udp6SocketLoopbackTest, TestCase::QUICK);
518  }
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:80
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:226
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:356
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:372
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:384
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:361
Helper class to auto-assign global IPv6 unicast addresses.
UdpTestSuite g_udpTestSuite
Ptr< Packet > m_receivedPacket2
Definition: udp-test.cc:332
void SendData(Ptr< Socket > socket, std::string to)
Definition: udp-test.cc:392
Describes an IPv6 address.
Definition: ipv6-address.h:47
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:347
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:331
Ptr< Packet > m_receivedPacket
Definition: udp-test.cc:150
Describes an IPv6 prefix.
Definition: ipv6-address.h:389
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:351
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:402
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.