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"
45 void DoRun()
override;
49 :
TestCase(
"Verify the IPv6 layer 3 protocol")
77 interface->SetDevice(device);
78 interface->SetNode(node);
79 index = ipv6->AddIpv6Interface(interface);
84 interface2->SetDevice(device2);
85 interface2->SetNode(node);
86 index = ipv6->AddIpv6Interface(interface2);
97 "interface has always a link-local address");
102 interface->AddAddress(ifaceAddr1);
105 interface->AddAddress(ifaceAddr2);
109 interface2->AddAddress(ifaceAddr3);
111 uint32_t num = interface->GetNAddresses();
115 "Number of addresses should be 3??");
117 num = interface2->GetNAddresses();
121 "1 global addresses + link-local ones");
123 interface->RemoveAddress(2);
124 num = interface->GetNAddresses();
130 index = ipv6->GetInterfaceForPrefix(
"2001:1234:5678:9000::0",
Ipv6Prefix(64));
133 "We should get one address??");
135 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9001::2");
138 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9000::1");
142 output = interface->RemoveAddress(
Ipv6Address(
"2001:1234:5678:9000::1"));
144 num = interface->GetNAddresses();
148 output = interface->RemoveAddress(
Ipv6Address(
"2001:1234:5678:9000::1"));
150 num = interface->GetNAddresses();
154 output = interface->RemoveAddress(Ipv6Address::GetLoopback());
156 num = interface->GetNAddresses();
160 index = ipv6->GetInterfaceForAddress(
"2001:ffff:5678:9001::2");
161 bool result = ipv6->RemoveAddress(index,
Ipv6Address(
"2001:ffff:5678:9001::2"));
163 num = interface2->GetNAddresses();
167 result = ipv6->RemoveAddress(index,
Ipv6Address(
"2001:ffff:5678:9001::2"));
169 num = interface2->GetNAddresses();
173 result = ipv6->RemoveAddress(index, Ipv6Address::GetLoopback());
175 num = interface2->GetNAddresses();
178 Simulator::Destroy();
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).
IPv6 address associated with an interface.
Ipv6Address GetAddress() const
Get the IPv6 address.
The IPv6 representation of a network interface.
Describes an IPv6 prefix.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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.