A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsr-options.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Yufei Cheng
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
18 *
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 *
25 * Work supported in part by NSF FIND (Future Internet Design) Program
26 * under grant CNS-0626918 (Postmodern Internet Architecture),
27 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28 * US Department of Defense (DoD), and ITTC at The University of Kansas.
29 */
30
31#ifndef DSR_OPTION_H
32#define DSR_OPTION_H
33
35#include "dsr-maintain-buff.h"
36#include "dsr-option-header.h"
37#include "dsr-rcache.h"
38#include "dsr-routing.h"
39#include "dsr-rsendbuff.h"
40
41#include "ns3/buffer.h"
42#include "ns3/callback.h"
43#include "ns3/ipv4-address.h"
44#include "ns3/ipv4-header.h"
45#include "ns3/ipv4-interface.h"
46#include "ns3/ipv4-route.h"
47#include "ns3/ipv4.h"
48#include "ns3/node.h"
49#include "ns3/object.h"
50#include "ns3/output-stream-wrapper.h"
51#include "ns3/packet.h"
52#include "ns3/ptr.h"
53#include "ns3/timer.h"
54#include "ns3/traced-callback.h"
55#include "ns3/udp-l4-protocol.h"
56
57#include <list>
58#include <map>
59
60namespace ns3
61{
62
63class Packet;
64class NetDevice;
65class Node;
66class Ipv4Address;
67class Ipv4Interface;
68class Ipv4Route;
69class Ipv4;
70class Time;
71
72namespace dsr
73{
74
75class DsrOptions : public Object
76{
77 public:
82 static TypeId GetTypeId();
86 DsrOptions();
90 ~DsrOptions() override;
95 virtual uint8_t GetOptionNumber() const = 0;
100 void SetNode(Ptr<Node> node);
105 Ptr<Node> GetNode() const;
114 bool ContainAddressAfter(Ipv4Address ipv4Address,
115 Ipv4Address destAddress,
116 std::vector<Ipv4Address>& nodeList);
124 std::vector<Ipv4Address> CutRoute(Ipv4Address ipv4Address, std::vector<Ipv4Address>& nodeList);
133 virtual Ptr<Ipv4Route> SetRoute(Ipv4Address nextHop, Ipv4Address srcAddress);
140 bool ReverseRoutes(std::vector<Ipv4Address>& vec);
148 Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
156 Ipv4Address ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
164 Ipv4Address ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
169 void PrintVector(std::vector<Ipv4Address>& vec);
177 bool IfDuplicates(std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2);
185 bool CheckDuplicates(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
191 void RemoveDuplicates(std::vector<Ipv4Address>& vec);
200 std::vector<Ipv4Address>& nodeList,
201 Ipv4Address& source,
202 Ipv4Address& destination);
231 virtual uint8_t Process(Ptr<Packet> packet,
232 Ptr<Packet> dsrP,
233 Ipv4Address ipv4Address,
234 Ipv4Address source,
235 const Ipv4Header& ipv4Header,
236 uint8_t protocol,
237 bool& isPromisc,
238 Ipv4Address promiscSource) = 0;
239
240 protected:
268 std::vector<Ipv4Address> m_ipv4Address;
272 std::vector<Ipv4Address> m_finalRoute;
281
282 private:
284};
285
291{
292 public:
296 static const uint8_t OPT_NUMBER = 224;
297
302 static TypeId GetTypeId();
303
305 ~DsrOptionPad1() override;
306
307 uint8_t GetOptionNumber() const override;
308 uint8_t Process(Ptr<Packet> packet,
309 Ptr<Packet> dsrP,
310 Ipv4Address ipv4Address,
311 Ipv4Address source,
312 const Ipv4Header& ipv4Header,
313 uint8_t protocol,
314 bool& isPromisc,
315 Ipv4Address promiscSource) override;
316};
317
323{
324 public:
328 static const uint8_t OPT_NUMBER = 0;
329
334 static TypeId GetTypeId();
335
337 ~DsrOptionPadn() override;
338
339 uint8_t GetOptionNumber() const override;
340 uint8_t Process(Ptr<Packet> packet,
341 Ptr<Packet> dsrP,
342 Ipv4Address ipv4Address,
343 Ipv4Address source,
344 const Ipv4Header& ipv4Header,
345 uint8_t protocol,
346 bool& isPromisc,
347 Ipv4Address promiscSource) override;
348};
349
355{
356 public:
360 static const uint8_t OPT_NUMBER = 1;
361
366 static TypeId GetTypeId();
371 TypeId GetInstanceTypeId() const override;
379 ~DsrOptionRreq() override;
380
381 uint8_t GetOptionNumber() const override;
382 uint8_t Process(Ptr<Packet> packet,
383 Ptr<Packet> dsrP,
384 Ipv4Address ipv4Address,
385 Ipv4Address source,
386 const Ipv4Header& ipv4Header,
387 uint8_t protocol,
388 bool& isPromisc,
389 Ipv4Address promiscSource) override;
390
391 private:
400};
401
407{
408 public:
412 static const uint8_t OPT_NUMBER = 2;
413
418 static TypeId GetTypeId();
423 TypeId GetInstanceTypeId() const override;
424
426 ~DsrOptionRrep() override;
427
428 uint8_t GetOptionNumber() const override;
429 uint8_t Process(Ptr<Packet> packet,
430 Ptr<Packet> dsrP,
431 Ipv4Address ipv4Address,
432 Ipv4Address source,
433 const Ipv4Header& ipv4Header,
434 uint8_t protocol,
435 bool& isPromisc,
436 Ipv4Address promiscSource) override;
437
438 private:
447};
448
454{
455 public:
459 static const uint8_t OPT_NUMBER = 96;
460
465 static TypeId GetTypeId();
470 TypeId GetInstanceTypeId() const override;
471
472 DsrOptionSR();
473 ~DsrOptionSR() override;
474
475 uint8_t GetOptionNumber() const override;
476 uint8_t Process(Ptr<Packet> packet,
477 Ptr<Packet> dsrP,
478 Ipv4Address ipv4Address,
479 Ipv4Address source,
480 const Ipv4Header& ipv4Header,
481 uint8_t protocol,
482 bool& isPromisc,
483 Ipv4Address promiscSource) override;
484
485 private:
490};
491
497{
498 public:
502 static const uint8_t OPT_NUMBER = 3;
503
508 static TypeId GetTypeId();
513 TypeId GetInstanceTypeId() const override;
514
516 ~DsrOptionRerr() override;
517
518 uint8_t GetOptionNumber() const override;
519 uint8_t Process(Ptr<Packet> packet,
520 Ptr<Packet> dsrP,
521 Ipv4Address ipv4Address,
522 Ipv4Address source,
523 const Ipv4Header& ipv4Header,
524 uint8_t protocol,
525 bool& isPromisc,
526 Ipv4Address promiscSource) override;
537 uint8_t DoSendError(Ptr<Packet> p,
539 uint32_t rerrSize,
540 Ipv4Address ipv4Address,
541 uint8_t protocol);
542
543 private:
552};
553
559{
560 public:
564 static const uint8_t OPT_NUMBER = 160;
565
570 static TypeId GetTypeId();
575 TypeId GetInstanceTypeId() const override;
576
578 ~DsrOptionAckReq() override;
579
580 uint8_t GetOptionNumber() const override;
581 uint8_t Process(Ptr<Packet> packet,
582 Ptr<Packet> dsrP,
583 Ipv4Address ipv4Address,
584 Ipv4Address source,
585 const Ipv4Header& ipv4Header,
586 uint8_t protocol,
587 bool& isPromisc,
588 Ipv4Address promiscSource) override;
589
590 private:
599};
600
606{
607 public:
611 static const uint8_t OPT_NUMBER = 32;
612
617 static TypeId GetTypeId();
622 TypeId GetInstanceTypeId() const override;
623
624 DsrOptionAck();
625 ~DsrOptionAck() override;
626
627 uint8_t GetOptionNumber() const override;
628 uint8_t Process(Ptr<Packet> packet,
629 Ptr<Packet> dsrP,
630 Ipv4Address ipv4Address,
631 Ipv4Address source,
632 const Ipv4Header& ipv4Header,
633 uint8_t protocol,
634 bool& isPromisc,
635 Ipv4Address promiscSource) override;
636
637 private:
646};
647} // namespace dsr
648} // Namespace ns3
649
650#endif
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Dsr Option Ack.
Definition: dsr-options.h:606
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:645
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
The Dsr Ack option number.
Definition: dsr-options.h:611
static TypeId GetTypeId()
Get the type ID.
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:641
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
static const uint8_t OPT_NUMBER
Dsr ack request option number.
Definition: dsr-options.h:564
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:594
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:598
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Dsr Option Pad1.
Definition: dsr-options.h:291
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:400
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:380
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:408
static const uint8_t OPT_NUMBER
Pad1 option number.
Definition: dsr-options.h:296
IPv4 Option Padn.
Definition: dsr-options.h:323
static const uint8_t OPT_NUMBER
PadN option number.
Definition: dsr-options.h:328
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:458
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:431
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:451
Dsr Option Route Error.
Definition: dsr-options.h:497
Ptr< Ipv4 > m_ipv4
The ipv4 layer 3.
Definition: dsr-options.h:551
uint8_t DoSendError(Ptr< Packet > p, DsrOptionRerrUnreachHeader &rerr, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol)
Do Send error message.
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:547
static const uint8_t OPT_NUMBER
Dsr Route Error option number.
Definition: dsr-options.h:502
static TypeId GetTypeId()
Get the type ID.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Route Error (RERR) Unreachable node address option Message Format.
Dsr Option Route Reply.
Definition: dsr-options.h:407
Ptr< Ipv4 > m_ipv4
The ip layer 3.
Definition: dsr-options.h:446
static const uint8_t OPT_NUMBER
Router alert option number.
Definition: dsr-options.h:412
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint8_t GetOptionNumber() const override
Get the option number.
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:442
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Dsr Option Rreq.
Definition: dsr-options.h:355
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:482
Ptr< Ipv4 > m_ipv4
The ipv4.
Definition: dsr-options.h:399
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Definition: dsr-options.cc:492
static const uint8_t OPT_NUMBER
Rreq option number.
Definition: dsr-options.h:360
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache.
Definition: dsr-options.h:395
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:516
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:508
~DsrOptionRreq() override
Destructor.
Definition: dsr-options.cc:502
DsrOptionRreq()
Constructor.
Definition: dsr-options.cc:497
Dsr Option Source Route.
Definition: dsr-options.h:454
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
Source Route option number.
Definition: dsr-options.h:459
Ptr< Ipv4 > m_ipv4
The ip layer 3.
Definition: dsr-options.h:489
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
Introspection did not find any typical Config paths.
Definition: dsr-options.h:76
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Search for the next hop in the route.
Definition: dsr-options.cc:175
Ipv4Address ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next two hop in the route.
Definition: dsr-options.cc:234
virtual uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource)=0
Process method.
TracedCallback< Ptr< const Packet > > m_dropTrace
Drop trace callback.
Definition: dsr-options.h:244
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node object with Ipv4Address.
Definition: dsr-options.cc:360
DsrOptions()
Constructor.
Definition: dsr-options.cc:98
Ptr< Node > GetNode() const
Get the node.
Definition: dsr-options.cc:116
Time ActiveRouteTimeout
The active route timeout value.
Definition: dsr-options.h:276
bool CheckDuplicates(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Check if the route already contains the node ip address.
Definition: dsr-options.cc:292
void SetNode(Ptr< Node > node)
Set the node.
Definition: dsr-options.cc:109
virtual uint8_t GetOptionNumber() const =0
Get the option number.
Ptr< dsr::DsrRreqTable > m_rreqTable
The route request table.
Definition: dsr-options.h:252
~DsrOptions() override
Destructor.
Definition: dsr-options.cc:103
std::vector< Ipv4Address > m_finalRoute
The vector of final Ipv4 address.
Definition: dsr-options.h:272
void PrintVector(std::vector< Ipv4Address > &vec)
Print out the elements in the route vector.
Definition: dsr-options.cc:254
bool IfDuplicates(std::vector< Ipv4Address > &vec, std::vector< Ipv4Address > &vec2)
Check if the two vectors contain duplicate or not.
Definition: dsr-options.cc:275
bool ReverseRoutes(std::vector< Ipv4Address > &vec)
Reverse the routes.
Definition: dsr-options.cc:165
void RemoveDuplicates(std::vector< Ipv4Address > &vec)
Remove the duplicates from the route.
Definition: dsr-options.cc:306
uint32_t GetIDfromIP(Ipv4Address address)
Get the node id with Ipv4Address.
Definition: dsr-options.cc:343
Ipv4Address Broadcast
The broadcast IP address.
Definition: dsr-options.h:248
static TypeId GetTypeId()
Get the type identificator.
Definition: dsr-options.cc:77
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:141
bool ContainAddressAfter(Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector< Ipv4Address > &nodeList)
Search for the ipv4 address in the node list.
Definition: dsr-options.cc:123
TracedCallback< const DsrOptionSRHeader & > m_rxPacketTrace
The receive trace back, only triggered when final destination receive data packet.
Definition: dsr-options.h:280
Ipv4Address ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next hop in the route.
Definition: dsr-options.cc:208
Ptr< Ipv4 > m_ipv4
The ipv4.
Definition: dsr-options.h:264
void ScheduleReply(Ptr< Packet > &packet, std::vector< Ipv4Address > &nodeList, Ipv4Address &source, Ipv4Address &destination)
Schedule the intermediate node route request broadcast.
Ptr< dsr::DsrRouteCache > m_routeCache
The route cache table.
Definition: dsr-options.h:256
Ptr< Ipv4Route > m_ipv4Route
The ipv4 route.
Definition: dsr-options.h:260
std::vector< Ipv4Address > m_ipv4Address
The vector of Ipv4 address.
Definition: dsr-options.h:268
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:154
Ptr< Node > m_node
the node
Definition: dsr-options.h:283
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:848
Every class exported by the ns3 library is enclosed in the ns3 namespace.