12#include "ns3/boolean.h"
13#include "ns3/error-model.h"
14#include "ns3/icmpv6-l4-protocol.h"
15#include "ns3/inet6-socket-address.h"
16#include "ns3/internet-stack-helper.h"
17#include "ns3/ipv6-address-helper.h"
18#include "ns3/ipv6-l3-protocol.h"
19#include "ns3/ipv6-list-routing.h"
20#include "ns3/ipv6-raw-socket-factory.h"
21#include "ns3/ipv6-static-routing.h"
23#include "ns3/node-container.h"
25#include "ns3/pointer.h"
26#include "ns3/simple-channel.h"
27#include "ns3/simple-net-device-helper.h"
28#include "ns3/simple-net-device.h"
29#include "ns3/simulator.h"
30#include "ns3/socket-factory.h"
31#include "ns3/socket.h"
33#include "ns3/uinteger.h"
36#include "ns3/win32-internet.h"
38#include <netinet/in.h>
39#include <sys/socket.h>
74 void DoRun()
override;
103 :
TestCase(
"ipv6-raw-fragmentation-test")
110 Ptr<Packet> p = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
113 if (p->PeekHeader(hdr))
115 p->RemoveHeader(hdr);
128 NS_LOG_DEBUG(
"Sender sent " << p->GetSize() <<
" bytes to " << dst);
151 rxDev->TraceConnectWithoutContext(
156 rxDev->SetChannel(ch);
157 txDev->SetChannel(ch);
160 stack.SetIpv4StackInstall(
false);
169 uint32_t ifRx = ipv6Rx->AddInterface(rxDev);
173 uint32_t ifTx = ipv6Tx->AddInterface(txDev);
187 std::vector<uint32_t> payloadSizes = {500, 1000, 5000, 10000, 20000, 40000, 60000};
189 for (
auto sentPayloadSize : payloadSizes)
205 "Reassembled packet size should be the same as the packet size sent");
212 std::vector<uint32_t> fragmentablePayloadSizes = {5000, 10000, 20000, 40000, 60000};
214 for (
auto sentPayloadSize : fragmentablePayloadSizes)
220 errModel->SetList({1});
222 rxDev->SetAttribute(
"ReceiveErrorModel",
PointerValue(errModel));
264 void DoRun()
override;
294 :
TestCase(
"Ipv6 Raw socket implementation")
314 availableData = socket->GetRxAvailable();
320 "Received packet size is not equal to Rx buffer size");
328 availableData = socket->GetRxAvailable();
331 m_receivedPacket2 = socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, addr);
334 "Received packet size is not equal to Rx buffer size");
395 ipv6 = rxNode->GetObject<
Ipv6>();
396 device = net1.
Get(0);
397 ifIndex = ipv6->GetInterfaceForDevice(device);
399 ipv6->AddAddress(ifIndex, ipv6Addr);
401 device = net2.
Get(0);
402 ifIndex = ipv6->GetInterfaceForDevice(device);
404 ipv6->AddAddress(ifIndex, ipv6Addr);
406 ipv6 = txNode->GetObject<
Ipv6>();
407 device = net1.
Get(1);
408 ifIndex = ipv6->GetInterfaceForDevice(device);
410 ipv6->AddAddress(ifIndex, ipv6Addr);
411 ipv6->SetForwarding(ifIndex,
true);
413 device = net2.
Get(1);
414 ifIndex = ipv6->GetInterfaceForDevice(device);
416 ipv6->AddAddress(ifIndex, ipv6Addr);
417 ipv6->SetForwarding(ifIndex,
true);
421 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
428 Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket();
436 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
447 "second interface should not receive it");
458 "second socket should not receive it (it is bound specifically to the "
459 "second interface's address");
469 rxSocket2->Dispose();
470 rxSocket2 = rxSocketFactory->CreateSocket();
487 int err = txSocket->GetPeerName(peerAddress);
491 "socket error code should be ERROR_NOTCONN");
494 err = txSocket->Connect(peer);
497 err = txSocket->GetPeerName(peerAddress);
502 "address from socket GetPeerName() should equal the connected address");
IPv6 Raw Socket Fragmentation Test Configuration : Two sockets.
Ipv6RawFragmentationTest()
void RxCallback(Ptr< Socket > socket)
Receive a packet.
void SendPacket(Ptr< Socket > socket, Ipv6Address dst, uint32_t size)
Send a packet.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_rxCount
Total count of packets received.
void PhyRxDropCallback(Ptr< const Packet > p)
Packet dropped callback at Phy Rx.
uint32_t m_droppedFragments
Number of dropped packets.
uint32_t m_rxPayloadSize
Size of the last packet received.
Ptr< Packet > m_receivedPacket2
Received packet (2).
Ptr< Packet > m_receivedPacket
Received packet (1).
void ReceivePacket2(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data.
void ReceivePkt2(Ptr< Socket > socket)
Receive data.
void DoRun() override
Implementation to actually run this TestCase.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
IPv6 RAW Socket TestSuite.
a polymophic address class
AttributeValue implementation for Boolean.
An implementation of the ICMPv6 protocol.
void SetPort(uint16_t port)
Set the port.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
Ipv6Address GetIpv6() const
Get the IPv6 address.
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...
Helper class to auto-assign global IPv6 unicast addresses.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Access to the IPv6 forwarding table, interfaces, and configuration.
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
Describes an IPv6 prefix.
API to create IPv6 RAW socket instances.
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 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.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static constexpr auto UNIT
Hold an unsigned integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
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 Ipv6RawTestSuite g_ipv6rawTestSuite
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.