blob: d14b2febd7293db5b56789bb298a00decad7910f [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Klaus Schneider38784302019-08-31 18:26:36 -07003 * Copyright (c) 2011-2019 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
99 */
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800100 static void
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +0000101 CalculateRoutes();
Alexander Afanasyevce810142012-04-17 15:50:36 -0700102
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800103 /**
Klaus Schneider38784302019-08-31 18:26:36 -0700104 * @brief Calculates a set of loop-free multipath routes.
105 *
106 * For full description please see tech tech report "Hop-by-Hop Multipath Routing:
107 * Choosing the Right Nexthop Set" and the associated Github repository:
108 *
109 * https://github.com/schneiderklaus/ndnSIM-routing
110 *
111 * @sa https://named-data.net/publications/techreports/mp_routing_tech_report/
112 */
113 static void
114 CalculateLfidRoutes();
115
116 /**
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800117 * @brief Calculate all possible next-hop independent alternative routes
118 *
119 * Refer to the implementation for more details.
120 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800121 * Note that this method is highly experimental and should be used with caution (very time
122 *consuming).
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800123 */
124 static void
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +0000125 CalculateAllPossibleRoutes();
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800126
Alexander Afanasyevce810142012-04-17 15:50:36 -0700127private:
128 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800129 Install(Ptr<Channel> channel);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700130};
131
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700132} // namespace ndn
133} // namespace ns3
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700134
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700135#endif // NDN_GLOBAL_ROUTING_HELPER_H