A Discrete-Event Network Simulator
API
ipv4-global-routing.h
Go to the documentation of this file.
1 // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-
2 //
3 // Copyright (c) 2008 University of Washington
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 //
19 
20 #ifndef IPV4_GLOBAL_ROUTING_H
21 #define IPV4_GLOBAL_ROUTING_H
22 
23 #include <list>
24 #include <stdint.h>
25 #include "ns3/ipv4-address.h"
26 #include "ns3/ipv4-header.h"
27 #include "ns3/ptr.h"
28 #include "ns3/ipv4.h"
29 #include "ns3/ipv4-routing-protocol.h"
30 #include "ns3/random-variable-stream.h"
31 
32 namespace ns3 {
33 
34 class Packet;
35 class NetDevice;
36 class Ipv4Interface;
37 class Ipv4Address;
38 class Ipv4Header;
39 class Ipv4RoutingTableEntry;
40 class Ipv4MulticastRoutingTableEntry;
41 class Node;
42 
43 
72 {
73 public:
78  static TypeId GetTypeId (void);
88  virtual ~Ipv4GlobalRouting ();
89 
90  // These methods inherited from base class
91  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
92 
93  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
96  virtual void NotifyInterfaceUp (uint32_t interface);
97  virtual void NotifyInterfaceDown (uint32_t interface);
98  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
99  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
100  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
101  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
102 
113  void AddHostRouteTo (Ipv4Address dest,
114  Ipv4Address nextHop,
115  uint32_t interface);
125  void AddHostRouteTo (Ipv4Address dest,
126  uint32_t interface);
127 
139  void AddNetworkRouteTo (Ipv4Address network,
140  Ipv4Mask networkMask,
141  Ipv4Address nextHop,
142  uint32_t interface);
143 
154  void AddNetworkRouteTo (Ipv4Address network,
155  Ipv4Mask networkMask,
156  uint32_t interface);
157 
167  void AddASExternalRouteTo (Ipv4Address network,
168  Ipv4Mask networkMask,
169  Ipv4Address nextHop,
170  uint32_t interface);
171 
179  uint32_t GetNRoutes (void) const;
180 
201  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
202 
219  void RemoveRoute (uint32_t i);
220 
229  int64_t AssignStreams (int64_t stream);
230 
231 protected:
232  void DoDispose (void);
233 
234 private:
241 
243  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
245  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
247  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
248 
250  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
252  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
254  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
255 
257  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
259  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
261  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
262 
270 
274 
276 };
277 
278 } // Namespace ns3
279 
280 #endif /* IPV4_GLOBAL_ROUTING_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Ipv4GlobalRouting::Ipv4GlobalRouting
Ipv4GlobalRouting()
Construct an empty Ipv4GlobalRouting routing protocol,.
Definition: ipv4-global-routing.cc:60
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::Ipv4GlobalRouting::m_randomEcmpRouting
bool m_randomEcmpRouting
Set to true if packets are randomly routed among ECMP; set to false for using only one route consiste...
Definition: ipv4-global-routing.h:236
ns3::Ipv4GlobalRouting::m_rand
Ptr< UniformRandomVariable > m_rand
A uniform random number generator for randomly routing packets among ECMP.
Definition: ipv4-global-routing.h:240
ns3::Ipv4GlobalRouting::AddASExternalRouteTo
void AddASExternalRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
Add an external route to the global routing table.
Definition: ipv4-global-routing.cc:124
ns3::Ipv4GlobalRouting::NotifyRemoveAddress
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
Definition: ipv4-global-routing.cc:578
ns3::Ipv4GlobalRouting::AddHostRouteTo
void AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface)
Add a host route to the global routing table.
Definition: ipv4-global-routing.cc:75
ns3::Ipv4GlobalRouting::m_hostRoutes
HostRoutes m_hostRoutes
Routes to hosts.
Definition: ipv4-global-routing.h:271
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::Ipv4GlobalRouting::SetIpv4
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
Definition: ipv4-global-routing.cc:590
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4GlobalRouting::m_networkRoutes
NetworkRoutes m_networkRoutes
Routes to networks.
Definition: ipv4-global-routing.h:272
ns3::Ipv4GlobalRouting::m_respondToInterfaceEvents
bool m_respondToInterfaceEvents
Set to true if this interface should respond to interface events by globallly recomputing routes.
Definition: ipv4-global-routing.h:238
ns3::Ipv4GlobalRouting::AddNetworkRouteTo
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
Add a network route to the global routing table.
Definition: ipv4-global-routing.cc:96
ns3::Ipv4GlobalRouting::NotifyAddAddress
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
Definition: ipv4-global-routing.cc:566
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv4GlobalRouting::GetNRoutes
uint32_t GetNRoutes(void) const
Get the number of individual unicast routes that have been added to the routing table.
Definition: ipv4-global-routing.cc:249
ns3::Ipv4GlobalRouting::RouteInput
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
Definition: ipv4-global-routing.cc:491
ns3::Ipv4RoutingTableEntry
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Definition: ipv4-routing-table-entry.h:37
ns3::Ipv4GlobalRouting::ASExternalRoutesCI
std::list< Ipv4RoutingTableEntry * >::const_iterator ASExternalRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to external AS)
Definition: ipv4-global-routing.h:259
ns3::Ipv4GlobalRouting::NotifyInterfaceUp
virtual void NotifyInterfaceUp(uint32_t interface)
Definition: ipv4-global-routing.cc:542
ns3::Ipv4GlobalRouting
Global routing protocol for IPv4 stacks.
Definition: ipv4-global-routing.h:72
ns3::Ipv4GlobalRouting::HostRoutesCI
std::list< Ipv4RoutingTableEntry * >::const_iterator HostRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to hosts)
Definition: ipv4-global-routing.h:245
ns3::Ipv4GlobalRouting::GetRoute
Ipv4RoutingTableEntry * GetRoute(uint32_t i) const
Get a route from the global unicast routing table.
Definition: ipv4-global-routing.cc:260
ns3::Ipv4GlobalRouting::m_ASexternalRoutes
ASExternalRoutes m_ASexternalRoutes
External routes imported.
Definition: ipv4-global-routing.h:273
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::Ipv4GlobalRouting::ASExternalRoutesI
std::list< Ipv4RoutingTableEntry * >::iterator ASExternalRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to external AS)
Definition: ipv4-global-routing.h:261
ns3::Ipv4GlobalRouting::ASExternalRoutes
std::list< Ipv4RoutingTableEntry * > ASExternalRoutes
container of Ipv4RoutingTableEntry (routes to external AS)
Definition: ipv4-global-routing.h:257
ns3::Ipv4GlobalRouting::NetworkRoutes
std::list< Ipv4RoutingTableEntry * > NetworkRoutes
container of Ipv4RoutingTableEntry (routes to networks)
Definition: ipv4-global-routing.h:250
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition: ipv4-interface-address.h:44
first.address
address
Definition: first.py:44
ns3::Ipv4GlobalRouting::HostRoutes
std::list< Ipv4RoutingTableEntry * > HostRoutes
container of Ipv4RoutingTableEntry (routes to hosts)
Definition: ipv4-global-routing.h:243
ns3::Ipv4GlobalRouting::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: ipv4-global-routing.cc:41
ns3::Ipv4RoutingProtocol
Abstract base class for IPv4 routing protocols.
Definition: ipv4-routing-protocol.h:57
ns3::Ipv4GlobalRouting::m_ipv4
Ptr< Ipv4 > m_ipv4
associated IPv4 instance
Definition: ipv4-global-routing.h:275
ns3::Ipv4GlobalRouting::PrintRoutingTable
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
Definition: ipv4-global-routing.cc:401
ns3::Ipv4GlobalRouting::NotifyInterfaceDown
virtual void NotifyInterfaceDown(uint32_t interface)
Definition: ipv4-global-routing.cc:554
ns3::Time::S
@ S
second
Definition: nstime.h:115
ns3::Ipv4GlobalRouting::HostRoutesI
std::list< Ipv4RoutingTableEntry * >::iterator HostRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to hosts)
Definition: ipv4-global-routing.h:247
ns3::Ipv4GlobalRouting::DoDispose
void DoDispose(void)
Destructor implementation.
Definition: ipv4-global-routing.cc:374
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
ns3::Ipv4GlobalRouting::NetworkRoutesI
std::list< Ipv4RoutingTableEntry * >::iterator NetworkRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to networks)
Definition: ipv4-global-routing.h:254
ns3::Ipv4GlobalRouting::~Ipv4GlobalRouting
virtual ~Ipv4GlobalRouting()
Definition: ipv4-global-routing.cc:69
ns3::Ipv4GlobalRouting::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: ipv4-global-routing.cc:366
ns3::Ipv4GlobalRouting::LookupGlobal
Ptr< Ipv4Route > LookupGlobal(Ipv4Address dest, Ptr< NetDevice > oif=0)
Lookup in the forwarding table for destination.
Definition: ipv4-global-routing.cc:140
ns3::Ipv4GlobalRouting::RemoveRoute
void RemoveRoute(uint32_t i)
Remove a route from the global unicast routing table.
Definition: ipv4-global-routing.cc:309
ns3::Ipv4GlobalRouting::RouteOutput
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
Definition: ipv4-global-routing.cc:462
ns3::Time::Unit
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:110
ns3::Ipv4GlobalRouting::NetworkRoutesCI
std::list< Ipv4RoutingTableEntry * >::const_iterator NetworkRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to networks)
Definition: ipv4-global-routing.h:252