A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-rip-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Universita' di Firenze
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7 */
8
9#include "ns3/boolean.h"
10#include "ns3/enum.h"
11#include "ns3/icmpv4-l4-protocol.h"
12#include "ns3/inet-socket-address.h"
13#include "ns3/internet-stack-helper.h"
14#include "ns3/ipv4-address-helper.h"
15#include "ns3/ipv4-l3-protocol.h"
16#include "ns3/ipv4-static-routing.h"
17#include "ns3/log.h"
18#include "ns3/node-container.h"
19#include "ns3/node.h"
20#include "ns3/rip-helper.h"
21#include "ns3/rip.h"
22#include "ns3/simple-channel.h"
23#include "ns3/simple-net-device.h"
24#include "ns3/simulator.h"
25#include "ns3/socket-factory.h"
26#include "ns3/socket.h"
27#include "ns3/test.h"
28#include "ns3/udp-l4-protocol.h"
29#include "ns3/udp-socket-factory.h"
30
31#include <limits>
32#include <string>
33
34using namespace ns3;
35
36/**
37 * @ingroup internet-test
38 *
39 * @brief IPv4 RIP Test
40 */
41class Ipv4RipTest : public TestCase
42{
43 Ptr<Packet> m_receivedPacket; //!< Received packet
44
45 /**
46 * @brief Send data.
47 * @param socket The sending socket.
48 * @param to Destination address.
49 */
50 void DoSendData(Ptr<Socket> socket, std::string to);
51 /**
52 * @brief Send data.
53 * @param socket The sending socket.
54 * @param to Destination address.
55 */
56 void SendData(Ptr<Socket> socket, std::string to);
57
58 public:
59 void DoRun() override;
61
62 /**
63 * @brief Receive data.
64 * @param socket The receiving socket.
65 */
66 void ReceivePkt(Ptr<Socket> socket);
67};
68
70 : TestCase("RIP")
71{
72}
73
74void
76{
77 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
78 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
79 NS_TEST_ASSERT_MSG_EQ(availableData,
81 "Received Packet size is not equal to the Rx buffer size");
82}
83
84void
85Ipv4RipTest::DoSendData(Ptr<Socket> socket, std::string to)
86{
87 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
88 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
89}
90
91void
92Ipv4RipTest::SendData(Ptr<Socket> socket, std::string to)
93{
95 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
96 Seconds(60),
98 this,
99 socket,
100 to);
103}
104
105void
107{
108 // Create topology
109
110 Ptr<Node> txNode = CreateObject<Node>();
111 Ptr<Node> rxNode = CreateObject<Node>();
112 Ptr<Node> routerA = CreateObject<Node>();
113 Ptr<Node> routerB = CreateObject<Node>();
114 Ptr<Node> routerC = CreateObject<Node>();
115
116 NodeContainer nodes(txNode, rxNode);
117 NodeContainer routers(routerA, routerB, routerC);
118 NodeContainer all(nodes, routers);
119
120 RipHelper ripRouting;
121 InternetStackHelper internetRouters;
122 internetRouters.SetRoutingHelper(ripRouting);
123 internetRouters.Install(routers);
124
125 InternetStackHelper internetNodes;
126 internetNodes.Install(nodes);
127
132
133 // Sender Node
135 {
137 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
138 txNode->AddDevice(txDev);
139 }
140 net1.Add(txDev);
141
142 // Router A
143 Ptr<SimpleNetDevice> fwDev1routerA;
144 Ptr<SimpleNetDevice> fwDev2routerA;
145 { // first interface
146 fwDev1routerA = CreateObject<SimpleNetDevice>();
147 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
148 routerA->AddDevice(fwDev1routerA);
149 }
150 net1.Add(fwDev1routerA);
151
152 { // second interface
153 fwDev2routerA = CreateObject<SimpleNetDevice>();
154 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
155 routerA->AddDevice(fwDev2routerA);
156 }
157 net2.Add(fwDev2routerA);
158
159 // Router B
160 Ptr<SimpleNetDevice> fwDev1routerB;
161 Ptr<SimpleNetDevice> fwDev2routerB;
162 { // first interface
163 fwDev1routerB = CreateObject<SimpleNetDevice>();
164 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
165 routerB->AddDevice(fwDev1routerB);
166 }
167 net2.Add(fwDev1routerB);
168
169 { // second interface
170 fwDev2routerB = CreateObject<SimpleNetDevice>();
171 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
172 routerB->AddDevice(fwDev2routerB);
173 }
174 net3.Add(fwDev2routerB);
175
176 // Router C
177 Ptr<SimpleNetDevice> fwDev1routerC;
178 Ptr<SimpleNetDevice> fwDev2routerC;
179 { // first interface
180 fwDev1routerC = CreateObject<SimpleNetDevice>();
181 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
182 routerC->AddDevice(fwDev1routerC);
183 }
184 net3.Add(fwDev1routerC);
185
186 { // second interface
187 fwDev2routerC = CreateObject<SimpleNetDevice>();
188 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
189 routerC->AddDevice(fwDev2routerC);
190 }
191 net4.Add(fwDev2routerC);
192
193 // Rx node
195 { // first interface
197 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
198 rxNode->AddDevice(rxDev);
199 }
200 net4.Add(rxDev);
201
202 // link the channels
204 txDev->SetChannel(channel1);
205 fwDev1routerA->SetChannel(channel1);
206
208 fwDev2routerA->SetChannel(channel2);
209 fwDev1routerB->SetChannel(channel2);
210
212 fwDev2routerB->SetChannel(channel3);
213 fwDev1routerC->SetChannel(channel3);
214
216 fwDev2routerC->SetChannel(channel4);
217 rxDev->SetChannel(channel4);
218
219 // Setup IPv4 addresses and forwarding
221
222 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
223 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
224
225 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
226 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
227
228 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
229 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
230
231 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
232 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
233
234 Ptr<Ipv4StaticRouting> staticRouting;
236 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
237 staticRouting->SetDefaultRoute("10.0.1.2", 1);
239 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
240 staticRouting->SetDefaultRoute("10.0.2.1", 1);
241
242 // Create the UDP sockets
243 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
244 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
245 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
246 0,
247 "trivial");
248 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipTest::ReceivePkt, this));
249
250 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
251 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
252 txSocket->SetAllowBroadcast(true);
253
254 // ------ Now the tests ------------
255
256 // Unicast test
257 SendData(txSocket, "10.0.2.2");
258 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 123, "IPv4 RIP should work.");
259
261
263}
264
265/**
266 * @ingroup internet-test
267 *
268 * @brief IPv4 RIP count to infinity Test
269 */
271{
272 Ptr<Packet> m_receivedPacket; //!< Received packet
273
274 /**
275 * @brief Send data.
276 * @param socket The sending socket.
277 * @param to Destination address.
278 */
279 void DoSendData(Ptr<Socket> socket, std::string to);
280 /**
281 * @brief Send data.
282 * @param socket The sending socket.
283 * @param to Destination address.
284 */
285 void SendData(Ptr<Socket> socket, std::string to);
286
287 public:
288 void DoRun() override;
290
291 /**
292 * @brief Receive data.
293 * @param socket The receiving socket.
294 */
295 void ReceivePkt(Ptr<Socket> socket);
296};
297
299 : TestCase("RIP counting to infinity")
300{
301}
302
303void
305{
306 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
307 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
308 NS_TEST_ASSERT_MSG_EQ(availableData,
310 "Received Packet size is not equal to the Rx buffer size");
311}
312
313void
315{
316 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
317 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
318}
319
320void
322{
324 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
325 Seconds(60),
327 this,
328 socket,
329 to);
332}
333
334void
336{
337 // Create topology
338
339 Ptr<Node> txNode = CreateObject<Node>();
340 Ptr<Node> rxNode = CreateObject<Node>();
341 Ptr<Node> routerA = CreateObject<Node>();
342 Ptr<Node> routerB = CreateObject<Node>();
343 Ptr<Node> routerC = CreateObject<Node>();
344
345 NodeContainer nodes(txNode, rxNode);
346 NodeContainer routers(routerA, routerB, routerC);
347 NodeContainer all(nodes, routers);
348
349 RipHelper ripNgRouting;
350 // Change the router's interface metric to 10, must not send packets (count to infinity)
351 // note: Interface 0 is the loopback.
352 ripNgRouting.SetInterfaceMetric(routerA, 2, 10);
353 ripNgRouting.SetInterfaceMetric(routerB, 1, 10);
354 ripNgRouting.SetInterfaceMetric(routerB, 2, 10);
355 ripNgRouting.SetInterfaceMetric(routerC, 1, 10);
356
357 InternetStackHelper internetv6routers;
358 internetv6routers.SetRoutingHelper(ripNgRouting);
359 internetv6routers.Install(routers);
360
361 InternetStackHelper internetv6nodes;
362 internetv6nodes.Install(nodes);
363
368
369 // Sender Node
371 {
373 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
374 txNode->AddDevice(txDev);
375 }
376 net1.Add(txDev);
377
378 // Router A
379 Ptr<SimpleNetDevice> fwDev1routerA;
380 Ptr<SimpleNetDevice> fwDev2routerA;
381 { // first interface
382 fwDev1routerA = CreateObject<SimpleNetDevice>();
383 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
384 routerA->AddDevice(fwDev1routerA);
385 }
386 net1.Add(fwDev1routerA);
387
388 { // second interface
389 fwDev2routerA = CreateObject<SimpleNetDevice>();
390 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
391 routerA->AddDevice(fwDev2routerA);
392 }
393 net2.Add(fwDev2routerA);
394
395 // Router B
396 Ptr<SimpleNetDevice> fwDev1routerB;
397 Ptr<SimpleNetDevice> fwDev2routerB;
398 { // first interface
399 fwDev1routerB = CreateObject<SimpleNetDevice>();
400 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
401 routerB->AddDevice(fwDev1routerB);
402 }
403 net2.Add(fwDev1routerB);
404
405 { // second interface
406 fwDev2routerB = CreateObject<SimpleNetDevice>();
407 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
408 routerB->AddDevice(fwDev2routerB);
409 }
410 net3.Add(fwDev2routerB);
411
412 // Router C
413 Ptr<SimpleNetDevice> fwDev1routerC;
414 Ptr<SimpleNetDevice> fwDev2routerC;
415 { // first interface
416 fwDev1routerC = CreateObject<SimpleNetDevice>();
417 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
418 routerC->AddDevice(fwDev1routerC);
419 }
420 net3.Add(fwDev1routerC);
421
422 { // second interface
423 fwDev2routerC = CreateObject<SimpleNetDevice>();
424 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
425 routerC->AddDevice(fwDev2routerC);
426 }
427 net4.Add(fwDev2routerC);
428
429 // Rx node
431 { // first interface
433 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
434 rxNode->AddDevice(rxDev);
435 }
436 net4.Add(rxDev);
437
438 // link the channels
440 txDev->SetChannel(channel1);
441 fwDev1routerA->SetChannel(channel1);
442
444 fwDev2routerA->SetChannel(channel2);
445 fwDev1routerB->SetChannel(channel2);
446
448 fwDev2routerB->SetChannel(channel3);
449 fwDev1routerC->SetChannel(channel3);
450
452 fwDev2routerC->SetChannel(channel4);
453 rxDev->SetChannel(channel4);
454
455 // Setup IPv4 addresses and forwarding
457
458 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
459 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
460
461 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
462 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
463
464 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
465 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
466
467 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
468 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
469
470 Ptr<Ipv4StaticRouting> staticRouting;
472 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
473 staticRouting->SetDefaultRoute("10.0.1.2", 1);
475 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
476 staticRouting->SetDefaultRoute("10.0.2.1", 1);
477
478 // Create the UDP sockets
479 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
480 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
481 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
482 0,
483 "trivial");
484 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipCountToInfinityTest::ReceivePkt, this));
485
486 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
487 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
488 txSocket->SetAllowBroadcast(true);
489
490 // ------ Now the tests ------------
491
492 SendData(txSocket, "10.0.2.2");
493 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 0, "RIP counting to infinity.");
494
496}
497
498/**
499 * @ingroup internet-test
500 *
501 * @brief IPv4 RIP SplitHorizon strategy Test
502 */
504{
507
508 public:
509 void DoRun() override;
510
511 /**
512 * @brief Constructor.
513 * @param strategy The SplitHorizon strategy.
514 */
516
517 /**
518 * @brief Receive data.
519 * @param socket The receiving socket.
520 */
521 void ReceivePktProbe(Ptr<Socket> socket);
522};
523
525 : TestCase("RIP Split Horizon strategy")
526{
527 m_setStrategy = strategy;
528}
529
530void
532{
533 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
534 Address srcAddr;
535 Ptr<Packet> receivedPacketProbe =
536 socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
537 NS_TEST_ASSERT_MSG_EQ(availableData,
538 receivedPacketProbe->GetSize(),
539 "Received Packet size is not equal to the Rx buffer size");
540 Ipv4Address senderAddress = InetSocketAddress::ConvertFrom(srcAddr).GetIpv4();
541
542 if (senderAddress == "192.168.0.2")
543 {
544 RipHeader hdr;
545 receivedPacketProbe->RemoveHeader(hdr);
546
547 std::list<RipRte> rtes = hdr.GetRteList();
548
549 // validate the RTEs before processing
550 for (auto iter = rtes.begin(); iter != rtes.end(); iter++)
551 {
552 if (iter->GetPrefix() == "10.0.1.0")
553 {
554 bool correct = false;
555 if (iter->GetRouteMetric() == 16)
556 {
557 correct = true;
559 }
560 else if (iter->GetRouteMetric() == 2)
561 {
562 correct = true;
564 }
565 NS_TEST_EXPECT_MSG_EQ(correct,
566 true,
567 "RIP: unexpected metric value: " << iter->GetRouteMetric());
568 }
569 }
570 }
571}
572
573void
575{
576 // Create topology
577
578 Ptr<Node> fakeNode = CreateObject<Node>();
579 Ptr<Node> listener = CreateObject<Node>();
580
581 Ptr<Node> routerA = CreateObject<Node>();
582 Ptr<Node> routerB = CreateObject<Node>();
583
584 NodeContainer listeners(listener, fakeNode);
585 NodeContainer routers(routerA, routerB);
586 NodeContainer all(routers, listeners);
587
588 RipHelper ripNgRouting;
589 ripNgRouting.Set("SplitHorizon", EnumValue(m_setStrategy));
590
591 InternetStackHelper internetRouters;
592 internetRouters.SetRoutingHelper(ripNgRouting);
593 internetRouters.Install(routers);
594
595 InternetStackHelper internetNodes;
596 internetNodes.Install(listeners);
597
600
601 // Fake Node
602 Ptr<SimpleNetDevice> silentDev;
603 {
604 silentDev = CreateObject<SimpleNetDevice>();
605 silentDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
606 fakeNode->AddDevice(silentDev);
607 }
608 net0.Add(silentDev);
609
610 // Router A
611 Ptr<SimpleNetDevice> silentDevRouterA;
612 Ptr<SimpleNetDevice> fwDevRouterA;
613 { // silent interface
614 silentDevRouterA = CreateObject<SimpleNetDevice>();
615 silentDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:02"));
616 routerA->AddDevice(silentDevRouterA);
617 }
618 net0.Add(silentDevRouterA);
619
620 { // first interface
621 fwDevRouterA = CreateObject<SimpleNetDevice>();
622 fwDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:03"));
623 routerA->AddDevice(fwDevRouterA);
624 }
625 net1.Add(fwDevRouterA);
626
627 // Router B
628 Ptr<SimpleNetDevice> fwDevRouterB;
629 { // first interface
630 fwDevRouterB = CreateObject<SimpleNetDevice>();
631 fwDevRouterB->SetAddress(Mac48Address("00:00:00:00:00:04"));
632 routerB->AddDevice(fwDevRouterB);
633 }
634 net1.Add(fwDevRouterB);
635
636 // listener A
637 Ptr<SimpleNetDevice> listenerDev;
638 {
639 listenerDev = CreateObject<SimpleNetDevice>();
640 listenerDev->SetAddress(Mac48Address("00:00:00:00:00:05"));
641 listener->AddDevice(listenerDev);
642 }
643 net1.Add(listenerDev);
644
645 // link the channels
647 silentDev->SetChannel(channel0);
648 silentDevRouterA->SetChannel(channel0);
649
651 fwDevRouterA->SetChannel(channel1);
652 fwDevRouterB->SetChannel(channel1);
653 listenerDev->SetChannel(channel1);
654
655 // Setup IPv6 addresses and forwarding
657
658 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
659 Ipv4InterfaceContainer iic0 = ipv4.Assign(net0);
660
661 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
662 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
663
664 // Create the UDP sockets
665 Ptr<SocketFactory> rxSocketFactory = listener->GetObject<UdpSocketFactory>();
666 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
667 rxSocket->BindToNetDevice(listenerDev);
668 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("224.0.0.9"), 520)),
669 0,
670 "trivial");
671 rxSocket->SetRecvCallback(
673
674 // ------ Now the tests ------------
675
676 // If the strategy is Split Horizon, then no packet will be received.
678
681 NS_TEST_EXPECT_MSG_EQ(m_detectedStrategy, m_setStrategy, "RIP counting to infinity.");
682
684}
685
686/**
687 * @ingroup internet-test
688 *
689 * @brief IPv4 RIP TestSuite
690 */
692{
693 public:
695 : TestSuite("ipv4-rip", Type::UNIT)
696 {
697 AddTestCase(new Ipv4RipTest, TestCase::Duration::QUICK);
698 AddTestCase(new Ipv4RipCountToInfinityTest, TestCase::Duration::QUICK);
700 TestCase::Duration::QUICK);
702 TestCase::Duration::QUICK);
704 TestCase::Duration::QUICK);
705 }
706};
707
708static Ipv4RipTestSuite g_ipv4ripTestSuite; //!< Static variable for test initialization
IPv4 RIP count to infinity Test.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
Ptr< Packet > m_receivedPacket
Received packet.
IPv4 RIP SplitHorizon strategy Test.
void ReceivePktProbe(Ptr< Socket > socket)
Receive data.
Rip::SplitHorizonType_e m_detectedStrategy
Strategy detected.
Ipv4RipSplitHorizonStrategyTest(Rip::SplitHorizonType_e strategy)
Constructor.
Rip::SplitHorizonType_e m_setStrategy
Strategy set.
void DoRun() override
Implementation to actually run this TestCase.
IPv4 RIP Test.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Ptr< Packet > m_receivedPacket
Received packet.
void DoRun() override
Implementation to actually run this TestCase.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
IPv4 RIP TestSuite.
a polymophic address class
Definition address.h:90
Hold variables of type enum.
Definition enum.h:52
an Inet address class
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
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...
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol() const =0
Get the routing protocol to be used by this Ipv4 stack.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
static Ptr< T > GetRouting(Ptr< Ipv4RoutingProtocol > protocol)
Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol.
an EUI-48 address
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition packet.h:850
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition packet.cc:382
Smart pointer class similar to boost::intrusive_ptr.
RipHeader - see RFC 2453
Definition rip-header.h:147
std::list< RipRte > GetRteList() const
Get the list of the RTEs included in the message.
Helper class that adds RIP routing to nodes.
Definition rip-helper.h:31
void Set(std::string name, const AttributeValue &value)
Definition rip-helper.cc:70
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
SplitHorizonType_e
Split Horizon strategy type.
Definition rip.h:201
@ SPLIT_HORIZON
Split Horizon.
Definition rip.h:203
@ NO_SPLIT_HORIZON
No Split Horizon.
Definition rip.h:202
@ POISON_REVERSE
Poison Reverse Split Horizon.
Definition rip.h:204
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition simulator.h:577
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static constexpr auto UNIT
Definition test.h:1291
API to create UDP socket instances.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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:134
#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:241
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
static Ipv4RipTestSuite g_ipv4ripTestSuite
Static variable for test initialization.
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:684