20#include "ns3/icmpv4-l4-protocol.h"
21#include "ns3/icmpv6-l4-protocol.h"
22#include "ns3/internet-stack-helper.h"
23#include "ns3/ipv4-address-helper.h"
24#include "ns3/ipv4-l3-protocol.h"
25#include "ns3/ipv4-routing-helper.h"
26#include "ns3/ipv6-address-helper.h"
27#include "ns3/ipv6-l3-protocol.h"
28#include "ns3/ipv6-routing-helper.h"
29#include "ns3/neighbor-cache-helper.h"
30#include "ns3/simple-channel.h"
31#include "ns3/simple-net-device-helper.h"
32#include "ns3/simple-net-device.h"
33#include "ns3/simulator.h"
34#include "ns3/socket-factory.h"
35#include "ns3/socket.h"
37#include "ns3/udp-l4-protocol.h"
38#include "ns3/udp-socket-factory.h"
109 void DoRun()
override;
124 "The DynamicNeighborCacheTestPopulate checks if neighbor caches are correctly populated "
125 "in global scope and updated when there is an IP address added or removed.")
136 "Received Packet size is not equal to the Rx buffer size");
158 Simulator::ScheduleWithContext(socket->
GetNode()->
GetId(),
170 Simulator::ScheduleWithContext(socket->
GetNode()->
GetId(),
207 Ptr<Node> tx1Node = CreateObject<Node>();
208 Ptr<Node> tx2Node = CreateObject<Node>();
210 Ptr<Node> snifferNode = CreateObject<Node>();
214 std::ostringstream stringStream1v4;
216 std::ostringstream stringStream1v6;
226 tx1Dev = CreateObject<SimpleNetDevice>();
234 tx2Dev = CreateObject<SimpleNetDevice>();
243 rxDev = CreateObject<SimpleNetDevice>();
252 snifferDev = CreateObject<SimpleNetDevice>();
253 snifferDev->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
263 snifferDev->SetChannel(
channel);
275 Simulator::Schedule(
Seconds(0.5),
283 Simulator::Schedule(
Seconds(1.5),
299 Simulator::Schedule(
Seconds(0.5),
307 Simulator::Schedule(
Seconds(1.5),
319 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
320 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
321 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(1), arpStream);
322 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(1), ndiscStream);
323 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(2), arpStream);
324 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(2), ndiscStream);
328 Ptr<Socket> rxSocketv4 = rxSocketFactory->CreateSocket();
329 Ptr<Socket> rxSocketv6 = rxSocketFactory->CreateSocket();
341 Ptr<Socket> snifferSocketv4 = snifferSocketFactory->CreateSocket();
342 Ptr<Socket> snifferSocketv6 = snifferSocketFactory->CreateSocket();
354 Ptr<Socket> tx1Socket = tx1SocketFactory->CreateSocket();
355 tx1Socket->SetAllowBroadcast(
true);
358 Ptr<Socket> tx2Socket = tx2SocketFactory->CreateSocket();
359 tx2Socket->SetAllowBroadcast(
true);
379 "Should receive packet sending to the added IPv4 address.");
382 "Should receive packet sending to the added IPv6 address.");
386 "Should receive only 1 packet from IPv4 interface and only 1 packet from IPv6 interface.");
391 constexpr auto arpCache =
392 "ARP Cache of node 0 at time 0\n"
393 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
394 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
395 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
396 "ARP Cache of node 1 at time 0\n"
397 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
398 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
399 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
400 "ARP Cache of node 2 at time 0\n"
401 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
402 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
403 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
404 "ARP Cache of node 3 at time 0\n"
405 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
406 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
407 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
408 "ARP Cache of node 0 at time 1\n"
409 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
410 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
411 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
412 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
413 "ARP Cache of node 1 at time 1\n"
414 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 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.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
417 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
418 "ARP Cache of node 2 at time 1\n"
419 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
420 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
421 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
422 "ARP Cache of node 3 at time 1\n"
423 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
424 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
425 "10.0.1.3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
426 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
427 "ARP Cache of node 0 at time 2\n"
428 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
429 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
430 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
431 "ARP Cache of node 1 at time 2\n"
432 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
433 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
434 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
435 "ARP Cache of node 2 at time 2\n"
436 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
437 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
438 "10.0.1.4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
439 "ARP Cache of node 3 at time 2\n"
440 "10.0.1.1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
441 "10.0.1.2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
442 "10.0.1.5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
449 "NDISC Cache of node 0 at time +0s\n"
450 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
451 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
452 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
453 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
454 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
455 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
456 "NDISC Cache of node 1 at time +0s\n"
457 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
458 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
459 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
460 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
461 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
462 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
463 "NDISC Cache of node 2 at time +0s\n"
464 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
465 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
466 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
467 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
468 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
469 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
470 "NDISC Cache of node 3 at time +0s\n"
471 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
472 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
473 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
474 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
475 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
476 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
477 "NDISC Cache of node 0 at time +1s\n"
478 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
479 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
480 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
481 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
482 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
483 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
484 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
485 "NDISC Cache of node 1 at time +1s\n"
486 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
487 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
488 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
489 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
490 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
491 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
492 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
493 "NDISC Cache of node 2 at time +1s\n"
494 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
495 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
496 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
497 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
498 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
499 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
500 "NDISC Cache of node 3 at time +1s\n"
501 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
502 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
503 "2001::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
504 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
505 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
506 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
507 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
508 "NDISC Cache of node 0 at time +2s\n"
509 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
510 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
511 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
512 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
513 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
514 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
515 "NDISC Cache of node 1 at time +2s\n"
516 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
517 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
518 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
519 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
520 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
521 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
522 "NDISC Cache of node 2 at time +2s\n"
523 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
524 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
525 "2001::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
526 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
527 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
528 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
529 "NDISC Cache of node 3 at time +2s\n"
530 "2001::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
531 "2001::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
532 "2001::200:ff:fe00:5 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
533 "fe80::200:ff:fe00:1 dev 1 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
534 "fe80::200:ff:fe00:2 dev 1 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
535 "fe80::200:ff:fe00:3 dev 1 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
540 Simulator::Destroy();
552 void DoRun()
override;
561 "The ChannelTest Check if neighbor caches are correctly populated on specific channel.")
585 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
587 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
601 std::ostringstream stringStream1v4;
603 std::ostringstream stringStream1v6;
607 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
608 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
613 constexpr auto arpCache =
"ARP Cache of node 0 at time 0\n"
614 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
615 "ARP Cache of node 1 at time 0\n"
616 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
617 "ARP Cache of node 2 at time 0\n";
622 "NDISC Cache of node 0 at time +0s\n"
623 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
624 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
625 "NDISC Cache of node 1 at time +0s\n"
626 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
627 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
628 "NDISC Cache of node 2 at time +0s\n";
630 Simulator::Destroy();
642 void DoRun()
override;
650 :
TestCase(
"The NetDeviceContainerTest check if neighbor caches are populated correctly on "
651 "specific netDeviceContainer.")
675 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
677 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
691 std::ostringstream stringStream1v4;
693 std::ostringstream stringStream1v6;
697 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
698 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
703 constexpr auto arpCache =
704 "ARP Cache of node 0 at time 0\n"
705 "ARP Cache of node 1 at time 0\n"
706 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
707 "ARP Cache of node 2 at time 0\n"
708 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
713 "NDISC Cache of node 0 at time +0s\n"
714 "NDISC Cache of node 1 at time +0s\n"
715 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
716 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
717 "NDISC Cache of node 2 at time +0s\n"
718 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
719 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
721 Simulator::Destroy();
733 void DoRun()
override;
741 :
TestCase(
"The InterfaceContainerTest check if neighbor caches are populated correctly on "
742 "specific interfaceContainer.")
766 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
768 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
783 std::ostringstream stringStream1v4;
785 std::ostringstream stringStream1v6;
789 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
790 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
795 constexpr auto arpCache =
"ARP Cache of node 0 at time 0\n"
796 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
797 "ARP Cache of node 1 at time 0\n"
798 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
799 "ARP Cache of node 2 at time 0\n";
804 "NDISC Cache of node 0 at time +0s\n"
805 "NDISC Cache of node 1 at time +0s\n"
806 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
807 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
808 "NDISC Cache of node 2 at time +0s\n"
809 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
810 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
812 Simulator::Destroy();
824 void DoRun()
override;
832 :
TestCase(
"The FlushTest checks that FlushAutoGenerated() will only remove "
833 "STATIC_AUTOGENERATED entries.")
857 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
859 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
874 std::pair<Ptr<Ipv4>,
uint32_t> returnValue = i.
Get(0);
876 uint32_t index = returnValue.second;
884 std::pair<Ptr<Ipv6>,
uint32_t> returnValue2 = icv61.
Get(0);
886 index = returnValue2.second;
896 std::ostringstream stringStream1v4;
898 std::ostringstream stringStream1v6;
902 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
903 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
907 constexpr auto ArpCache =
"ARP Cache of node 0 at time 0\n"
908 "10.1.1.4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
909 "ARP Cache of node 1 at time 0\n"
910 "ARP Cache of node 2 at time 0\n";
915 "NDISC Cache of node 0 at time +0s\n"
916 "2001::200:ff:fe00:4 dev 0 lladdr 04-06-00:00:00:00:00:01 PERMANENT\n"
917 "NDISC Cache of node 1 at time +0s\n"
918 "NDISC Cache of node 2 at time +0s\n";
920 Simulator::Destroy();
932 void DoRun()
override;
940 :
TestCase(
"The DuplicateTest checks that populate neighbor caches in overlapped scope does "
941 "not raise an error or generate duplicate entries.")
965 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
967 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
985 std::ostringstream stringStream1v4;
987 std::ostringstream stringStream1v6;
991 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
992 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
997 "ARP Cache of node 0 at time 0\n"
998 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
999 "ARP Cache of node 1 at time 0\n"
1000 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1001 "10.1.2.2 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1002 "ARP Cache of node 2 at time 0\n"
1003 "10.1.2.1 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1008 "NDISC Cache of node 0 at time +0s\n"
1009 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1010 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1011 "NDISC Cache of node 1 at time +0s\n"
1012 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1013 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1014 "2001:1::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1015 "fe80::200:ff:fe00:4 dev 1 lladdr 04-06-00:00:00:00:00:04 STATIC_AUTOGENERATED\n"
1016 "NDISC Cache of node 2 at time +0s\n"
1017 "2001:1::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n"
1018 "fe80::200:ff:fe00:3 dev 0 lladdr 04-06-00:00:00:00:00:03 STATIC_AUTOGENERATED\n";
1020 Simulator::Destroy();
1032 void DoRun()
override;
1068 :
TestCase(
"The DynamicPartialTest checks if dynamic neighbor cache update correctly when "
1069 "generating on a non-global scope.")
1117 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.252");
1119 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.252");
1127 Simulator::Schedule(
Seconds(0.5),
1135 Simulator::Schedule(
Seconds(1.5),
1153 Simulator::Schedule(
Seconds(0.5),
1161 Simulator::Schedule(
Seconds(1.5),
1172 std::ostringstream stringStream1v4;
1174 std::ostringstream stringStream1v6;
1178 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), arpStream);
1179 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(0), ndiscStream);
1180 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(1), arpStream);
1181 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(1), ndiscStream);
1182 Ipv4RoutingHelper::PrintNeighborCacheAllAt(
Seconds(2), arpStream);
1183 Ipv6RoutingHelper::PrintNeighborCacheAllAt(
Seconds(2), ndiscStream);
1188 constexpr auto ArpCache =
"ARP Cache of node 0 at time 0\n"
1189 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1190 "ARP Cache of node 1 at time 0\n"
1191 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1192 "ARP Cache of node 2 at time 0\n"
1193 "ARP Cache of node 0 at time 1\n"
1194 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1195 "ARP Cache of node 1 at time 1\n"
1196 "10.1.1.1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1197 "ARP Cache of node 2 at time 1\n"
1198 "ARP Cache of node 0 at time 2\n"
1199 "10.1.1.2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1200 "ARP Cache of node 1 at time 2\n"
1201 "ARP Cache of node 2 at time 2\n";
1207 "NDISC Cache of node 0 at time +0s\n"
1208 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1209 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1210 "NDISC Cache of node 1 at time +0s\n"
1211 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1212 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1213 "NDISC Cache of node 2 at time +0s\n"
1214 "NDISC Cache of node 0 at time +1s\n"
1215 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1216 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1217 "NDISC Cache of node 1 at time +1s\n"
1218 "2001::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1219 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1220 "NDISC Cache of node 2 at time +1s\n"
1221 "NDISC Cache of node 0 at time +2s\n"
1222 "2001::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1223 "fe80::200:ff:fe00:2 dev 0 lladdr 04-06-00:00:00:00:00:02 STATIC_AUTOGENERATED\n"
1224 "NDISC Cache of node 1 at time +2s\n"
1225 "fe80::200:ff:fe00:1 dev 0 lladdr 04-06-00:00:00:00:00:01 STATIC_AUTOGENERATED\n"
1226 "NDISC Cache of node 2 at time +2s\n";
1228 Simulator::Destroy();
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)
ArpCache::Entry * Add(Ipv4Address to)
Add an Ipv4Address to this ARP cache.
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.
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.
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.
bool AddAddress(Ipv4InterfaceAddress address)
Ptr< ArpCache > GetArpCache() const
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
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.
Ipv6InterfaceAddress RemoveAddress(uint32_t index)
Remove an address from interface.
bool AddAddress(Ipv6InterfaceAddress iface)
Add an IPv6 address.
Ptr< NdiscCache > GetNdiscCache() const
IPv6 layer implementation.
Describes an IPv6 prefix.
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.
virtual NdiscCache::Entry * Add(Ipv6Address to)
Add an entry.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/diable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chang...
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.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
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...
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this 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.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
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.
#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...
static NeighborCacheTestSuite g_neighborcacheTestSuite
Static variable for test initialization.