21 #include "ns3/simulator.h"
24 #include "ns3/boolean.h"
25 #include "ns3/inet6-socket-address.h"
27 #include "ns3/simple-net-device.h"
29 #include "ns3/ipv6-interface.h"
30 #include "ns3/ipv6-l3-protocol.h"
31 #include "ns3/icmpv6-l4-protocol.h"
57 TestCase (
"Verify the IPv6 layer 3 protocol")
79 ipv6->Insert (icmpv6);
83 interface->SetDevice (device);
84 interface->SetNode (node);
85 index = ipv6->AddIpv6Interface (interface);
90 interface2->SetDevice (device2);
91 interface2->SetNode (node);
92 index = ipv6->AddIpv6Interface (interface2);
97 "Should be link local??");
101 "interface has always a link-local address");
103 interface2->SetUp ();
107 interface->AddAddress (ifaceAddr1);
110 interface->AddAddress (ifaceAddr2);
114 interface2->AddAddress (ifaceAddr3);
116 uint32_t num = interface->GetNAddresses ();
119 num = interface2->GetNAddresses ();
122 interface->RemoveAddress (2);
123 num = interface->GetNAddresses ();
128 "Should be the interface address 1?");
130 index = ipv6->GetInterfaceForPrefix (
"2001:1234:5678:9000::0",
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 "Removed non-existent address??");
150 num = interface->GetNAddresses ();
154 output = interface->RemoveAddress (Ipv6Address::GetLoopback ());
156 "Able to remove loopback address??");
157 num = interface->GetNAddresses ();
161 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9001::2");
162 bool result = ipv6->RemoveAddress (index,
Ipv6Address
163 (
"2001:ffff:5678:9001::2"));
165 num = interface2->GetNAddresses ();
170 (
"2001:ffff:5678:9001::2"));
172 num = interface2->GetNAddresses ();
176 result = ipv6->RemoveAddress (index, Ipv6Address::GetLoopback ());
178 num = interface2->GetNAddresses ();
181 Simulator::Destroy ();
AttributeValue implementation for Boolean.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
virtual ~Ipv6L3ProtocolTestCase()
Destructor.
IPv6 address associated with an interface.
This test suite implements a Unit Test.
virtual void DoRun()
Run unit tests for this class.
IPv6L3ProtocolTestSuite g_ipv6protocolTestSuite
Ipv6Address GetAddress() const
Get the IPv6 address.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Describes an IPv6 address.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Describes an IPv6 prefix.
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
IPv6L3ProtocolTestSuite()
Ipv6L3ProtocolTestCase()
Constructor.