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