22 #include "ns3/olsr-header.h" 23 #include "ns3/packet.h" 38 virtual void DoRun (
void);
42 :
TestCase (
"Check Emf olsr time conversion")
48 for (
int time = 1; time <= 30; time++)
68 virtual void DoRun (
void);
72 :
TestCase (
"Check Mid olsr messages")
81 olsr::PacketHeader hdr;
82 olsr::MessageHeader msg1;
84 olsr::MessageHeader msg2;
95 msg1.SetTimeToLive (255);
96 msg1.SetOriginatorAddress (
Ipv4Address (
"11.22.33.44"));
98 msg1.SetMessageSequenceNumber (7);
108 msg2.SetTimeToLive (254);
109 msg2.SetOriginatorAddress (
Ipv4Address (
"12.22.33.44"));
111 msg2.SetMessageType (olsr::MessageHeader::MID_MESSAGE);
112 msg2.SetMessageSequenceNumber (7);
115 hdr.SetPacketLength (hdr.GetSerializedSize () + msg1.GetSerializedSize () + msg2.GetSerializedSize ());
116 hdr.SetPacketSequenceNumber (123);
126 olsr::PacketHeader hdr;
129 uint32_t sizeLeft = hdr.GetPacketLength () - hdr.GetSerializedSize ();
131 olsr::MessageHeader msg1;
145 sizeLeft -= msg1.GetSerializedSize ();
150 olsr::MessageHeader msg2;
164 sizeLeft -= msg2.GetSerializedSize ();
181 virtual void DoRun (
void);
185 :
TestCase (
"Check Hello olsr messages")
192 olsr::MessageHeader msgIn;
214 olsr::MessageHeader msgOut;
248 virtual void DoRun (
void);
252 :
TestCase (
"Check Tc olsr messages")
259 olsr::MessageHeader msgIn;
267 olsr::MessageHeader msgOut;
293 virtual void DoRun (
void);
297 :
TestCase (
"Check Hna olsr messages")
305 olsr::MessageHeader msgIn;
314 olsr::MessageHeader msgOut;
348 :
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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
a class to represent an Ipv4 address mask
Check Hello olsr messages.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
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.
Check olsr header messages.
Ipv4 addresses are stored in host order in this class.
Time Seconds(double value)
Construct a Time in the indicated unit.
Check Emf olsr time conversion.
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.