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
54 for (b = 0; (seconds/
OLSR_C) >= (1 << b); ++b)
61 double tmp = 16*(seconds/(
OLSR_C*(1<<b))-1);
64 a = (int) std::ceil (tmp-0.5);
78 return (uint8_t)((a << 4) | b);
90 int a = (olsrFormat >> 4);
91 int b = (olsrFormat & 0xf);
93 return OLSR_C * (1 + a/16.0) * (1 << b);
115 .SetGroupName (
"Olsr")
174 .SetGroupName (
"Olsr")
192 size +=
m_message.mid.GetSerializedSize ();
196 size +=
m_message.hello.GetSerializedSize ();
199 size +=
m_message.tc.GetSerializedSize ();
202 size +=
m_message.hna.GetSerializedSize ();
302 for (std::vector<Ipv4Address>::const_iterator iter = this->interfaceAddresses.begin ();
303 iter != this->interfaceAddresses.end (); iter++)
314 this->interfaceAddresses.clear ();
318 this->interfaceAddresses.erase (this->interfaceAddresses.begin (),
319 this->interfaceAddresses.end ());
320 for (
int n = 0; n < numAddresses; ++n)
333 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin ();
334 iter != this->linkMessages.end (); iter++)
358 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin ();
359 iter != this->linkMessages.end (); iter++)
387 this->linkMessages.clear ();
389 uint16_t helloSizeLeft = messageSize;
392 this->hTime = i.
ReadU8 ();
393 this->willingness = i.
ReadU8 ();
397 while (helloSizeLeft)
409 helloSizeLeft -= lmSize;
410 this->linkMessages.push_back (lm);
440 for (std::vector<Ipv4Address>::const_iterator iter = this->neighborAddresses.begin ();
441 iter != this->neighborAddresses.end (); iter++)
452 this->neighborAddresses.clear ();
460 this->neighborAddresses.clear ();
461 for (
int n = 0; n < numAddresses; ++n)
487 for (
size_t n = 0; n < this->associations.size (); ++n)
501 this->associations.clear ();
502 for (
int n = 0; n < numAddresses; ++n)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
a class to represent an Ipv4 address mask
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t ReadNtohU32(void)
iterator in a Buffer instance
uint32_t Get(void) const
Get the host-order 32-bit IP address.
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteHtonU32(uint32_t data)
Ipv4 addresses are stored in host order in this class.
void WriteU8(uint8_t data)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint8_t SecondsToEmf(double seconds)
Converts a decimal number of seconds to the mantissa/exponent format.
double EmfToSeconds(uint8_t olsrFormat)
Converts a number of seconds in the mantissa/exponent format to a decimal number. ...
uint16_t ReadNtohU16(void)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.