blob: b3dffa42abcd46f7be5438b9323ee94e126bd7e5 [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
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070024#include "ns3/ndnSIM/model/ndn-common.hpp"
25
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070026#include "ns3/ptr.h"
27
28namespace ns3 {
29
30class Node;
Alexander Afanasyevce810142012-04-17 15:50:36 -070031class NodeContainer;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070032class Channel;
33
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070034namespace ndn {
35
Alexander Afanasyevce810142012-04-17 15:50:36 -070036/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070037 * @ingroup ndn-helpers
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070038 * @brief Helper for GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070039 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040class GlobalRoutingHelper {
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070041public:
Alexander Afanasyevce810142012-04-17 15:50:36 -070042 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070043 * @brief Install GlobalRouter interface on a node
Alexander Afanasyevce810142012-04-17 15:50:36 -070044 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070046 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070047 * @param node Node to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070048 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070049 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 Install(Ptr<Node> node);
Alexander Afanasyev49165862013-01-31 00:38:20 -080051
Alexander Afanasyevce810142012-04-17 15:50:36 -070052 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053 * @brief Install GlobalRouter interface on nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070054 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055 * Note that GlobalRouter will also be installed on all connected nodes and channels
Alexander Afanasyevce810142012-04-17 15:50:36 -070056 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070057 * @param nodes NodeContainer to install GlobalRouter interface
Alexander Afanasyevce810142012-04-17 15:50:36 -070058 */
59 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 Install(const NodeContainer& nodes);
Alexander Afanasyevce810142012-04-17 15:50:36 -070061
62 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 * @brief Install GlobalRouter interface on all nodes
Alexander Afanasyevce810142012-04-17 15:50:36 -070064 */
65 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 InstallAll();
Alexander Afanasyevce810142012-04-17 15:50:36 -070067
68 /**
69 * @brief Add `prefix' as origin on `node'
70 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
71 * @param node Pointer to a node
72 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070073 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 AddOrigin(const std::string& prefix, Ptr<Node> node);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070075
Alexander Afanasyevce810142012-04-17 15:50:36 -070076 /**
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070077 * @brief Add `prefix' as origin on all `nodes'
78 * @param prefix Prefix that is originated by nodes
79 * @param nodes NodeContainer
80 */
81 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 AddOrigins(const std::string& prefix, const NodeContainer& nodes);
Alexander Afanasyev49165862013-01-31 00:38:20 -080083
Alexander Afanasyev06d3a612012-04-17 22:25:40 -070084 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070085 * @brief Add `prefix' as origin on node `nodeName'
86 * @param prefix Prefix that is originated by node, e.g., node is a producer for this prefix
87 * @param nodeName Name of the node that is associated with Ptr<Node> using ns3::Names
88 */
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070089 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 AddOrigin(const std::string& prefix, const std::string& nodeName);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070091
Alexander Afanasyevce810142012-04-17 15:50:36 -070092 /**
Alexander Afanasyev49165862013-01-31 00:38:20 -080093 * @brief Add origin to each node based on the node's name (using Names class)
94 */
95 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 AddOriginsForAll();
Alexander Afanasyev49165862013-01-31 00:38:20 -080097
98 /**
Alexander Afanasyevce810142012-04-17 15:50:36 -070099 * @brief Calculate for every node shortest path trees and install routes to all prefix origins
Alexander Afanasyev16d252a2013-12-19 10:54:24 -0800100 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800101 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
102 *as is
Alexander Afanasyevce810142012-04-17 15:50:36 -0700103 */
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800104 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800105 CalculateRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevce810142012-04-17 15:50:36 -0700106
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800107 /**
108 * @brief Calculate all possible next-hop independent alternative routes
109 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800110 * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
111 *as is
Alexander Afanasyev16d252a2013-12-19 10:54:24 -0800112 *
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800113 * Refer to the implementation for more details.
114 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800115 * Note that this method is highly experimental and should be used with caution (very time
116 *consuming).
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800117 */
118 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800119 CalculateAllPossibleRoutes(bool invalidatedRoutes = true);
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800120
Alexander Afanasyevce810142012-04-17 15:50:36 -0700121private:
122 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800123 Install(Ptr<Channel> channel);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700124};
125
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700126} // namespace ndn
127} // namespace ns3
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700128
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700129#endif // NDN_GLOBAL_ROUTING_HELPER_H