Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Klaus Schneider | 3878430 | 2019-08-31 18:26:36 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2011-2019 Regents of the University of California. |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * 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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * 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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * 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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 19 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 20 | #ifndef NDN_GLOBAL_ROUTING_HELPER_H |
| 21 | #define NDN_GLOBAL_ROUTING_HELPER_H |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 22 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 24 | |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 25 | #include "ns3/ptr.h" |
| 26 | |
| 27 | namespace ns3 { |
| 28 | |
| 29 | class Node; |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 30 | class NodeContainer; |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 31 | class Channel; |
| 32 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 33 | namespace ndn { |
| 34 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 35 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 36 | * @ingroup ndn-helpers |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 37 | * @brief Helper for GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 38 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 39 | class GlobalRoutingHelper { |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 40 | public: |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 41 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 42 | * @brief Install GlobalRouter interface on a node |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 43 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 44 | * 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] | 45 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 46 | * @param node Node to install GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 47 | */ |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 48 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 49 | Install(Ptr<Node> node); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 51 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 52 | * @brief Install GlobalRouter interface on nodes |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 53 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 54 | * 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] | 55 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 56 | * @param nodes NodeContainer to install GlobalRouter interface |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 57 | */ |
| 58 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 59 | Install(const NodeContainer& nodes); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 62 | * @brief Install GlobalRouter interface on all nodes |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 63 | */ |
| 64 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | InstallAll(); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 66 | |
| 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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 72 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 73 | AddOrigin(const std::string& prefix, Ptr<Node> node); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 74 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 75 | /** |
Alexander Afanasyev | 06d3a61 | 2012-04-17 22:25:40 -0700 | [diff] [blame] | 76 | * @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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 81 | AddOrigins(const std::string& prefix, const NodeContainer& nodes); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 82 | |
Alexander Afanasyev | 06d3a61 | 2012-04-17 22:25:40 -0700 | [diff] [blame] | 83 | /** |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 84 | * @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 Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 88 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 89 | AddOrigin(const std::string& prefix, const std::string& nodeName); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 91 | /** |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 92 | * @brief Add origin to each node based on the node's name (using Names class) |
| 93 | */ |
| 94 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 95 | AddOriginsForAll(); |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 96 | |
| 97 | /** |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 98 | * @brief Calculate for every node shortest path trees and install routes to all prefix origins |
| 99 | */ |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 100 | static void |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 101 | CalculateRoutes(); |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 102 | |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 103 | /** |
Klaus Schneider | 3878430 | 2019-08-31 18:26:36 -0700 | [diff] [blame^] | 104 | * @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 Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 117 | * @brief Calculate all possible next-hop independent alternative routes |
| 118 | * |
| 119 | * Refer to the implementation for more details. |
| 120 | * |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 121 | * Note that this method is highly experimental and should be used with caution (very time |
| 122 | *consuming). |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 123 | */ |
| 124 | static void |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 125 | CalculateAllPossibleRoutes(); |
Alexander Afanasyev | f484fb9 | 2013-03-04 10:37:27 -0800 | [diff] [blame] | 126 | |
Alexander Afanasyev | ce81014 | 2012-04-17 15:50:36 -0700 | [diff] [blame] | 127 | private: |
| 128 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 129 | Install(Ptr<Channel> channel); |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 132 | } // namespace ndn |
| 133 | } // namespace ns3 |
Alexander Afanasyev | ad3757f | 2012-04-17 10:27:59 -0700 | [diff] [blame] | 134 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 135 | #endif // NDN_GLOBAL_ROUTING_HELPER_H |