8#include "ns3/boolean.h" 
   10#include "ns3/error-channel.h" 
   11#include "ns3/icmpv6-l4-protocol.h" 
   12#include "ns3/inet-socket-address.h" 
   13#include "ns3/internet-stack-helper.h" 
   14#include "ns3/ipv6-raw-socket-factory.h" 
   17#include "ns3/simple-net-device.h" 
   18#include "ns3/simulator.h" 
   19#include "ns3/sixlowpan-net-device.h" 
   20#include "ns3/socket-factory.h" 
   21#include "ns3/socket.h" 
   23#include "ns3/udp-socket-factory.h" 
   24#include "ns3/udp-socket.h" 
   25#include "ns3/uinteger.h" 
   28#include "ns3/win32-internet.h" 
   30#include <netinet/in.h> 
   58    void DoRun() 
override;
 
 
  115    : 
TestCase(
"Verify the 6LoWPAN protocol fragmentation and reassembly")
 
 
  156    while ((packet = socket->RecvFrom(from)))
 
  160            packet->RemoveAllPacketTags();
 
  161            packet->RemoveAllByteTags();
 
 
  191    while ((packet = socket->RecvFrom(from)))
 
 
  217        m_data = 
new uint8_t[dataSize];
 
  221    if (fillSize >= dataSize)
 
  223        memcpy(
m_data, fill, dataSize);
 
  228    while (filled + fillSize < dataSize)
 
  230        memcpy(&
m_data[filled], fill, fillSize);
 
  234    memcpy(&
m_data[filled], fill, dataSize - filled);
 
 
  261    internet.SetIpv4StackInstall(
false);
 
  266    internet.Install(serverNode);
 
  275        serverDev->SetMtu(1500);
 
  276        serverDev->SetReceiveErrorModel(serverDevErrorModel);
 
  277        serverDevErrorModel->Disable();
 
  278        serverNode->AddDevice(serverDev);
 
  281        serverNode->AddDevice(serverSix);
 
  282        serverSix->SetNetDevice(serverDev);
 
  285        ipv6->AddInterface(serverDev);
 
  286        uint32_t netdev_idx = ipv6->AddInterface(serverSix);
 
  289        ipv6->AddAddress(netdev_idx, ipv6Addr);
 
  290        ipv6->SetUp(netdev_idx);
 
  296    internet.Install(clientNode);
 
  305        clientDev->SetMtu(150);
 
  306        clientDev->SetReceiveErrorModel(clientDevErrorModel);
 
  307        clientDevErrorModel->Disable();
 
  308        clientNode->AddDevice(clientDev);
 
  311        clientNode->AddDevice(clientSix);
 
  312        clientSix->SetNetDevice(clientDev);
 
  315        ipv6->AddInterface(clientDev);
 
  316        uint32_t netdev_idx = ipv6->AddInterface(clientSix);
 
  319        ipv6->AddAddress(netdev_idx, ipv6Addr);
 
  320        ipv6->SetUp(netdev_idx);
 
  326    serverDev->SetChannel(channel);
 
  327    clientDev->SetChannel(channel);
 
  330    uint32_t packetSizes[5] = {200, 300, 400, 500, 600};
 
  333    uint8_t fillData[78];
 
  334    for (
uint32_t k = 48; k <= 125; k++)
 
  336        fillData[k - 48] = k;
 
  340    for (
int i = 0; i < 5; i++)
 
  353        uint8_t recvBuffer[65000];
 
  359                              "Packet size not correct: recvSize: " 
  360                                  << recvSize << 
" packetSizes[" << i << 
"]: " << packetSizes[i]);
 
  365                              "Packet content differs");
 
  371    channel->SetJumpingMode(
true);
 
  372    for (
int i = 0; i < 5; i++)
 
  385        uint8_t recvBuffer[65000];
 
  391                              "Packet size not correct: recvSize: " 
  392                                  << recvSize << 
" packetSizes[" << i << 
"]: " << packetSizes[i]);
 
  397                              "Packet content differs");
 
  399    channel->SetJumpingMode(
false);
 
  403    channel->SetDuplicateMode(
true);
 
  404    for (
int i = 1; i < 5; i++)
 
  411        serverDevErrorModel->Reset();
 
  422        uint8_t recvBuffer[65000];
 
  428                              "Packet size not correct: recvSize: " 
  429                                  << recvSize << 
" packetSizes[" << i << 
"]: " << packetSizes[i]);
 
  434                              "Packet content differs");
 
  436    channel->SetDuplicateMode(
false);
 
  441    clientDevErrorModel->Disable();
 
  442    serverDevErrorModel->Enable();
 
  443    for (
int i = 1; i < 5; i++)
 
  450        serverDevErrorModel->Reset();
 
 
6LoWPAN Fragmentation Test
 
uint8_t m_icmpType
ICMP type.
 
Ptr< Packet > m_sentPacketClient
Packet sent by client.
 
void StartClient(Ptr< Node > clientNode)
Start the client node.
 
void StartServer(Ptr< Node > serverNode)
Start the server node.
 
Ptr< Socket > m_socketServer
Socket on the server.
 
Ptr< Socket > m_socketClient
Socket on the client.
 
~SixlowpanFragmentationTest() override
 
uint8_t m_icmpCode
ICMP code.
 
void SetFill(uint8_t *fill, uint32_t fillSize, uint32_t dataSize)
Set the packet optional content.
 
void HandleReadIcmpClient(Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Handles incoming ICMP packets in the client.
 
Ptr< Packet > m_receivedPacketServer
packet received by the server.
 
void HandleReadServer(Ptr< Socket > socket)
Handles incoming packets in the server.
 
SixlowpanFragmentationTest()
 
uint32_t m_dataSize
Size of the data (if any).
 
void HandleReadClient(Ptr< Socket > socket)
Handles incoming packets in the client.
 
Ptr< Packet > SendClient()
Send a packet to the server.
 
uint32_t m_size
Size of the packet if no data has been provided.
 
void DoRun() override
Implementation to actually run this TestCase.
 
Ptr< Packet > m_receivedPacketClient
Packet received by the client.
 
uint8_t * m_data
Data to be carried in the packet.
 
6LoWPAN Fragmentation TestSuite
 
SixlowpanFragmentationTestSuite()
 
a polymophic address class
 
AttributeValue implementation for Boolean.
 
AttributeValue implementation for Callback.
 
An implementation of the ICMPv6 protocol.
 
static bool IsMatchingType(const Address &addr)
If the address match.
 
aggregate IP/TCP/UDP functionality to existing Nodes.
 
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.
 
Describes an IPv6 prefix.
 
static Mac48Address ConvertFrom(const Address &address)
 
static Mac48Address Allocate()
Allocate a new Mac48Address.
 
static void EnablePrinting()
Enable printing packets metadata.
 
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.
 
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
 
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
 
TestCase(const TestCase &)=delete
 
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
 
a unique identifier for an interface.
 
static TypeId LookupByName(std::string name)
Get a TypeId by name.
 
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_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.
 
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.
 
static SixlowpanFragmentationTestSuite g_sixlowpanFragmentationTestSuite
Static variable for test initialization.
 
static const uint32_t packetSize
Packet size generated at the AP.