Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 21 | #ifndef NDN_GLOBAL_ROUTING_HELPER_H |
| 22 | #define NDN_GLOBAL_ROUTING_HELPER_H |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 23 | |
| 24 | #include "ns3/ptr.h" |
| 25 | |
| 26 | namespace ns3 { |
| 27 | |
| 28 | class Node; |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 29 | class NodeContainer; |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 30 | class Channel; |
| 31 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 32 | namespace ndn { |
| 33 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 34 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 35 | * @ingroup ndn-helpers |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 36 | * @brief Helper for GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 37 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 38 | class GlobalRoutingHelper { |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 39 | public: |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 40 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 41 | * @brief Install GlobalRouter interface on a node |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 42 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 43 | * Note that GlobalRouter will also be installed on all connected nodes and channels |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 44 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 45 | * @param node Node to install GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 46 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 47 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 48 | Install(Ptr<Node> node); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 50 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 51 | * @brief Install GlobalRouter interface on nodes |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 52 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 53 | * Note that GlobalRouter will also be installed on all connected nodes and channels |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 54 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 55 | * @param nodes NodeContainer to install GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 56 | */ |
| 57 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 58 | Install(const NodeContainer& nodes); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 61 | * @brief Install GlobalRouter interface on all nodes |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 62 | */ |
| 63 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 64 | InstallAll(); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 65 | |
| 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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 71 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | AddOrigin(const std::string& prefix, Ptr<Node> node); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 73 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 74 | /** |
Alexander Afanasyev | 06d3a61 | 2012-04-17 22:25:40 -0700 | [diff] [blame] | 75 | * @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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | AddOrigins(const std::string& prefix, const NodeContainer& nodes); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 81 | |
Alexander Afanasyev | 06d3a61 | 2012-04-17 22:25:40 -0700 | [diff] [blame] | 82 | /** |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 83 | * @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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 87 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 88 | AddOrigin(const std::string& prefix, const std::string& nodeName); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 89 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 90 | /** |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 91 | * @brief Add origin to each node based on the node's name (using Names class) |
| 92 | */ |
| 93 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 94 | AddOriginsForAll(); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 97 | * @brief Calculate for every node shortest path trees and install routes to all prefix origins |
Alexander Afanasyev | 16d252a | 2013-12-19 10:54:24 -0800 | [diff] [blame] | 98 | * |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 99 | * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps |
| 100 | *as is |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 101 | */ |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 102 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 103 | CalculateRoutes(bool invalidatedRoutes = true); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 105 | /** |
| 106 | * @brief Calculate all possible next-hop independent alternative routes |
| 107 | * |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 108 | * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps |
| 109 | *as is |
Alexander Afanasyev | 16d252a | 2013-12-19 10:54:24 -0800 | [diff] [blame] | 110 | * |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 111 | * Refer to the implementation for more details. |
| 112 | * |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 113 | * Note that this method is highly experimental and should be used with caution (very time |
| 114 | *consuming). |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 115 | */ |
| 116 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 117 | CalculateAllPossibleRoutes(bool invalidatedRoutes = true); |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 118 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 119 | private: |
| 120 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 121 | Install(Ptr<Channel> channel); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 122 | }; |
| 123 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 124 | } // namespace ndn |
| 125 | } // namespace ns3 |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 126 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 127 | #endif // NDN_GLOBAL_ROUTING_HELPER_H |