20#include "ns3/boolean.h"
21#include "ns3/icmpv6-l4-protocol.h"
22#include "ns3/inet6-socket-address.h"
23#include "ns3/ipv6-interface.h"
24#include "ns3/ipv6-l3-protocol.h"
27#include "ns3/simple-net-device.h"
28#include "ns3/simulator.h"
44 void DoRun()
override;
48 :
TestCase(
"Verify the IPv6 layer 3 protocol")
70 node->AggregateObject(ipv6);
71 node->AggregateObject(icmpv6);
75 node->AddDevice(device);
76 interface->SetDevice(device);
77 interface->SetNode(node);
78 index = ipv6->AddIpv6Interface(interface);
82 node->AddDevice(device2);
83 interface2->SetDevice(device2);
84 interface2->SetNode(node);
85 index = ipv6->AddIpv6Interface(interface2);
96 "interface has always a link-local address");
101 interface->AddAddress(ifaceAddr1);
104 interface->AddAddress(ifaceAddr2);
108 interface2->AddAddress(ifaceAddr3);
110 uint32_t num = interface->GetNAddresses();
114 "Number of addresses should be 3??");
116 num = interface2->GetNAddresses();
120 "1 global addresses + link-local ones");
122 interface->RemoveAddress(2);
123 num = interface->GetNAddresses();
129 index = ipv6->GetInterfaceForPrefix(
"2001:1234:5678:9000::0",
Ipv6Prefix(64));
132 "We should get one address??");
134 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9001::2");
137 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9000::1");
141 output = interface->RemoveAddress(
Ipv6Address(
"2001:1234:5678:9000::1"));
143 num = interface->GetNAddresses();
147 output = interface->RemoveAddress(
Ipv6Address(
"2001:1234:5678:9000::1"));
149 num = interface->GetNAddresses();
155 num = interface->GetNAddresses();
159 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9001::2");
160 bool result = ipv6->RemoveAddress(index,
Ipv6Address(
"2001:ffff:5678:9001::2"));
162 num = interface2->GetNAddresses();
166 result = ipv6->RemoveAddress(index,
Ipv6Address(
"2001:ffff:5678:9001::2"));
168 num = interface2->GetNAddresses();
174 num = interface2->GetNAddresses();
IPv6L3ProtocolTestSuite()
void DoRun() override
Implementation to actually run this TestCase.
~Ipv6L3ProtocolTestCase() override
AttributeValue implementation for Boolean.
Describes an IPv6 address.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
static Ipv6Address GetLoopback()
Get the loopback address.
IPv6 address associated with an interface.
Ipv6Address GetAddress() const
Get the IPv6 address.
The IPv6 representation of a network interface.
Describes an IPv6 prefix.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
static IPv6L3ProtocolTestSuite g_ipv6protocolTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.