26 #include "ns3/ipv6-address.h"
27 #include "ns3/ipv6-packet-info-tag.h"
29 #include "ns3/abort.h"
30 #include "ns3/attribute.h"
31 #include "ns3/simple-net-device.h"
32 #include "ns3/object-factory.h"
33 #include "ns3/socket-factory.h"
34 #include "ns3/udp-socket-factory.h"
35 #include "ns3/udp-socket.h"
36 #include "ns3/ipv6-l3-protocol.h"
37 #include "ns3/ipv6-raw-socket-factory.h"
38 #include "ns3/ipv6-interface.h"
39 #include "ns3/icmpv6-l4-protocol.h"
40 #include "ns3/ipv6-static-routing.h"
41 #include "ns3/ipv6-list-routing.h"
42 #include "ns3/inet6-socket-address.h"
43 #include "ns3/simulator.h"
44 #include "ns3/uinteger.h"
45 #include "ns3/boolean.h"
76 virtual void DoRun (
void);
78 void DoSendData (
Ptr<Socket> socket, std::string to);
81 Ipv6PacketInfoTagTest::Ipv6PacketInfoTagTest ()
89 uint32_t availableData;
93 m_receivedPacket = socket->
Recv (std::numeric_limits<uint32_t>::max (), 0);
94 NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->
GetSize (),
"Did not read expected data");
99 NS_TEST_ASSERT_MSG_EQ (found,
true,
"Could not find tag");
103 Ipv6PacketInfoTagTest::DoSendData (
Ptr<Socket> socket, std::string to)
106 if (DynamicCast<UdpSocket> (socket) != 0)
108 NS_TEST_EXPECT_MSG_EQ (socket->
SendTo (Create<Packet> (123), 0, realTo),
114 socket->
SendTo (Create<Packet> (123), 0, realTo);
129 AddInternetStack (node0);
140 node1->AddDevice (device2);
141 AddInternetStack (node1);
155 socket->SetAttribute (
"Protocol",
UintegerValue (Ipv6Header::IPV6_ICMPV6));
156 socket->Bind (local);
157 socket->SetRecvPktInfo (
true);
158 socket->SetRecvCallback (
MakeCallback (&Ipv6PacketInfoTagTest::RxCb,
this));
161 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (),
Seconds (0),
162 &Ipv6PacketInfoTagTest::DoSendData,
this, socket,
"::1");
167 std::stringstream dst;
169 Simulator::ScheduleWithContext (socket2->GetNode ()->GetId (),
Seconds (0),
170 &Ipv6PacketInfoTagTest::DoSendData,
this, socket,
174 #ifdef UDP6_SUPPORTED
179 socket->Bind (local);
180 socket->SetRecvPktInfo (
true);
181 socket->SetRecvCallback (
MakeCallback (&Ipv6PacketInfoTagTest::RxCb,
this));
184 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (),
Seconds (0),
185 &Ipv6PacketInfoTagTest::DoSendData,
this, socket,
"::1");
190 Simulator::ScheduleWithContext (socket2->GetNode ()->GetId (),
Seconds (0),
191 &Ipv6PacketInfoTagTest::DoSendData,
this, socket,
"10.1.1.1");
194 #endif // UDP6_SUPPORTED
196 Simulator::Destroy ();
205 } g_packetinfotagTests;
207 Ipv6PacketInfoTagTestSuite::Ipv6PacketInfoTagTestSuite ()
208 :
TestSuite (
"ipv6-packet-info-tag", UNIT)
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
Set metric on specified Ipv6 interface.
Access to the IPv6 forwarding table, interfaces, and configuration.
IPv6 address associated with an interface.
uint32_t GetSize(void) const
virtual Ptr< Socket > CreateSocket(void)=0
virtual void DoRun(void)
Implementation to actually run this test case.
Object to create transport layer instances that provide a socket API to applications.
virtual void AddRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
a polymophic address class
Ipv6Address GetAddress() const
Get the IPv6 address.
Hold an unsigned integer type.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void AggregateObject(Ptr< Object > other)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
virtual void RegisterExtensions()
Register the IPv6 Extensions.
Describes an IPv6 address.
void SetRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol)
Set routing protocol for this stack.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint32_t AddDevice(Ptr< NetDevice > device)
bool RemovePacketTag(Tag &tag)
void Insert(Ptr< IpL4Protocol > protocol)
Add an L4 protocol.
virtual void RegisterOptions()
Register the IPv6 Options.
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
This class implements a tag that carries socket ancillary data to the socket interface. This is used like socket option of IP_PKTINFO/IPV6_PKTINFO in RFC 3542 See: http://tools.ietf.org/html/rfc3542.
Ptr< T > GetObject(void) const
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual uint32_t GetRxAvailable(void) const =0