src/routing/global-routing/model/ipv4-global-routing.h
author Tom Henderson <tomh@tomh.org>
Mon, 20 Dec 2010 16:34:59 -0800
changeset 6701 a590022a1536
parent 6648 d1785ce489c5
permissions -rw-r--r--
[bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
// Copyright (c) 2008 University of Washington
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
// This program is free software; you can redistribute it and/or modify
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
// it under the terms of the GNU General Public License version 2 as
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
// published by the Free Software Foundation;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
// This program is distributed in the hope that it will be useful,
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
// GNU General Public License for more details.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
// You should have received a copy of the GNU General Public License
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
// along with this program; if not, write to the Free Software
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
//
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
#ifndef IPV4_GLOBAL_ROUTING_H
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
#define IPV4_GLOBAL_ROUTING_H
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
#include <list>
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
#include <stdint.h>
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
#include "ns3/ipv4-address.h"
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
#include "ns3/ipv4-header.h"
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
#include "ns3/ptr.h"
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
#include "ns3/ipv4.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    29
#include "ns3/ipv4-routing-protocol.h"
5858
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
    30
#include "ns3/random-variable.h"
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
namespace ns3 {
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
class Packet;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
class NetDevice;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
class Ipv4Interface;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
class Ipv4Address;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
class Ipv4Header;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    39
class Ipv4RoutingTableEntry;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    40
class Ipv4MulticastRoutingTableEntry;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
class Node;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    45
 * \brief Global routing protocol for IP version 4 stacks.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
 * In ns-3 we have the concept of a pluggable routing protocol.  Routing
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
 * protocols are added to a list maintained by the Ipv4L3Protocol.  Every 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
 * stack gets one routing protocol for free -- the Ipv4StaticRouting routing
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
 * protocol is added in the constructor of the Ipv4L3Protocol (this is the 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
 * piece of code that implements the functionality of the IP layer).
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
 * As an option to running a dynamic routing protocol, a GlobalRouteManager
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
 * object has been created to allow users to build routes for all participating
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
 * nodes.  One can think of this object as a "routing oracle"; it has
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
 * an omniscient view of the topology, and can construct shortest path
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
 * routes between all pairs of nodes.  These routes must be stored 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
 * somewhere in the node, so therefore this class Ipv4GlobalRouting
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
 * is used as one of the pluggable routing protocols.  It is kept distinct
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
 * from Ipv4StaticRouting because these routes may be dynamically cleared
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
 * and rebuilt in the middle of the simulation, while manually entered
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
 * routes into the Ipv4StaticRouting may need to be kept distinct.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
 * This class deals with Ipv4 unicast routes only.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    66
 * \see Ipv4RoutingProtocol
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    67
 * \see GlobalRouteManager
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
class Ipv4GlobalRouting : public Ipv4RoutingProtocol
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
{
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
public:
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
  static TypeId GetTypeId (void);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    74
 * \brief Construct an empty Ipv4GlobalRouting routing protocol,
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
 * The Ipv4GlobalRouting class supports host and network unicast routes.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
 * This method initializes the lists containing these routes to empty.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    79
 * \see Ipv4GlobalRouting
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
  Ipv4GlobalRouting ();
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    82
  virtual ~Ipv4GlobalRouting ();
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
6317
e4a750adf12c bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents: 6273
diff changeset
    84
  // These methods inherited from base class
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4745
diff changeset
    85
  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    86
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    87
  virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    88
                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    89
                             LocalDeliverCallback lcb, ErrorCallback ecb);
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
    90
  virtual void NotifyInterfaceUp (uint32_t interface);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
    91
  virtual void NotifyInterfaceDown (uint32_t interface);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
    92
  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
    93
  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
    94
  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6648
diff changeset
    95
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
    98
 * \brief Add a host route to the global routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   100
 * \param dest The Ipv4Address destination for this route.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   101
 * \param nextHop The Ipv4Address of the next hop in the route.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   102
 * \param interface The network interface index used to send packets to the
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
 * destination.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   105
 * \see Ipv4Address
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  void AddHostRouteTo (Ipv4Address dest, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
                       Ipv4Address nextHop, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
                       uint32_t interface);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   111
 * \brief Add a host route to the global routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   113
 * \param dest The Ipv4Address destination for this route.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   114
 * \param interface The network interface index used to send packets to the
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
 * destination.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   117
 * \see Ipv4Address
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  void AddHostRouteTo (Ipv4Address dest, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
                       uint32_t interface);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   123
 * \brief Add a network route to the global routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   125
 * \param network The Ipv4Address network for this route.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   126
 * \param networkMask The Ipv4Mask to extract the network.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   127
 * \param nextHop The next hop in the route to the destination network.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   128
 * \param interface The network interface index used to send packets to the
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
 * destination.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   131
 * \see Ipv4Address
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
  void AddNetworkRouteTo (Ipv4Address network, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
                          Ipv4Mask networkMask, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
                          Ipv4Address nextHop, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
                          uint32_t interface);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   137
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   139
 * \brief Add a network route to the global routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   141
 * \param network The Ipv4Address network for this route.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   142
 * \param networkMask The Ipv4Mask to extract the network.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   143
 * \param interface The network interface index used to send packets to the
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
 * destination.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   146
 * \see Ipv4Address
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
  void AddNetworkRouteTo (Ipv4Address network, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
                          Ipv4Mask networkMask, 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
                          uint32_t interface);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
/**
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   153
 * \brief Add an external route to the global routing table.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   154
 *
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   155
 * \param network The Ipv4Address network for this route.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   156
 * \param networkMask The Ipv4Mask to extract the network.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   157
 * \param nextHop The next hop Ipv4Address
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   158
 * \param interface The network interface index used to send packets to the
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   159
 * destination.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   160
 */
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   161
  void AddASExternalRouteTo (Ipv4Address network,
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   162
                             Ipv4Mask networkMask,
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   163
                             Ipv4Address nextHop,
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   164
                             uint32_t interface);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   165
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   166
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   167
 * \brief Get the number of individual unicast routes that have been added
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
 * to the routing table.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   170
 * \warning The default route counts as one of the routes.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
 */
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6648
diff changeset
   172
  uint32_t GetNRoutes (void) const;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   175
 * \brief Get a route from the global unicast routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
 * Externally, the unicast global routing table appears simply as a table with
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5858
diff changeset
   178
 * n entries.  The one subtlety of note is that if a default route has been set
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
 * it will appear as the zeroth entry in the table.  This means that if you
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
 * add only a default route, the table will have one entry that can be accessed
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5858
diff changeset
   181
 * either by explicitly calling GetDefaultRoute () or by calling GetRoute (0).
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   182
 * 
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
 * Similarly, if the default route has been set, calling RemoveRoute (0) will
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
 * remove the default route.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   186
 * \param i The index (into the routing table) of the route to retrieve.  If
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   187
 * the default route has been set, it will occupy index zero.
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   188
 * \return If route is set, a pointer to that Ipv4RoutingTableEntry is returned, otherwise
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
 * a zero pointer is returned.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   191
 * \see Ipv4RoutingTableEntry
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   192
 * \see Ipv4GlobalRouting::RemoveRoute
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
 */
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6648
diff changeset
   194
  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
/**
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   197
 * \brief Remove a route from the global unicast routing table.
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
 *
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
 * Externally, the unicast global routing table appears simply as a table with
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5858
diff changeset
   200
 * n entries.  The one subtlety of note is that if a default route has been set
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
 * it will appear as the zeroth entry in the table.  This means that if the
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   202
 * default route has been set, calling RemoveRoute (0) will remove the
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   203
 * default route.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   204
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   205
 * \param i The index (into the routing table) of the route to remove.  If
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   206
 * the default route has been set, it will occupy index zero.
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
 *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   208
 * \see Ipv4RoutingTableEntry
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   209
 * \see Ipv4GlobalRouting::GetRoute
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   210
 * \see Ipv4GlobalRouting::AddRoute
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
 */
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
  void RemoveRoute (uint32_t i);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
protected:
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
  void DoDispose (void);
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
private:
5858
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
   218
  /// Set to true if packets are randomly routed among ECMP; set to false for using only one route consistently
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
   219
  bool m_randomEcmpRouting;
6317
e4a750adf12c bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents: 6273
diff changeset
   220
  /// Set to true if this interface should respond to interface events by globallly recomputing routes 
e4a750adf12c bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents: 6273
diff changeset
   221
  bool m_respondToInterfaceEvents;
5858
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
   222
  /// A uniform random number generator for randomly routing packets among ECMP 
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
   223
  UniformVariable m_rand;
afb51c7f34c2 bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents: 5856
diff changeset
   224
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   225
  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   226
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   227
  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   228
  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   229
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   230
  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   231
  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   232
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   233
  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4745
diff changeset
   235
  Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   236
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
  HostRoutes m_hostRoutes;
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   238
  NetworkRoutes m_networkRoutes;
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   239
  ASExternalRoutes m_ASexternalRoutes; // External routes imported
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4603
diff changeset
   240
  
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4527
diff changeset
   241
  Ptr<Ipv4> m_ipv4;
3962
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
};
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   243
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   244
} // Namespace ns3
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   245
4d63e53d26ba add missing files
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   246
#endif /* IPV4_GLOBAL_ROUTING_H */