22 #include "ns3/socket-factory.h"
23 #include "ns3/udp-socket-factory.h"
24 #include "ns3/simulator.h"
25 #include "ns3/simple-channel.h"
26 #include "ns3/simple-net-device.h"
27 #include "ns3/drop-tail-queue.h"
28 #include "ns3/socket.h"
29 #include "ns3/boolean.h"
33 #include "ns3/inet-socket-address.h"
35 #include "ns3/arp-l3-protocol.h"
36 #include "ns3/ipv4-l3-protocol.h"
37 #include "ns3/icmpv4-l4-protocol.h"
38 #include "ns3/udp-l4-protocol.h"
39 #include "ns3/ipv4-static-routing.h"
71 void DoSendData (
Ptr<Socket> socket, std::string to);
75 virtual void DoRun (
void);
82 :
TestCase (
"UDP socket implementation")
88 uint32_t availableData;
106 Simulator::ScheduleWithContext (socket->
GetNode ()->
GetId (), Seconds (0),
117 Ptr<Node> rxNode = CreateObject<Node> ();
121 rxDev = CreateObject<SimpleNetDevice> ();
122 rxDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
128 ipv4->
SetUp (netdev_idx);
132 Ptr<Node> fwNode = CreateObject<Node> ();
136 fwDev1 = CreateObject<SimpleNetDevice> ();
137 fwDev1->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
143 ipv4->
SetUp (netdev_idx);
147 fwDev2 = CreateObject<SimpleNetDevice> ();
148 fwDev2->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
154 ipv4->
SetUp (netdev_idx);
158 Ptr<Node> txNode = CreateObject<Node> ();
162 txDev = CreateObject<SimpleNetDevice> ();
163 txDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
169 ipv4->
SetUp (netdev_idx);
207 Simulator::Destroy ();
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
void DoSendData(Ptr< Socket > socket, std::string to)
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
a class to represent an Ipv4 address mask
Ptr< Packet > m_receivedPacket
#define NS_ASSERT(condition)
uint32_t GetSize(void) const
virtual Ptr< Socket > CreateSocket(void)=0
virtual void DoRun(void)
Implementation to actually run this TestCase.
a polymophic address class
void SendData(Ptr< Socket > socket, std::string to)
virtual void SetUp(uint32_t interface)=0
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ipv4ForwardingTestSuite()
void AggregateObject(Ptr< Object > other)
Access to the Ipv4 forwarding table, interfaces, and configuration.
Static routing protocol for IP version 4 stacks.
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 child TestCase case to this TestCase.
static void AddInternetStack(Ptr< Node > node)
Ipv4 addresses are stored in host order in this class.
void ReceivePkt(Ptr< Socket > socket)
uint32_t AddDevice(Ptr< NetDevice > device)
uint32_t GetId(void) const
a class to store IPv4 address information on an interface
virtual Ptr< Node > GetNode(void) const =0
virtual void SetAddress(Address address)
void RemoveAllByteTags(void)
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
API to create UDP socket instances.
This test suite implements a Unit Test.
Ipv4ForwardingTestSuite g_ipv4forwardingTestSuite
void SetChannel(Ptr< SimpleChannel > channel)
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
virtual uint32_t GetRxAvailable(void) const =0
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.