22 #include "ns3/olsr-header.h"
23 #include "ns3/packet.h"
31 virtual void DoRun (
void);
35 :
TestCase (
"Check Emf olsr time conversion")
41 for (
int time = 1; time <= 30; time++)
55 virtual void DoRun (
void);
59 :
TestCase (
"Check Mid olsr messages")
68 olsr::PacketHeader hdr;
69 olsr::MessageHeader msg1;
71 olsr::MessageHeader msg2;
82 msg1.SetTimeToLive (255);
83 msg1.SetOriginatorAddress (
Ipv4Address (
"11.22.33.44"));
85 msg1.SetMessageSequenceNumber (7);
95 msg2.SetTimeToLive (254);
96 msg2.SetOriginatorAddress (
Ipv4Address (
"12.22.33.44"));
98 msg2.SetMessageType (olsr::MessageHeader::MID_MESSAGE);
99 msg2.SetMessageSequenceNumber (7);
102 hdr.SetPacketLength (hdr.GetSerializedSize () + msg1.GetSerializedSize () + msg2.GetSerializedSize ());
103 hdr.SetPacketSequenceNumber (123);
113 olsr::PacketHeader hdr;
116 uint32_t sizeLeft = hdr.GetPacketLength () - hdr.GetSerializedSize ();
118 olsr::MessageHeader msg1;
132 sizeLeft -= msg1.GetSerializedSize ();
137 olsr::MessageHeader msg2;
151 sizeLeft -= msg2.GetSerializedSize ();
162 virtual void DoRun (
void);
166 :
TestCase (
"Check Hello olsr messages")
173 olsr::MessageHeader msgIn;
195 olsr::MessageHeader msgOut;
223 virtual void DoRun (
void);
227 :
TestCase (
"Check Tc olsr messages")
234 olsr::MessageHeader msgIn;
242 olsr::MessageHeader msgOut;
262 virtual void DoRun (
void);
266 :
TestCase (
"Check Hna olsr messages")
274 olsr::MessageHeader msgIn;
283 olsr::MessageHeader msgOut;
311 :
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.
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.