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 * 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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19
20#include "ns3/boolean.h"
21#include "ns3/enum.h"
22#include "ns3/icmpv4-l4-protocol.h"
23#include "ns3/inet-socket-address.h"
24#include "ns3/internet-stack-helper.h"
25#include "ns3/ipv4-address-helper.h"
26#include "ns3/ipv4-l3-protocol.h"
27#include "ns3/ipv4-static-routing.h"
28#include "ns3/log.h"
29#include "ns3/node-container.h"
30#include "ns3/node.h"
31#include "ns3/rip-helper.h"
32#include "ns3/rip.h"
33#include "ns3/simple-channel.h"
34#include "ns3/simple-net-device.h"
35#include "ns3/simulator.h"
36#include "ns3/socket-factory.h"
37#include "ns3/socket.h"
38#include "ns3/test.h"
39#include "ns3/udp-l4-protocol.h"
40#include "ns3/udp-socket-factory.h"
41
42#include <limits>
43#include <string>
44
45using namespace ns3;
46
52class Ipv4RipTest : public TestCase
53{
55
61 void DoSendData(Ptr<Socket> socket, std::string to);
67 void SendData(Ptr<Socket> socket, std::string to);
68
69 public:
70 void DoRun() override;
72
77 void ReceivePkt(Ptr<Socket> socket);
78};
79
81 : TestCase("RIP")
82{
83}
84
85void
87{
88 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
89 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
90 NS_TEST_ASSERT_MSG_EQ(availableData,
92 "Received Packet size is not equal to the Rx buffer size");
93}
94
95void
96Ipv4RipTest::DoSendData(Ptr<Socket> socket, std::string to)
97{
98 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
99 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
100}
101
102void
103Ipv4RipTest::SendData(Ptr<Socket> socket, std::string to)
104{
105 m_receivedPacket = Create<Packet>();
106 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
107 Seconds(60),
109 this,
110 socket,
111 to);
114}
115
116void
118{
119 // Create topology
120
121 Ptr<Node> txNode = CreateObject<Node>();
122 Ptr<Node> rxNode = CreateObject<Node>();
123 Ptr<Node> routerA = CreateObject<Node>();
124 Ptr<Node> routerB = CreateObject<Node>();
125 Ptr<Node> routerC = CreateObject<Node>();
126
127 NodeContainer nodes(txNode, rxNode);
128 NodeContainer routers(routerA, routerB, routerC);
129 NodeContainer all(nodes, routers);
130
131 RipHelper ripRouting;
132 InternetStackHelper internetRouters;
133 internetRouters.SetRoutingHelper(ripRouting);
134 internetRouters.Install(routers);
135
136 InternetStackHelper internetNodes;
137 internetNodes.Install(nodes);
138
143
144 // Sender Node
146 {
147 txDev = CreateObject<SimpleNetDevice>();
148 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
149 txNode->AddDevice(txDev);
150 }
151 net1.Add(txDev);
152
153 // Router A
154 Ptr<SimpleNetDevice> fwDev1routerA;
155 Ptr<SimpleNetDevice> fwDev2routerA;
156 { // first interface
157 fwDev1routerA = CreateObject<SimpleNetDevice>();
158 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
159 routerA->AddDevice(fwDev1routerA);
160 }
161 net1.Add(fwDev1routerA);
162
163 { // second interface
164 fwDev2routerA = CreateObject<SimpleNetDevice>();
165 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
166 routerA->AddDevice(fwDev2routerA);
167 }
168 net2.Add(fwDev2routerA);
169
170 // Router B
171 Ptr<SimpleNetDevice> fwDev1routerB;
172 Ptr<SimpleNetDevice> fwDev2routerB;
173 { // first interface
174 fwDev1routerB = CreateObject<SimpleNetDevice>();
175 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
176 routerB->AddDevice(fwDev1routerB);
177 }
178 net2.Add(fwDev1routerB);
179
180 { // second interface
181 fwDev2routerB = CreateObject<SimpleNetDevice>();
182 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
183 routerB->AddDevice(fwDev2routerB);
184 }
185 net3.Add(fwDev2routerB);
186
187 // Router C
188 Ptr<SimpleNetDevice> fwDev1routerC;
189 Ptr<SimpleNetDevice> fwDev2routerC;
190 { // first interface
191 fwDev1routerC = CreateObject<SimpleNetDevice>();
192 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
193 routerC->AddDevice(fwDev1routerC);
194 }
195 net3.Add(fwDev1routerC);
196
197 { // second interface
198 fwDev2routerC = CreateObject<SimpleNetDevice>();
199 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
200 routerC->AddDevice(fwDev2routerC);
201 }
202 net4.Add(fwDev2routerC);
203
204 // Rx node
206 { // first interface
207 rxDev = CreateObject<SimpleNetDevice>();
208 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
209 rxNode->AddDevice(rxDev);
210 }
211 net4.Add(rxDev);
212
213 // link the channels
214 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
215 txDev->SetChannel(channel1);
216 fwDev1routerA->SetChannel(channel1);
217
218 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
219 fwDev2routerA->SetChannel(channel2);
220 fwDev1routerB->SetChannel(channel2);
221
222 Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
223 fwDev2routerB->SetChannel(channel3);
224 fwDev1routerC->SetChannel(channel3);
225
226 Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
227 fwDev2routerC->SetChannel(channel4);
228 rxDev->SetChannel(channel4);
229
230 // Setup IPv4 addresses and forwarding
232
233 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
234 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
235
236 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
237 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
238
239 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
240 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
241
242 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
243 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
244
245 Ptr<Ipv4StaticRouting> staticRouting;
246 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
247 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
248 staticRouting->SetDefaultRoute("10.0.1.2", 1);
249 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
250 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
251 staticRouting->SetDefaultRoute("10.0.2.1", 1);
252
253 // Create the UDP sockets
254 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
255 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
256 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
257 0,
258 "trivial");
259 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipTest::ReceivePkt, this));
260
261 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
262 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
263 txSocket->SetAllowBroadcast(true);
264
265 // ------ Now the tests ------------
266
267 // Unicast test
268 SendData(txSocket, "10.0.2.2");
269 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 123, "IPv4 RIP should work.");
270
272
274}
275
282{
284
290 void DoSendData(Ptr<Socket> socket, std::string to);
296 void SendData(Ptr<Socket> socket, std::string to);
297
298 public:
299 void DoRun() override;
301
306 void ReceivePkt(Ptr<Socket> socket);
307};
308
310 : TestCase("RIP counting to infinity")
311{
312}
313
314void
316{
317 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
318 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
319 NS_TEST_ASSERT_MSG_EQ(availableData,
321 "Received Packet size is not equal to the Rx buffer size");
322}
323
324void
326{
327 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
328 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
329}
330
331void
333{
334 m_receivedPacket = Create<Packet>();
335 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
336 Seconds(60),
338 this,
339 socket,
340 to);
343}
344
345void
347{
348 // Create topology
349
350 Ptr<Node> txNode = CreateObject<Node>();
351 Ptr<Node> rxNode = CreateObject<Node>();
352 Ptr<Node> routerA = CreateObject<Node>();
353 Ptr<Node> routerB = CreateObject<Node>();
354 Ptr<Node> routerC = CreateObject<Node>();
355
356 NodeContainer nodes(txNode, rxNode);
357 NodeContainer routers(routerA, routerB, routerC);
358 NodeContainer all(nodes, routers);
359
360 RipHelper ripNgRouting;
361 // Change the router's interface metric to 10, must not send packets (count to infinity)
362 // note: Interface 0 is the loopback.
363 ripNgRouting.SetInterfaceMetric(routerA, 2, 10);
364 ripNgRouting.SetInterfaceMetric(routerB, 1, 10);
365 ripNgRouting.SetInterfaceMetric(routerB, 2, 10);
366 ripNgRouting.SetInterfaceMetric(routerC, 1, 10);
367
368 InternetStackHelper internetv6routers;
369 internetv6routers.SetRoutingHelper(ripNgRouting);
370 internetv6routers.Install(routers);
371
372 InternetStackHelper internetv6nodes;
373 internetv6nodes.Install(nodes);
374
379
380 // Sender Node
382 {
383 txDev = CreateObject<SimpleNetDevice>();
384 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
385 txNode->AddDevice(txDev);
386 }
387 net1.Add(txDev);
388
389 // Router A
390 Ptr<SimpleNetDevice> fwDev1routerA;
391 Ptr<SimpleNetDevice> fwDev2routerA;
392 { // first interface
393 fwDev1routerA = CreateObject<SimpleNetDevice>();
394 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
395 routerA->AddDevice(fwDev1routerA);
396 }
397 net1.Add(fwDev1routerA);
398
399 { // second interface
400 fwDev2routerA = CreateObject<SimpleNetDevice>();
401 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
402 routerA->AddDevice(fwDev2routerA);
403 }
404 net2.Add(fwDev2routerA);
405
406 // Router B
407 Ptr<SimpleNetDevice> fwDev1routerB;
408 Ptr<SimpleNetDevice> fwDev2routerB;
409 { // first interface
410 fwDev1routerB = CreateObject<SimpleNetDevice>();
411 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
412 routerB->AddDevice(fwDev1routerB);
413 }
414 net2.Add(fwDev1routerB);
415
416 { // second interface
417 fwDev2routerB = CreateObject<SimpleNetDevice>();
418 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
419 routerB->AddDevice(fwDev2routerB);
420 }
421 net3.Add(fwDev2routerB);
422
423 // Router C
424 Ptr<SimpleNetDevice> fwDev1routerC;
425 Ptr<SimpleNetDevice> fwDev2routerC;
426 { // first interface
427 fwDev1routerC = CreateObject<SimpleNetDevice>();
428 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
429 routerC->AddDevice(fwDev1routerC);
430 }
431 net3.Add(fwDev1routerC);
432
433 { // second interface
434 fwDev2routerC = CreateObject<SimpleNetDevice>();
435 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
436 routerC->AddDevice(fwDev2routerC);
437 }
438 net4.Add(fwDev2routerC);
439
440 // Rx node
442 { // first interface
443 rxDev = CreateObject<SimpleNetDevice>();
444 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
445 rxNode->AddDevice(rxDev);
446 }
447 net4.Add(rxDev);
448
449 // link the channels
450 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
451 txDev->SetChannel(channel1);
452 fwDev1routerA->SetChannel(channel1);
453
454 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
455 fwDev2routerA->SetChannel(channel2);
456 fwDev1routerB->SetChannel(channel2);
457
458 Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
459 fwDev2routerB->SetChannel(channel3);
460 fwDev1routerC->SetChannel(channel3);
461
462 Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
463 fwDev2routerC->SetChannel(channel4);
464 rxDev->SetChannel(channel4);
465
466 // Setup IPv4 addresses and forwarding
468
469 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
470 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
471
472 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
473 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
474
475 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
476 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
477
478 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
479 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
480
481 Ptr<Ipv4StaticRouting> staticRouting;
482 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
483 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
484 staticRouting->SetDefaultRoute("10.0.1.2", 1);
485 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
486 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
487 staticRouting->SetDefaultRoute("10.0.2.1", 1);
488
489 // Create the UDP sockets
490 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
491 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
492 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
493 0,
494 "trivial");
495 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipCountToInfinityTest::ReceivePkt, this));
496
497 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
498 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
499 txSocket->SetAllowBroadcast(true);
500
501 // ------ Now the tests ------------
502
503 SendData(txSocket, "10.0.2.2");
504 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 0, "RIP counting to infinity.");
505
507}
508
515{
518
519 public:
520 void DoRun() override;
521
527
532 void ReceivePktProbe(Ptr<Socket> socket);
533};
534
536 : TestCase("RIP Split Horizon strategy")
537{
538 m_setStrategy = strategy;
539}
540
541void
543{
544 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
545 Address srcAddr;
546 Ptr<Packet> receivedPacketProbe =
547 socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
548 NS_TEST_ASSERT_MSG_EQ(availableData,
549 receivedPacketProbe->GetSize(),
550 "Received Packet size is not equal to the Rx buffer size");
551 Ipv4Address senderAddress = InetSocketAddress::ConvertFrom(srcAddr).GetIpv4();
552
553 if (senderAddress == "192.168.0.2")
554 {
555 RipHeader hdr;
556 receivedPacketProbe->RemoveHeader(hdr);
557
558 std::list<RipRte> rtes = hdr.GetRteList();
559
560 // validate the RTEs before processing
561 for (auto iter = rtes.begin(); iter != rtes.end(); iter++)
562 {
563 if (iter->GetPrefix() == "10.0.1.0")
564 {
565 bool correct = false;
566 if (iter->GetRouteMetric() == 16)
567 {
568 correct = true;
570 }
571 else if (iter->GetRouteMetric() == 2)
572 {
573 correct = true;
575 }
576 NS_TEST_EXPECT_MSG_EQ(correct,
577 true,
578 "RIP: unexpected metric value: " << iter->GetRouteMetric());
579 }
580 }
581 }
582}
583
584void
586{
587 // Create topology
588
589 Ptr<Node> fakeNode = CreateObject<Node>();
590 Ptr<Node> listener = CreateObject<Node>();
591
592 Ptr<Node> routerA = CreateObject<Node>();
593 Ptr<Node> routerB = CreateObject<Node>();
594
595 NodeContainer listeners(listener, fakeNode);
596 NodeContainer routers(routerA, routerB);
597 NodeContainer all(routers, listeners);
598
599 RipHelper ripNgRouting;
600 ripNgRouting.Set("SplitHorizon", EnumValue(m_setStrategy));
601
602 InternetStackHelper internetRouters;
603 internetRouters.SetRoutingHelper(ripNgRouting);
604 internetRouters.Install(routers);
605
606 InternetStackHelper internetNodes;
607 internetNodes.Install(listeners);
608
611
612 // Fake Node
613 Ptr<SimpleNetDevice> silentDev;
614 {
615 silentDev = CreateObject<SimpleNetDevice>();
616 silentDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
617 fakeNode->AddDevice(silentDev);
618 }
619 net0.Add(silentDev);
620
621 // Router A
622 Ptr<SimpleNetDevice> silentDevRouterA;
623 Ptr<SimpleNetDevice> fwDevRouterA;
624 { // silent interface
625 silentDevRouterA = CreateObject<SimpleNetDevice>();
626 silentDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:02"));
627 routerA->AddDevice(silentDevRouterA);
628 }
629 net0.Add(silentDevRouterA);
630
631 { // first interface
632 fwDevRouterA = CreateObject<SimpleNetDevice>();
633 fwDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:03"));
634 routerA->AddDevice(fwDevRouterA);
635 }
636 net1.Add(fwDevRouterA);
637
638 // Router B
639 Ptr<SimpleNetDevice> fwDevRouterB;
640 { // first interface
641 fwDevRouterB = CreateObject<SimpleNetDevice>();
642 fwDevRouterB->SetAddress(Mac48Address("00:00:00:00:00:04"));
643 routerB->AddDevice(fwDevRouterB);
644 }
645 net1.Add(fwDevRouterB);
646
647 // listener A
648 Ptr<SimpleNetDevice> listenerDev;
649 {
650 listenerDev = CreateObject<SimpleNetDevice>();
651 listenerDev->SetAddress(Mac48Address("00:00:00:00:00:05"));
652 listener->AddDevice(listenerDev);
653 }
654 net1.Add(listenerDev);
655
656 // link the channels
657 Ptr<SimpleChannel> channel0 = CreateObject<SimpleChannel>();
658 silentDev->SetChannel(channel0);
659 silentDevRouterA->SetChannel(channel0);
660
661 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
662 fwDevRouterA->SetChannel(channel1);
663 fwDevRouterB->SetChannel(channel1);
664 listenerDev->SetChannel(channel1);
665
666 // Setup IPv6 addresses and forwarding
668
669 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
670 Ipv4InterfaceContainer iic0 = ipv4.Assign(net0);
671
672 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
673 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
674
675 // Create the UDP sockets
676 Ptr<SocketFactory> rxSocketFactory = listener->GetObject<UdpSocketFactory>();
677 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
678 rxSocket->BindToNetDevice(listenerDev);
679 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("224.0.0.9"), 520)),
680 0,
681 "trivial");
682 rxSocket->SetRecvCallback(
684
685 // ------ Now the tests ------------
686
687 // If the strategy is Split Horizon, then no packet will be received.
689
692 NS_TEST_EXPECT_MSG_EQ(m_detectedStrategy, m_setStrategy, "RIP counting to infinity.");
693
695}
696
703{
704 public:
706 : TestSuite("ipv4-rip", Type::UNIT)
707 {
708 AddTestCase(new Ipv4RipTest, TestCase::Duration::QUICK);
709 AddTestCase(new Ipv4RipCountToInfinityTest, TestCase::Duration::QUICK);
711 TestCase::Duration::QUICK);
713 TestCase::Duration::QUICK);
715 TestCase::Duration::QUICK);
716 }
717};
718
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:101
Hold variables of type enum.
Definition: enum.h:62
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.
Definition: ipv4-address.h:42
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
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
Definition: ipv4-address.h:257
an EUI-48 address
Definition: mac48-address.h:46
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:861
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
RipHeader - see RFC 2453
Definition: rip-header.h:158
std::list< RipRte > GetRteList() const
Get the list of the RTEs included in the message.
Definition: rip-header.cc:300
Helper class that adds RIP routing to nodes.
Definition: rip-helper.h:42
void Set(std::string name, const AttributeValue &value)
Definition: rip-helper.cc:81
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
Definition: rip-helper.cc:177
SplitHorizonType_e
Split Horizon strategy type.
Definition: rip.h:212
@ SPLIT_HORIZON
Split Horizon.
Definition: rip.h:214
@ NO_SPLIT_HORIZON
No Split Horizon.
Definition: rip.h:213
@ POISON_REVERSE
Poison Reverse Split Horizon.
Definition: rip.h:215
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
static constexpr auto UNIT
Definition: test.h:1286
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:145
#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:252
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
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:704