28 #include "ns3/ipv4-packet-info-tag.h"
29 #include "ns3/ipv4-address.h"
31 #include "ns3/abort.h"
32 #include "ns3/attribute.h"
33 #include "ns3/simple-net-device.h"
34 #include "ns3/object-factory.h"
35 #include "ns3/socket-factory.h"
36 #include "ns3/udp-socket-factory.h"
37 #include "ns3/udp-socket.h"
38 #include "ns3/inet-socket-address.h"
39 #include "ns3/ipv4-l3-protocol.h"
40 #include "ns3/ipv4-raw-socket-factory.h"
41 #include "ns3/ipv4-interface.h"
42 #include "ns3/arp-l3-protocol.h"
43 #include "ns3/icmpv4-l4-protocol.h"
44 #include "ns3/ipv4-static-routing.h"
45 #include "ns3/ipv4-list-routing.h"
46 #include "ns3/udp-l4-protocol.h"
47 #include "ns3/tcp-l4-protocol.h"
48 #include "ns3/traffic-control-layer.h"
49 #include "ns3/simulator.h"
51 #include "ns3/internet-stack-helper.h"
52 #include "ns3/simple-net-device-helper.h"
67 virtual void DoRun (
void);
79 void DoSendData (
Ptr<Socket> socket, std::string to);
90 uint32_t availableData;
107 if (DynamicCast<UdpSocket> (socket) != 0)
115 socket->
SendTo (Create<Packet> (123), 0, realTo);
138 uint32_t index = ipv4->AddInterface (device);
141 ipv4->AddAddress (index, ifaceAddr1);
142 ipv4->SetMetric (index, 1);
150 index = ipv4->AddInterface (device2);
153 ipv4->AddAddress (index, ifaceAddr2);
154 ipv4->SetMetric (index, 1);
161 socket->Bind (local);
162 socket->SetRecvPktInfo (
true);
166 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (),
Seconds (0),
172 Simulator::ScheduleWithContext (socket2->GetNode ()->GetId (),
Seconds (0),
178 socket = factory->CreateSocket ();
180 socket->Bind (local);
181 socket->SetRecvPktInfo (
true);
185 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (),
Seconds (0),
190 socket2 = factory2->CreateSocket ();
191 Simulator::ScheduleWithContext (socket2->GetNode ()->GetId (),
Seconds (0),
194 Simulator::Destroy ();
211 :
TestSuite (
"ipv4-packet-info-tag", UNIT)
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void RxCb(Ptr< Socket > socket)
Receive callback.
IPv4 PacketInfoTag TestSuite.
Ipv4PacketInfoTagTestSuite()
a polymophic address class
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
Object to create transport layer instances that provide a socket API to applications.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static Ipv4PacketInfoTagTestSuite g_packetinfotagTests
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...