A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
21
namespace
ns3
22
{
23
namespace
olsr
24
{
25
26
double
EmfToSeconds
(uint8_t emf);
27
uint8_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
*/
67
class
PacketHeader
:
public
Header
68
{
69
public
:
70
PacketHeader
();
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
{
97
m_packetSequenceNumber
= seqnum;
98
}
99
100
/**
101
* Get the packet sequence number.
102
* \returns The packet sequence number.
103
*/
104
uint16_t
GetPacketSequenceNumber
()
const
105
{
106
return
m_packetSequenceNumber
;
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
*/
149
class
MessageHeader
:
public
Header
150
{
151
public
:
152
/**
153
* Message type
154
*/
155
enum
MessageType
156
{
157
HELLO_MESSAGE
= 1,
158
TC_MESSAGE
= 2,
159
MID_MESSAGE
= 3,
160
HNA_MESSAGE
= 4,
161
};
162
163
MessageHeader
();
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
*/
179
MessageType
GetMessageType
()
const
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
{
190
m_vTime
=
SecondsToEmf
(time.
GetSeconds
());
191
}
192
193
/**
194
* Get the validity time.
195
* \return The validity time.
196
*/
197
Time
GetVTime
()
const
198
{
199
return
Seconds
(
EmfToSeconds
(
m_vTime
));
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
*/
215
Ipv4Address
GetOriginatorAddress
()
const
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
*/
269
uint16_t
GetMessageSequenceNumber
()
const
270
{
271
return
m_messageSequenceNumber
;
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
*/
323
uint32_t
GetSerializedSize
()
const
;
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
*/
379
struct
LinkMessage
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
*/
401
Time
GetHTime
()
const
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
*/
419
uint32_t
GetSerializedSize
()
const
;
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
*/
472
uint32_t
GetSerializedSize
()
const
;
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
*/
518
struct
Association
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
*/
535
uint32_t
GetSerializedSize
()
const
;
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
*/
573
Mid
&
GetMid
()
574
{
575
if
(
m_messageType
== 0)
576
{
577
m_messageType
=
MID_MESSAGE
;
578
}
579
else
580
{
581
NS_ASSERT
(
m_messageType
==
MID_MESSAGE
);
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
*/
590
Hello
&
GetHello
()
591
{
592
if
(
m_messageType
== 0)
593
{
594
m_messageType
=
HELLO_MESSAGE
;
595
}
596
else
597
{
598
NS_ASSERT
(
m_messageType
==
HELLO_MESSAGE
);
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
*/
607
Tc
&
GetTc
()
608
{
609
if
(
m_messageType
== 0)
610
{
611
m_messageType
=
TC_MESSAGE
;
612
}
613
else
614
{
615
NS_ASSERT
(
m_messageType
==
TC_MESSAGE
);
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
*/
624
Hna
&
GetHna
()
625
{
626
if
(
m_messageType
== 0)
627
{
628
m_messageType
=
HNA_MESSAGE
;
629
}
630
else
631
{
632
NS_ASSERT
(
m_messageType
==
HNA_MESSAGE
);
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
{
643
NS_ASSERT
(
m_messageType
==
MID_MESSAGE
);
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
{
653
NS_ASSERT
(
m_messageType
==
HELLO_MESSAGE
);
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
{
663
NS_ASSERT
(
m_messageType
==
TC_MESSAGE
);
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
{
673
NS_ASSERT
(
m_messageType
==
HNA_MESSAGE
);
674
return
m_message
.hna;
675
}
676
};
677
678
inline
std::ostream&
679
operator<<
(std::ostream& os,
const
PacketHeader
& packet)
680
{
681
packet.
Print
(os);
682
return
os;
683
}
684
685
inline
std::ostream&
686
operator<<
(std::ostream& os,
const
MessageHeader
& message)
687
{
688
message.
Print
(os);
689
return
os;
690
}
691
692
typedef
std::vector<MessageHeader>
MessageList
;
693
694
inline
std::ostream&
695
operator<<
(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 */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition
ipv4-address.h:246
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::Time::GetSeconds
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition
nstime.h:392
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::olsr::MessageHeader
This header can store HELP, TC, MID and HNA messages.
Definition
olsr-header.h:150
ns3::olsr::MessageHeader::mid
Mid mid
MID message (optional).
Definition
olsr-header.h:562
ns3::olsr::MessageHeader::~MessageHeader
~MessageHeader() override
Definition
olsr-header.cc:155
ns3::olsr::MessageHeader::GetHello
const Hello & GetHello() const
Get the HELLO message.
Definition
olsr-header.h:651
ns3::olsr::MessageHeader::SetOriginatorAddress
void SetOriginatorAddress(Ipv4Address originatorAddress)
Set the originator address.
Definition
olsr-header.h:206
ns3::olsr::MessageHeader::GetOriginatorAddress
Ipv4Address GetOriginatorAddress() const
Get the originator address.
Definition
olsr-header.h:215
ns3::olsr::MessageHeader::SetHopCount
void SetHopCount(uint8_t hopCount)
Set the hop count.
Definition
olsr-header.h:242
ns3::olsr::MessageHeader::Print
void Print(std::ostream &os) const override
Definition
olsr-header.cc:202
ns3::olsr::MessageHeader::GetHna
const Hna & GetHna() const
Get the HNA message.
Definition
olsr-header.h:671
ns3::olsr::MessageHeader::m_messageType
MessageType m_messageType
The message type.
Definition
olsr-header.h:275
ns3::olsr::MessageHeader::m_message
struct ns3::olsr::MessageHeader::@66 m_message
Structure holding the message content.
ns3::olsr::MessageHeader::GetMid
Mid & GetMid()
Set the message type to MID and return the message content.
Definition
olsr-header.h:573
ns3::olsr::MessageHeader::GetTc
Tc & GetTc()
Set the message type to TC and return the message content.
Definition
olsr-header.h:607
ns3::olsr::MessageHeader::GetHello
Hello & GetHello()
Set the message type to HELLO and return the message content.
Definition
olsr-header.h:590
ns3::olsr::MessageHeader::GetTimeToLive
uint8_t GetTimeToLive() const
Get the time to live.
Definition
olsr-header.h:233
ns3::olsr::MessageHeader::GetMid
const Mid & GetMid() const
Get the MID message.
Definition
olsr-header.h:641
ns3::olsr::MessageHeader::m_hopCount
uint8_t m_hopCount
The hop count.
Definition
olsr-header.h:279
ns3::olsr::MessageHeader::hello
Hello hello
HELLO message (optional).
Definition
olsr-header.h:563
ns3::olsr::MessageHeader::m_originatorAddress
Ipv4Address m_originatorAddress
The originator address.
Definition
olsr-header.h:277
ns3::olsr::MessageHeader::GetTc
const Tc & GetTc() const
Get the TC message.
Definition
olsr-header.h:661
ns3::olsr::MessageHeader::hna
Hna hna
HNA message (optional).
Definition
olsr-header.h:565
ns3::olsr::MessageHeader::m_vTime
uint8_t m_vTime
The validity time.
Definition
olsr-header.h:276
ns3::olsr::MessageHeader::SetMessageSequenceNumber
void SetMessageSequenceNumber(uint16_t messageSequenceNumber)
Set the message sequence number.
Definition
olsr-header.h:260
ns3::olsr::MessageHeader::m_timeToLive
uint8_t m_timeToLive
The time to live.
Definition
olsr-header.h:278
ns3::olsr::MessageHeader::tc
Tc tc
TC message (optional).
Definition
olsr-header.h:564
ns3::olsr::MessageHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
olsr-header.cc:170
ns3::olsr::MessageHeader::SetMessageType
void SetMessageType(MessageType messageType)
Set the message type.
Definition
olsr-header.h:170
ns3::olsr::MessageHeader::GetHopCount
uint8_t GetHopCount() const
Get the hop count.
Definition
olsr-header.h:251
ns3::olsr::MessageHeader::MessageHeader
MessageHeader()
Definition
olsr-header.cc:150
ns3::olsr::MessageHeader::GetMessageType
MessageType GetMessageType() const
Get the message type.
Definition
olsr-header.h:179
ns3::olsr::MessageHeader::GetHna
Hna & GetHna()
Set the message type to HNA and return the message content.
Definition
olsr-header.h:624
ns3::olsr::MessageHeader::GetVTime
Time GetVTime() const
Get the validity time.
Definition
olsr-header.h:197
ns3::olsr::MessageHeader::SetTimeToLive
void SetTimeToLive(uint8_t timeToLive)
Set the time to live.
Definition
olsr-header.h:224
ns3::olsr::MessageHeader::m_messageSize
uint16_t m_messageSize
The message size.
Definition
olsr-header.h:281
ns3::olsr::MessageHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
olsr-header.cc:176
ns3::olsr::MessageHeader::GetMessageSequenceNumber
uint16_t GetMessageSequenceNumber() const
Get the message sequence number.
Definition
olsr-header.h:269
ns3::olsr::MessageHeader::SetVTime
void SetVTime(Time time)
Set the validity time.
Definition
olsr-header.h:188
ns3::olsr::MessageHeader::m_messageSequenceNumber
uint16_t m_messageSequenceNumber
The message sequence number.
Definition
olsr-header.h:280
ns3::olsr::MessageHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
olsr-header.cc:278
ns3::olsr::MessageHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
olsr-header.cc:247
ns3::olsr::MessageHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
olsr-header.cc:160
ns3::olsr::MessageHeader::MessageType
MessageType
Message type.
Definition
olsr-header.h:156
ns3::olsr::MessageHeader::TC_MESSAGE
@ TC_MESSAGE
Definition
olsr-header.h:158
ns3::olsr::MessageHeader::HNA_MESSAGE
@ HNA_MESSAGE
Definition
olsr-header.h:160
ns3::olsr::MessageHeader::MID_MESSAGE
@ MID_MESSAGE
Definition
olsr-header.h:159
ns3::olsr::MessageHeader::HELLO_MESSAGE
@ HELLO_MESSAGE
Definition
olsr-header.h:157
ns3::olsr::PacketHeader
The basic layout of any packet in OLSR is as follows (omitting IP and UDP headers):
Definition
olsr-header.h:68
ns3::olsr::PacketHeader::PacketHeader
PacketHeader()
Definition
olsr-header.cc:93
ns3::olsr::PacketHeader::SetPacketSequenceNumber
void SetPacketSequenceNumber(uint16_t seqnum)
Set the packet sequence number.
Definition
olsr-header.h:95
ns3::olsr::PacketHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
olsr-header.cc:102
ns3::olsr::PacketHeader::~PacketHeader
~PacketHeader() override
Definition
olsr-header.cc:97
ns3::olsr::PacketHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
olsr-header.cc:138
ns3::olsr::PacketHeader::SetPacketLength
void SetPacketLength(uint16_t length)
Set the packet total length.
Definition
olsr-header.h:77
ns3::olsr::PacketHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
olsr-header.cc:118
ns3::olsr::PacketHeader::m_packetLength
uint16_t m_packetLength
The packet length.
Definition
olsr-header.h:110
ns3::olsr::PacketHeader::GetPacketLength
uint16_t GetPacketLength() const
Get the packet total length.
Definition
olsr-header.h:86
ns3::olsr::PacketHeader::Print
void Print(std::ostream &os) const override
Definition
olsr-header.cc:124
ns3::olsr::PacketHeader::m_packetSequenceNumber
uint16_t m_packetSequenceNumber
The packet sequence number.
Definition
olsr-header.h:111
ns3::olsr::PacketHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
olsr-header.cc:130
ns3::olsr::PacketHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
olsr-header.cc:112
ns3::olsr::PacketHeader::GetPacketSequenceNumber
uint16_t GetPacketSequenceNumber() const
Get the packet sequence number.
Definition
olsr-header.h:104
uint32_t
NS_ASSERT
#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
ns3::olsr::Willingness
Willingness
Willingness for forwarding packets from other nodes.
Definition
olsr-repositories.h:36
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
ns3::olsr::operator<<
std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition
olsr-header.h:679
ns3::olsr::EmfToSeconds
double EmfToSeconds(uint8_t olsrFormat)
Converts a number of seconds in the mantissa/exponent format to a decimal number.
Definition
olsr-header.cc:81
ns3::olsr::SecondsToEmf
uint8_t SecondsToEmf(double seconds)
Converts a decimal number of seconds to the mantissa/exponent format.
Definition
olsr-header.cc:38
ns3::olsr::MessageList
std::vector< MessageHeader > MessageList
Definition
olsr-header.h:692
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
olsr
Definition
olsr.py:1
olsr-repositories.h
ns3::olsr::MessageHeader::Hello::LinkMessage
Link message item.
Definition
olsr-header.h:380
ns3::olsr::MessageHeader::Hello::LinkMessage::linkCode
uint8_t linkCode
Link code.
Definition
olsr-header.h:381
ns3::olsr::MessageHeader::Hello::LinkMessage::neighborInterfaceAddresses
std::vector< Ipv4Address > neighborInterfaceAddresses
Neighbor interface address container.
Definition
olsr-header.h:383
ns3::olsr::MessageHeader::Hello
HELLO Message Format.
Definition
olsr-header.h:375
ns3::olsr::MessageHeader::Hello::SetHTime
void SetHTime(Time time)
Set the HELLO emission interval.
Definition
olsr-header.h:392
ns3::olsr::MessageHeader::Hello::Deserialize
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:444
ns3::olsr::MessageHeader::Hello::willingness
Willingness willingness
The willingness of a node to carry and forward traffic for other nodes.
Definition
olsr-header.h:406
ns3::olsr::MessageHeader::Hello::Print
void Print(std::ostream &os) const
This method is used to print the content of a Hello message.
Definition
olsr-header.cc:385
ns3::olsr::MessageHeader::Hello::linkMessages
std::vector< LinkMessage > linkMessages
Link messages container.
Definition
olsr-header.h:408
ns3::olsr::MessageHeader::Hello::hTime
uint8_t hTime
HELLO emission interval (coded)
Definition
olsr-header.h:386
ns3::olsr::MessageHeader::Hello::GetSerializedSize
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition
olsr-header.cc:372
ns3::olsr::MessageHeader::Hello::GetHTime
Time GetHTime() const
Get the HELLO emission interval.
Definition
olsr-header.h:401
ns3::olsr::MessageHeader::Hello::Serialize
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:413
ns3::olsr::MessageHeader::Hna::Association
Association item structure.
Definition
olsr-header.h:519
ns3::olsr::MessageHeader::Hna::Association::mask
Ipv4Mask mask
IPv4 netmask.
Definition
olsr-header.h:521
ns3::olsr::MessageHeader::Hna::Association::address
Ipv4Address address
IPv4 Address.
Definition
olsr-header.h:520
ns3::olsr::MessageHeader::Hna
HNA (Host Network Association) Message Format.
Definition
olsr-header.h:514
ns3::olsr::MessageHeader::Hna::Serialize
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:573
ns3::olsr::MessageHeader::Hna::Deserialize
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:585
ns3::olsr::MessageHeader::Hna::associations
std::vector< Association > associations
Association container.
Definition
olsr-header.h:524
ns3::olsr::MessageHeader::Hna::Print
void Print(std::ostream &os) const
This method is used to print the content of a Hna message.
Definition
olsr-header.cc:553
ns3::olsr::MessageHeader::Hna::GetSerializedSize
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition
olsr-header.cc:547
ns3::olsr::MessageHeader::Mid
MID Message Format.
Definition
olsr-header.h:312
ns3::olsr::MessageHeader::Mid::GetSerializedSize
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition
olsr-header.cc:314
ns3::olsr::MessageHeader::Mid::interfaceAddresses
std::vector< Ipv4Address > interfaceAddresses
Interface Address container.
Definition
olsr-header.h:313
ns3::olsr::MessageHeader::Mid::Serialize
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:340
ns3::olsr::MessageHeader::Mid::Print
void Print(std::ostream &os) const
This method is used to print the content of a MID message.
Definition
olsr-header.cc:320
ns3::olsr::MessageHeader::Mid::Deserialize
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:352
ns3::olsr::MessageHeader::Tc
TC Message Format.
Definition
olsr-header.h:459
ns3::olsr::MessageHeader::Tc::ansn
uint16_t ansn
Advertised Neighbor Sequence Number.
Definition
olsr-header.h:461
ns3::olsr::MessageHeader::Tc::neighborAddresses
std::vector< Ipv4Address > neighborAddresses
Neighbor address container.
Definition
olsr-header.h:460
ns3::olsr::MessageHeader::Tc::Serialize
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:509
ns3::olsr::MessageHeader::Tc::GetSerializedSize
uint32_t GetSerializedSize() const
Returns the expected size of the header.
Definition
olsr-header.cc:482
ns3::olsr::MessageHeader::Tc::Print
void Print(std::ostream &os) const
This method is used to print the content of a Tc message.
Definition
olsr-header.cc:488
ns3::olsr::MessageHeader::Tc::Deserialize
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:523
src
olsr
model
olsr-header.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0