A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
aodv-packet.h
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 IITP RAS
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Based on
19
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
20
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
21
*
22
* AODV-UU implementation by Erik Nordström of Uppsala University
23
* http://core.it.uu.se/core/index.php/AODV-UU
24
*
25
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
26
* Pavel Boyko <boyko@iitp.ru>
27
*/
28
#ifndef AODVPACKET_H
29
#define AODVPACKET_H
30
31
#include <iostream>
32
#include "ns3/header.h"
33
#include "ns3/enum.h"
34
#include "ns3/ipv4-address.h"
35
#include <map>
36
#include "ns3/nstime.h"
37
38
namespace
ns3 {
39
namespace
aodv {
40
41
enum
MessageType
42
{
43
AODVTYPE_RREQ = 1,
44
AODVTYPE_RREP = 2,
45
AODVTYPE_RERR = 3,
46
AODVTYPE_RREP_ACK = 4
47
};
48
53
class
TypeHeader
:
public
Header
54
{
55
public
:
57
TypeHeader
(MessageType t = AODVTYPE_RREQ);
58
60
//\{
61
static
TypeId
GetTypeId ();
62
TypeId
GetInstanceTypeId
()
const
;
63
uint32_t
GetSerializedSize
()
const
;
64
void
Serialize
(
Buffer::Iterator
start)
const
;
65
uint32_t
Deserialize
(
Buffer::Iterator
start);
66
void
Print
(std::ostream &os)
const
;
67
//\}
68
70
MessageType
Get
()
const
{
return
m_type; }
72
bool
IsValid
()
const
{
return
m_valid; }
73
bool
operator== (
TypeHeader
const
& o)
const
;
74
private
:
75
MessageType m_type;
76
bool
m_valid;
77
};
78
79
std::ostream &
operator<<
(std::ostream & os, TypeHeader
const
& h);
80
102
class
RreqHeader
:
public
Header
103
{
104
public
:
106
RreqHeader
(uint8_t flags = 0, uint8_t reserved = 0, uint8_t hopCount = 0,
107
uint32_t requestID = 0,
Ipv4Address
dst =
Ipv4Address
(),
108
uint32_t dstSeqNo = 0,
Ipv4Address
origin =
Ipv4Address
(),
109
uint32_t originSeqNo = 0, uint16_t channel = 1);
110
112
//\{
113
static
TypeId
GetTypeId ();
114
TypeId
GetInstanceTypeId
()
const
;
115
uint32_t
GetSerializedSize
()
const
;
116
void
Serialize
(
Buffer::Iterator
start)
const
;
117
uint32_t
Deserialize
(
Buffer::Iterator
start);
118
void
Print
(std::ostream &os)
const
;
119
//\}
120
122
//\{
123
void
SetHopCount (uint8_t count) {
m_hopCount
= count; }
124
uint8_t GetHopCount ()
const
{
return
m_hopCount
; }
125
void
SetId (uint32_t
id
) {
m_requestID
= id; }
126
uint32_t GetId ()
const
{
return
m_requestID
; }
127
void
SetDst (
Ipv4Address
a) {
m_dst
= a; }
128
Ipv4Address
GetDst ()
const
{
return
m_dst
; }
129
void
SetDstSeqno (uint32_t s) {
m_dstSeqNo
= s; }
130
uint32_t GetDstSeqno ()
const
{
return
m_dstSeqNo
; }
131
void
SetOrigin (
Ipv4Address
a) {
m_origin
= a; }
132
Ipv4Address
GetOrigin ()
const
{
return
m_origin
; }
133
void
SetOriginSeqno (uint32_t s) {
m_originSeqNo
= s; }
134
uint32_t GetOriginSeqno ()
const
{
return
m_originSeqNo
; }
135
void
SetRXChannel (uint16_t s) {
m_channelNo
= s; }
136
uint16_t GetRXChannel ()
const
{
return
m_channelNo
; }
137
//\}
138
140
//\{
141
void
SetGratiousRrep (
bool
f);
142
bool
GetGratiousRrep ()
const
;
143
void
SetDestinationOnly (
bool
f);
144
bool
GetDestinationOnly ()
const
;
145
void
SetUnknownSeqno (
bool
f);
146
bool
GetUnknownSeqno ()
const
;
147
//\}
148
149
bool
operator== (
RreqHeader
const
& o)
const
;
150
private
:
151
uint8_t
m_flags
;
152
uint8_t
m_reserved
;
153
uint8_t
m_hopCount
;
154
uint32_t
m_requestID
;
155
Ipv4Address
m_dst
;
156
uint32_t
m_dstSeqNo
;
157
Ipv4Address
m_origin
;
158
uint32_t
m_originSeqNo
;
159
uint16_t
m_channelNo
;
160
};
161
162
std::ostream &
operator<<
(std::ostream & os,
RreqHeader
const
&);
163
183
class
RrepHeader
:
public
Header
184
{
185
public
:
187
RrepHeader
(uint8_t prefixSize = 0, uint8_t hopCount = 0,
Ipv4Address
dst =
188
Ipv4Address
(), uint32_t dstSeqNo = 0,
Ipv4Address
origin =
189
Ipv4Address
(),
Time
lifetime =
MilliSeconds
(0),
190
uint16_t channel = 1);
192
//\{
193
static
TypeId
GetTypeId ();
194
TypeId
GetInstanceTypeId
()
const
;
195
uint32_t
GetSerializedSize
()
const
;
196
void
Serialize
(
Buffer::Iterator
start)
const
;
197
uint32_t
Deserialize
(
Buffer::Iterator
start);
198
void
Print
(std::ostream &os)
const
;
199
//\}
200
202
//\{
203
void
SetHopCount (uint8_t count) {
m_hopCount
= count; }
204
uint8_t GetHopCount ()
const
{
return
m_hopCount
; }
205
void
SetDst (
Ipv4Address
a) {
m_dst
= a; }
206
Ipv4Address
GetDst ()
const
{
return
m_dst
; }
207
void
SetDstSeqno (uint32_t s) {
m_dstSeqNo
= s; }
208
uint32_t GetDstSeqno ()
const
{
return
m_dstSeqNo
; }
209
void
SetOrigin (
Ipv4Address
a) {
m_origin
= a; }
210
Ipv4Address
GetOrigin ()
const
{
return
m_origin
; }
211
void
SetRXChannel (uint16_t s) {
m_channelNo
= s; }
212
uint16_t GetRXChannel ()
const
{
return
m_channelNo
; }
213
void
SetLifeTime (
Time
t);
214
Time
GetLifeTime ()
const
;
215
//\}
216
218
//\{
219
void
SetAckRequired (
bool
f);
220
bool
GetAckRequired ()
const
;
221
void
SetPrefixSize (uint8_t sz);
222
uint8_t GetPrefixSize ()
const
;
223
//\}
224
226
void
SetHello
(
Ipv4Address
src, uint32_t srcSeqNo,
Time
lifetime);
227
228
bool
operator== (
RrepHeader
const
& o)
const
;
229
private
:
230
uint8_t
m_flags
;
231
uint8_t
m_prefixSize
;
232
uint8_t
m_hopCount
;
233
Ipv4Address
m_dst
;
234
uint32_t
m_dstSeqNo
;
235
Ipv4Address
m_origin
;
236
uint32_t
m_lifeTime
;
237
uint16_t
m_channelNo
;
238
};
239
240
std::ostream &
operator<<
(std::ostream & os,
RrepHeader
const
&);
241
253
class
RrepAckHeader
:
public
Header
254
{
255
public
:
257
RrepAckHeader
();
258
260
//\{
261
static
TypeId
GetTypeId ();
262
TypeId
GetInstanceTypeId
()
const
;
263
uint32_t
GetSerializedSize
()
const
;
264
void
Serialize
(
Buffer::Iterator
start)
const
;
265
uint32_t
Deserialize
(
Buffer::Iterator
start);
266
void
Print
(std::ostream &os)
const
;
267
//\}
268
269
bool
operator== (
RrepAckHeader
const
& o)
const
;
270
private
:
271
uint8_t m_reserved;
272
};
273
std::ostream &
operator<<
(std::ostream & os,
RrepAckHeader
const
&);
274
275
295
class
RerrHeader
:
public
Header
296
{
297
public
:
299
RerrHeader
();
300
302
//\{
303
static
TypeId
GetTypeId ();
304
TypeId
GetInstanceTypeId
()
const
;
305
uint32_t
GetSerializedSize
()
const
;
306
void
Serialize
(
Buffer::Iterator
i)
const
;
307
uint32_t
Deserialize
(
Buffer::Iterator
start);
308
void
Print
(std::ostream &os)
const
;
309
//\}
310
312
//\{
313
void
SetNoDelete (
bool
f);
314
bool
GetNoDelete ()
const
;
315
//\}
316
321
bool
AddUnDestination
(
Ipv4Address
dst, uint32_t seqNo);
325
bool
RemoveUnDestination
(std::pair<Ipv4Address, uint32_t> & un);
327
void
Clear
();
329
uint8_t
GetDestCount
()
const
{
return
(uint8_t)
m_unreachableDstSeqNo
.size (); }
330
bool
operator== (
RerrHeader
const
& o)
const
;
331
private
:
332
uint8_t
m_flag
;
333
uint8_t
m_reserved
;
334
336
std::map<Ipv4Address, uint32_t>
m_unreachableDstSeqNo
;
337
};
338
339
std::ostream &
operator<<
(std::ostream & os,
RerrHeader
const
&);
340
}
341
}
342
#endif
/* AODVPACKET_H */
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::Time
keep track of time unit.
Definition:
nstime.h:149
ns3::aodv::RrepAckHeader::RrepAckHeader
RrepAckHeader()
c-tor
Definition:
aodv-packet.cc:431
ns3::aodv::TypeHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Definition:
aodv-packet.cc:55
ns3::aodv::RrepAckHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Definition:
aodv-packet.cc:448
ns3::aodv::RerrHeader
Route Error (RERR) Message Format.
Definition:
aodv-packet.h:295
ns3::aodv::RerrHeader::Serialize
void Serialize(Buffer::Iterator i) const
Definition:
aodv-packet.cc:526
ns3::aodv::RreqHeader::m_requestID
uint32_t m_requestID
RREQ ID.
Definition:
aodv-packet.h:154
ns3::aodv::RreqHeader::RreqHeader
RreqHeader(uint8_t flags=0, uint8_t reserved=0, uint8_t hopCount=0, uint32_t requestID=0, Ipv4Address dst=Ipv4Address(), uint32_t dstSeqNo=0, Ipv4Address origin=Ipv4Address(), uint32_t originSeqNo=0, uint16_t channel=1)
c-tor
Definition:
aodv-packet.cc:142
ns3::aodv::RrepHeader::m_lifeTime
uint32_t m_lifeTime
Lifetime (in milliseconds)
Definition:
aodv-packet.h:236
ns3::aodv::RreqHeader
Route Request (RREQ) Message Format.
Definition:
aodv-packet.h:102
ns3::aodv::RrepAckHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
aodv-packet.cc:466
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::aodv::RerrHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition:
aodv-packet.cc:520
ns3::aodv::RreqHeader::Print
void Print(std::ostream &os) const
Definition:
aodv-packet.cc:207
ns3::aodv::RerrHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
aodv-packet.cc:540
ns3::aodv::TypeHeader::IsValid
bool IsValid() const
Check that type if valid.
Definition:
aodv-packet.h:72
ns3::aodv::TypeHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
aodv-packet.cc:67
ns3::aodv::RerrHeader::Clear
void Clear()
Clear header.
Definition:
aodv-packet.cc:611
ns3::aodv::TypeHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
aodv-packet.cc:73
ns3::aodv::RreqHeader::m_originSeqNo
uint32_t m_originSeqNo
Source Sequence Number.
Definition:
aodv-packet.h:158
ns3::aodv::RrepHeader::m_origin
Ipv4Address m_origin
Source IP Address.
Definition:
aodv-packet.h:235
ns3::aodv::RrepHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
aodv-packet.cc:329
ns3::aodv::RerrHeader::GetDestCount
uint8_t GetDestCount() const
Return number of unreachable destinations in RERR message.
Definition:
aodv-packet.h:329
ns3::aodv::RreqHeader::m_channelNo
uint16_t m_channelNo
RX channel of source.
Definition:
aodv-packet.h:159
ns3::aodv::RerrHeader::AddUnDestination
bool AddUnDestination(Ipv4Address dst, uint32_t seqNo)
Definition:
aodv-packet.cc:589
ns3::aodv::RerrHeader::m_flag
uint8_t m_flag
No delete flag.
Definition:
aodv-packet.h:332
ns3::aodv::RrepHeader::Print
void Print(std::ostream &os) const
Definition:
aodv-packet.cc:348
ns3::aodv::TypeHeader::Print
void Print(std::ostream &os) const
Definition:
aodv-packet.cc:97
ns3::aodv::RreqHeader::m_origin
Ipv4Address m_origin
Originator IP Address.
Definition:
aodv-packet.h:157
ns3::aodv::RrepHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
aodv-packet.cc:316
ns3::aodv::RerrHeader::RerrHeader
RerrHeader()
c-tor
Definition:
aodv-packet.cc:496
ns3::aodv::RerrHeader::m_reserved
uint8_t m_reserved
Not used.
Definition:
aodv-packet.h:333
ns3::aodv::RrepHeader
Route Reply (RREP) Message Format.
Definition:
aodv-packet.h:183
ns3::aodv::RrepHeader::m_flags
uint8_t m_flags
A - acknowledgment required flag.
Definition:
aodv-packet.h:230
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:43
ns3::aodv::RrepHeader::m_dst
Ipv4Address m_dst
Destination IP Address.
Definition:
aodv-packet.h:233
ns3::aodv::RreqHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
aodv-packet.cc:174
ns3::aodv::RrepHeader::SetHello
void SetHello(Ipv4Address src, uint32_t srcSeqNo, Time lifetime)
Configure RREP to be a Hello message.
Definition:
aodv-packet.cc:409
ns3::aodv::RrepAckHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
aodv-packet.cc:460
ns3::aodv::RrepAckHeader::Print
void Print(std::ostream &os) const
Definition:
aodv-packet.cc:476
ns3::aodv::RerrHeader::RemoveUnDestination
bool RemoveUnDestination(std::pair< Ipv4Address, uint32_t > &un)
Definition:
aodv-packet.cc:600
ns3::aodv::RrepHeader::m_dstSeqNo
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition:
aodv-packet.h:234
ns3::aodv::TypeHeader::TypeHeader
TypeHeader(MessageType t=AODVTYPE_RREQ)
c-tor
Definition:
aodv-packet.cc:39
ns3::aodv::RerrHeader::m_unreachableDstSeqNo
std::map< Ipv4Address, uint32_t > m_unreachableDstSeqNo
List of Unreachable destination: IP addresses and sequence numbers.
Definition:
aodv-packet.h:336
ns3::aodv::RrepHeader::m_channelNo
uint16_t m_channelNo
Source RX channel number.
Definition:
aodv-packet.h:237
ns3::aodv::RrepAckHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition:
aodv-packet.cc:454
ns3::aodv::RrepHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition:
aodv-packet.cc:310
ns3::aodv::RrepAckHeader
Route Reply Acknowledgment (RREP-ACK) Message Format.
Definition:
aodv-packet.h:253
ns3::aodv::RreqHeader::m_hopCount
uint8_t m_hopCount
Hop Count.
Definition:
aodv-packet.h:153
ns3::aodv::RreqHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
aodv-packet.cc:188
ns3::aodv::RerrHeader::Print
void Print(std::ostream &os) const
Definition:
aodv-packet.cc:562
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::aodv::RreqHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition:
aodv-packet.cc:168
ns3::aodv::RreqHeader::m_dst
Ipv4Address m_dst
Destination IP Address.
Definition:
aodv-packet.h:155
ns3::aodv::TypeHeader::GetSerializedSize
uint32_t GetSerializedSize() const
Definition:
aodv-packet.cc:61
ns3::aodv::RrepHeader::RrepHeader
RrepHeader(uint8_t prefixSize=0, uint8_t hopCount=0, Ipv4Address dst=Ipv4Address(), uint32_t dstSeqNo=0, Ipv4Address origin=Ipv4Address(), Time lifetime=MilliSeconds(0), uint16_t channel=1)
c-tor
Definition:
aodv-packet.cc:283
ns3::aodv::TypeHeader
AODV types.
Definition:
aodv-packet.h:53
ns3::MilliSeconds
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
Definition:
nstime.h:601
ns3::aodv::RrepHeader::m_hopCount
uint8_t m_hopCount
Hop Count.
Definition:
aodv-packet.h:232
ns3::aodv::RreqHeader::m_reserved
uint8_t m_reserved
Not used.
Definition:
aodv-packet.h:152
ns3::aodv::RerrHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Definition:
aodv-packet.cc:514
ns3::aodv::RreqHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Definition:
aodv-packet.cc:162
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:44
ns3::aodv::TypeHeader::Get
MessageType Get() const
Return type.
Definition:
aodv-packet.h:70
ns3::aodv::RreqHeader::m_flags
uint8_t m_flags
|J|R|G|D|U| bit flags, see RFC
Definition:
aodv-packet.h:151
ns3::aodv::RrepHeader::m_prefixSize
uint8_t m_prefixSize
Prefix Size.
Definition:
aodv-packet.h:231
ns3::aodv::RreqHeader::m_dstSeqNo
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition:
aodv-packet.h:156
ns3::aodv::RrepHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Definition:
aodv-packet.cc:304
src
aodv
model
aodv-packet.h
Generated on Sun Mar 16 2014 11:25:01 for ns-3 by
1.8.6