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" 47 virtual void DoRun ();
51 TestCase (
"Verify the IPv6 layer 3 protocol")
75 ipv6->Insert (icmpv6);
79 interface->SetDevice (device);
80 interface->SetNode (node);
81 index = ipv6->AddIpv6Interface (interface);
86 interface2->SetDevice (device2);
87 interface2->SetNode (node);
88 index = ipv6->AddIpv6Interface (interface2);
93 "Should be link local??");
97 "interface has always a link-local address");
103 interface->AddAddress (ifaceAddr1);
106 interface->AddAddress (ifaceAddr2);
110 interface2->AddAddress (ifaceAddr3);
112 uint32_t num = interface->GetNAddresses ();
115 num = interface2->GetNAddresses ();
118 interface->RemoveAddress (2);
119 num = interface->GetNAddresses ();
124 "Should be the interface address 1?");
126 index = ipv6->GetInterfaceForPrefix (
"2001:1234:5678:9000::0",
130 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9001::2");
133 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9000::1");
137 output = interface->RemoveAddress (
Ipv6Address (
"2001:1234:5678:9000::1"));
139 num = interface->GetNAddresses ();
143 output = interface->RemoveAddress (
Ipv6Address (
"2001:1234:5678:9000::1"));
145 "Removed non-existent address??");
146 num = interface->GetNAddresses ();
150 output = interface->RemoveAddress (Ipv6Address::GetLoopback ());
152 "Able to remove loopback address??");
153 num = interface->GetNAddresses ();
157 index = ipv6->GetInterfaceForAddress (
"2001:ffff:5678:9001::2");
158 bool result = ipv6->RemoveAddress (index,
Ipv6Address 159 (
"2001:ffff:5678:9001::2"));
161 num = interface2->GetNAddresses ();
166 (
"2001:ffff:5678:9001::2"));
168 num = interface2->GetNAddresses ();
172 result = ipv6->RemoveAddress (index, Ipv6Address::GetLoopback ());
174 num = interface2->GetNAddresses ();
177 Simulator::Destroy ();
Ipv6Address GetAddress() const
Get the IPv6 address.
AttributeValue implementation for Boolean.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
virtual ~Ipv6L3ProtocolTestCase()
IPv6 address associated with an interface.
static IPv6L3ProtocolTestSuite g_ipv6protocolTestSuite
Static variable for test initialization.
virtual void DoRun()
Implementation to actually run this TestCase.
The IPv6 representation of a network interface.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
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.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
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.
This test suite implements a Unit Test.
IPv6L3ProtocolTestSuite()