A Discrete-Event Network Simulator
API
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
53class Ipv4RipTest : public TestCase
54{
56
62 void DoSendData(Ptr<Socket> socket, std::string to);
68 void SendData(Ptr<Socket> socket, std::string to);
69
70 public:
71 void DoRun() override;
73
78 void ReceivePkt(Ptr<Socket> socket);
79};
80
82 : TestCase("RIP")
83{
84}
85
86void
88{
89 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
91 NS_TEST_ASSERT_MSG_EQ(availableData,
93 "Received Packet size is not equal to the Rx buffer size");
94}
95
96void
97Ipv4RipTest::DoSendData(Ptr<Socket> socket, std::string to)
98{
99 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
100 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
101}
102
103void
104Ipv4RipTest::SendData(Ptr<Socket> socket, std::string to)
105{
106 m_receivedPacket = Create<Packet>();
107 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
108 Seconds(60),
110 this,
111 socket,
112 to);
113 Simulator::Stop(Seconds(66));
114 Simulator::Run();
115}
116
117void
119{
120 // Create topology
121
122 Ptr<Node> txNode = CreateObject<Node>();
123 Ptr<Node> rxNode = CreateObject<Node>();
124 Ptr<Node> routerA = CreateObject<Node>();
125 Ptr<Node> routerB = CreateObject<Node>();
126 Ptr<Node> routerC = CreateObject<Node>();
127
128 NodeContainer nodes(txNode, rxNode);
129 NodeContainer routers(routerA, routerB, routerC);
130 NodeContainer all(nodes, routers);
131
132 RipHelper ripRouting;
133 InternetStackHelper internetRouters;
134 internetRouters.SetRoutingHelper(ripRouting);
135 internetRouters.Install(routers);
136
137 InternetStackHelper internetNodes;
138 internetNodes.Install(nodes);
139
144
145 // Sender Node
147 {
148 txDev = CreateObject<SimpleNetDevice>();
149 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
150 txNode->AddDevice(txDev);
151 }
152 net1.Add(txDev);
153
154 // Router A
155 Ptr<SimpleNetDevice> fwDev1routerA;
156 Ptr<SimpleNetDevice> fwDev2routerA;
157 { // first interface
158 fwDev1routerA = CreateObject<SimpleNetDevice>();
159 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
160 routerA->AddDevice(fwDev1routerA);
161 }
162 net1.Add(fwDev1routerA);
163
164 { // second interface
165 fwDev2routerA = CreateObject<SimpleNetDevice>();
166 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
167 routerA->AddDevice(fwDev2routerA);
168 }
169 net2.Add(fwDev2routerA);
170
171 // Router B
172 Ptr<SimpleNetDevice> fwDev1routerB;
173 Ptr<SimpleNetDevice> fwDev2routerB;
174 { // first interface
175 fwDev1routerB = CreateObject<SimpleNetDevice>();
176 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
177 routerB->AddDevice(fwDev1routerB);
178 }
179 net2.Add(fwDev1routerB);
180
181 { // second interface
182 fwDev2routerB = CreateObject<SimpleNetDevice>();
183 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
184 routerB->AddDevice(fwDev2routerB);
185 }
186 net3.Add(fwDev2routerB);
187
188 // Router C
189 Ptr<SimpleNetDevice> fwDev1routerC;
190 Ptr<SimpleNetDevice> fwDev2routerC;
191 { // first interface
192 fwDev1routerC = CreateObject<SimpleNetDevice>();
193 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
194 routerC->AddDevice(fwDev1routerC);
195 }
196 net3.Add(fwDev1routerC);
197
198 { // second interface
199 fwDev2routerC = CreateObject<SimpleNetDevice>();
200 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
201 routerC->AddDevice(fwDev2routerC);
202 }
203 net4.Add(fwDev2routerC);
204
205 // Rx node
207 { // first interface
208 rxDev = CreateObject<SimpleNetDevice>();
209 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
210 rxNode->AddDevice(rxDev);
211 }
212 net4.Add(rxDev);
213
214 // link the channels
215 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
216 txDev->SetChannel(channel1);
217 fwDev1routerA->SetChannel(channel1);
218
219 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
220 fwDev2routerA->SetChannel(channel2);
221 fwDev1routerB->SetChannel(channel2);
222
223 Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
224 fwDev2routerB->SetChannel(channel3);
225 fwDev1routerC->SetChannel(channel3);
226
227 Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
228 fwDev2routerC->SetChannel(channel4);
229 rxDev->SetChannel(channel4);
230
231 // Setup IPv4 addresses and forwarding
233
234 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
235 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
236
237 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
238 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
239
240 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
241 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
242
243 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
244 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
245
246 Ptr<Ipv4StaticRouting> staticRouting;
247 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
248 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
249 staticRouting->SetDefaultRoute("10.0.1.2", 1);
250 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
251 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
252 staticRouting->SetDefaultRoute("10.0.2.1", 1);
253
254 // Create the UDP sockets
255 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
256 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
257 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
258 0,
259 "trivial");
260 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipTest::ReceivePkt, this));
261
262 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
263 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
264 txSocket->SetAllowBroadcast(true);
265
266 // ------ Now the tests ------------
267
268 // Unicast test
269 SendData(txSocket, "10.0.2.2");
270 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 123, "IPv4 RIP should work.");
271
273
274 Simulator::Destroy();
275}
276
284{
286
292 void DoSendData(Ptr<Socket> socket, std::string to);
298 void SendData(Ptr<Socket> socket, std::string to);
299
300 public:
301 void DoRun() override;
303
308 void ReceivePkt(Ptr<Socket> socket);
309};
310
312 : TestCase("RIP counting to infinity")
313{
314}
315
316void
318{
319 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
321 NS_TEST_ASSERT_MSG_EQ(availableData,
323 "Received Packet size is not equal to the Rx buffer size");
324}
325
326void
328{
329 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
330 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
331}
332
333void
335{
336 m_receivedPacket = Create<Packet>();
337 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
338 Seconds(60),
340 this,
341 socket,
342 to);
343 Simulator::Stop(Seconds(66));
344 Simulator::Run();
345}
346
347void
349{
350 // Create topology
351
352 Ptr<Node> txNode = CreateObject<Node>();
353 Ptr<Node> rxNode = CreateObject<Node>();
354 Ptr<Node> routerA = CreateObject<Node>();
355 Ptr<Node> routerB = CreateObject<Node>();
356 Ptr<Node> routerC = CreateObject<Node>();
357
358 NodeContainer nodes(txNode, rxNode);
359 NodeContainer routers(routerA, routerB, routerC);
360 NodeContainer all(nodes, routers);
361
362 RipHelper ripNgRouting;
363 // Change the router's interface metric to 10, must not send packets (count to infinity)
364 // note: Interface 0 is the loopback.
365 ripNgRouting.SetInterfaceMetric(routerA, 2, 10);
366 ripNgRouting.SetInterfaceMetric(routerB, 1, 10);
367 ripNgRouting.SetInterfaceMetric(routerB, 2, 10);
368 ripNgRouting.SetInterfaceMetric(routerC, 1, 10);
369
370 InternetStackHelper internetv6routers;
371 internetv6routers.SetRoutingHelper(ripNgRouting);
372 internetv6routers.Install(routers);
373
374 InternetStackHelper internetv6nodes;
375 internetv6nodes.Install(nodes);
376
381
382 // Sender Node
384 {
385 txDev = CreateObject<SimpleNetDevice>();
386 txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
387 txNode->AddDevice(txDev);
388 }
389 net1.Add(txDev);
390
391 // Router A
392 Ptr<SimpleNetDevice> fwDev1routerA;
393 Ptr<SimpleNetDevice> fwDev2routerA;
394 { // first interface
395 fwDev1routerA = CreateObject<SimpleNetDevice>();
396 fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
397 routerA->AddDevice(fwDev1routerA);
398 }
399 net1.Add(fwDev1routerA);
400
401 { // second interface
402 fwDev2routerA = CreateObject<SimpleNetDevice>();
403 fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
404 routerA->AddDevice(fwDev2routerA);
405 }
406 net2.Add(fwDev2routerA);
407
408 // Router B
409 Ptr<SimpleNetDevice> fwDev1routerB;
410 Ptr<SimpleNetDevice> fwDev2routerB;
411 { // first interface
412 fwDev1routerB = CreateObject<SimpleNetDevice>();
413 fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
414 routerB->AddDevice(fwDev1routerB);
415 }
416 net2.Add(fwDev1routerB);
417
418 { // second interface
419 fwDev2routerB = CreateObject<SimpleNetDevice>();
420 fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
421 routerB->AddDevice(fwDev2routerB);
422 }
423 net3.Add(fwDev2routerB);
424
425 // Router C
426 Ptr<SimpleNetDevice> fwDev1routerC;
427 Ptr<SimpleNetDevice> fwDev2routerC;
428 { // first interface
429 fwDev1routerC = CreateObject<SimpleNetDevice>();
430 fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
431 routerC->AddDevice(fwDev1routerC);
432 }
433 net3.Add(fwDev1routerC);
434
435 { // second interface
436 fwDev2routerC = CreateObject<SimpleNetDevice>();
437 fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
438 routerC->AddDevice(fwDev2routerC);
439 }
440 net4.Add(fwDev2routerC);
441
442 // Rx node
444 { // first interface
445 rxDev = CreateObject<SimpleNetDevice>();
446 rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
447 rxNode->AddDevice(rxDev);
448 }
449 net4.Add(rxDev);
450
451 // link the channels
452 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
453 txDev->SetChannel(channel1);
454 fwDev1routerA->SetChannel(channel1);
455
456 Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
457 fwDev2routerA->SetChannel(channel2);
458 fwDev1routerB->SetChannel(channel2);
459
460 Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
461 fwDev2routerB->SetChannel(channel3);
462 fwDev1routerC->SetChannel(channel3);
463
464 Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
465 fwDev2routerC->SetChannel(channel4);
466 rxDev->SetChannel(channel4);
467
468 // Setup IPv4 addresses and forwarding
470
471 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
472 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
473
474 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
475 Ipv4InterfaceContainer iic2 = ipv4.Assign(net2);
476
477 ipv4.SetBase(Ipv4Address("192.168.1.0"), Ipv4Mask("255.255.255.0"));
478 Ipv4InterfaceContainer iic3 = ipv4.Assign(net3);
479
480 ipv4.SetBase(Ipv4Address("10.0.2.0"), Ipv4Mask("255.255.255.0"));
481 Ipv4InterfaceContainer iic4 = ipv4.Assign(net4);
482
483 Ptr<Ipv4StaticRouting> staticRouting;
484 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
485 txNode->GetObject<Ipv4>()->GetRoutingProtocol());
486 staticRouting->SetDefaultRoute("10.0.1.2", 1);
487 staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(
488 rxNode->GetObject<Ipv4>()->GetRoutingProtocol());
489 staticRouting->SetDefaultRoute("10.0.2.1", 1);
490
491 // Create the UDP sockets
492 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
493 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
494 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("10.0.2.2"), 1234)),
495 0,
496 "trivial");
497 rxSocket->SetRecvCallback(MakeCallback(&Ipv4RipCountToInfinityTest::ReceivePkt, this));
498
499 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
500 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
501 txSocket->SetAllowBroadcast(true);
502
503 // ------ Now the tests ------------
504
505 SendData(txSocket, "10.0.2.2");
506 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 0, "RIP counting to infinity.");
507
508 Simulator::Destroy();
509}
510
518{
521
522 public:
523 void DoRun() override;
524
530
535 void ReceivePktProbe(Ptr<Socket> socket);
536};
537
539 : TestCase("RIP Split Horizon strategy")
540{
541 m_setStrategy = strategy;
542}
543
544void
546{
547 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
548 Address srcAddr;
549 Ptr<Packet> receivedPacketProbe =
550 socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
551 NS_TEST_ASSERT_MSG_EQ(availableData,
552 receivedPacketProbe->GetSize(),
553 "Received Packet size is not equal to the Rx buffer size");
554 Ipv4Address senderAddress = InetSocketAddress::ConvertFrom(srcAddr).GetIpv4();
555
556 if (senderAddress == "192.168.0.2")
557 {
558 RipHeader hdr;
559 receivedPacketProbe->RemoveHeader(hdr);
560
561 std::list<RipRte> rtes = hdr.GetRteList();
562
563 // validate the RTEs before processing
564 for (std::list<RipRte>::iterator iter = rtes.begin(); iter != rtes.end(); iter++)
565 {
566 if (iter->GetPrefix() == "10.0.1.0")
567 {
568 bool correct = false;
569 if (iter->GetRouteMetric() == 16)
570 {
571 correct = true;
572 m_detectedStrategy = Rip::POISON_REVERSE;
573 }
574 else if (iter->GetRouteMetric() == 2)
575 {
576 correct = true;
577 m_detectedStrategy = Rip::NO_SPLIT_HORIZON;
578 }
579 NS_TEST_EXPECT_MSG_EQ(correct,
580 true,
581 "RIP: unexpected metric value: " << iter->GetRouteMetric());
582 }
583 }
584 }
585}
586
587void
589{
590 // Create topology
591
592 Ptr<Node> fakeNode = CreateObject<Node>();
593 Ptr<Node> listener = CreateObject<Node>();
594
595 Ptr<Node> routerA = CreateObject<Node>();
596 Ptr<Node> routerB = CreateObject<Node>();
597
598 NodeContainer listeners(listener, fakeNode);
599 NodeContainer routers(routerA, routerB);
600 NodeContainer all(routers, listeners);
601
602 RipHelper ripNgRouting;
603 ripNgRouting.Set("SplitHorizon", EnumValue(m_setStrategy));
604
605 InternetStackHelper internetRouters;
606 internetRouters.SetRoutingHelper(ripNgRouting);
607 internetRouters.Install(routers);
608
609 InternetStackHelper internetNodes;
610 internetNodes.Install(listeners);
611
614
615 // Fake Node
616 Ptr<SimpleNetDevice> silentDev;
617 {
618 silentDev = CreateObject<SimpleNetDevice>();
619 silentDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
620 fakeNode->AddDevice(silentDev);
621 }
622 net0.Add(silentDev);
623
624 // Router A
625 Ptr<SimpleNetDevice> silentDevRouterA;
626 Ptr<SimpleNetDevice> fwDevRouterA;
627 { // silent interface
628 silentDevRouterA = CreateObject<SimpleNetDevice>();
629 silentDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:02"));
630 routerA->AddDevice(silentDevRouterA);
631 }
632 net0.Add(silentDevRouterA);
633
634 { // first interface
635 fwDevRouterA = CreateObject<SimpleNetDevice>();
636 fwDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:03"));
637 routerA->AddDevice(fwDevRouterA);
638 }
639 net1.Add(fwDevRouterA);
640
641 // Router B
642 Ptr<SimpleNetDevice> fwDevRouterB;
643 { // first interface
644 fwDevRouterB = CreateObject<SimpleNetDevice>();
645 fwDevRouterB->SetAddress(Mac48Address("00:00:00:00:00:04"));
646 routerB->AddDevice(fwDevRouterB);
647 }
648 net1.Add(fwDevRouterB);
649
650 // listener A
651 Ptr<SimpleNetDevice> listenerDev;
652 {
653 listenerDev = CreateObject<SimpleNetDevice>();
654 listenerDev->SetAddress(Mac48Address("00:00:00:00:00:05"));
655 listener->AddDevice(listenerDev);
656 }
657 net1.Add(listenerDev);
658
659 // link the channels
660 Ptr<SimpleChannel> channel0 = CreateObject<SimpleChannel>();
661 silentDev->SetChannel(channel0);
662 silentDevRouterA->SetChannel(channel0);
663
664 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
665 fwDevRouterA->SetChannel(channel1);
666 fwDevRouterB->SetChannel(channel1);
667 listenerDev->SetChannel(channel1);
668
669 // Setup IPv6 addresses and forwarding
671
672 ipv4.SetBase(Ipv4Address("10.0.1.0"), Ipv4Mask("255.255.255.0"));
673 Ipv4InterfaceContainer iic0 = ipv4.Assign(net0);
674
675 ipv4.SetBase(Ipv4Address("192.168.0.0"), Ipv4Mask("255.255.255.0"));
676 Ipv4InterfaceContainer iic1 = ipv4.Assign(net1);
677
678 // Create the UDP sockets
679 Ptr<SocketFactory> rxSocketFactory = listener->GetObject<UdpSocketFactory>();
680 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
681 rxSocket->BindToNetDevice(listenerDev);
682 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(InetSocketAddress(Ipv4Address("224.0.0.9"), 520)),
683 0,
684 "trivial");
685 rxSocket->SetRecvCallback(
687
688 // ------ Now the tests ------------
689
690 // If the strategy is Split Horizon, then no packet will be received.
691 m_detectedStrategy = Rip::SPLIT_HORIZON;
692
693 Simulator::Stop(Seconds(66));
694 Simulator::Run();
695 NS_TEST_EXPECT_MSG_EQ(m_detectedStrategy, m_setStrategy, "RIP counting to infinity.");
696
697 Simulator::Destroy();
698}
699
707{
708 public:
710 : TestSuite("ipv4-rip", UNIT)
711 {
712 AddTestCase(new Ipv4RipTest, TestCase::QUICK);
713 AddTestCase(new Ipv4RipCountToInfinityTest, TestCase::QUICK);
714 AddTestCase(new Ipv4RipSplitHorizonStrategyTest(Rip::POISON_REVERSE), TestCase::QUICK);
715 AddTestCase(new Ipv4RipSplitHorizonStrategyTest(Rip::SPLIT_HORIZON), TestCase::QUICK);
716 AddTestCase(new Ipv4RipSplitHorizonStrategyTest(Rip::NO_SPLIT_HORIZON), TestCase::QUICK);
717 }
718};
719
#define max(a, b)
Definition: 80211b.c:43
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:92
Hold variables of type enum.
Definition: enum.h:56
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...
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
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:258
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 AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
uint32_t GetId() const
Definition: node.cc:117
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
RipHeader - see RFC 2453
Definition: rip-header.h:157
std::list< RipRte > GetRteList() const
Get the list of the RTEs included in the message.
Definition: rip-header.cc:302
Helper class that adds RIP routing to nodes.
Definition: rip-helper.h:41
void Set(std::string name, const AttributeValue &value)
Definition: rip-helper.cc:83
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
Definition: rip-helper.cc:179
SplitHorizonType_e
Split Horizon strategy type.
Definition: rip.h:211
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1265
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_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:1338
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:691