Need clarification in olsr-header.h file

29 views
Skip to first unread message

Doaa

unread,
Apr 2, 2016, 4:04:49 PM4/2/16
to ns-3-users
Hi all,
I am studying the OlSR protocol, There is a part of the code that I did not understand in olsr-header.h file

592  {
593  if (m_messageType == 0)
594  {
595  m_messageType = HELLO_MESSAGE;
596  }
597  else
598  {
599  NS_ASSERT (m_messageType == HELLO_MESSAGE);
600  }
601  return m_message.hello;
602  }

How come if m_messageType == 0, then m_messageType is a hello msg?
or Is this have another meaning?

Thanks in advance

Tommaso Pecorella

unread,
Apr 2, 2016, 5:37:44 PM4/2/16
to ns-3-users
Hi,

it's a (questionable) design choice. I wouldn't have done in this way, but it works. As a consequence, it's just a choice.

All the OLSR headers are the very same header class. The m_messageType variable decides what header kind is for real.
When you create a header, its type is zero. When you "use" it for the first time as a particular header its type is written into m_messageType and never changed again (quite logical).

As I said, I wouldn't have done this, but it works.

Cheers,

T.

Doaa

unread,
Apr 3, 2016, 5:08:13 PM4/3/16
to ns-3-users
Thanks  Tommaso  for the clarification!
Reply all
Reply to author
Forward
0 new messages