22 #include "ns3/socket-factory.h" 23 #include "ns3/simulator.h" 24 #include "ns3/socket.h" 25 #include "ns3/boolean.h" 29 #include "ns3/inet6-socket-address.h" 30 #include "ns3/internet-stack-helper.h" 31 #include "ns3/ipv6-address-helper.h" 32 #include "ns3/icmpv6-l4-protocol.h" 34 #include "ns3/sixlowpan-net-device.h" 35 #include "ns3/sixlowpan-header.h" 36 #include "ns3/sixlowpan-helper.h" 111 virtual void DoRun (
void);
116 :
TestCase (
"Sixlowpan IPHC stateful implementation")
126 incomingPkt.
src = source;
127 incomingPkt.
dst = destination;
134 Simulator::ScheduleWithContext (
id,
Time(1), &MockNetDevice::Receive, mockDev, incomingPkt.
packet, protocol, destination, source, packetType);
145 incomingPkt.
src = source;
146 incomingPkt.
dst = destination;
158 ipHdr.SetDestinationAddress (to);
159 ipHdr.SetHopLimit (64);
160 ipHdr.SetPayloadLength (10);
161 ipHdr.SetNextHeader (0xff);
175 nodes.Get (0)->AddDevice (mockNetDevice0);
178 mockNetDevice0->
SetMtu (150);
184 nodes.Get (1)->AddDevice (mockNetDevice1);
187 mockNetDevice1->
SetMtu (150);
203 for (
auto i =
nodes.Begin (); i !=
nodes.End (); i++)
226 Ipv6Address::GetAny (),
241 Simulator::Stop (
Seconds (10));
244 Simulator::Destroy ();
334 :
TestSuite (
"sixlowpan-iphc-stateful", UNIT)
NetDeviceContainer m_mockDevices
MockNetDevice container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
uint8_t GetDstContextId(void) const
Get the DstContextId.
AttributeValue implementation for Boolean.
uint32_t GetId(void) const
Keep track of a set of IPv6 interfaces.
IPv6 layer implementation.
bool PromiscReceiveFromSixLowPanDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, NetDevice::PacketType packetType)
Promiscuous receive from a SixLowPanNetDevice.
LOWPAN_IPHC base Encoding - see RFC 6282.
virtual void DoRun(void)
Implementation to actually run this TestCase.
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
NetDeviceContainer m_sixDevices
SixLowPanNetDevice container.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
void SetSendCallback(PromiscReceiveCallback cb)
Add a callback to be invoked when the MockNetDevice has a packet to "send".
a polymophic address class
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
uint8_t GetSrcContextId(void) const
Get the SrcContextId.
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
bool ReceiveFromMockDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, NetDevice::PacketType packetType)
Receive from a MockDevice.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
static SixlowpanIphcStatefulTestSuite g_sixlowpanIphcStatefulTestSuite
Static variable for test initialization.
Address src
Source address.
holds a vector of ns3::NetDevice pointers
An implementation of the ICMPv6 protocol.
Ptr< Packet > packet
Packet data.
NetDeviceContainer Install(NetDeviceContainer c)
Install the SixLoWPAN stack on top of an existing NetDevice.
bool GetCid(void) const
Get the CID (Context Identifier Extension) compression.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Address dst
Destination address.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
std::vector< Data > m_rxPackets
Received packets.
bool GetSac(void) const
Get the SAC (Source Address Compression) compression.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
Send one packet.
Structure to hold the Rx/Tx packets.
virtual void SetNode(Ptr< Node > node)
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
SixlowpanIphcStatefulTestSuite()
Helper class to auto-assign global IPv6 unicast addresses.
Time Minutes(double value)
Construct a Time in the indicated unit.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
SixlowpanIphcStatefulImplTest()
Describes an IPv6 address.
6LoWPAN IPHC stateful compression Test
Time Seconds(double value)
Construct a Time in the indicated unit.
Describes an IPv6 prefix.
PacketType
Packet types are used as they are in Linux.
bool GetM(void) const
Get the M (Multicast) compression.
Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.
virtual Ptr< Node > GetNode(void) const
virtual bool SetMtu(const uint16_t mtu)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
void SendOnePacket(Ptr< NetDevice > device, Ipv6Address from, Ipv6Address to)
Send one packet.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::vector< Data > m_txPackets
Transmitted packets.
void AddHeader(const Header &header)
Add header to this packet.
virtual void SetAddress(Address address)
Set the address of this interface.
void AddContext(NetDeviceContainer c, uint8_t contextId, Ipv6Prefix context, Time validity)
Adds a compression Context to a set of NetDevices.