9#include "ns3/arp-cache.h"
10#include "ns3/icmpv4-l4-protocol.h"
11#include "ns3/icmpv6-l4-protocol.h"
12#include "ns3/internet-stack-helper.h"
13#include "ns3/ipv4-address-helper.h"
14#include "ns3/ipv4-l3-protocol.h"
15#include "ns3/ipv4-routing-helper.h"
16#include "ns3/ipv6-address-helper.h"
17#include "ns3/ipv6-l3-protocol.h"
18#include "ns3/ipv6-routing-helper.h"
19#include "ns3/ndisc-cache.h"
20#include "ns3/neighbor-cache-helper.h"
21#include "ns3/simple-channel.h"
22#include "ns3/simple-net-device-helper.h"
23#include "ns3/simple-net-device.h"
24#include "ns3/simulator.h"
25#include "ns3/socket-factory.h"
26#include "ns3/socket.h"
28#include "ns3/udp-l4-protocol.h"
29#include "ns3/udp-socket-factory.h"
99 void DoRun()
override;
114 "The DynamicNeighborCacheTestPopulate checks if neighbor caches are correctly populated "
115 "in global scope and updated when there is an IP address added or removed.")
122 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
126 "Received Packet size is not equal to the Rx buffer size");
172 ipv4Interface->AddAddress(ifaceAddr);
179 ipv6Interface->AddAddress(ifaceAddr);
185 ipv4Interface->RemoveAddress(index);
191 ipv6Interface->RemoveAddress(index);
204 std::ostringstream stringStream1v4;
206 std::ostringstream stringStream1v6;
218 tx1Node->AddDevice(tx1Dev);
226 tx2Node->AddDevice(tx2Dev);
235 rxNode->AddDevice(rxDev);
243 snifferDev->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
244 snifferNode->AddDevice(snifferDev);
250 tx1Dev->SetChannel(channel);
251 tx2Dev->SetChannel(channel);
252 rxDev->SetChannel(channel);
253 snifferDev->SetChannel(channel);
318 Ptr<Socket> rxSocketv4 = rxSocketFactory->CreateSocket();
319 Ptr<Socket> rxSocketv6 = rxSocketFactory->CreateSocket();
331 Ptr<Socket> snifferSocketv4 = snifferSocketFactory->CreateSocket();
332 Ptr<Socket> snifferSocketv6 = snifferSocketFactory->CreateSocket();
344 Ptr<Socket> tx1Socket = tx1SocketFactory->CreateSocket();
345 tx1Socket->SetAllowBroadcast(
true);
348 Ptr<Socket> tx2Socket = tx2SocketFactory->CreateSocket();
349 tx2Socket->SetAllowBroadcast(
true);
369 "Should receive packet sending to the added IPv4 address.");
372 "Should receive packet sending to the added IPv6 address.");
376 "Should receive only 1 packet from IPv4 interface and only 1 packet from IPv6 interface.");
381 constexpr auto arpCache =
382 "ARP Cache of node 0 at time 0\n"
383 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
384 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
385 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
386 "ARP Cache of node 1 at time 0\n"
387 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
388 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
389 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
390 "ARP Cache of node 2 at time 0\n"
391 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
392 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
393 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
394 "ARP Cache of node 3 at time 0\n"
395 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
396 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
397 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
398 "ARP Cache of node 0 at time 1\n"
399 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
400 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
401 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
402 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
403 "ARP Cache of node 1 at time 1\n"
404 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
405 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
406 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
407 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
408 "ARP Cache of node 2 at time 1\n"
409 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
410 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
411 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
412 "ARP Cache of node 3 at time 1\n"
413 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
414 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
415 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
416 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
417 "ARP Cache of node 0 at time 2\n"
418 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
419 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
420 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
421 "ARP Cache of node 1 at time 2\n"
422 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
423 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
424 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
425 "ARP Cache of node 2 at time 2\n"
426 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
427 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
428 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
429 "ARP Cache of node 3 at time 2\n"
430 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
431 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
432 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
439 "NDISC Cache of node 0 at time +0s\n"
440 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
441 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
442 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
443 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
444 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
445 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
446 "NDISC Cache of node 1 at time +0s\n"
447 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
448 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
449 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
450 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
451 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
452 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
453 "NDISC Cache of node 2 at time +0s\n"
454 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
455 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
456 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
457 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
458 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
459 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
460 "NDISC Cache of node 3 at time +0s\n"
461 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
462 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
463 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
464 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
465 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
466 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
467 "NDISC Cache of node 0 at time +1s\n"
468 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
469 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
470 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
471 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
472 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
473 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
474 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
475 "NDISC Cache of node 1 at time +1s\n"
476 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
477 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
478 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
479 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
480 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
481 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
482 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
483 "NDISC Cache of node 2 at time +1s\n"
484 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
485 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
486 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
487 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
488 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
489 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
490 "NDISC Cache of node 3 at time +1s\n"
491 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
492 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
493 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
494 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
495 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
496 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
497 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
498 "NDISC Cache of node 0 at time +2s\n"
499 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
500 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
501 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
502 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
503 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
504 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
505 "NDISC Cache of node 1 at time +2s\n"
506 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
507 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
508 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
509 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
510 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
511 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
512 "NDISC Cache of node 2 at time +2s\n"
513 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
514 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
515 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
516 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
517 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
518 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
519 "NDISC Cache of node 3 at time +2s\n"
520 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
521 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
522 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
523 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
524 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
525 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
541 void DoRun()
override;
550 "The ChannelTest Check if neighbor caches are correctly populated on specific channel.")
574 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
576 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
590 std::ostringstream stringStream1v4;
592 std::ostringstream stringStream1v6;
602 constexpr auto arpCache =
"ARP Cache of node 0 at time 0\n"
603 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
604 "ARP Cache of node 1 at time 0\n"
605 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
606 "ARP Cache of node 2 at time 0\n";
611 "NDISC Cache of node 0 at time +0s\n"
612 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
613 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
614 "NDISC Cache of node 1 at time +0s\n"
615 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
616 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
617 "NDISC Cache of node 2 at time +0s\n";
630 void DoRun()
override;
638 :
TestCase(
"The NetDeviceContainerTest check if neighbor caches are populated correctly on "
639 "specific netDeviceContainer.")
663 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
665 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
679 std::ostringstream stringStream1v4;
681 std::ostringstream stringStream1v6;
691 constexpr auto arpCache =
692 "ARP Cache of node 0 at time 0\n"
693 "ARP Cache of node 1 at time 0\n"
694 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
695 "ARP Cache of node 2 at time 0\n"
696 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
701 "NDISC Cache of node 0 at time +0s\n"
702 "NDISC Cache of node 1 at time +0s\n"
703 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
704 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
705 "NDISC Cache of node 2 at time +0s\n"
706 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
707 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
720 void DoRun()
override;
728 :
TestCase(
"The InterfaceContainerTest check if neighbor caches are populated correctly on "
729 "specific interfaceContainer.")
753 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
755 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
770 std::ostringstream stringStream1v4;
772 std::ostringstream stringStream1v6;
782 constexpr auto arpCache =
"ARP Cache of node 0 at time 0\n"
783 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
784 "ARP Cache of node 1 at time 0\n"
785 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
786 "ARP Cache of node 2 at time 0\n";
791 "NDISC Cache of node 0 at time +0s\n"
792 "NDISC Cache of node 1 at time +0s\n"
793 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
794 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
795 "NDISC Cache of node 2 at time +0s\n"
796 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
797 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
810 void DoRun()
override;
818 :
TestCase(
"The FlushTest checks that FlushAutoGenerated() will only remove "
819 "STATIC_AUTOGENERATED entries.")
843 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
845 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
860 std::pair<Ptr<Ipv4>,
uint32_t> returnValue = i.
Get(0);
862 uint32_t index = returnValue.second;
870 std::pair<Ptr<Ipv6>,
uint32_t> returnValue2 = icv61.
Get(0);
872 index = returnValue2.second;
882 std::ostringstream stringStream1v4;
884 std::ostringstream stringStream1v6;
896 std::ostringstream stringStream2v4;
898 std::ostringstream stringStream2v6;
912 std::ostringstream stringStream5v4;
914 std::ostringstream stringStream5v6;
924 constexpr auto ArpCache =
"ARP Cache of node 0 at time 0\n"
925 "10.1.1.4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
926 "ARP Cache of node 1 at time 0\n"
927 "ARP Cache of node 2 at time 0\n";
932 "NDISC Cache of node 0 at time +0s\n"
933 "2001::200:ff:fe00:4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
934 "NDISC Cache of node 1 at time +0s\n"
935 "NDISC Cache of node 2 at time +0s\n";
939 constexpr auto ArpCache2 =
"ARP Cache of node 0 at time 2\n"
940 "ARP Cache of node 1 at time 2\n"
941 "ARP Cache of node 2 at time 2\n";
944 "Arp cache is incorrect after Flush().");
945 constexpr auto NdiscCache2 =
"NDISC Cache of node 0 at time +2s\n"
946 "NDISC Cache of node 1 at time +2s\n"
947 "NDISC Cache of node 2 at time +2s\n";
950 "Ndisc cache is incorrect after Flush().");
955 constexpr auto ArpCache5 =
956 "ARP Cache of node 0 at time 5\n"
957 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n";
958 constexpr auto NdiscCache5 =
959 "NDISC Cache of node 0 at time +5s\n"
960 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
961 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n";
964 "Arp cache is incorrect after second Flush().");
967 "Ndisc cache is incorrect after second Flush().");
980 void DoRun()
override;
988 :
TestCase(
"The DuplicateTest checks that populate neighbor caches in overlapped scope does "
989 "not raise an error or generate duplicate entries.")
1013 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
1015 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
1033 std::ostringstream stringStream1v4;
1035 std::ostringstream stringStream1v6;
1046 "ARP Cache of node 0 at time 0\n"
1047 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1048 "ARP Cache of node 1 at time 0\n"
1049 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1050 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1051 "ARP Cache of node 2 at time 0\n"
1052 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1058 "NDISC Cache of node 0 at time +0s\n"
1059 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1060 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1061 "NDISC Cache of node 1 at time +0s\n"
1062 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1063 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1064 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1065 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1066 "NDISC Cache of node 2 at time +0s\n"
1067 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
1068 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1081 void DoRun()
override;
1117 :
TestCase(
"The DynamicPartialTest checks if dynamic neighbor cache update correctly when "
1118 "generating on a non-global scope.")
1125 ipv4Interface->AddAddress(ifaceAddr);
1131 ipv6Interface->AddAddress(ifaceAddr);
1137 ipv4Interface->RemoveAddress(index);
1143 ipv6Interface->RemoveAddress(index);
1166 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
1168 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
1221 std::ostringstream stringStream1v4;
1223 std::ostringstream stringStream1v6;
1237 constexpr auto ArpCache =
"ARP Cache of node 0 at time 0\n"
1238 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1239 "ARP Cache of node 1 at time 0\n"
1240 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1241 "ARP Cache of node 2 at time 0\n"
1242 "ARP Cache of node 0 at time 1\n"
1243 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1244 "ARP Cache of node 1 at time 1\n"
1245 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1246 "ARP Cache of node 2 at time 1\n"
1247 "ARP Cache of node 0 at time 2\n"
1248 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1249 "ARP Cache of node 1 at time 2\n"
1250 "ARP Cache of node 2 at time 2\n";
1256 "NDISC Cache of node 0 at time +0s\n"
1257 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1258 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1259 "NDISC Cache of node 1 at time +0s\n"
1260 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1261 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1262 "NDISC Cache of node 2 at time +0s\n"
1263 "NDISC Cache of node 0 at time +1s\n"
1264 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1265 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1266 "NDISC Cache of node 1 at time +1s\n"
1267 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1268 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1269 "NDISC Cache of node 2 at time +1s\n"
1270 "NDISC Cache of node 0 at time +2s\n"
1271 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1272 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1273 "NDISC Cache of node 1 at time +2s\n"
1274 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1275 "NDISC Cache of node 2 at time +2s\n";
Neighbor cache on Channel Test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache on Overlapped Scope Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
Dynamic Neighbor Cache Test.
std::vector< uint32_t > m_receivedPacketSizes
Received packet sizes.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void RemoveIpv4Address(Ptr< Ipv4Interface > ipv4Interface, uint32_t index)
Remove an IPv4 address from an IPv4 interface.
DynamicNeighborCacheTest()
void AddIpv4Address(Ptr< Ipv4Interface > ipv4Interface, Ipv4InterfaceAddress ifaceAddr)
Add an IPv4 address to an IPv4 interface.
void AddIpv6Address(Ptr< Ipv6Interface > ipv6Interface, Ipv6InterfaceAddress ifaceAddr)
Add an IPv6 address to an IPv6 interface.
void DoRun() override
Implementation to actually run this TestCase.
void DoSendDatav4(Ptr< Socket > socket, Ipv4Address to)
Send data immediately after being called.
void RemoveIpv6Address(Ptr< Ipv6Interface > ipv6Interface, uint32_t index)
Remove an IPv6 address from an IPv6 interface.
void DoSendDatav6(Ptr< Socket > socket, Ipv6Address to)
Send data immediately after being called.
void SendData(Ptr< Socket > socket, Ipv4Address to)
Schedules the DoSendData () function to send the data.
Ptr< Packet > m_receivedPacket
Received packet.
Dynamic Neighbor Cache on Reduced Scope Test.
void DoRun() override
Implementation to actually run this TestCase.
void AddIpv6Address(Ptr< Ipv6Interface > ipv6Interface, Ipv6InterfaceAddress ifaceAddr)
Add an IPv6 address to an IPv6 interface.
void RemoveIpv4Address(Ptr< Ipv4Interface > ipv4Interface, uint32_t index)
Remove an IPv4 address from an IPv4 interface.
void RemoveIpv6Address(Ptr< Ipv6Interface > ipv6Interface, uint32_t index)
Remove an IPv6 address from an IPv6 interface.
void AddIpv4Address(Ptr< Ipv4Interface > ipv4Interface, Ipv4InterfaceAddress ifaceAddr)
Add an IPv4 address to an IPv4 interface.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache Flush Test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
Neighbor Cache on InterfaceContainer Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
Neighbor Cache on NetDeviceContainer Test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
a polymophic address class
A record that that holds information about an ArpCache entry.
void MarkPermanent()
Changes the state of this entry to Permanent.
void SetMacAddress(Address macAddress)
void Flush()
Clear the ArpCache of all entries except auto-generated entries.
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...
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.
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
static void PrintNeighborCacheAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at a particular time.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
std::pair< Ptr< Ipv6 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
IPv6 layer implementation.
Describes an IPv6 prefix.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
static void PrintNeighborCacheAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at a particular time.
A record that holds information about a NdiscCache entry.
void MarkPermanent()
Change the state to this entry to PERMANENT.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
IPv6 Neighbor Discovery cache.
void Flush()
Clear the cache of all entries except auto-generated entries.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chan...
void FlushAutoGenerated() const
Remove entries generated from NeighborCacheHelper from ARP cache and NDISC cache.
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.
Smart pointer class similar to boost::intrusive_ptr.
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
API to create UDP socket instances.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
static NeighborCacheTestSuite g_neighborcacheTestSuite
Static variable for test initialization.