20 #include "ns3/olsr-header.h"
21 #include "ns3/olsr-repositories.h"
22 #include "ns3/packet.h"
37 void DoRun()
override;
41 :
TestCase(
"Check Emf olsr time conversion")
48 for (
int time = 1; time <= 30; time++)
66 void DoRun()
override;
70 :
TestCase(
"Check Mid olsr messages")
80 olsr::PacketHeader hdr;
81 olsr::MessageHeader msg1;
83 olsr::MessageHeader msg2;
90 addresses.emplace_back(
"1.2.3.4");
91 addresses.emplace_back(
"1.2.3.5");
94 msg1.SetTimeToLive(255);
95 msg1.SetOriginatorAddress(
Ipv4Address(
"11.22.33.44"));
97 msg1.SetMessageSequenceNumber(7);
103 addresses.emplace_back(
"2.2.3.4");
104 addresses.emplace_back(
"2.2.3.5");
107 msg2.SetTimeToLive(254);
108 msg2.SetOriginatorAddress(
Ipv4Address(
"12.22.33.44"));
110 msg2.SetMessageType(olsr::MessageHeader::MID_MESSAGE);
111 msg2.SetMessageSequenceNumber(7);
114 hdr.SetPacketLength(hdr.GetSerializedSize() + msg1.GetSerializedSize() +
115 msg2.GetSerializedSize());
116 hdr.SetPacketSequenceNumber(123);
125 olsr::PacketHeader hdr;
128 uint32_t sizeLeft = hdr.GetPacketLength() - hdr.GetSerializedSize();
130 olsr::MessageHeader msg1;
144 sizeLeft -= msg1.GetSerializedSize();
149 olsr::MessageHeader msg2;
163 sizeLeft -= msg2.GetSerializedSize();
179 void DoRun()
override;
183 :
TestCase(
"Check Hello olsr messages")
191 olsr::MessageHeader msgIn;
213 olsr::MessageHeader msgOut;
250 void DoRun()
override;
254 :
TestCase(
"Check Tc olsr messages")
262 olsr::MessageHeader msgIn;
270 olsr::MessageHeader msgOut;
293 void DoRun()
override;
297 :
TestCase(
"Check Hna olsr messages")
305 olsr::MessageHeader msgIn;
314 olsr::MessageHeader msgOut;
Check Emf olsr time conversion.
void DoRun() override
Implementation to actually run this TestCase.
Check Hello olsr messages.
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Check olsr header messages.
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
double EmfToSeconds(uint8_t olsrFormat)
Converts a number of seconds in the mantissa/exponent format to a decimal number.
uint8_t SecondsToEmf(double seconds)
Converts a decimal number of seconds to the mantissa/exponent format.
Every class exported by the ns3 library is enclosed in the ns3 namespace.