22 #include "ns3/olsr-header.h"
23 #include "ns3/packet.h"
30 virtual void DoRun (
void);
34 :
TestCase (
"Check Emf olsr time conversion")
40 for (
int time = 1; time <= 30; time++)
53 virtual void DoRun (
void);
57 :
TestCase (
"Check Mid olsr messages")
66 olsr::PacketHeader hdr;
67 olsr::MessageHeader msg1;
69 olsr::MessageHeader msg2;
80 msg1.SetTimeToLive (255);
81 msg1.SetOriginatorAddress (
Ipv4Address (
"11.22.33.44"));
83 msg1.SetMessageSequenceNumber (7);
93 msg2.SetTimeToLive (254);
94 msg2.SetOriginatorAddress (
Ipv4Address (
"12.22.33.44"));
96 msg2.SetMessageType (olsr::MessageHeader::MID_MESSAGE);
97 msg2.SetMessageSequenceNumber (7);
100 hdr.SetPacketLength (hdr.GetSerializedSize () + msg1.GetSerializedSize () + msg2.GetSerializedSize ());
101 hdr.SetPacketSequenceNumber (123);
111 olsr::PacketHeader hdr;
114 uint32_t sizeLeft = hdr.GetPacketLength () - hdr.GetSerializedSize ();
116 olsr::MessageHeader msg1;
130 sizeLeft -= msg1.GetSerializedSize ();
135 olsr::MessageHeader msg2;
149 sizeLeft -= msg2.GetSerializedSize ();
159 virtual void DoRun (
void);
163 :
TestCase (
"Check Hello olsr messages")
170 olsr::MessageHeader msgIn;
192 olsr::MessageHeader msgOut;
219 virtual void DoRun (
void);
223 :
TestCase (
"Check Tc olsr messages")
230 olsr::MessageHeader msgIn;
238 olsr::MessageHeader msgOut;
257 virtual void DoRun (
void);
261 :
TestCase (
"Check Hna olsr messages")
269 olsr::MessageHeader msgIn;
278 olsr::MessageHeader msgOut;
306 :
TestSuite (
"routing-olsr-header", UNIT)
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
a class to represent an Ipv4 address mask
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv4 addresses are stored in host order in this class.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint8_t SecondsToEmf(double seconds)
Converts a decimal number of seconds to the mantissa/exponent format.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double EmfToSeconds(uint8_t olsrFormat)
Converts a number of seconds in the mantissa/exponent format to a decimal number. ...
void AddHeader(const Header &header)
Add header to this packet.