A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dsr-options.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
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  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22  * Information and Telecommunication Technology Center (ITTC)
23  * and Department of Electrical Engineering and Computer Science
24  * The University of Kansas Lawrence, KS USA.
25  *
26  * Work supported in part by NSF FIND (Future Internet Design) Program
27  * under grant CNS-0626918 (Postmodern Internet Architecture),
28  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
30  */
31 
32 #ifndef DSR_OPTION_H
33 #define DSR_OPTION_H
34 
35 #include <map>
36 #include <list>
37 
38 #include "ns3/buffer.h"
39 #include "ns3/packet.h"
40 #include "ns3/callback.h"
41 #include "ns3/ptr.h"
42 #include "ns3/udp-l4-protocol.h"
43 #include "ns3/ipv4.h"
44 #include "ns3/ipv4-route.h"
45 #include "ns3/object.h"
46 #include "ns3/node.h"
47 #include "ns3/ipv4-interface.h"
48 #include "ns3/ipv4-header.h"
49 #include "ns3/ipv4-address.h"
50 #include "ns3/traced-callback.h"
51 #include "ns3/output-stream-wrapper.h"
52 #include "ns3/timer.h"
53 
54 #include "dsr-rsendbuff.h"
55 #include "dsr-maintain-buff.h"
56 #include "dsr-option-header.h"
57 #include "dsr-rcache.h"
58 #include "dsr-routing.h"
60 
61 namespace ns3 {
62 
63 class Packet;
64 class NetDevice;
65 class Node;
66 class Ipv4Address;
67 class Ipv4Interface;
68 class Ipv4Route;
69 class Ipv4;
70 class Time;
71 
72 namespace dsr {
73 
74 class DsrOptions : public Object
75 {
76 public:
81  static TypeId GetTypeId (void);
85  DsrOptions ();
89  virtual ~DsrOptions ();
94  virtual uint8_t GetOptionNumber () const = 0;
99  void SetNode (Ptr<Node> node);
104  Ptr<Node> GetNode () const;
113  bool ContainAddressAfter (Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector<Ipv4Address> &nodeList);
121  std::vector<Ipv4Address> CutRoute (Ipv4Address ipv4Address, std::vector<Ipv4Address> &nodeList);
130  virtual Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress);
137  bool ReverseRoutes (std::vector<Ipv4Address>& vec);
145  Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
153  Ipv4Address ReverseSearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
161  Ipv4Address ReverseSearchNextTwoHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
165  void PrintVector (std::vector<Ipv4Address>& vec);
173  bool IfDuplicates (std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2);
181  bool CheckDuplicates (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
188  void RemoveDuplicates (std::vector<Ipv4Address>& vec);
196  void ScheduleReply (Ptr<Packet> &packet, std::vector<Ipv4Address> &nodeList, Ipv4Address &source, Ipv4Address &destination);
203  uint32_t GetIDfromIP (Ipv4Address address);
225  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) = 0;
226 
227 protected:
255  std::vector<Ipv4Address> m_ipv4Address;
259  std::vector<Ipv4Address> m_finalRoute;
268 
269 private:
271 };
272 
277 class DsrOptionPad1 : public DsrOptions
278 {
279 public:
283  static const uint8_t OPT_NUMBER = 224;
284 
285  static TypeId GetTypeId ();
286 
287  DsrOptionPad1 ();
288  virtual ~DsrOptionPad1 ();
289 
290  virtual uint8_t GetOptionNumber () const;
291  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
292 };
293 
298 class DsrOptionPadn : public DsrOptions
299 {
300 public:
304  static const uint8_t OPT_NUMBER = 0;
305 
306  static TypeId GetTypeId ();
307 
308  DsrOptionPadn ();
309  virtual ~DsrOptionPadn ();
310 
311  virtual uint8_t GetOptionNumber () const;
312  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
313 };
314 
319 class DsrOptionRreq : public DsrOptions
320 {
321 public:
325  static const uint8_t OPT_NUMBER = 1;
326 
327  static TypeId GetTypeId ();
332  virtual TypeId GetInstanceTypeId () const;
336  DsrOptionRreq ();
340  virtual ~DsrOptionRreq ();
341 
342  virtual uint8_t GetOptionNumber () const;
343  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
344 
345 private:
354 };
355 
360 class DsrOptionRrep : public DsrOptions
361 {
362 public:
366  static const uint8_t OPT_NUMBER = 2;
367 
368  static TypeId GetTypeId ();
373  virtual TypeId GetInstanceTypeId () const;
374 
375  DsrOptionRrep ();
376  virtual ~DsrOptionRrep ();
377 
378  virtual uint8_t GetOptionNumber () const;
379  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
380 
381 private:
390 };
391 
396 class DsrOptionSR : public DsrOptions
397 {
398 public:
402  static const uint8_t OPT_NUMBER = 96;
403 
404  static TypeId GetTypeId ();
409  virtual TypeId GetInstanceTypeId () const;
410 
411  DsrOptionSR ();
412  virtual ~DsrOptionSR ();
413 
414  virtual uint8_t GetOptionNumber () const;
415  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
416 
417 private:
422 };
423 
428 class DsrOptionRerr : public DsrOptions
429 {
430 public:
434  static const uint8_t OPT_NUMBER = 3;
435 
436  static TypeId GetTypeId ();
441  virtual TypeId GetInstanceTypeId () const;
442 
443  DsrOptionRerr ();
444  virtual ~DsrOptionRerr ();
445 
446  virtual uint8_t GetOptionNumber () const;
447  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
458  uint8_t DoSendError (Ptr<Packet> p, DsrOptionRerrUnreachHeader &rerr, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol);
459 
460 private:
469 };
470 
476 {
477 public:
481  static const uint8_t OPT_NUMBER = 160;
482 
483  static TypeId GetTypeId ();
488  virtual TypeId GetInstanceTypeId () const;
489 
490  DsrOptionAckReq ();
491  virtual ~DsrOptionAckReq ();
492 
493  virtual uint8_t GetOptionNumber () const;
494  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
495 
496 private:
505 };
506 
511 class DsrOptionAck : public DsrOptions
512 {
513 public:
517  static const uint8_t OPT_NUMBER = 32;
518 
519  static TypeId GetTypeId ();
524  virtual TypeId GetInstanceTypeId () const;
525 
526  DsrOptionAck ();
527  virtual ~DsrOptionAck ();
528 
529  virtual uint8_t GetOptionNumber () const;
530  virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
531 
532 private:
541 };
542 } // namespace dsr
543 } // Namespace ns3
544 
545 #endif
static const uint8_t OPT_NUMBER
Dsr Route Error option number.
Definition: dsr-options.h:434
Ptr< Ipv4 > m_ipv4
The ip layer 3.
Definition: dsr-options.h:389
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
virtual uint8_t GetOptionNumber() const
Get the option number.
static const uint8_t OPT_NUMBER
Rreq option number.
Definition: dsr-options.h:325
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
static const uint8_t OPT_NUMBER
Dsr ack request option number.
Definition: dsr-options.h:481
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:468
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:74
static TypeId GetTypeId()
Definition: dsr-options.cc:419
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual uint8_t GetOptionNumber() const =0
Get the option number.
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:428
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Definition: dsr-options.cc:469
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)=0
Process method.
void SetNode(Ptr< Node > node)
Set the node.
Definition: dsr-options.cc:95
static const uint8_t OPT_NUMBER
Pad1 option number.
Definition: dsr-options.h:283
uint8_t DoSendError(Ptr< Packet > p, DsrOptionRerrUnreachHeader &rerr, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol)
Do Send error message.
Ptr< dsr::RreqTable > m_rreqTable
The route request table.
Definition: dsr-options.h:239
uint32_t GetIDfromIP(Ipv4Address address)
Get the node id with Ipv4Address.
Definition: dsr-options.cc:342
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:504
Packet header for IPv4.
Definition: ipv4-header.h:31
void ScheduleReply(Ptr< Packet > &packet, std::vector< Ipv4Address > &nodeList, Ipv4Address &source, Ipv4Address &destination)
Schedule the intermediate node route request broadcast.
virtual uint8_t GetOptionNumber() const
Get the option number.
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:360
static TypeId GetTypeId()
Definition: dsr-options.cc:959
DsrOptionRreq()
Constructor.
Definition: dsr-options.cc:474
Ipv4Address ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next two hop in the route.
Definition: dsr-options.cc:221
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Definition: dsr-options.cc:990
Ptr< dsr::RouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:385
TracedCallback< Ptr< const Packet > > m_dropTrace
Drop trace callback.
Definition: dsr-options.h:231
static const uint8_t OPT_NUMBER
Router alert option number.
Definition: dsr-options.h:366
static TypeId GetTypeId()
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Definition: dsr-options.cc:444
static const uint8_t OPT_NUMBER
PadN option number.
Definition: dsr-options.h:304
Ipv4Address Broadcast
The broadcast IP address.
Definition: dsr-options.h:235
virtual ~DsrOptionRreq()
Destructor.
Definition: dsr-options.cc:479
std::vector< Ipv4Address > m_finalRoute
The vector of final Ipv4 address.
Definition: dsr-options.h:259
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void RemoveDuplicates(std::vector< Ipv4Address > &vec)
Remove the duplicates from the route.
Definition: dsr-options.cc:297
Time ActiveRouteTimeout
The active route timeout value.
Definition: dsr-options.h:263
void PrintVector(std::vector< Ipv4Address > &vec)
Print out the elements in the route vector.
Definition: dsr-options.cc:240
DsrOptions()
Constructor.
Definition: dsr-options.cc:85
Ptr< dsr::RouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:536
static const uint8_t OPT_NUMBER
The Dsr Ack option number.
Definition: dsr-options.h:517
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Search for the next hop in the route.
Definition: dsr-options.cc:163
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:396
TracedCallback< const DsrOptionSRHeader & > m_rxPacketTrace
The receive trace back, only triggered when final destination receive data packet.
Definition: dsr-options.h:267
static TypeId GetTypeId()
Ptr< Ipv4 > m_ipv4
The ip layer 3.
Definition: dsr-options.h:421
virtual ~DsrOptions()
Destructor.
Definition: dsr-options.cc:90
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Definition: dsr-options.cc:404
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:540
Ptr< Node > m_node
Definition: dsr-options.h:270
static TypeId GetTypeId()
Definition: dsr-options.cc:378
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:319
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:298
bool CheckDuplicates(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Check if the route already contains the node ip address.
Definition: dsr-options.cc:280
bool ReverseRoutes(std::vector< Ipv4Address > &vec)
Reverse the routes.
Definition: dsr-options.cc:145
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Definition: dsr-options.cc:491
Route Error (RERR) Unreachable node address option Message Format.
Ptr< Ipv4Route > m_ipv4Route
The ipv4 route.
Definition: dsr-options.h:247
Ptr< Ipv4 > m_ipv4
The ipv4.
Definition: dsr-options.h:251
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Ipv4Address ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next hop in the route.
Definition: dsr-options.cc:195
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId(void)
Get the type identificator.
Definition: dsr-options.cc:71
bool ContainAddressAfter(Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector< Ipv4Address > &nodeList)
Search for the ipv4 address in the node list.
Definition: dsr-options.cc:107
virtual uint8_t GetOptionNumber() const
Get the option number.
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: dsr-options.cc:397
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: dsr-options.cc:438
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:511
Ptr< Ipv4 > m_ipv4
The ipv4.
Definition: dsr-options.h:353
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Definition: dsr-options.cc:978
static const uint8_t OPT_NUMBER
Source Route option number.
Definition: dsr-options.h:402
std::vector< Ipv4Address > m_ipv4Address
The vector of Ipv4 address.
Definition: dsr-options.h:255
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:475
Ptr< dsr::RouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:500
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: dsr-options.cc:983
a base class which provides memory management and object aggregation
Definition: object.h:63
tuple address
Definition: first.py:37
Doxygen introspection did not find any typical Config paths.
Definition: dsr-options.h:277
Ptr< Node > GetNode() const
Get the node.
Definition: dsr-options.cc:101
virtual Ptr< Ipv4Route > SetRoute(Ipv4Address nextHop, Ipv4Address srcAddress)
Set the route to use for data packets, used by the option headers when sending data/control packets...
Definition: dsr-options.cc:135
bool IfDuplicates(std::vector< Ipv4Address > &vec, std::vector< Ipv4Address > &vec2)
Check if the two vectors contain duplicate or not.
Definition: dsr-options.cc:260
Ptr< dsr::RouteCache > m_routeCache
The route cache table.
Definition: dsr-options.h:243
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node object with Ipv4Address.
Definition: dsr-options.cc:358
static TypeId GetTypeId()
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)
Process method.
Ptr< dsr::RouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:349
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< dsr::RouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:464
std::vector< Ipv4Address > CutRoute(Ipv4Address ipv4Address, std::vector< Ipv4Address > &nodeList)
Cut the route from ipv4Address to the end of the route vector.
Definition: dsr-options.cc:123
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: dsr-options.cc:484
static TypeId GetTypeId()
Definition: dsr-options.cc:460
virtual uint8_t GetOptionNumber() const
Get the option number.