22#include "ns3/assert.h"
27#define IPV4_ADDRESS_SIZE 4
28#define OLSR_MSG_HEADER_SIZE 12
29#define OLSR_PKT_HEADER_SIZE 4
54 NS_ASSERT_MSG(seconds >=
OLSR_C,
"SecondsToEmf - Can not convert a value less than OLSR_C");
57 for (b = 1; (seconds /
OLSR_C) >= (1 << b); ++b)
65 double tmp = 16 * (seconds / (
OLSR_C * (1 << b)) - 1);
68 a = (int)std::ceil(tmp - 0.5);
82 return (uint8_t)((a << 4) | b);
94 int a = (olsrFormat >> 4);
95 int b = (olsrFormat & 0xf);
97 return OLSR_C * (1 + a / 16.0) * (1 << b);
117 .SetGroupName(
"Olsr")
175 .SetGroupName(
"Olsr")
193 size +=
m_message.mid.GetSerializedSize();
198 size +=
m_message.hello.GetSerializedSize();
201 size +=
m_message.tc.GetSerializedSize();
204 size +=
m_message.hna.GetSerializedSize();
234 os <<
" Validity: " << +
m_vTime;
335 for (
const auto& iAddr : interfaceAddresses)
355 for (std::vector<Ipv4Address>::const_iterator iter = this->interfaceAddresses.begin();
356 iter != this->interfaceAddresses.end();
368 this->interfaceAddresses.clear();
372 this->interfaceAddresses.erase(this->interfaceAddresses.begin(),
373 this->interfaceAddresses.end());
374 for (
int n = 0; n < numAddresses; ++n)
376 this->interfaceAddresses.emplace_back(i.
ReadNtohU32());
387 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin();
388 iter != this->linkMessages.end();
401 os <<
" Interval: " << +hTime <<
" (" <<
EmfToSeconds(hTime) <<
"s)";
402 os <<
" Willingness: " << willingness;
404 for (
const auto& ilinkMessage : linkMessages)
407 os <<
" Link code: " << +(lm.
linkCode);
433 i.
WriteU8(
static_cast<uint8_t
>(this->willingness));
435 for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin();
436 iter != this->linkMessages.end();
450 for (std::vector<Ipv4Address>::const_iterator neigh_iter =
467 this->linkMessages.clear();
469 uint16_t helloSizeLeft = messageSize;
477 while (helloSizeLeft)
489 helloSizeLeft -= lmSize;
490 this->linkMessages.push_back(lm);
507 os <<
" Adv. SeqNo: " << ansn;
510 for (
const auto& iAddr : neighborAddresses)
533 for (std::vector<Ipv4Address>::const_iterator iter = this->neighborAddresses.begin();
534 iter != this->neighborAddresses.end();
546 this->neighborAddresses.clear();
554 this->neighborAddresses.clear();
555 for (
int n = 0; n < numAddresses; ++n)
557 this->neighborAddresses.emplace_back(i.
ReadNtohU32());
576 for (
const auto& iAssoc : associations)
586 os << iAssoc.address <<
"/" << iAssoc.mask.GetPrefixLength();
596 for (
size_t n = 0; n < this->associations.size(); ++n)
610 this->associations.clear();
611 for (
int n = 0; n < numAddresses; ++n)
615 this->associations.push_back((
Association){address, mask});
iterator in a Buffer instance
void WriteU8(uint8_t data)
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
void WriteHtonU32(uint32_t data)
Ipv4 addresses are stored in host order in this class.
uint32_t Get() 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.
Willingness
Willingness for forwarding packets from other nodes.
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.