22 #include "ns3/socket-factory.h" 23 #include "ns3/udp-socket-factory.h" 24 #include "ns3/simulator.h" 25 #include "ns3/simple-channel.h" 26 #include "ns3/simple-net-device.h" 27 #include "ns3/socket.h" 28 #include "ns3/boolean.h" 32 #include "ns3/inet6-socket-address.h" 33 #include "ns3/internet-stack-helper.h" 35 #include "ns3/sixlowpan-net-device.h" 58 void DoSendData (
Ptr<Socket> socket, std::string to);
69 virtual void DoRun (
void);
89 :
TestCase (
"Sixlowpan implementation")
100 uint32_t availableData;
106 (void) availableData;
113 uint8_t buffer [] =
"\"Can you tell me where my country lies?\" \\ said the unifaun to his true love's eyes. \\ \"It lies with me!\" cried the Queen of Maybe \\ - for her merchandise, he traded in his prize.";
137 Ptr<Node> rxNode = CreateObject<Node> ();
141 rxDev = CreateObject<SimpleNetDevice> ();
142 rxDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
156 ipv6->
SetUp (netdev_idx);
160 Ptr<Node> txNode = CreateObject<Node> ();
164 txDev = CreateObject<SimpleNetDevice> ();
165 txDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
179 ipv6->
SetUp (netdev_idx);
199 SendData (txSocket,
"2001:0100::1");
201 uint8_t rxBuffer [180];
202 uint8_t txBuffer [180] =
"\"Can you tell me where my country lies?\" \\ said the unifaun to his true love's eyes. \\ \"It lies with me!\" cried the Queen of Maybe \\ - for her merchandise, he traded in his prize.";
208 Simulator::Destroy ();
AttributeValue implementation for Boolean.
uint32_t GetId(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Access to the IPv6 forwarding table, interfaces, and configuration.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void ReceivePacket(Ptr< Socket > socket)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
IPv6 address associated with an interface.
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.
virtual Ptr< Socket > CreateSocket(void)=0
static SixlowpanHc1TestSuite g_sixlowpanHc1TestSuite
Static variable for test initialization.
void SetNetDevice(Ptr< NetDevice > device)
Setup SixLowPan to be a proxy for the specified NetDevice.
a polymophic address class
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SendData(Ptr< Socket > socket, std::string to)
Send data function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Describes an IPv6 address.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Packet receive function.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void SetAddress(Address address)
Set the address of this interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
Describes an IPv6 prefix.
void ReceivePkt(Ptr< Socket > socket)
Packet receive function.
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
API to create UDP socket instances.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< Packet > m_receivedPacket
received packet
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.