A Discrete-Event Network Simulator
API
ipv4-routing-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef IPV4_ROUTING_HELPER_H
22 #define IPV4_ROUTING_HELPER_H
23 
24 #include "ns3/ptr.h"
25 #include "ns3/nstime.h"
26 #include "ns3/output-stream-wrapper.h"
27 #include "ns3/ipv4-list-routing.h"
28 
29 namespace ns3 {
30 
31 class Ipv4RoutingProtocol;
32 class Node;
33 
44 {
45 public:
46  /*
47  * Destroy an instance of an Ipv4RoutingHelper
48  */
49  virtual ~Ipv4RoutingHelper ();
50 
58  virtual Ipv4RoutingHelper* Copy (void) const = 0;
59 
64  virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const = 0;
65 
75  static void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream);
76 
86  static void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream);
87 
98  static void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
99 
110  static void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
111 
125  static void PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream);
126 
140  static void PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream);
141 
156  static void PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
157 
172  static void PrintNeighborCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
173 
183  template<class T>
184  static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol);
185 
186 private:
196  static void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
197 
208  static void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
209 
223  static void PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
224 
239  static void PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
240 };
241 
242 
252 template<class T>
254 {
255  Ptr<T> ret = DynamicCast<T> (protocol);
256  if (ret == 0)
257  {
258  // trying to check if protocol is a list routing
259  Ptr<Ipv4ListRouting> lrp = DynamicCast<Ipv4ListRouting> (protocol);
260  if (lrp != 0)
261  {
262  for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++)
263  {
264  int16_t priority;
265  ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
266  if (ret != 0)
267  break;
268  }
269  }
270  }
271 
272  return ret;
273 }
274 
275 } // namespace ns3
276 
277 
278 #endif /* IPV4_ROUTING_HELPER_H */
static void Print(Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the routing tables of a node.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of all nodes at a particular time.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
static void PrintNeighborCacheAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of all nodes at regular intervals specified by user.
static Ptr< T > GetRouting(Ptr< Ipv4RoutingProtocol > protocol)
Request a specified routing protocol from Ipv4RoutingProtocol protocol.
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
static void PrintRoutingTableAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream)
prints the routing tables of all nodes at regular intervals specified by user.
static void PrintNeighborCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of a node at regular intervals specified by user.
static void PrintEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the routing tables of a node at regular intervals specified by user.
a factory to create ns3::Ipv4RoutingProtocol objects
static void PrintArpCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of a node at regular intervals specified by user.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream)
prints the routing tables of all nodes at a particular time.
static void PrintArpCache(Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of a node.
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
static void PrintRoutingTableEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the routing tables of a node at regular intervals specified by user.
static void PrintNeighborCacheAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the neighbor cache of a node at a particular time.
static void PrintRoutingTableAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream)
prints the routing tables of a node at a particular time.