blob: 0e658109613f66d7edbd62ead0cf4e72668ea8d2 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070019
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_GLOBAL_ROUTING_HELPER_H
21#define NDN_GLOBAL_ROUTING_HELPER_H
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
24
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070025#include "ns3/ptr.h"
26
27namespace ns3 {
28
29class Node;
Alexander Afanasyevce810142012-04-17 15:50:36 -070030class NodeContainer;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070031class Channel;
32
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070033namespace ndn {
34
Alexander Afanasyevce810142012-04-17 15:50:36 -070035/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070036 * @ingroup ndn-helpers
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070037 * @brief Helper for GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070038 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039class GlobalRoutingHelper {
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070040public:
Alexander Afanasyevce810142012-04-17 15:50:36 -070041 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070042 * @brief Install GlobalRouter interface on a node
Alexander Afanasyevce810142012-04-17 15:50:36 -070043 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070044 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070045 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070046 * @param node Node to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070047 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070048 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 Install(Ptr<Node> node);
Alexander Afanasyev49165862013-01-31 00:38:20 -080050
Alexander Afanasyevce810142012-04-17 15:50:36 -070051 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070052 * @brief Install GlobalRouter interface on nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070053 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070054 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070055 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056 * @param nodes NodeContainer to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070057 */
58 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 Install(const NodeContainer& nodes);
Alexander Afanasyevce810142012-04-17 15:50:36 -070060
61 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070062 * @brief Install GlobalRouter interface on all nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070063 */
64 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 InstallAll();
Alexander Afanasyevce810142012-04-17 15:50:36 -070066
67 /**
68 * @brief Add `prefix' as origin on `node'
69 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
70 * @param node Pointer to a node
71 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070072 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 AddOrigin(const std::string& prefix, Ptr<Node> node);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070074
Alexander Afanasyevce810142012-04-17 15:50:36 -070075 /**
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070076 * @brief Add `prefix' as origin on all `nodes'
77 * @param prefix Prefix that is originated by nodes
78 * @param nodes NodeContainer
79 */
80 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 AddOrigins(const std::string& prefix, const NodeContainer& nodes);
Alexander Afanasyev49165862013-01-31 00:38:20 -080082
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070083 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070084 * @brief Add `prefix' as origin on node `nodeName'
85 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
86 * @param nodeName Name of the node that is associated with Ptr<Node> using ns3::Names
87 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070088 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 AddOrigin(const std::string& prefix, const std::string& nodeName);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070090
Alexander Afanasyevce810142012-04-17 15:50:36 -070091 /**
Alexander Afanasyev49165862013-01-31 00:38:20 -080092 * @brief Add origin to each node based on the node's name (using Names class)
93 */
94 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 AddOriginsForAll();
Alexander Afanasyev49165862013-01-31 00:38:20 -080096
97 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070098 * @brief Calculate for every node shortest path trees and install routes to all prefix origins
Alexander Afanasyev16d252a2013-12-19 10:54:24 -080099 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800100 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
101 *as is
Alexander Afanasyevce810142012-04-17 15:50:36 -0700102 */
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800103 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 CalculateRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevce810142012-04-17 15:50:36 -0700105
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800106 /**
107 * @brief Calculate all possible next-hop independent alternative routes
108 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800109 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
110 *as is
Alexander Afanasyev16d252a2013-12-19 10:54:24 -0800111 *
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800112 * Refer to the implementation for more details.
113 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800114 * Note that this method is highly experimental and should be used with caution (very time
115 *consuming).
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800116 */
117 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800118 CalculateAllPossibleRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800119
Alexander Afanasyevce810142012-04-17 15:50:36 -0700120private:
121 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800122 Install(Ptr<Channel> channel);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700123};
124
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700125} // namespace ndn
126} // namespace ns3
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700127
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700128#endif // NDN_GLOBAL_ROUTING_HELPER_H