A Discrete-Event Network Simulator
API
ipv6-ripng-test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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/icmpv6-l4-protocol.h"
23 #include "ns3/inet6-socket-address.h"
24 #include "ns3/internet-stack-helper.h"
25 #include "ns3/ipv6-address-helper.h"
26 #include "ns3/ipv6-l3-protocol.h"
27 #include "ns3/log.h"
28 #include "ns3/node-container.h"
29 #include "ns3/node.h"
30 #include "ns3/ripng-helper.h"
31 #include "ns3/ripng.h"
32 #include "ns3/simple-channel.h"
33 #include "ns3/simple-net-device.h"
34 #include "ns3/simulator.h"
35 #include "ns3/socket-factory.h"
36 #include "ns3/socket.h"
37 #include "ns3/test.h"
38 #include "ns3/udp-l4-protocol.h"
39 #include "ns3/udp-socket-factory.h"
40 
41 #include <limits>
42 #include <string>
43 
44 using namespace ns3;
45 
51 class Ipv6RipngTest : public TestCase
52 {
54 
60  void DoSendData(Ptr<Socket> socket, std::string to);
66  void SendData(Ptr<Socket> socket, std::string to);
67 
68  public:
69  void DoRun() override;
70  Ipv6RipngTest();
71 
76  void ReceivePkt(Ptr<Socket> socket);
77 };
78 
80  : TestCase("RIPng")
81 {
82 }
83 
84 void
86 {
87  uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
89  NS_TEST_ASSERT_MSG_EQ(availableData,
91  "Received packet size is not equal to Rx buffer size");
92 }
93 
94 void
95 Ipv6RipngTest::DoSendData(Ptr<Socket> socket, std::string to)
96 {
97  Address realTo = Inet6SocketAddress(Ipv6Address(to.c_str()), 1234);
98  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
99 }
100 
101 void
102 Ipv6RipngTest::SendData(Ptr<Socket> socket, std::string to)
103 {
104  m_receivedPacket = Create<Packet>();
105  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
106  Seconds(60),
108  this,
109  socket,
110  to);
111  Simulator::Stop(Seconds(66));
112  Simulator::Run();
113 }
114 
115 void
117 {
118  // Create topology
119 
120  Ptr<Node> txNode = CreateObject<Node>();
121  Ptr<Node> rxNode = CreateObject<Node>();
122  Ptr<Node> routerA = CreateObject<Node>();
123  Ptr<Node> routerB = CreateObject<Node>();
124  Ptr<Node> routerC = CreateObject<Node>();
125 
126  NodeContainer nodes(txNode, rxNode);
127  NodeContainer routers(routerA, routerB, routerC);
128  NodeContainer all(nodes, routers);
129 
130  RipNgHelper ripNgRouting;
131  InternetStackHelper internetv6routers;
132  internetv6routers.SetRoutingHelper(ripNgRouting);
133  internetv6routers.Install(routers);
134 
135  InternetStackHelper internetv6nodes;
136  internetv6nodes.Install(nodes);
137 
138  NetDeviceContainer net1;
139  NetDeviceContainer net2;
140  NetDeviceContainer net3;
141  NetDeviceContainer net4;
142 
143  // Sender Node
144  Ptr<SimpleNetDevice> txDev;
145  {
146  txDev = CreateObject<SimpleNetDevice>();
147  txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
148  txNode->AddDevice(txDev);
149  }
150  net1.Add(txDev);
151 
152  // Router A
153  Ptr<SimpleNetDevice> fwDev1routerA;
154  Ptr<SimpleNetDevice> fwDev2routerA;
155  { // first interface
156  fwDev1routerA = CreateObject<SimpleNetDevice>();
157  fwDev1routerA->SetAddress(Mac48Address("00:00:00:00:00:02"));
158  routerA->AddDevice(fwDev1routerA);
159  }
160  net1.Add(fwDev1routerA);
161 
162  { // second interface
163  fwDev2routerA = CreateObject<SimpleNetDevice>();
164  fwDev2routerA->SetAddress(Mac48Address("00:00:00:00:00:03"));
165  routerA->AddDevice(fwDev2routerA);
166  }
167  net2.Add(fwDev2routerA);
168 
169  // Router B
170  Ptr<SimpleNetDevice> fwDev1routerB;
171  Ptr<SimpleNetDevice> fwDev2routerB;
172  { // first interface
173  fwDev1routerB = CreateObject<SimpleNetDevice>();
174  fwDev1routerB->SetAddress(Mac48Address("00:00:00:00:00:04"));
175  routerB->AddDevice(fwDev1routerB);
176  }
177  net2.Add(fwDev1routerB);
178 
179  { // second interface
180  fwDev2routerB = CreateObject<SimpleNetDevice>();
181  fwDev2routerB->SetAddress(Mac48Address("00:00:00:00:00:05"));
182  routerB->AddDevice(fwDev2routerB);
183  }
184  net3.Add(fwDev2routerB);
185 
186  // Router C
187  Ptr<SimpleNetDevice> fwDev1routerC;
188  Ptr<SimpleNetDevice> fwDev2routerC;
189  { // first interface
190  fwDev1routerC = CreateObject<SimpleNetDevice>();
191  fwDev1routerC->SetAddress(Mac48Address("00:00:00:00:00:06"));
192  routerC->AddDevice(fwDev1routerC);
193  }
194  net3.Add(fwDev1routerC);
195 
196  { // second interface
197  fwDev2routerC = CreateObject<SimpleNetDevice>();
198  fwDev2routerC->SetAddress(Mac48Address("00:00:00:00:00:07"));
199  routerC->AddDevice(fwDev2routerC);
200  }
201  net4.Add(fwDev2routerC);
202 
203  // Rx node
204  Ptr<SimpleNetDevice> rxDev;
205  { // first interface
206  rxDev = CreateObject<SimpleNetDevice>();
207  rxDev->SetAddress(Mac48Address("00:00:00:00:00:08"));
208  rxNode->AddDevice(rxDev);
209  }
210  net4.Add(rxDev);
211 
212  // link the channels
213  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
214  txDev->SetChannel(channel1);
215  fwDev1routerA->SetChannel(channel1);
216 
217  Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
218  fwDev2routerA->SetChannel(channel2);
219  fwDev1routerB->SetChannel(channel2);
220 
221  Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
222  fwDev2routerB->SetChannel(channel3);
223  fwDev1routerC->SetChannel(channel3);
224 
225  Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
226  fwDev2routerC->SetChannel(channel4);
227  rxDev->SetChannel(channel4);
228 
229  // Setup IPv6 addresses and forwarding
230  Ipv6AddressHelper ipv6;
231 
232  ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
234  iic1.SetForwarding(1, true);
236 
238  iic2.SetForwarding(0, true);
239  iic2.SetForwarding(1, true);
240 
242  iic3.SetForwarding(0, true);
243  iic3.SetForwarding(1, true);
244 
245  ipv6.SetBase(Ipv6Address("2001:2::"), Ipv6Prefix(64));
247  iic4.SetForwarding(0, true);
249 
250  // Create the UDP sockets
251  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
252  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
254  rxSocket->Bind(Inet6SocketAddress(Ipv6Address("2001:2::200:ff:fe00:8"), 1234)),
255  0,
256  "trivial");
257  rxSocket->SetRecvCallback(MakeCallback(&Ipv6RipngTest::ReceivePkt, this));
258 
259  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
260  Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
261  txSocket->SetAllowBroadcast(true);
262 
263  // ------ Now the tests ------------
264 
265  // Unicast test
266  SendData(txSocket, "2001:2::200:ff:fe00:8");
267  NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 123, "IPv6 RIPng should work.");
268 
270 
271  Simulator::Destroy();
272 }
273 
274 // Ipv6RipngCountToInfinityTest
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("RIPng counting to infinity")
311 {
312 }
313 
314 void
316 {
317  uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
319  NS_TEST_ASSERT_MSG_EQ(availableData,
321  "Received packet size is not equal to Rx buffer size");
322 }
323 
324 void
326 {
327  Address realTo = Inet6SocketAddress(Ipv6Address(to.c_str()), 1234);
328  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(Create<Packet>(123), 0, realTo), 123, "100");
329 }
330 
331 void
333 {
334  m_receivedPacket = Create<Packet>();
335  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
336  Seconds(60),
338  this,
339  socket,
340  to);
341  Simulator::Stop(Seconds(66));
342  Simulator::Run();
343 }
344 
345 void
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  RipNgHelper 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 
375  NetDeviceContainer net1;
376  NetDeviceContainer net2;
377  NetDeviceContainer net3;
378  NetDeviceContainer net4;
379 
380  // Sender Node
381  Ptr<SimpleNetDevice> txDev;
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
441  Ptr<SimpleNetDevice> rxDev;
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 IPv6 addresses and forwarding
467  Ipv6AddressHelper ipv6;
468 
469  ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
471  iic1.SetForwarding(1, true);
473 
475  iic2.SetForwarding(0, true);
476  iic2.SetForwarding(1, true);
477 
479  iic3.SetForwarding(0, true);
480  iic3.SetForwarding(1, true);
481 
482  ipv6.SetBase(Ipv6Address("2001:2::"), Ipv6Prefix(64));
484  iic4.SetForwarding(0, true);
486 
487  // Create the UDP sockets
488  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
489  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
491  rxSocket->Bind(Inet6SocketAddress(Ipv6Address("2001:2::200:ff:fe00:8"), 1234)),
492  0,
493  "trivial");
494  rxSocket->SetRecvCallback(MakeCallback(&Ipv6RipngCountToInfinityTest::ReceivePkt, this));
495 
496  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
497  Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
498  txSocket->SetAllowBroadcast(true);
499 
500  // ------ Now the tests ------------
501 
502  SendData(txSocket, "2001:2::200:ff:fe00:8");
503  NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 0, "RIPng counting to infinity.");
504 
505  Simulator::Destroy();
506 }
507 
514 {
517 
518  public:
519  void DoRun() override;
525 
530  void ReceivePktProbe(Ptr<Socket> socket);
531 };
532 
534  RipNg::SplitHorizonType_e strategy)
535  : TestCase("RIPng Split Horizon strategy")
536 {
537  m_setStrategy = strategy;
538 }
539 
540 void
542 {
543  uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
544  Address srcAddr;
545  Ptr<Packet> receivedPacketProbe =
546  socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
547  NS_TEST_ASSERT_MSG_EQ(availableData,
548  receivedPacketProbe->GetSize(),
549  "ReceivedPacketProbe size is not equal to the Rx buffer size");
550  Ipv6Address senderAddress = Inet6SocketAddress::ConvertFrom(srcAddr).GetIpv6();
551 
552  if (senderAddress == "fe80::200:ff:fe00:4")
553  {
554  RipNgHeader hdr;
555  receivedPacketProbe->RemoveHeader(hdr);
556  std::list<RipNgRte> rtes = hdr.GetRteList();
557 
558  // validate the RTEs before processing
559  for (auto iter = rtes.begin(); iter != rtes.end(); iter++)
560  {
561  if (iter->GetPrefix() == "2001:1::")
562  {
563  bool correct = false;
564  if (iter->GetRouteMetric() == 16)
565  {
566  correct = true;
567  m_detectedStrategy = RipNg::POISON_REVERSE;
568  }
569  else if (iter->GetRouteMetric() == 2)
570  {
571  correct = true;
572  m_detectedStrategy = RipNg::NO_SPLIT_HORIZON;
573  }
574  NS_TEST_EXPECT_MSG_EQ(correct,
575  true,
576  "RIPng: unexpected metric value: " << iter->GetRouteMetric());
577  }
578  }
579  }
580 }
581 
582 void
584 {
585  // Create topology
586 
587  Ptr<Node> fakeNode = CreateObject<Node>();
588  Ptr<Node> listener = CreateObject<Node>();
589 
590  Ptr<Node> routerA = CreateObject<Node>();
591  Ptr<Node> routerB = CreateObject<Node>();
592 
593  NodeContainer listeners(listener, fakeNode);
594  NodeContainer routers(routerA, routerB);
595  NodeContainer all(routers, listeners);
596 
597  RipNgHelper ripNgRouting;
598  ripNgRouting.Set("SplitHorizon", EnumValue(m_setStrategy));
599 
600  InternetStackHelper internetv6routers;
601  internetv6routers.SetRoutingHelper(ripNgRouting);
602  internetv6routers.Install(routers);
603 
604  InternetStackHelper internetv6nodes;
605  internetv6nodes.Install(listeners);
606 
607  NetDeviceContainer net0;
608  NetDeviceContainer net1;
609 
610  // Fake Node
611  Ptr<SimpleNetDevice> silentDev;
612  {
613  silentDev = CreateObject<SimpleNetDevice>();
614  silentDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
615  fakeNode->AddDevice(silentDev);
616  }
617  net0.Add(silentDev);
618 
619  // Router A
620  Ptr<SimpleNetDevice> silentDevRouterA;
621  Ptr<SimpleNetDevice> fwDevRouterA;
622  { // silent interface
623  silentDevRouterA = CreateObject<SimpleNetDevice>();
624  silentDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:02"));
625  routerA->AddDevice(silentDevRouterA);
626  }
627  net0.Add(silentDevRouterA);
628 
629  { // first interface
630  fwDevRouterA = CreateObject<SimpleNetDevice>();
631  fwDevRouterA->SetAddress(Mac48Address("00:00:00:00:00:03"));
632  routerA->AddDevice(fwDevRouterA);
633  }
634  net1.Add(fwDevRouterA);
635 
636  // Router B
637  Ptr<SimpleNetDevice> fwDevRouterB;
638  { // first interface
639  fwDevRouterB = CreateObject<SimpleNetDevice>();
640  fwDevRouterB->SetAddress(Mac48Address("00:00:00:00:00:04"));
641  routerB->AddDevice(fwDevRouterB);
642  }
643  net1.Add(fwDevRouterB);
644 
645  // listener A
646  Ptr<SimpleNetDevice> listenerDev;
647  {
648  listenerDev = CreateObject<SimpleNetDevice>();
649  listenerDev->SetAddress(Mac48Address("00:00:00:00:00:05"));
650  listener->AddDevice(listenerDev);
651  }
652  net1.Add(listenerDev);
653 
654  // link the channels
655  Ptr<SimpleChannel> channel0 = CreateObject<SimpleChannel>();
656  silentDev->SetChannel(channel0);
657  silentDevRouterA->SetChannel(channel0);
658 
659  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
660  fwDevRouterA->SetChannel(channel1);
661  fwDevRouterB->SetChannel(channel1);
662  listenerDev->SetChannel(channel1);
663 
664  // Setup IPv6 addresses and forwarding
665  Ipv6AddressHelper ipv6;
666 
667  ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
669 
671  iic1.SetForwarding(0, true);
672  iic1.SetForwarding(1, true);
673 
674  // Create the UDP sockets
675  Ptr<SocketFactory> rxSocketFactory = listener->GetObject<UdpSocketFactory>();
676  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
677  rxSocket->BindToNetDevice(listenerDev);
678  NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(Inet6SocketAddress(Ipv6Address("ff02::9"), 521)),
679  0,
680  "trivial");
681  rxSocket->SetRecvCallback(
683 
684  // ------ Now the tests ------------
685 
686  // If the strategy is Split Horizon, then no packet will be received.
687  m_detectedStrategy = RipNg::SPLIT_HORIZON;
688 
689  Simulator::Stop(Seconds(66));
690  Simulator::Run();
691  NS_TEST_EXPECT_MSG_EQ(m_detectedStrategy, m_setStrategy, "RIPng counting to infinity.");
692 
693  Simulator::Destroy();
694 }
695 
702 {
703  public:
705  : TestSuite("ipv6-ripng", UNIT)
706  {
707  AddTestCase(new Ipv6RipngTest, TestCase::QUICK);
708  AddTestCase(new Ipv6RipngCountToInfinityTest, TestCase::QUICK);
709  AddTestCase(new Ipv6RipngSplitHorizonStrategyTest(RipNg::POISON_REVERSE), TestCase::QUICK);
710  AddTestCase(new Ipv6RipngSplitHorizonStrategyTest(RipNg::SPLIT_HORIZON), TestCase::QUICK);
711  AddTestCase(new Ipv6RipngSplitHorizonStrategyTest(RipNg::NO_SPLIT_HORIZON),
712  TestCase::QUICK);
713  }
714 };
715 
#define max(a, b)
Definition: 80211b.c:42
IPv6 RIPng count to infinity Test.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoSendData(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.
IPv6 RIPng SplitHorizon strategy Test.
Ipv6RipngSplitHorizonStrategyTest(RipNg::SplitHorizonType_e strategy)
Constructor.
RipNg::SplitHorizonType_e m_setStrategy
Strategy set.
void DoRun() override
Implementation to actually run this TestCase.
RipNg::SplitHorizonType_e m_detectedStrategy
Strategy detected.
void ReceivePktProbe(Ptr< Socket > socket)
Receive data.
IPv6 RIPng Test.
Ptr< Packet > m_receivedPacket
Received packet.
void DoRun() override
Implementation to actually run this TestCase.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
IPv6 RIPng TestSuite.
a polymophic address class
Definition: address.h:101
Hold variables of type enum.
Definition: enum.h:62
An Inet6 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)
Helper class to auto-assign global IPv6 unicast addresses.
Ipv6InterfaceContainer AssignWithoutAddress(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer AssignWithoutOnLink(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses, but do not set the on-link property ...
Describes an IPv6 address.
Definition: ipv6-address.h:49
Keep track of a set of IPv6 interfaces.
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
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:861
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Definition: packet.cc:393
RipNgHeader - see RFC 2080
Definition: ripng-header.h:147
std::list< RipNgRte > GetRteList() const
Get the list of the RTEs included in the message.
Helper class that adds RIPng routing to nodes.
Definition: ripng-helper.h:44
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
void Set(std::string name, const AttributeValue &value)
Definition: ripng-helper.cc:83
SplitHorizonType_e
Split Horizon strategy type.
Definition: ripng.h:224
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 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 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:301
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:1326
static Ipv6RipngTestSuite g_ipv6ripngTestSuite
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