/usr/include/ns3.27/ns3/aodv-packet.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Based on
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
*
* AODV-UU implementation by Erik Nordström of Uppsala University
* http://core.it.uu.se/core/index.php/AODV-UU
*
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
* Pavel Boyko <boyko@iitp.ru>
*/
#ifndef AODVPACKET_H
#define AODVPACKET_H
#include <iostream>
#include "ns3/header.h"
#include "ns3/enum.h"
#include "ns3/ipv4-address.h"
#include <map>
#include "ns3/nstime.h"
namespace ns3 {
namespace aodv {
/**
* \ingroup aodv
* \brief MessageType enumeration
*/
enum MessageType
{
AODVTYPE_RREQ = 1, //!< AODVTYPE_RREQ
AODVTYPE_RREP = 2, //!< AODVTYPE_RREP
AODVTYPE_RERR = 3, //!< AODVTYPE_RERR
AODVTYPE_RREP_ACK = 4 //!< AODVTYPE_RREP_ACK
};
/**
* \ingroup aodv
* \brief AODV types
*/
class TypeHeader : public Header
{
public:
/**
* constructor
* \param t the AODV RREQ type
*/
TypeHeader (MessageType t = AODVTYPE_RREQ);
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
void Print (std::ostream &os) const;
/**
* \returns the type
*/
MessageType Get () const
{
return m_type;
}
/**
* Check that type if valid
* \returns true if the type is valid
*/
bool IsValid () const
{
return m_valid;
}
/**
* \brief Comparison operator
* \param o header to compare
* \return true if the headers are equal
*/
bool operator== (TypeHeader const & o) const;
private:
MessageType m_type; ///< type of the message
bool m_valid; ///< Indicates if the message is valid
};
/**
* \brief Stream output operator
* \param os output stream
* \return updated stream
*/
std::ostream & operator<< (std::ostream & os, TypeHeader const & h);
/**
* \ingroup aodv
* \brief Route Request (RREQ) Message Format
\verbatim
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type |J|R|G|D|U| Reserved | Hop Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RREQ ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Originator IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Originator Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
class RreqHeader : public Header
{
public:
/**
* constructor
*
* \param flags the message flags (0)
* \param reserved the reserved bits (0)
* \param hopCount the hop count
* \param requestID the request ID
* \param dst the destination IP address
* \param dstSeqNo the destination sequence number
* \param origin the origin IP address
* \param originSeqNo the origin sequence number
*/
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);
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
void Print (std::ostream &os) const;
// Fields
/**
* \brief Set the hop count
* \param count the hop count
*/
void SetHopCount (uint8_t count)
{
m_hopCount = count;
}
/**
* \brief Get the hop count
* \return the hop count
*/
uint8_t GetHopCount () const
{
return m_hopCount;
}
/**
* \brief Set the request ID
* \param id the request ID
*/
void SetId (uint32_t id)
{
m_requestID = id;
}
/**
* \brief Get the request ID
* \return the request ID
*/
uint32_t GetId () const
{
return m_requestID;
}
/**
* \brief Set the destination address
* \param a the destination address
*/
void SetDst (Ipv4Address a)
{
m_dst = a;
}
/**
* \brief Get the destination address
* \return the destination address
*/
Ipv4Address GetDst () const
{
return m_dst;
}
/**
* \brief Set the destination sequence number
* \param s the destination sequence number
*/
void SetDstSeqno (uint32_t s)
{
m_dstSeqNo = s;
}
/**
* \brief Get the destination sequence number
* \return the destination sequence number
*/
uint32_t GetDstSeqno () const
{
return m_dstSeqNo;
}
/**
* \brief Set the origin address
* \param a the origin address
*/
void SetOrigin (Ipv4Address a)
{
m_origin = a;
}
/**
* \brief Get the origin address
* \return the origin address
*/
Ipv4Address GetOrigin () const
{
return m_origin;
}
/**
* \brief Set the origin sequence number
* \param s the origin sequence number
*/
void SetOriginSeqno (uint32_t s)
{
m_originSeqNo = s;
}
/**
* \brief Get the origin sequence number
* \return the origin sequence number
*/
uint32_t GetOriginSeqno () const
{
return m_originSeqNo;
}
// Flags
/**
* \brief Set the gratuitous RREP flag
* \param f the gratuitous RREP flag
*/
void SetGratuitousRrep (bool f);
/**
* \brief Get the gratuitous RREP flag
* \return the gratuitous RREP flag
*/
bool GetGratuitousRrep () const;
/**
* \brief Set the Destination only flag
* \param f the Destiantion only flag
*/
void SetDestinationOnly (bool f);
/**
* \brief Get the Destination only flag
* \return the Destination only flag
*/
bool GetDestinationOnly () const;
/**
* \brief Set the unknown sequence number flag
* \param f the unknown sequence number flag
*/
void SetUnknownSeqno (bool f);
/**
* \brief Get the unknown sequence number flag
* \return the unknown sequence number flag
*/
bool GetUnknownSeqno () const;
/**
* \brief Comparison operator
* \param o RREQ header to compare
* \return true if the RREQ headers are equal
*/
bool operator== (RreqHeader const & o) const;
private:
uint8_t m_flags; ///< |J|R|G|D|U| bit flags, see RFC
uint8_t m_reserved; ///< Not used (must be 0)
uint8_t m_hopCount; ///< Hop Count
uint32_t m_requestID; ///< RREQ ID
Ipv4Address m_dst; ///< Destination IP Address
uint32_t m_dstSeqNo; ///< Destination Sequence Number
Ipv4Address m_origin; ///< Originator IP Address
uint32_t m_originSeqNo; ///< Source Sequence Number
};
/**
* \brief Stream output operator
* \param os output stream
* \return updated stream
*/
std::ostream & operator<< (std::ostream & os, RreqHeader const &);
/**
* \ingroup aodv
* \brief Route Reply (RREP) Message Format
\verbatim
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type |R|A| Reserved |Prefix Sz| Hop Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination IP address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Originator IP address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Lifetime |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
class RrepHeader : public Header
{
public:
/**
* constructor
*
* \param prefixSize the prefix size (0)
* \param hopCount the hop count (0)
* \param dst the destination IP address
* \param dstSeqNo the destination sequence number
* \param origin the origin IP address
* \param lifetime the lifetime
*/
RrepHeader (uint8_t prefixSize = 0, uint8_t hopCount = 0, Ipv4Address dst =
Ipv4Address (), uint32_t dstSeqNo = 0, Ipv4Address origin =
Ipv4Address (), Time lifetime = MilliSeconds (0));
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
void Print (std::ostream &os) const;
// Fields
/**
* \brief Set the hop count
* \param count the hop count
*/
void SetHopCount (uint8_t count)
{
m_hopCount = count;
}
/**
* \brief Get the hop count
* \return the hop count
*/
uint8_t GetHopCount () const
{
return m_hopCount;
}
/**
* \brief Set the destination address
* \param a the destination address
*/
void SetDst (Ipv4Address a)
{
m_dst = a;
}
/**
* \brief Get the destination address
* \return the destination address
*/
Ipv4Address GetDst () const
{
return m_dst;
}
/**
* \brief Set the destination sequence number
* \param s the destination sequence number
*/
void SetDstSeqno (uint32_t s)
{
m_dstSeqNo = s;
}
/**
* \brief Get the destination sequence number
* \return the destination sequence number
*/
uint32_t GetDstSeqno () const
{
return m_dstSeqNo;
}
/**
* \brief Set the origin address
* \param a the origin address
*/
void SetOrigin (Ipv4Address a)
{
m_origin = a;
}
/**
* \brief Get the origin address
* \return the origin address
*/
Ipv4Address GetOrigin () const
{
return m_origin;
}
/**
* \brief Set the lifetime
* \param t the lifetime
*/
void SetLifeTime (Time t);
/**
* \brief Get the lifetime
* \return the lifetime
*/
Time GetLifeTime () const;
// Flags
/**
* \brief Set the ack required flag
* \param f the ack required flag
*/
void SetAckRequired (bool f);
/**
* \brief get the ack required flag
* \return the ack required flag
*/
bool GetAckRequired () const;
/**
* \brief Set the prefix size
* \param sz the prefix size
*/
void SetPrefixSize (uint8_t sz);
/**
* \brief Set the pefix size
* \return the prefix size
*/
uint8_t GetPrefixSize () const;
/**
* Configure RREP to be a Hello message
*
* \param src the source IP address
* \param srcSeqNo the source sequence number
* \param lifetime the lifetime of the message
*/
void SetHello (Ipv4Address src, uint32_t srcSeqNo, Time lifetime);
/**
* \brief Comparison operator
* \param o RREP header to compare
* \return true if the RREP headers are equal
*/
bool operator== (RrepHeader const & o) const;
private:
uint8_t m_flags; ///< A - acknowledgment required flag
uint8_t m_prefixSize; ///< Prefix Size
uint8_t m_hopCount; ///< Hop Count
Ipv4Address m_dst; ///< Destination IP Address
uint32_t m_dstSeqNo; ///< Destination Sequence Number
Ipv4Address m_origin; ///< Source IP Address
uint32_t m_lifeTime; ///< Lifetime (in milliseconds)
};
/**
* \brief Stream output operator
* \param os output stream
* \return updated stream
*/
std::ostream & operator<< (std::ostream & os, RrepHeader const &);
/**
* \ingroup aodv
* \brief Route Reply Acknowledgment (RREP-ACK) Message Format
\verbatim
0 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
class RrepAckHeader : public Header
{
public:
/// constructor
RrepAckHeader ();
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
void Print (std::ostream &os) const;
/**
* \brief Comparison operator
* \param o RREP header to compare
* \return true if the RREQ headers are equal
*/
bool operator== (RrepAckHeader const & o) const;
private:
uint8_t m_reserved; ///< Not used (must be 0)
};
/**
* \brief Stream output operator
* \param os output stream
* \return updated stream
*/
std::ostream & operator<< (std::ostream & os, RrepAckHeader const &);
/**
* \ingroup aodv
* \brief Route Error (RERR) Message Format
\verbatim
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type |N| Reserved | DestCount |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Unreachable Destination IP Address (1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Unreachable Destination Sequence Number (1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| Additional Unreachable Destination IP Addresses (if needed) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Additional Unreachable Destination Sequence Numbers (if needed)|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
class RerrHeader : public Header
{
public:
/// constructor
RerrHeader ();
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
uint32_t GetSerializedSize () const;
void Serialize (Buffer::Iterator i) const;
uint32_t Deserialize (Buffer::Iterator start);
void Print (std::ostream &os) const;
// No delete flag
/**
* \brief Set the no delete flag
* \param f the no delete flag
*/
void SetNoDelete (bool f);
/**
* \brief Get the no delete flag
* \return the no delete flag
*/
bool GetNoDelete () const;
/**
* \brief Add unreachable node address and its sequence number in RERR header
* \param dst unreachable IPv4 address
* \param seqNo unreachable sequence number
* \return false if we already added maximum possible number of unreachable destinations
*/
bool AddUnDestination (Ipv4Address dst, uint32_t seqNo);
/**
* \brief Delete pair (address + sequence number) from REER header, if the number of unreachable destinations > 0
* \param un unreachable pair (address + sequence number)
* \return true on success
*/
bool RemoveUnDestination (std::pair<Ipv4Address, uint32_t> & un);
/// Clear header
void Clear ();
/**
* \returns number of unreachable destinations in RERR message
*/
uint8_t GetDestCount () const
{
return (uint8_t)m_unreachableDstSeqNo.size ();
}
/**
* \brief Comparison operator
* \param o RERR header to compare
* \return true if the RERR headers are equal
*/
bool operator== (RerrHeader const & o) const;
private:
uint8_t m_flag; ///< No delete flag
uint8_t m_reserved; ///< Not used (must be 0)
/// List of Unreachable destination: IP addresses and sequence numbers
std::map<Ipv4Address, uint32_t> m_unreachableDstSeqNo;
};
/**
* \brief Stream output operator
* \param os output stream
* \return updated stream
*/
std::ostream & operator<< (std::ostream & os, RerrHeader const &);
} // namespace aodv
} // namespace ns3
#endif /* AODVPACKET_H */
|