A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
70 {
71 public:
76  static TypeId GetTypeId (void);
86  virtual ~Ipv4GlobalRouting ();
87 
88  // These methods inherited from base class
89  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
90 
91  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
94  virtual void NotifyInterfaceUp (uint32_t interface);
95  virtual void NotifyInterfaceDown (uint32_t interface);
96  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
97  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
98  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
99  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
100 
111  void AddHostRouteTo (Ipv4Address dest,
112  Ipv4Address nextHop,
113  uint32_t interface);
123  void AddHostRouteTo (Ipv4Address dest,
124  uint32_t interface);
125 
137  void AddNetworkRouteTo (Ipv4Address network,
138  Ipv4Mask networkMask,
139  Ipv4Address nextHop,
140  uint32_t interface);
141 
152  void AddNetworkRouteTo (Ipv4Address network,
153  Ipv4Mask networkMask,
154  uint32_t interface);
155 
165  void AddASExternalRouteTo (Ipv4Address network,
166  Ipv4Mask networkMask,
167  Ipv4Address nextHop,
168  uint32_t interface);
169 
177  uint32_t GetNRoutes (void) const;
178 
199  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
200 
217  void RemoveRoute (uint32_t i);
218 
227  int64_t AssignStreams (int64_t stream);
228 
229 protected:
230  void DoDispose (void);
231 
232 private:
239 
241  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
243  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
245  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
246 
248  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
250  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
252  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
253 
255  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
257  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
259  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
260 
262 
266 
268 };
269 
270 } // Namespace ns3
271 
272 #endif /* IPV4_GLOBAL_ROUTING_H */
std::list< Ipv4RoutingTableEntry * >::iterator HostRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to hosts)
virtual void NotifyInterfaceUp(uint32_t interface)
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Callback template class.
Definition: callback.h:920
Ipv4GlobalRouting()
Construct an empty Ipv4GlobalRouting routing protocol,.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
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)
virtual void NotifyInterfaceDown(uint32_t interface)
void RemoveRoute(uint32_t i)
Remove a route from the global unicast routing table.
Ipv4RoutingTableEntry * GetRoute(uint32_t i) const
Get a route from the global unicast routing table.
std::list< Ipv4RoutingTableEntry * > HostRoutes
container of Ipv4RoutingTableEntry (routes to hosts)
std::list< Ipv4RoutingTableEntry * >::const_iterator ASExternalRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to external AS)
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ASExternalRoutes m_ASexternalRoutes
External routes imported.
Packet header for IPv4.
Definition: ipv4-header.h:31
HostRoutes m_hostRoutes
Routes to hosts.
Ptr< UniformRandomVariable > m_rand
A uniform random number generator for randomly routing packets among ECMP.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Ptr< Ipv4 > m_ipv4
associated IPv4 instance
bool m_respondToInterfaceEvents
Set to true if this interface should respond to interface events by globallly recomputing routes...
Global routing protocol for IP version 4 stacks.
std::list< Ipv4RoutingTableEntry * >::const_iterator NetworkRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to networks)
bool m_randomEcmpRouting
Set to true if packets are randomly routed among ECMP; set to false for using only one route consiste...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< Ipv4Route > LookupGlobal(Ipv4Address dest, Ptr< NetDevice > oif=0)
std::list< Ipv4RoutingTableEntry * >::const_iterator HostRoutesCI
const iterator of container of Ipv4RoutingTableEntry (routes to hosts)
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.
std::list< Ipv4RoutingTableEntry * >::iterator ASExternalRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to external AS)
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
Add a network route to the global routing table.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
std::list< Ipv4RoutingTableEntry * >::iterator NetworkRoutesI
iterator of container of Ipv4RoutingTableEntry (routes to networks)
a class to store IPv4 address information on an interface
std::list< Ipv4RoutingTableEntry * > NetworkRoutes
container of Ipv4RoutingTableEntry (routes to networks)
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
Abstract base class for IPv4 routing protocols.
NetworkRoutes m_networkRoutes
Routes to networks.
tuple address
Definition: first.py:37
static TypeId GetTypeId(void)
Get the type ID.
std::list< Ipv4RoutingTableEntry * > ASExternalRoutes
container of Ipv4RoutingTableEntry (routes to external AS)
a unique identifier for an interface.
Definition: type-id.h:49
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
uint32_t GetNRoutes(void) const
Get the number of individual unicast routes that have been added to the routing table.
void AddASExternalRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
Add an external route to the global routing table.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
void AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface)
Add a host route to the global routing table.