24 #include "ns3/socket-factory.h"
25 #include "ns3/tcp-socket-factory.h"
26 #include "ns3/simulator.h"
27 #include "ns3/simple-channel.h"
28 #include "ns3/simple-net-device.h"
29 #include "ns3/config.h"
30 #include "ns3/ipv4-static-routing.h"
31 #include "ns3/ipv4-list-routing.h"
32 #include "ns3/ipv6-static-routing.h"
33 #include "ns3/ipv6-list-routing.h"
35 #include "ns3/inet-socket-address.h"
36 #include "ns3/inet6-socket-address.h"
37 #include "ns3/uinteger.h"
40 #include "ns3/ipv4-end-point.h"
41 #include "ns3/arp-l3-protocol.h"
42 #include "ns3/ipv4-l3-protocol.h"
43 #include "ns3/ipv6-l3-protocol.h"
44 #include "ns3/icmpv4-l4-protocol.h"
45 #include "ns3/icmpv6-l4-protocol.h"
46 #include "ns3/udp-l4-protocol.h"
47 #include "ns3/tcp-l4-protocol.h"
60 virtual void DoRun (
void);
61 virtual void DoTeardown (
void);
89 CreateDualStackNode ()
103 ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
125 ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
163 DualStackTestCase::SetUpSim ()
165 node0 = CreateDualStackNode ();
166 node1 = CreateDualStackNode ();
174 dev0->SetChannel (channel);
175 dev1->SetChannel (channel);
194 DualStackTestCase::ServerHandleConnectionCreated1 (
Ptr<Socket> s,
const Address & addr)
196 receivedAddr1 = addr;
201 DualStackTestCase::ServerHandleConnectionCreated2 (
Ptr<Socket> s,
const Address & addr)
203 receivedAddr2 = addr;
208 DualStackTestCase::ServerHandleConnectionCreated3 (
Ptr<Socket> s,
const Address & addr)
210 receivedAddr3 = addr;
215 DualStackTestCase::ServerHandleConnectionCreated4 (
Ptr<Socket> s,
const Address & addr)
217 receivedAddr4 = addr;
222 DualStackTestCase::DualStackTestCase ()
236 uint16_t port1 = 5000;
237 uint16_t port2 = 5001;
238 uint16_t port3 = 5002;
239 uint16_t port4 = 5003;
245 MakeCallback (&DualStackTestCase::ServerHandleConnectionCreated1,
this));
251 MakeCallback (&DualStackTestCase::ServerHandleConnectionCreated2,
this));
257 MakeCallback (&DualStackTestCase::ServerHandleConnectionCreated3,
this));
263 MakeCallback (&DualStackTestCase::ServerHandleConnectionCreated4,
this));
281 NS_TEST_EXPECT_MSG_EQ (InetSocketAddress::IsMatchingType(receivedAddr1),
true,
"Accepted address is of proper type");
282 NS_TEST_EXPECT_MSG_EQ(InetSocketAddress::ConvertFrom(receivedAddr1).GetIpv4 (),
Ipv4Address(
"10.0.0.2"),
"Accepted address is correct");
285 NS_TEST_EXPECT_MSG_EQ(receivedAddr2.
IsInvalid(),
true,
"IPv4 socket correctly ignored IPv6 connection");
288 NS_TEST_EXPECT_MSG_EQ (Inet6SocketAddress::IsMatchingType(receivedAddr3),
true,
"Accepted address is of proper type");
289 NS_TEST_EXPECT_MSG_EQ(Inet6SocketAddress::ConvertFrom(receivedAddr3).GetIpv6 (),
Ipv6Address(
"::ffff:0a00:0002"),
"Accepted address is correct");
292 NS_TEST_EXPECT_MSG_EQ (Inet6SocketAddress::IsMatchingType(receivedAddr4),
true,
"Accepted address is of proper type");
293 NS_TEST_EXPECT_MSG_EQ(Inet6SocketAddress::ConvertFrom(receivedAddr4).GetIpv6 (),
Ipv6Address(
"2001::2"),
"Accepted address is correct");
299 Simulator::Destroy ();
311 } g_ipv6DualStackTestSuite;
bool IsInvalid(void) const
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Access to the IPv6 forwarding table, interfaces, and configuration.
API to create TCP socket instances.
a class to represent an Ipv4 address mask
#define NS_LOG_COMPONENT_DEFINE(name)
IPv6 address associated with an interface.
virtual Ptr< Socket > CreateSocket(void)=0
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
a polymophic address class
virtual int Listen(void)=0
Listen for incoming connections.
static Mac48Address Allocate(void)
virtual void SetUp(uint32_t interface)=0
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
void AggregateObject(Ptr< Object > other)
static Mac48Address ConvertFrom(const Address &address)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Access to the Ipv4 forwarding table, interfaces, and configuration.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Callback< R > MakeNullCallback(void)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
virtual void RegisterExtensions()
Register the IPv6 Extensions.
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
void SetRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol)
Set routing protocol for this stack.
uint32_t AddDevice(Ptr< NetDevice > device)
a class to store IPv4 address information on an interface
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void SetAddress(Address address)
virtual void RegisterOptions()
Register the IPv6 Options.
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
Ptr< T > GetObject(void) const
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.