11#include "ns3/boolean.h"
12#include "ns3/icmpv6-l4-protocol.h"
13#include "ns3/inet6-socket-address.h"
14#include "ns3/internet-stack-helper.h"
15#include "ns3/ipv6-address-helper.h"
18#include "ns3/simulator.h"
19#include "ns3/sixlowpan-header.h"
20#include "ns3/sixlowpan-helper.h"
21#include "ns3/sixlowpan-net-device.h"
22#include "ns3/socket-factory.h"
23#include "ns3/socket.h"
98 void DoRun()
override;
103 :
TestCase(
"Sixlowpan IPHC stateful implementation")
116 incomingPkt.
packet = packet->Copy();
117 incomingPkt.
src = source;
118 incomingPkt.
dst = destination;
124 uint32_t id = mockDev->GetNode()->GetId();
147 incomingPkt.
packet = packet->Copy();
148 incomingPkt.
src = source;
149 incomingPkt.
dst = destination;
167 pkt->AddHeader(ipHdr);
169 device->Send(pkt,
Mac48Address(
"00:00:00:00:00:02"), 0);
181 mockNetDevice0->SetNode(
nodes.
Get(0));
182 mockNetDevice0->SetAddress(
Mac48Address(
"00:00:00:00:00:01"));
183 mockNetDevice0->SetMtu(150);
184 mockNetDevice0->SetSendCallback(
191 mockNetDevice1->SetNode(
nodes.
Get(1));
192 mockNetDevice1->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
193 mockNetDevice1->SetMtu(150);
217 ipv6L3->SetAttribute(
"SendIcmpv6Redirect",
BooleanValue(
false));
278 "SAM should be HC_INLINE, it is not");
285 "DAM should be HC_COMPR_0, it is not");
291 "Src address wrongly rebuilt");
300 "SAM should be HC_COMPR_64, it is not");
307 "DAM should be HC_COMPR_16, it is not");
313 "Src address wrongly rebuilt");
316 "Dst address wrongly rebuilt");
324 "SAM should be HC_COMPR_16, it is not");
331 "DAM should be HC_COMPR_64, it is not");
337 "Src address wrongly rebuilt");
340 "Dst address wrongly rebuilt");
348 "SAM should be HC_COMPR_0, it is not");
355 "DAM should be HC_COMPR_64, it is not");
362 "Dst address wrongly rebuilt");
6LoWPAN IPHC stateful compression Test
std::vector< Data > m_txPackets
Transmitted packets.
bool ReceiveFromMockDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, NetDevice::PacketType packetType)
Receive from a MockDevice.
void DoRun() override
Implementation to actually run this TestCase.
bool PromiscReceiveFromSixLowPanDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, NetDevice::PacketType packetType)
Promiscuous receive from a SixLowPanNetDevice.
NetDeviceContainer m_mockDevices
MockNetDevice container.
std::vector< Data > m_rxPackets
Received packets.
void SendOnePacket(Ptr< NetDevice > device, Ipv6Address from, Ipv6Address to)
Send one packet.
SixlowpanIphcStatefulImplTest()
NetDeviceContainer m_sixDevices
SixLowPanNetDevice container.
SixlowpanIphcStatefulTestSuite()
a polymophic address class
AttributeValue implementation for Boolean.
An implementation of the ICMPv6 protocol.
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.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
static Ipv6Address MakeAutoconfiguredAddress(Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address from a Mac address.
Keep track of a set of IPv6 interfaces.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
IPv6 layer implementation.
Describes an IPv6 prefix.
void Receive(Ptr< Packet > packet, uint16_t protocol, Address to, Address from, NetDevice::PacketType packetType)
Pretend that a packet has been received from a connected Channel.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
PacketType
Packet types are used as they are in Linux.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Smart pointer class similar to boost::intrusive_ptr.
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.
Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.
NetDeviceContainer Install(NetDeviceContainer c)
Install the SixLoWPAN stack on top of an existing NetDevice.
void AddContext(NetDeviceContainer c, uint8_t contextId, Ipv6Prefix context, Time validity)
Adds a compression Context to a set of NetDevices.
LOWPAN_IPHC base Encoding - see RFC 6282 .
bool GetSac() const
Get the SAC (Source Address Compression) compression.
HeaderCompression_e GetDam() const
Get the DAM (Destination Address Mode) compression.
bool GetDac() const
Get the DAC (Destination Address Compression) compression.
bool GetM() const
Get the M (Multicast) compression.
HeaderCompression_e GetSam() const
Get the SAM (Source Address Mode) compression.
bool GetCid() const
Get the CID (Context Identifier Extension) compression.
uint8_t GetSrcContextId() const
Get the SrcContextId.
uint8_t GetDstContextId() const
Get the DstContextId.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
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.
Time Minutes(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 SixlowpanIphcStatefulTestSuite g_sixlowpanIphcStatefulTestSuite
Static variable for test initialization.
Structure to hold the Rx/Tx packets.
Address dst
Destination address.
Address src
Source address.
Ptr< Packet > packet
Packet data.