blob: a765ebfba8f6c1357d9d4b845dc53f0e08e147ab [file] [log] [blame]
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 UCLA
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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021#ifndef NDN_GLOBAL_ROUTING_HELPER_H
22#define NDN_GLOBAL_ROUTING_HELPER_H
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070023
24#include "ns3/ptr.h"
25
26namespace ns3 {
27
28class Node;
Alexander Afanasyevce810142012-04-17 15:50:36 -070029class NodeContainer;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070030class Channel;
31
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070032namespace ndn {
33
Alexander Afanasyevce810142012-04-17 15:50:36 -070034/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070035 * @ingroup ndn-helpers
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070036 * @brief Helper for GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070037 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038class GlobalRoutingHelper {
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070039public:
Alexander Afanasyevce810142012-04-17 15:50:36 -070040 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070041 * @brief Install GlobalRouter interface on a node
Alexander Afanasyevce810142012-04-17 15:50:36 -070042 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070043 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070044 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045 * @param node Node to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070046 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070047 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 Install(Ptr<Node> node);
Alexander Afanasyev49165862013-01-31 00:38:20 -080049
Alexander Afanasyevce810142012-04-17 15:50:36 -070050 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051 * @brief Install GlobalRouter interface on nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070052 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070054 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055 * @param nodes NodeContainer to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070056 */
57 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058 Install(const NodeContainer& nodes);
Alexander Afanasyevce810142012-04-17 15:50:36 -070059
60 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070061 * @brief Install GlobalRouter interface on all nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070062 */
63 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 InstallAll();
Alexander Afanasyevce810142012-04-17 15:50:36 -070065
66 /**
67 * @brief Add `prefix' as origin on `node'
68 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
69 * @param node Pointer to a node
70 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070071 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 AddOrigin(const std::string& prefix, Ptr<Node> node);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070073
Alexander Afanasyevce810142012-04-17 15:50:36 -070074 /**
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070075 * @brief Add `prefix' as origin on all `nodes'
76 * @param prefix Prefix that is originated by nodes
77 * @param nodes NodeContainer
78 */
79 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 AddOrigins(const std::string& prefix, const NodeContainer& nodes);
Alexander Afanasyev49165862013-01-31 00:38:20 -080081
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070082 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070083 * @brief Add `prefix' as origin on node `nodeName'
84 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
85 * @param nodeName Name of the node that is associated with Ptr<Node> using ns3::Names
86 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070087 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 AddOrigin(const std::string& prefix, const std::string& nodeName);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070089
Alexander Afanasyevce810142012-04-17 15:50:36 -070090 /**
Alexander Afanasyev49165862013-01-31 00:38:20 -080091 * @brief Add origin to each node based on the node's name (using Names class)
92 */
93 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 AddOriginsForAll();
Alexander Afanasyev49165862013-01-31 00:38:20 -080095
96 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070097 * @brief Calculate for every node shortest path trees and install routes to all prefix origins
Alexander Afanasyev16d252a2013-12-19 10:54:24 -080098 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080099 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
100 *as is
Alexander Afanasyevce810142012-04-17 15:50:36 -0700101 */
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800102 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 CalculateRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevce810142012-04-17 15:50:36 -0700104
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800105 /**
106 * @brief Calculate all possible next-hop independent alternative routes
107 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800108 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
109 *as is
Alexander Afanasyev16d252a2013-12-19 10:54:24 -0800110 *
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800111 * Refer to the implementation for more details.
112 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800113 * Note that this method is highly experimental and should be used with caution (very time
114 *consuming).
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800115 */
116 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800117 CalculateAllPossibleRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800118
Alexander Afanasyevce810142012-04-17 15:50:36 -0700119private:
120 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800121 Install(Ptr<Channel> channel);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700122};
123
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700124} // namespace ndn
125} // namespace ns3
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700126
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700127#endif // NDN_GLOBAL_ROUTING_HELPER_H