A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
olsr-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INESC Porto
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
18 */
19
20#ifndef OLSR_HEADER_H
21#define OLSR_HEADER_H
22
23#include "olsr-repositories.h"
24
25#include "ns3/header.h"
26#include "ns3/ipv4-address.h"
27#include "ns3/nstime.h"
28
29#include <stdint.h>
30#include <vector>
31
32namespace ns3
33{
34namespace olsr
35{
36
37double EmfToSeconds(uint8_t emf);
38uint8_t SecondsToEmf(double seconds);
39
40/**
41 * \ingroup olsr
42 *
43 * The basic layout of any packet in OLSR is as follows (omitting IP and
44 * UDP headers):
45 \verbatim
46 0 1 2 3
47 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
48 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 | Packet Length | Packet Sequence Number |
50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 | Message Type | Vtime | Message Size |
52 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 | Originator Address |
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 | Time To Live | Hop Count | Message Sequence Number |
56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 | |
58 : MESSAGE :
59 | |
60 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 | Message Type | Vtime | Message Size |
62 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 | Originator Address |
64 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 | Time To Live | Hop Count | Message Sequence Number |
66 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 | |
68 : MESSAGE :
69 | |
70 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71 : :
72 (etc.)
73 \endverbatim
74 *
75 * This header only holds the common part of a message group, i.e.,
76 * the first 4 bytes.
77 */
78class PacketHeader : public Header
79{
80 public:
82 ~PacketHeader() override;
83
84 /**
85 * Set the packet total length.
86 * \param length The packet length.
87 */
88 void SetPacketLength(uint16_t length)
89 {
90 m_packetLength = length;
91 }
92
93 /**
94 * Get the packet total length.
95 * \return The packet length.
96 */
97 uint16_t GetPacketLength() const
98 {
99 return m_packetLength;
100 }
101
102 /**
103 * Set the packet sequence number.
104 * \param seqnum The packet sequence number.
105 */
106 void SetPacketSequenceNumber(uint16_t seqnum)
107 {
108 m_packetSequenceNumber = seqnum;
109 }
110
111 /**
112 * Get the packet sequence number.
113 * \returns The packet sequence number.
114 */
115 uint16_t GetPacketSequenceNumber() const
116 {
118 }
119
120 private:
121 uint16_t m_packetLength; //!< The packet length.
122 uint16_t m_packetSequenceNumber; //!< The packet sequence number.
123
124 public:
125 /**
126 * \brief Get the type ID.
127 * \return The object TypeId.
128 */
129 static TypeId GetTypeId();
130 TypeId GetInstanceTypeId() const override;
131 void Print(std::ostream& os) const override;
132 uint32_t GetSerializedSize() const override;
133 void Serialize(Buffer::Iterator start) const override;
134 uint32_t Deserialize(Buffer::Iterator start) override;
135};
136
137/**
138 * \ingroup olsr
139 *
140 * This header can store HELP, TC, MID and HNA messages.
141 * The header size is variable, and depends on the
142 * actual message type.
143 *
144 \verbatim
145 0 1 2 3
146 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
147 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 | Message Type | Vtime | Message Size |
149 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 | Originator Address |
151 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 | Time To Live | Hop Count | Message Sequence Number |
153 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 | |
155 : MESSAGE :
156 | |
157 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158 \endverbatim
159 */
160class MessageHeader : public Header
161{
162 public:
163 /**
164 * Message type
165 */
167 {
172 };
173
175 ~MessageHeader() override;
176
177 /**
178 * Set the message type.
179 * \param messageType The message type.
180 */
181 void SetMessageType(MessageType messageType)
182 {
183 m_messageType = messageType;
184 }
185
186 /**
187 * Get the message type.
188 * \return The message type.
189 */
191 {
192 return m_messageType;
193 }
194
195 /**
196 * Set the validity time.
197 * \param time The validity time.
198 */
199 void SetVTime(Time time)
200 {
202 }
203
204 /**
205 * Get the validity time.
206 * \return The validity time.
207 */
209 {
211 }
212
213 /**
214 * Set the originator address.
215 * \param originatorAddress The originator address.
216 */
217 void SetOriginatorAddress(Ipv4Address originatorAddress)
218 {
219 m_originatorAddress = originatorAddress;
220 }
221
222 /**
223 * Get the originator address.
224 * \return The originator address.
225 */
227 {
228 return m_originatorAddress;
229 }
230
231 /**
232 * Set the time to live.
233 * \param timeToLive The time to live.
234 */
235 void SetTimeToLive(uint8_t timeToLive)
236 {
237 m_timeToLive = timeToLive;
238 }
239
240 /**
241 * Get the time to live.
242 * \return The time to live.
243 */
244 uint8_t GetTimeToLive() const
245 {
246 return m_timeToLive;
247 }
248
249 /**
250 * Set the hop count.
251 * \param hopCount The hop count.
252 */
253 void SetHopCount(uint8_t hopCount)
254 {
255 m_hopCount = hopCount;
256 }
257
258 /**
259 * Get the hop count.
260 * \return The hop count.
261 */
262 uint8_t GetHopCount() const
263 {
264 return m_hopCount;
265 }
266
267 /**
268 * Set the message sequence number.
269 * \param messageSequenceNumber The message sequence number.
270 */
271 void SetMessageSequenceNumber(uint16_t messageSequenceNumber)
272 {
273 m_messageSequenceNumber = messageSequenceNumber;
274 }
275
276 /**
277 * Get the message sequence number.
278 * \return The message sequence number.
279 */
281 {
283 }
284
285 private:
286 MessageType m_messageType; //!< The message type
287 uint8_t m_vTime; //!< The validity time.
288 Ipv4Address m_originatorAddress; //!< The originator address.
289 uint8_t m_timeToLive; //!< The time to live.
290 uint8_t m_hopCount; //!< The hop count.
291 uint16_t m_messageSequenceNumber; //!< The message sequence number.
292 uint16_t m_messageSize; //!< The message size.
293
294 public:
295 /**
296 * \brief Get the type ID.
297 * \return The object TypeId.
298 */
299 static TypeId GetTypeId();
300 TypeId GetInstanceTypeId() const override;
301 void Print(std::ostream& os) const override;
302 uint32_t GetSerializedSize() const override;
303 void Serialize(Buffer::Iterator start) const override;
304 uint32_t Deserialize(Buffer::Iterator start) override;
305
306 /**
307 * \ingroup olsr
308 * MID Message Format
309 *
310 \verbatim
311 0 1 2 3
312 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
313 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314 | OLSR Interface Address |
315 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
316 | OLSR Interface Address |
317 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318 | ... |
319 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
320 \endverbatim
321 */
322 struct Mid
323 {
324 std::vector<Ipv4Address> interfaceAddresses; //!< Interface Address container.
325 /**
326 * This method is used to print the content of a MID message.
327 * \param os output stream
328 */
329 void Print(std::ostream& os) const;
330 /**
331 * Returns the expected size of the header.
332 * \returns the expected size of the header.
333 */
335 /**
336 * This method is used by Packet::AddHeader to
337 * store a header into the byte buffer of a packet.
338 *
339 * \param start an iterator which points to where the header should
340 * be written.
341 */
342 void Serialize(Buffer::Iterator start) const;
343 /**
344 * This method is used by Packet::RemoveHeader to
345 * re-create a header from the byte buffer of a packet.
346 *
347 * \param start an iterator which points to where the header should
348 * read from.
349 * \param messageSize the message size.
350 * \returns the number of bytes read.
351 */
352 uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize);
353 };
354
355 /**
356 * \ingroup olsr
357 * HELLO Message Format
358 *
359 \verbatim
360 0 1 2 3
361 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
362
363 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
364 | Reserved | Htime | Willingness |
365 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
366 | Link Code | Reserved | Link Message Size |
367 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
368 | Neighbor Interface Address |
369 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370 | Neighbor Interface Address |
371 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
372 : . . . :
373 : :
374 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375 | Link Code | Reserved | Link Message Size |
376 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
377 | Neighbor Interface Address |
378 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
379 | Neighbor Interface Address |
380 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 : :
382 (etc.)
383 \endverbatim
384 */
385 struct Hello
386 {
387 /**
388 * Link message item
389 */
391 {
392 uint8_t linkCode; //!< Link code
393 std::vector<Ipv4Address>
394 neighborInterfaceAddresses; //!< Neighbor interface address container.
395 };
396
397 uint8_t hTime; //!< HELLO emission interval (coded)
398
399 /**
400 * Set the HELLO emission interval.
401 * \param time The HELLO emission interval.
402 */
403 void SetHTime(Time time)
404 {
405 this->hTime = SecondsToEmf(time.GetSeconds());
406 }
407
408 /**
409 * Get the HELLO emission interval.
410 * \return The HELLO emission interval.
411 */
413 {
414 return Seconds(EmfToSeconds(this->hTime));
415 }
416
417 Willingness willingness; //!< The willingness of a node to carry and forward traffic for
418 //!< other nodes.
419 std::vector<LinkMessage> linkMessages; //!< Link messages container.
420
421 /**
422 * This method is used to print the content of a Hello message.
423 * \param os output stream
424 */
425 void Print(std::ostream& os) const;
426 /**
427 * Returns the expected size of the header.
428 * \returns the expected size of the header.
429 */
431 /**
432 * This method is used by Packet::AddHeader to
433 * store a header into the byte buffer of a packet.
434 *
435 * \param start an iterator which points to where the header should
436 * be written.
437 */
438 void Serialize(Buffer::Iterator start) const;
439 /**
440 * This method is used by Packet::RemoveHeader to
441 * re-create a header from the byte buffer of a packet.
442 *
443 * \param start an iterator which points to where the header should
444 * read from.
445 * \param messageSize the message size.
446 * \returns the number of bytes read.
447 */
448 uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize);
449 };
450
451 /**
452 * \ingroup olsr
453 * TC Message Format
454 *
455 \verbatim
456 0 1 2 3
457 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
458 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
459 | ANSN | Reserved |
460 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
461 | Advertised Neighbor Main Address |
462 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
463 | Advertised Neighbor Main Address |
464 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
465 | ... |
466 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
467 \endverbatim
468 */
469 struct Tc
470 {
471 std::vector<Ipv4Address> neighborAddresses; //!< Neighbor address container.
472 uint16_t ansn; //!< Advertised Neighbor Sequence Number.
473
474 /**
475 * This method is used to print the content of a Tc message.
476 * \param os output stream
477 */
478 void Print(std::ostream& os) const;
479 /**
480 * Returns the expected size of the header.
481 * \returns the expected size of the header.
482 */
484 /**
485 * This method is used by Packet::AddHeader to
486 * store a header into the byte buffer of a packet.
487 *
488 * \param start an iterator which points to where the header should
489 * be written.
490 */
491 void Serialize(Buffer::Iterator start) const;
492 /**
493 * This method is used by Packet::RemoveHeader to
494 * re-create a header from the byte buffer of a packet.
495 *
496 * \param start an iterator which points to where the header should
497 * read from.
498 * \param messageSize the message size.
499 * \returns the number of bytes read.
500 */
501 uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize);
502 };
503
504 /**
505 * \ingroup olsr
506 * HNA (Host Network Association) Message Format
507 *
508 \verbatim
509 0 1 2 3
510 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
511 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
512 | Network Address |
513 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
514 | Netmask |
515 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 | Network Address |
517 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
518 | Netmask |
519 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
520 | ... |
521 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
522 \endverbatim
523 */
524 struct Hna
525 {
526 /**
527 * Association item structure.
528 */
530 {
531 Ipv4Address address; //!< IPv4 Address.
532 Ipv4Mask mask; //!< IPv4 netmask.
533 };
534
535 std::vector<Association> associations; //!< Association container.
536
537 /**
538 * This method is used to print the content of a Hna message.
539 * \param os output stream
540 */
541 void Print(std::ostream& os) const;
542 /**
543 * Returns the expected size of the header.
544 * \returns the expected size of the header.
545 */
547 /**
548 * This method is used by Packet::AddHeader to
549 * store a header into the byte buffer of a packet.
550 *
551 * \param start an iterator which points to where the header should
552 * be written.
553 */
554 void Serialize(Buffer::Iterator start) const;
555 /**
556 * This method is used by Packet::RemoveHeader to
557 * re-create a header from the byte buffer of a packet.
558 *
559 * \param start an iterator which points to where the header should
560 * read from.
561 * \param messageSize the message size.
562 * \returns the number of bytes read.
563 */
564 uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize);
565 };
566
567 private:
568 /**
569 * Structure holding the message content.
570 */
571 struct
572 {
573 Mid mid; //!< MID message (optional).
574 Hello hello; //!< HELLO message (optional).
575 Tc tc; //!< TC message (optional).
576 Hna hna; //!< HNA message (optional).
577 } m_message; //!< The actual message being carried.
578
579 public:
580 /**
581 * Set the message type to MID and return the message content.
582 * \returns The MID message.
583 */
585 {
586 if (m_messageType == 0)
587 {
589 }
590 else
591 {
593 }
594 return m_message.mid;
595 }
596
597 /**
598 * Set the message type to HELLO and return the message content.
599 * \returns The HELLO message.
600 */
602 {
603 if (m_messageType == 0)
604 {
606 }
607 else
608 {
610 }
611 return m_message.hello;
612 }
613
614 /**
615 * Set the message type to TC and return the message content.
616 * \returns The TC message.
617 */
619 {
620 if (m_messageType == 0)
621 {
623 }
624 else
625 {
627 }
628 return m_message.tc;
629 }
630
631 /**
632 * Set the message type to HNA and return the message content.
633 * \returns The HNA message.
634 */
636 {
637 if (m_messageType == 0)
638 {
640 }
641 else
642 {
644 }
645 return m_message.hna;
646 }
647
648 /**
649 * Get the MID message.
650 * \returns The MID message.
651 */
652 const Mid& GetMid() const
653 {
655 return m_message.mid;
656 }
657
658 /**
659 * Get the HELLO message.
660 * \returns The HELLO message.
661 */
662 const Hello& GetHello() const
663 {
665 return m_message.hello;
666 }
667
668 /**
669 * Get the TC message.
670 * \returns The TC message.
671 */
672 const Tc& GetTc() const
673 {
675 return m_message.tc;
676 }
677
678 /**
679 * Get the HNA message.
680 * \returns The HNA message.
681 */
682 const Hna& GetHna() const
683 {
685 return m_message.hna;
686 }
687};
688
689inline std::ostream&
690operator<<(std::ostream& os, const PacketHeader& packet)
691{
692 packet.Print(os);
693 return os;
694}
695
696inline std::ostream&
697operator<<(std::ostream& os, const MessageHeader& message)
698{
699 message.Print(os);
700 return os;
701}
702
703typedef std::vector<MessageHeader> MessageList;
704
705inline std::ostream&
706operator<<(std::ostream& os, const MessageList& messages)
707{
708 os << "[";
709 for (auto messageIter = messages.begin(); messageIter != messages.end(); messageIter++)
710 {
711 messageIter->Print(os);
712 if (messageIter + 1 != messages.end())
713 {
714 os << ", ";
715 }
716 }
717 os << "]";
718 return os;
719}
720
721} // namespace olsr
722} // namespace ns3
723
724#endif /* OLSR_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
a unique identifier for an interface.
Definition: type-id.h:59
This header can store HELP, TC, MID and HNA messages.
Definition: olsr-header.h:161
Mid mid
MID message (optional).
Definition: olsr-header.h:573
const Hello & GetHello() const
Get the HELLO message.
Definition: olsr-header.h:662
void SetOriginatorAddress(Ipv4Address originatorAddress)
Set the originator address.
Definition: olsr-header.h:217
Ipv4Address GetOriginatorAddress() const
Get the originator address.
Definition: olsr-header.h:226
void SetHopCount(uint8_t hopCount)
Set the hop count.
Definition: olsr-header.h:253
void Print(std::ostream &os) const override
Definition: olsr-header.cc:213
const Hna & GetHna() const
Get the HNA message.
Definition: olsr-header.h:682
MessageType m_messageType
The message type.
Definition: olsr-header.h:286
struct ns3::olsr::MessageHeader::@66 m_message
Structure holding the message content.
Mid & GetMid()
Set the message type to MID and return the message content.
Definition: olsr-header.h:584
Tc & GetTc()
Set the message type to TC and return the message content.
Definition: olsr-header.h:618
Hello & GetHello()
Set the message type to HELLO and return the message content.
Definition: olsr-header.h:601
uint8_t GetTimeToLive() const
Get the time to live.
Definition: olsr-header.h:244
const Mid & GetMid() const
Get the MID message.
Definition: olsr-header.h:652
uint8_t m_hopCount
The hop count.
Definition: olsr-header.h:290
Hello hello
HELLO message (optional).
Definition: olsr-header.h:574
Ipv4Address m_originatorAddress
The originator address.
Definition: olsr-header.h:288
const Tc & GetTc() const
Get the TC message.
Definition: olsr-header.h:672
Hna hna
HNA message (optional).
Definition: olsr-header.h:576
uint8_t m_vTime
The validity time.
Definition: olsr-header.h:287
void SetMessageSequenceNumber(uint16_t messageSequenceNumber)
Set the message sequence number.
Definition: olsr-header.h:271
uint8_t m_timeToLive
The time to live.
Definition: olsr-header.h:289
Tc tc
TC message (optional).
Definition: olsr-header.h:575
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: olsr-header.cc:181
void SetMessageType(MessageType messageType)
Set the message type.
Definition: olsr-header.h:181
uint8_t GetHopCount() const
Get the hop count.
Definition: olsr-header.h:262
MessageType GetMessageType() const
Get the message type.
Definition: olsr-header.h:190
Hna & GetHna()
Set the message type to HNA and return the message content.
Definition: olsr-header.h:635
Time GetVTime() const
Get the validity time.
Definition: olsr-header.h:208
void SetTimeToLive(uint8_t timeToLive)
Set the time to live.
Definition: olsr-header.h:235
uint16_t m_messageSize
The message size.
Definition: olsr-header.h:292
uint32_t GetSerializedSize() const override
Definition: olsr-header.cc:187
uint16_t GetMessageSequenceNumber() const
Get the message sequence number.
Definition: olsr-header.h:280
void SetVTime(Time time)
Set the validity time.
Definition: olsr-header.h:199
uint16_t m_messageSequenceNumber
The message sequence number.
Definition: olsr-header.h:291
uint32_t Deserialize(Buffer::Iterator start) override
Definition: olsr-header.cc:289
void Serialize(Buffer::Iterator start) const override
Definition: olsr-header.cc:258
static TypeId GetTypeId()
Get the type ID.
Definition: olsr-header.cc:171
MessageType
Message type.
Definition: olsr-header.h:167
The basic layout of any packet in OLSR is as follows (omitting IP and UDP headers):
Definition: olsr-header.h:79
void SetPacketSequenceNumber(uint16_t seqnum)
Set the packet sequence number.
Definition: olsr-header.h:106
static TypeId GetTypeId()
Get the type ID.
Definition: olsr-header.cc:113
uint32_t Deserialize(Buffer::Iterator start) override
Definition: olsr-header.cc:149
void SetPacketLength(uint16_t length)
Set the packet total length.
Definition: olsr-header.h:88
uint32_t GetSerializedSize() const override
Definition: olsr-header.cc:129
uint16_t m_packetLength
The packet length.
Definition: olsr-header.h:121
uint16_t GetPacketLength() const
Get the packet total length.
Definition: olsr-header.h:97
void Print(std::ostream &os) const override
Definition: olsr-header.cc:135
uint16_t m_packetSequenceNumber
The packet sequence number.
Definition: olsr-header.h:122
void Serialize(Buffer::Iterator start) const override
Definition: olsr-header.cc:141
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: olsr-header.cc:123
uint16_t GetPacketSequenceNumber() const
Get the packet sequence number.
Definition: olsr-header.h:115
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Willingness
Willingness for forwarding packets from other nodes.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:690
double EmfToSeconds(uint8_t olsrFormat)
Converts a number of seconds in the mantissa/exponent format to a decimal number.
Definition: olsr-header.cc:92
uint8_t SecondsToEmf(double seconds)
Converts a decimal number of seconds to the mantissa/exponent format.
Definition: olsr-header.cc:49
std::vector< MessageHeader > MessageList
Definition: olsr-header.h:703
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: olsr.py:1
HELLO Message Format.
Definition: olsr-header.h:386
void SetHTime(Time time)
Set the HELLO emission interval.
Definition: olsr-header.h:403
uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize)
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet.
Definition: olsr-header.cc:455
Willingness willingness
The willingness of a node to carry and forward traffic for other nodes.
Definition: olsr-header.h:417
void Print(std::ostream &os) const
This method is used to print the content of a Hello message.
Definition: olsr-header.cc:396
std::vector< LinkMessage > linkMessages
Link messages container.
Definition: olsr-header.h:419
uint8_t hTime
HELLO emission interval (coded)
Definition: olsr-header.h:397
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition: olsr-header.cc:383
Time GetHTime() const
Get the HELLO emission interval.
Definition: olsr-header.h:412
void Serialize(Buffer::Iterator start) const
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet.
Definition: olsr-header.cc:424
HNA (Host Network Association) Message Format.
Definition: olsr-header.h:525
void Serialize(Buffer::Iterator start) const
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet.
Definition: olsr-header.cc:584
uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize)
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet.
Definition: olsr-header.cc:596
std::vector< Association > associations
Association container.
Definition: olsr-header.h:535
void Print(std::ostream &os) const
This method is used to print the content of a Hna message.
Definition: olsr-header.cc:564
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition: olsr-header.cc:558
MID Message Format.
Definition: olsr-header.h:323
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition: olsr-header.cc:325
std::vector< Ipv4Address > interfaceAddresses
Interface Address container.
Definition: olsr-header.h:324
void Serialize(Buffer::Iterator start) const
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet.
Definition: olsr-header.cc:351
void Print(std::ostream &os) const
This method is used to print the content of a MID message.
Definition: olsr-header.cc:331
uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize)
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet.
Definition: olsr-header.cc:363
TC Message Format.
Definition: olsr-header.h:470
uint16_t ansn
Advertised Neighbor Sequence Number.
Definition: olsr-header.h:472
std::vector< Ipv4Address > neighborAddresses
Neighbor address container.
Definition: olsr-header.h:471
void Serialize(Buffer::Iterator start) const
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet.
Definition: olsr-header.cc:520
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition: olsr-header.cc:493
void Print(std::ostream &os) const
This method is used to print the content of a Tc message.
Definition: olsr-header.cc:499
uint32_t Deserialize(Buffer::Iterator start, uint32_t messageSize)
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet.
Definition: olsr-header.cc:534