A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
udp-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 Georgia Tech Research Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Raj Bhattacharjea <raj.b@gatech.edu>
18 */
24#include "ns3/arp-l3-protocol.h"
25#include "ns3/boolean.h"
26#include "ns3/icmpv4-l4-protocol.h"
27#include "ns3/icmpv6-l4-protocol.h"
28#include "ns3/inet-socket-address.h"
29#include "ns3/inet6-socket-address.h"
30#include "ns3/internet-stack-helper.h"
31#include "ns3/ipv4-l3-protocol.h"
32#include "ns3/ipv4-list-routing.h"
33#include "ns3/ipv4-queue-disc-item.h"
34#include "ns3/ipv4-static-routing.h"
35#include "ns3/ipv6-address-helper.h"
36#include "ns3/ipv6-l3-protocol.h"
37#include "ns3/ipv6-list-routing.h"
38#include "ns3/ipv6-static-routing.h"
39#include "ns3/log.h"
40#include "ns3/node.h"
41#include "ns3/simple-channel.h"
42#include "ns3/simple-net-device-helper.h"
43#include "ns3/simple-net-device.h"
44#include "ns3/simulator.h"
45#include "ns3/socket-factory.h"
46#include "ns3/socket.h"
47#include "ns3/tcp-l4-protocol.h"
48#include "ns3/test.h"
49#include "ns3/traffic-control-helper.h"
50#include "ns3/udp-l4-protocol.h"
51#include "ns3/udp-socket-factory.h"
52
53#include <limits>
54#include <string>
55
56using namespace ns3;
57
64{
65 public:
67 void DoRun() override;
68
73 void ReceivePkt(Ptr<Socket> socket);
75};
76
78 : TestCase("UDP loopback test")
79{
80}
81
82void
84{
85 uint32_t availableData;
86 availableData = socket->GetRxAvailable();
87 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
88 NS_TEST_ASSERT_MSG_EQ(availableData,
90 "ReceivedPacket size is not equal to the Rx buffer size");
91}
92
93void
95{
96 Ptr<Node> rxNode = CreateObject<Node>();
97 InternetStackHelper internet;
98 internet.Install(rxNode);
99
100 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
101 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
102 rxSocket->Bind(InetSocketAddress(Ipv4Address::GetAny(), 80));
103 rxSocket->SetRecvCallback(MakeCallback(&UdpSocketLoopbackTest::ReceivePkt, this));
104
105 Ptr<Socket> txSocket = rxSocketFactory->CreateSocket();
106 txSocket->SendTo(Create<Packet>(246), 0, InetSocketAddress("127.0.0.1", 80));
110 246,
111 "first socket should not receive it (it is bound specifically to the "
112 "second interface's address");
113}
114
121{
122 public:
124 void DoRun() override;
125
130 void ReceivePkt(Ptr<Socket> socket);
132};
133
135 : TestCase("UDP6 loopback test")
136{
137}
138
139void
141{
142 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
143 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
144 NS_TEST_ASSERT_MSG_EQ(availableData,
146 "ReceivedPacket size is not equal to the Rx buffer size");
147}
148
149void
151{
152 Ptr<Node> rxNode = CreateObject<Node>();
153 InternetStackHelper internet;
154 internet.Install(rxNode);
155
156 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
157 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
158 rxSocket->Bind(Inet6SocketAddress(Ipv6Address::GetAny(), 80));
159 rxSocket->SetRecvCallback(MakeCallback(&Udp6SocketLoopbackTest::ReceivePkt, this));
160
161 Ptr<Socket> txSocket = rxSocketFactory->CreateSocket();
162 txSocket->SendTo(Create<Packet>(246), 0, Inet6SocketAddress("::1", 80));
166 246,
167 "first socket should not receive it (it is bound specifically to the "
168 "second interface's address");
169}
170
177{
181
187
193
199 void DoSendDataTo(Ptr<Socket> socket, std::string to);
205 void SendDataTo(Ptr<Socket> socket, std::string to);
210 void DoSendData(Ptr<Socket> socket);
215 void SendData(Ptr<Socket> socket);
216
217 public:
218 void DoRun() override;
220
225 void ReceivePkt(Ptr<Socket> socket);
230 void ReceivePkt2(Ptr<Socket> socket);
231
237};
238
240 : TestCase("UDP socket implementation")
241{
242}
243
244void
246{
247 uint32_t availableData;
248 availableData = socket->GetRxAvailable();
249 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
250 NS_TEST_ASSERT_MSG_EQ(availableData,
252 "ReceivedPacket size is not equal to the Rx buffer size");
253}
254
255void
257{
258 uint32_t availableData;
259 availableData = socket->GetRxAvailable();
260 m_receivedPacket2 = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
261 NS_TEST_ASSERT_MSG_EQ(availableData,
263 "ReceivedPacket size is not equal to the Rx buffer size");
264}
265
266void
268{
269 Ptr<const Ipv4QueueDiscItem> ipv4Item = DynamicCast<const Ipv4QueueDiscItem>(item);
270 NS_TEST_EXPECT_MSG_NE(ipv4Item, nullptr, "no IPv4 packet");
271 Address addr;
273 Create<Ipv4QueueDiscItem>(ipv4Item->GetPacket()->Copy(), addr, 0, ipv4Item->GetHeader());
274}
275
278{
279 return static_cast<uint32_t>(m_sentPacket->GetHeader().GetTos());
280}
281
284{
285 SocketPriorityTag priorityTag;
286 bool found = m_sentPacket->GetPacket()->PeekPacketTag(priorityTag);
287 NS_TEST_EXPECT_MSG_EQ(found, true, "the packet should carry a SocketPriorityTag");
288 return static_cast<uint32_t>(priorityTag.GetPriority());
289}
290
291void
293{
294 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
295 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
296}
297
298void
300{
301 m_receivedPacket = Create<Packet>();
302 m_receivedPacket2 = Create<Packet>();
303 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
304 Seconds(0),
306 this,
307 socket,
308 to);
310}
311
312void
314{
315 NS_TEST_EXPECT_MSG_EQ(socket->Send(Create<Packet>(123), 0), 123, "100");
316}
317
318void
320{
321 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
322 Seconds(0),
324 this,
325 socket);
327}
328
329void
331{
332 // Create topology
333
334 // Receiver Node
335 Ptr<Node> rxNode = CreateObject<Node>();
336 // Sender Node
337 Ptr<Node> txNode = CreateObject<Node>();
338
339 NodeContainer nodes(rxNode, txNode);
340
341 SimpleNetDeviceHelper helperChannel1;
342 helperChannel1.SetNetDevicePointToPointMode(true);
343 NetDeviceContainer net1 = helperChannel1.Install(nodes);
344
345 SimpleNetDeviceHelper helperChannel2;
346 helperChannel2.SetNetDevicePointToPointMode(true);
347 NetDeviceContainer net2 = helperChannel2.Install(nodes);
348
349 InternetStackHelper internet;
350 internet.Install(nodes);
351
353 QueueDiscContainer qdiscs = tch.Install(net1.Get(1));
354
355 Ptr<Ipv4> ipv4;
356 uint32_t netdev_idx;
357 Ipv4InterfaceAddress ipv4Addr;
358
359 // Receiver Node
360 ipv4 = rxNode->GetObject<Ipv4>();
361 netdev_idx = ipv4->AddInterface(net1.Get(0));
362 ipv4Addr = Ipv4InterfaceAddress(Ipv4Address("10.0.0.1"), Ipv4Mask("/24"));
363 ipv4->AddAddress(netdev_idx, ipv4Addr);
364 ipv4->SetUp(netdev_idx);
365
366 netdev_idx = ipv4->AddInterface(net2.Get(0));
367 ipv4Addr = Ipv4InterfaceAddress(Ipv4Address("10.0.1.1"), Ipv4Mask("/24"));
368 ipv4->AddAddress(netdev_idx, ipv4Addr);
369 ipv4->SetUp(netdev_idx);
370
371 // Sender Node
372 ipv4 = txNode->GetObject<Ipv4>();
373 netdev_idx = ipv4->AddInterface(net1.Get(1));
374 ipv4Addr = Ipv4InterfaceAddress(Ipv4Address("10.0.0.2"), Ipv4Mask("/24"));
375 ipv4->AddAddress(netdev_idx, ipv4Addr);
376 ipv4->SetUp(netdev_idx);
377
378 netdev_idx = ipv4->AddInterface(net2.Get(1));
379 ipv4Addr = Ipv4InterfaceAddress(Ipv4Address("10.0.1.2"), Ipv4Mask("/24"));
380 ipv4->AddAddress(netdev_idx, ipv4Addr);
381 ipv4->SetUp(netdev_idx);
382
383 // Create the UDP sockets
384 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
385
386 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
387 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.0.1"), 1234)),
388 0,
389 "trivial");
390 rxSocket->SetRecvCallback(MakeCallback(&UdpSocketImplTest::ReceivePkt, this));
391
392 Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket();
393 NS_TEST_EXPECT_MSG_EQ(rxSocket2->Bind(InetSocketAddress(Ipv4Address("10.0.1.1"), 1234)),
394 0,
395 "trivial");
396 rxSocket2->SetRecvCallback(MakeCallback(&UdpSocketImplTest::ReceivePkt2, this));
397
398 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
399 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
400 txSocket->SetAllowBroadcast(true);
401
402 // ------ Now the tests ------------
403
404 // Unicast test
405 SendDataTo(txSocket, "10.0.0.1");
408 0,
409 "second interface should not receive it");
410
413
414 // Simple broadcast test
415
416 SendDataTo(txSocket, "255.255.255.255");
418 0,
419 "first socket should not receive it (it is bound specifically to the "
420 "first interface's address");
422 0,
423 "second socket should not receive it (it is bound specifically to the "
424 "second interface's address");
425
428
429 // Broadcast test with multiple receiving sockets
430
431 // When receiving broadcast packets, all sockets sockets bound to
432 // the address/port should receive a copy of the same packet -- if
433 // the socket address matches.
434 rxSocket2->Dispose();
435 rxSocket2 = rxSocketFactory->CreateSocket();
436 rxSocket2->SetRecvCallback(MakeCallback(&UdpSocketImplTest::ReceivePkt2, this));
437 NS_TEST_EXPECT_MSG_EQ(rxSocket2->Bind(InetSocketAddress(Ipv4Address("0.0.0.0"), 1234)),
438 0,
439 "trivial");
440
441 SendDataTo(txSocket, "255.255.255.255");
443 0,
444 "first socket should not receive it (it is bound specifically to the "
445 "first interface's address");
447
448 m_receivedPacket = nullptr;
449 m_receivedPacket2 = nullptr;
450
451 // Simple Link-local multicast test
452
453 txSocket->BindToNetDevice(net1.Get(1));
454 SendDataTo(txSocket, "224.0.0.9");
456 0,
457 "first socket should not receive it (it is bound specifically to the "
458 "first interface's address");
459 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket2->GetSize(), 123, "recv2: 224.0.0.9");
460
463
464 // Simple getpeername tests
465
466 Address peerAddress;
467 int err = txSocket->GetPeerName(peerAddress);
468 NS_TEST_EXPECT_MSG_EQ(err, -1, "socket GetPeerName() should fail when socket is not connected");
469 NS_TEST_EXPECT_MSG_EQ(txSocket->GetErrno(),
471 "socket error code should be ERROR_NOTCONN");
472
473 InetSocketAddress peer("10.0.0.1", 1234);
474 err = txSocket->Connect(peer);
475 NS_TEST_EXPECT_MSG_EQ(err, 0, "socket Connect() should succeed");
476
477 err = txSocket->GetPeerName(peerAddress);
478 NS_TEST_EXPECT_MSG_EQ(err, 0, "socket GetPeerName() should succeed when socket is connected");
479 NS_TEST_EXPECT_MSG_EQ(peerAddress,
480 peer,
481 "address from socket GetPeerName() should equal the connected address");
482
485
486 // TOS and priority tests
487
488 // Intercept the packets dequeued by the queue disc on the sender node
489 qdiscs.Get(0)->TraceConnectWithoutContext("Dequeue",
491
492 // The socket is not connected.
493 txSocket->SetIpTos(0x28); // AF11
494 txSocket->SetPriority(6); // Interactive
495 // Send a packet to a specified destination:
496 // - for not connected sockets, the tos specified in the destination address (0) is used
497 // - since the tos is zero, the priority set for the socket is used
498 SendDataTo(txSocket, "10.0.0.1");
500
501 NS_TEST_EXPECT_MSG_EQ(GetTos(), 0, "the TOS should be set to 0");
502 NS_TEST_EXPECT_MSG_EQ(GetPriority(), 6, "Interactive (6)");
503
505
506 InetSocketAddress dest("10.0.0.1", 1234);
507 dest.SetTos(0xb8); // EF
508 // the connect operation sets the tos (and priority) for the socket
509 NS_TEST_EXPECT_MSG_EQ(txSocket->Connect(dest), 0, "the connect operation failed");
510
511 SendData(txSocket);
513
514 NS_TEST_EXPECT_MSG_EQ(GetTos(), 0xb8, "the TOS should be set to 0xb8");
515 NS_TEST_EXPECT_MSG_EQ(GetPriority(), 4, "Interactive bulk (4)");
516
518
520}
521
528{
531
537 void DoSendDataTo(Ptr<Socket> socket, std::string to);
543 void SendDataTo(Ptr<Socket> socket, std::string to);
544
545 public:
546 void DoRun() override;
548
555 void ReceivePacket(Ptr<Socket> socket, Ptr<Packet> packet, const Address& from);
562 void ReceivePacket2(Ptr<Socket> socket, Ptr<Packet> packet, const Address& from);
567 void ReceivePkt(Ptr<Socket> socket);
572 void ReceivePkt2(Ptr<Socket> socket);
573};
574
576 : TestCase("UDP6 socket implementation")
577{
578}
579
580void
582{
583 m_receivedPacket = packet;
584}
585
586void
588{
589 m_receivedPacket2 = packet;
590}
591
592void
594{
595 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
596 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
597 NS_TEST_ASSERT_MSG_EQ(availableData,
599 "ReceivedPacket size is not equal to the Rx buffer size");
600}
601
602void
604{
605 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
606 m_receivedPacket2 = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
607 NS_TEST_ASSERT_MSG_EQ(availableData,
609 "ReceivedPacket size is not equal to the Rx buffer size");
610}
611
612void
614{
615 Address realTo = Inet6SocketAddress(Ipv6Address(to.c_str()), 1234);
616 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "200");
617}
618
619void
621{
622 m_receivedPacket = Create<Packet>();
623 m_receivedPacket2 = Create<Packet>();
624 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
625 Seconds(0),
627 this,
628 socket,
629 to);
631}
632
633void
635{
636 // Create topology
637
638 // Receiver Node
639 Ptr<Node> rxNode = CreateObject<Node>();
640 // Sender Node
641 Ptr<Node> txNode = CreateObject<Node>();
642
643 NodeContainer nodes(rxNode, txNode);
644
645 SimpleNetDeviceHelper helperChannel1;
646 helperChannel1.SetNetDevicePointToPointMode(true);
647 NetDeviceContainer net1 = helperChannel1.Install(nodes);
648
649 SimpleNetDeviceHelper helperChannel2;
650 helperChannel2.SetNetDevicePointToPointMode(true);
651 NetDeviceContainer net2 = helperChannel2.Install(nodes);
652
653 InternetStackHelper internetv6;
654 internetv6.Install(nodes);
655
656 txNode->GetObject<Icmpv6L4Protocol>()->SetAttribute("DAD", BooleanValue(false));
657 rxNode->GetObject<Icmpv6L4Protocol>()->SetAttribute("DAD", BooleanValue(false));
658
659 Ipv6AddressHelper ipv6helper;
660 Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress(net1);
661 Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress(net2);
662
663 Ptr<NetDevice> device;
664 Ptr<Ipv6> ipv6;
665 int32_t ifIndex;
666 Ipv6InterfaceAddress ipv6Addr;
667
668 ipv6 = rxNode->GetObject<Ipv6>();
669 device = net1.Get(0);
670 ifIndex = ipv6->GetInterfaceForDevice(device);
671 ipv6Addr = Ipv6InterfaceAddress(Ipv6Address("2001:0100::1"), Ipv6Prefix(64));
672 ipv6->AddAddress(ifIndex, ipv6Addr);
673 ipv6->SetUp(ifIndex);
674
675 device = net2.Get(0);
676 ifIndex = ipv6->GetInterfaceForDevice(device);
677 ipv6Addr = Ipv6InterfaceAddress(Ipv6Address("2001:0100:1::1"), Ipv6Prefix(64));
678 ipv6->AddAddress(ifIndex, ipv6Addr);
679 ipv6->SetUp(ifIndex);
680
681 ipv6 = txNode->GetObject<Ipv6>();
682 device = net1.Get(1);
683 ifIndex = ipv6->GetInterfaceForDevice(device);
684 ipv6Addr = Ipv6InterfaceAddress(Ipv6Address("2001:0100::2"), Ipv6Prefix(64));
685 ipv6->AddAddress(ifIndex, ipv6Addr);
686 ipv6->SetUp(ifIndex);
687
688 device = net2.Get(1);
689 ifIndex = ipv6->GetInterfaceForDevice(device);
690 ipv6Addr = Ipv6InterfaceAddress(Ipv6Address("2001:0100:1::2"), Ipv6Prefix(64));
691 ipv6->AddAddress(ifIndex, ipv6Addr);
692 ipv6->SetUp(ifIndex);
693
694 // Create the UDP sockets
695 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
696 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
697 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(Inet6SocketAddress(Ipv6Address("2001:0100::1"), 1234)),
698 0,
699 "trivial");
700 rxSocket->SetRecvCallback(MakeCallback(&Udp6SocketImplTest::ReceivePkt, this));
701
702 Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket();
703 rxSocket2->SetRecvCallback(MakeCallback(&Udp6SocketImplTest::ReceivePkt2, this));
704 NS_TEST_EXPECT_MSG_EQ(rxSocket2->Bind(Inet6SocketAddress(Ipv6Address("2001:0100:1::1"), 1234)),
705 0,
706 "trivial");
707
708 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
709 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
710 txSocket->SetAllowBroadcast(true);
711 // ------ Now the tests ------------
712
713 // Unicast test
714 SendDataTo(txSocket, "2001:0100::1");
716 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket2->GetSize(), 0, "second interface should receive it");
717
720
721 // Simple Link-local multicast test
722
723 // When receiving broadcast packets, all sockets sockets bound to
724 // the address/port should receive a copy of the same packet -- if
725 // the socket address matches.
726 rxSocket2->Dispose();
727 rxSocket2 = rxSocketFactory->CreateSocket();
728 rxSocket2->SetRecvCallback(MakeCallback(&Udp6SocketImplTest::ReceivePkt2, this));
729 NS_TEST_EXPECT_MSG_EQ(rxSocket2->Bind(Inet6SocketAddress(Ipv6Address("::"), 1234)),
730 0,
731 "trivial");
732
733 txSocket->BindToNetDevice(net1.Get(1));
734 SendDataTo(txSocket, "ff02::1");
736 0,
737 "first socket should not receive it (it is bound specifically to the "
738 "second interface's address");
739 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket2->GetSize(), 123, "recv2: ff02::1");
740
743
744 // Simple getpeername tests
745 Address peerAddress;
746 int err = txSocket->GetPeerName(peerAddress);
747 NS_TEST_EXPECT_MSG_EQ(err, -1, "socket GetPeerName() should fail when socket is not connected");
748 NS_TEST_EXPECT_MSG_EQ(txSocket->GetErrno(),
750 "socket error code should be ERROR_NOTCONN");
751
752 Inet6SocketAddress peer("2001:0100::1", 1234);
753 err = txSocket->Connect(peer);
754 NS_TEST_EXPECT_MSG_EQ(err, 0, "socket Connect() should succeed");
755
756 err = txSocket->GetPeerName(peerAddress);
757 NS_TEST_EXPECT_MSG_EQ(err, 0, "socket GetPeerName() should succeed when socket is connected");
758 NS_TEST_EXPECT_MSG_EQ(peerAddress,
759 peer,
760 "address from socket GetPeerName() should equal the connected address");
761
763}
764
771{
772 public:
774 : TestSuite("udp", UNIT)
775 {
780 }
781};
782
UDP Socket over IPv6 Test.
Definition: udp-test.cc:528
Ptr< Packet > m_receivedPacket
Received packet (1).
Definition: udp-test.cc:529
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive packets (1).
Definition: udp-test.cc:581
void SendDataTo(Ptr< Socket > socket, std::string to)
Send data.
Definition: udp-test.cc:620
void ReceivePkt2(Ptr< Socket > socket)
Receive packets (2).
Definition: udp-test.cc:603
void DoRun() override
Implementation to actually run this TestCase.
Definition: udp-test.cc:634
Ptr< Packet > m_receivedPacket2
Received packet (2).
Definition: udp-test.cc:530
void ReceivePkt(Ptr< Socket > socket)
Receive packets (1).
Definition: udp-test.cc:593
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive packets (2).
Definition: udp-test.cc:587
void DoSendDataTo(Ptr< Socket > socket, std::string to)
Send data.
Definition: udp-test.cc:613
UDP Socket Loopback over IPv6 Test.
Definition: udp-test.cc:121
void ReceivePkt(Ptr< Socket > socket)
Receive a packet.
Definition: udp-test.cc:140
Ptr< Packet > m_receivedPacket
Received packet.
Definition: udp-test.cc:131
void DoRun() override
Implementation to actually run this TestCase.
Definition: udp-test.cc:150
UDP Socket over IPv4 Test.
Definition: udp-test.cc:177
uint32_t GetTos()
Get the TOS of the received packet.
Definition: udp-test.cc:277
uint32_t GetPriority()
Get the priority of the received packet.
Definition: udp-test.cc:283
void SendData(Ptr< Socket > socket)
Send data.
Definition: udp-test.cc:319
void ReceivePkt2(Ptr< Socket > socket)
Receive packets (2).
Definition: udp-test.cc:256
void SendDataTo(Ptr< Socket > socket, std::string to)
Send data.
Definition: udp-test.cc:299
Ptr< Packet > m_receivedPacket
Received packet (1).
Definition: udp-test.cc:178
void DoRun() override
Implementation to actually run this TestCase.
Definition: udp-test.cc:330
void DoSendData(Ptr< Socket > socket)
Send data.
Definition: udp-test.cc:313
Ptr< Ipv4QueueDiscItem > m_sentPacket
Sent packet.
Definition: udp-test.cc:180
void ReceivePkt(Ptr< Socket > socket)
Receive packets (1).
Definition: udp-test.cc:245
void SentPkt(Ptr< const QueueDiscItem > item)
Adds a packet to the list of sent packets.
Definition: udp-test.cc:267
Ptr< Packet > m_receivedPacket2
Received packet (2).
Definition: udp-test.cc:179
void DoSendDataTo(Ptr< Socket > socket, std::string to)
Send data.
Definition: udp-test.cc:292
UDP Socket Loopback over IPv4 Test.
Definition: udp-test.cc:64
Ptr< Packet > m_receivedPacket
Received packet.
Definition: udp-test.cc:74
void ReceivePkt(Ptr< Socket > socket)
Receive a packet.
Definition: udp-test.cc:83
void DoRun() override
Implementation to actually run this TestCase.
Definition: udp-test.cc:94
UDP TestSuite.
Definition: udp-test.cc:771
a polymophic address class
Definition: address.h:100
AttributeValue implementation for Boolean.
Definition: boolean.h:37
An implementation of the ICMPv6 protocol.
An Inet6 address class.
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
uint8_t GetTos() const
Definition: ipv4-header.cc:196
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
const Ipv4Header & GetHeader() const
Helper class to auto-assign global IPv6 unicast addresses.
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:311
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:1002
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Holds a vector of ns3::QueueDisc pointers.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
Ptr< Packet > GetPacket() const
Definition: queue-item.cc:43
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:587
static void Run()
Run the simulation.
Definition: simulator.cc:176
@ ERROR_NOTCONN
Definition: socket.h:87
indicates whether the socket has a priority set.
Definition: socket.h:1316
uint8_t GetPriority() const
Get the tag's priority.
Definition: socket.cc:858
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1265
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
static TrafficControlHelper Default(std::size_t nTxQueues=1)
API to create UDP socket instances.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:144
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Definition: test.h:666
#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:251
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:702
static UdpTestSuite g_udpTestSuite
Static variable for test initialization.
Definition: udp-test.cc:783