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);
86 NS_TEST_ASSERT_MSG_EQ (index, 1,
"The index is not 1??");
90 interface2->SetDevice (device2);
91 interface2->SetNode (node);
92 index = ipv6->AddIpv6Interface (interface2);
93 NS_TEST_ASSERT_MSG_EQ (index, 2,
"The index is not 2??");
97 "Should be link local??");
100 NS_TEST_ASSERT_MSG_EQ (interface->GetNAddresses (), 1,
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 ();
117 NS_TEST_ASSERT_MSG_EQ (num, 3,
"Number of addresses should be 3??");
119 num = interface2->GetNAddresses ();
120 NS_TEST_ASSERT_MSG_EQ (num, 2,
"1 global addresses + link-local ones");
122 interface->RemoveAddress (2);
123 num = interface->GetNAddresses ();
124 NS_TEST_ASSERT_MSG_EQ (num, 2,
"Number of addresses should be 2??");
127 NS_TEST_ASSERT_MSG_EQ (ifaceAddr1, output,
128 "Should be the interface address 1?");
130 index = ipv6->GetInterfaceForPrefix (
"2001:1234:5678:9000::0",
132 NS_TEST_ASSERT_MSG_EQ (index, 1,
"We should get one address??");
134 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9001::2");
135 NS_TEST_ASSERT_MSG_EQ (index, 2,
"Number of addresses should be 2??");
137 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9000::1");
138 NS_TEST_ASSERT_MSG_EQ (index, (uint32_t) -1,
"Address should not be found??");
149 } g_ipv6protocolTestSuite;
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
IPv6 address associated with an interface.
virtual ~Ipv6L3ProtocolTestCase()
Destructor.
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Ipv6Address GetAddress() const
Get the IPv6 address.
virtual void DoRun()
Run unit tests for this class.
void AggregateObject(Ptr< Object > other)
static void Destroy(void)
Ipv6L3ProtocolTestCase()
Constructor.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
uint32_t AddDevice(Ptr< NetDevice > device)
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.