23 #include "ns3/assert.h"
28 #define IPV4_ADDRESS_SIZE 4
29 #define OLSR_MSG_HEADER_SIZE 12
30 #define OLSR_PKT_HEADER_SIZE 4
53 NS_ASSERT_MSG (seconds >=
OLSR_C,
"SecondsToEmf - Can not convert a value less than OLSR_C");
56 for (b = 1; (seconds /
OLSR_C) >= (1 << b); ++b)
64 double tmp = 16 * (seconds / (
OLSR_C * (1 << b)) - 1);
67 a = (int) std::ceil (tmp - 0.5);
81 return (uint8_t)((a << 4) | b);
93 int a = (olsrFormat >> 4);
94 int b = (olsrFormat & 0xf);
96 return OLSR_C * (1 + a / 16.0) * (1 << b);
118 .SetGroupName (
"Olsr")
177 .SetGroupName (
"Olsr")
195 size +=
m_message.mid.GetSerializedSize ();
199 size +=
m_message.hello.GetSerializedSize ();
202 size +=
m_message.tc.GetSerializedSize ();
205 size +=
m_message.hna.GetSerializedSize ();
235 os <<
" Validity: " << +
m_vTime;
338 for (
const auto& iAddr : interfaceAddresses)
358 for (std::vector<Ipv4Address>::const_iterator iter = this->interfaceAddresses.begin ();
359 iter != this->interfaceAddresses.end (); iter++)
370 this->interfaceAddresses.clear ();
374 this->interfaceAddresses.erase (this->interfaceAddresses.begin (),
375 this->interfaceAddresses.end ());
376 for (
int n = 0; n < numAddresses; ++n)
391 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin ();
392 iter != this->linkMessages.end (); iter++)
404 os <<
" Interval: " << +hTime <<
" (" <<
EmfToSeconds (hTime) <<
"s)";
405 os <<
" Willingness: " << +willingness;
407 for (
const auto& ilinkMessage : linkMessages)
410 os <<
" Link code: " << +(lm.
linkCode);
439 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin ();
440 iter != this->linkMessages.end (); iter++)
468 this->linkMessages.clear ();
470 uint16_t helloSizeLeft = messageSize;
473 this->hTime = i.
ReadU8 ();
474 this->willingness = i.
ReadU8 ();
478 while (helloSizeLeft)
490 helloSizeLeft -= lmSize;
491 this->linkMessages.push_back (lm);
510 os <<
" Adv. SeqNo: " << ansn;
513 for (
const auto& iAddr : neighborAddresses)
536 for (std::vector<Ipv4Address>::const_iterator iter = this->neighborAddresses.begin ();
537 iter != this->neighborAddresses.end (); iter++)
548 this->neighborAddresses.clear ();
556 this->neighborAddresses.clear ();
557 for (
int n = 0; n < numAddresses; ++n)
579 for (
const auto& iAssoc : associations)
589 os << iAssoc.address <<
"/" << iAssoc.mask.GetPrefixLength ();
599 for (
size_t n = 0; n < this->associations.size (); ++n)
613 this->associations.clear ();
614 for (
int n = 0; n < numAddresses; ++n)
iterator in a Buffer instance
uint16_t ReadNtohU16(void)
void WriteU8(uint8_t data)
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
void WriteHtonU32(uint32_t data)
uint32_t ReadNtohU32(void)
Ipv4 addresses are stored in host order in this class.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
a class to represent an Ipv4 address mask
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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.