A Discrete-Event Network Simulator
API
nix-vector-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The Georgia Institute of Technology
3  * Copyright (c) 2021 NITK Surathkal
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  * This file is adapted from the old ipv4-nix-vector-helper.h.
19  *
20  * Authors: Josh Pelkey <jpelkey@gatech.edu>
21  *
22  * Modified by: Ameya Deshpande <ameyanrd@outlook.com>
23  */
24 
25 #ifndef NIX_VECTOR_HELPER_H
26 #define NIX_VECTOR_HELPER_H
27 
28 #include "ns3/ipv4-routing-helper.h"
29 #include "ns3/ipv6-routing-helper.h"
30 #include "ns3/object-factory.h"
31 
32 namespace ns3
33 {
34 
49 template <typename T>
50 class NixVectorHelper : public std::enable_if_t<std::is_same_v<Ipv4RoutingHelper, T> ||
51  std::is_same_v<Ipv6RoutingHelper, T>,
52  T>
53 {
55  static constexpr bool IsIpv4 = std::is_same_v<Ipv4RoutingHelper, T>;
57  using Ip = typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
59  using IpAddress = typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
62  typename std::conditional_t<IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol>;
63 
64  public:
70 
78 
79  // Delete assignment operator to avoid misuse
81 
88  NixVectorHelper<T>* Copy() const override;
89 
96  Ptr<IpRoutingProtocol> Create(Ptr<Node> node) const override;
97 
112  void PrintRoutingPathAt(Time printTime,
113  Ptr<Node> source,
114  IpAddress dest,
116  Time::Unit unit = Time::S);
117 
118  private:
120 
133  static void PrintRoute(Ptr<Node> source,
134  IpAddress dest,
136  Time::Unit unit = Time::S);
137 };
138 
146 
152 } // namespace ns3
153 
154 #endif /* NIX_VECTOR_HELPER_H */
Helper class that adds Nix-vector routing to nodes.
static void PrintRoute(Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for the source and destination.
NixVectorHelper< T > * Copy() const override
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
ObjectFactory m_agentFactory
Object factory.
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingHelper or Ipv6RoutingHelper.
void PrintRoutingPathAt(Time printTime, Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for a source and destination at a particular time.
NixVectorHelper & operator=(const NixVectorHelper &)=delete
NixVectorHelper()
Construct an NixVectorHelper to make life easier while adding Nix-vector routing to nodes.
Ptr< IpRoutingProtocol > Create(Ptr< Node > node) const override
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
typename std::conditional_t< IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol > IpRoutingProtocol
Alias for Ipv4RoutingProtocol and Ipv6RoutingProtocol classes.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:111
@ S
second
Definition: nstime.h:116
NixVectorHelper< Ipv6RoutingHelper > Ipv6NixVectorHelper
Create the typedef Ipv6NixVectorHelper with T as Ipv6RoutingHelper.
NixVectorHelper< Ipv4RoutingHelper > Ipv4NixVectorHelper
Create the typedef Ipv4NixVectorHelper with T as Ipv4RoutingHelper.
typename std::enable_if< B, T >::type enable_if_t
Definition: json.h:2746
Every class exported by the ns3 library is enclosed in the ns3 namespace.