9#include "ns3/arp-l3-protocol.h"
10#include "ns3/boolean.h"
11#include "ns3/icmpv4-l4-protocol.h"
12#include "ns3/inet-socket-address.h"
13#include "ns3/internet-stack-helper.h"
14#include "ns3/ipv4-l3-protocol.h"
15#include "ns3/ipv4-routing-helper.h"
16#include "ns3/ipv4-static-routing.h"
19#include "ns3/simple-channel.h"
20#include "ns3/simple-net-device.h"
21#include "ns3/simulator.h"
22#include "ns3/socket-factory.h"
23#include "ns3/socket.h"
25#include "ns3/traffic-control-layer.h"
26#include "ns3/udp-l4-protocol.h"
27#include "ns3/udp-socket-factory.h"
57 void DoRun()
override;
68 :
TestCase(
"UDP socket implementation")
76 availableData = socket->GetRxAvailable();
80 "Received packet size is not equal to Rx buffer size");
112 internet.SetIpv6StackInstall(
false);
114 internet.Install(rxNode);
119 rxNode->AddDevice(rxDev);
121 uint32_t netdev_idx = ipv4->AddInterface(rxDev);
124 ipv4->AddAddress(netdev_idx, ipv4Addr);
125 ipv4->SetUp(netdev_idx);
131 internet.Install(fwNode);
137 fwNode->AddDevice(fwDev1);
139 uint32_t netdev_idx = ipv4->AddInterface(fwDev1);
142 ipv4->AddAddress(netdev_idx, ipv4Addr);
143 ipv4->SetUp(netdev_idx);
149 fwNode->AddDevice(fwDev2);
151 uint32_t netdev_idx = ipv4->AddInterface(fwDev2);
154 ipv4->AddAddress(netdev_idx, ipv4Addr);
155 ipv4->SetUp(netdev_idx);
161 internet.Install(txNode);
166 txNode->AddDevice(txDev);
168 uint32_t netdev_idx = ipv4->AddInterface(txDev);
171 ipv4->AddAddress(netdev_idx, ipv4Addr);
172 ipv4->SetUp(netdev_idx);
175 ipv4StaticRouting->SetDefaultRoute(
Ipv4Address(
"10.1.0.1"), netdev_idx);
180 rxDev->SetChannel(channel1);
181 fwDev1->SetChannel(channel1);
184 fwDev2->SetChannel(channel2);
185 txDev->SetChannel(channel2);
189 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
196 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
197 txSocket->SetAllowBroadcast(
true);
Ptr< Packet > m_receivedPacket
Received packet.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoRun() override
Implementation to actually run this TestCase.
IPv4 Forwarding TestSuite.
Ipv4ForwardingTestSuite()
a polymophic address class
AttributeValue implementation for Boolean.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol() const =0
Get the routing protocol to be used by this Ipv4 stack.
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
static Ptr< T > GetRouting(Ptr< Ipv4RoutingProtocol > protocol)
Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol.
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address Allocate()
Allocate a new Mac48Address.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
API to create UDP socket instances.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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 Ipv4ForwardingTestSuite g_ipv4forwardingTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...