Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
| 7 | * |
| 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. |
| 11 | * |
| 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. |
| 15 | * |
| 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 | **/ |
| 19 | |
| 20 | #ifndef NDN_FIB_HELPER_H |
| 21 | #define NDN_FIB_HELPER_H |
| 22 | |
| 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 24 | |
| 25 | #include "ns3/node.h" |
| 26 | #include "ns3/object-vector.h" |
| 27 | #include "ns3/pointer.h" |
| 28 | |
Spyridon Mastorakis | f6d3285 | 2017-09-27 20:28:52 -0700 | [diff] [blame] | 29 | #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 30 | |
| 31 | namespace ns3 { |
| 32 | namespace ndn { |
| 33 | |
| 34 | using ::ndn::nfd::ControlParameters; |
| 35 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 36 | /** |
| 37 | * @ingroup ndn-helpers |
| 38 | * @brief Forwarding Information Base (FIB) helper |
| 39 | * |
| 40 | * The FIB helper interacts with the FIB manager of NFD by sending special Interest |
| 41 | * commands to the manager in order to add/remove a next hop from FIB entries or add |
| 42 | * routes to the FIB manually (manual configuration of FIB). |
| 43 | */ |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 44 | class FibHelper { |
| 45 | public: |
| 46 | /** |
| 47 | * \brief Add forwarding entry to FIB |
| 48 | * |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 49 | * \param node Node |
| 50 | * \param prefix Routing prefix |
| 51 | * \param face Face |
| 52 | * \param metric Routing metric |
| 53 | */ |
| 54 | static void |
| 55 | AddRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face, int32_t metric); |
| 56 | |
| 57 | /** |
| 58 | * \brief Add forwarding entry to FIB |
| 59 | * |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 60 | * \param nodeName Node name |
| 61 | * \param prefix Routing prefix |
| 62 | * \param faceId Face index |
| 63 | * \param metric Routing metric |
| 64 | */ |
| 65 | static void |
| 66 | AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric); |
| 67 | |
| 68 | /** |
| 69 | * \brief Add forwarding entry to FIB |
| 70 | * |
| 71 | * \param nodeName Node |
| 72 | * \param prefix Routing prefix |
| 73 | * \param faceId Face index |
| 74 | * \param metric Routing metric |
| 75 | */ |
| 76 | static void |
| 77 | AddRoute(Ptr<Node> node, const Name& prefix, uint32_t faceId, int32_t metric); |
| 78 | |
| 79 | /** |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 80 | * @brief Add forwarding entry to FIB (work only with point-to-point links) |
| 81 | * |
| 82 | * \param node Node |
| 83 | * \param prefix Routing prefix |
| 84 | * \param otherNode The other node, to which interests (will be used to infer face id |
| 85 | * \param metric Routing metric |
| 86 | */ |
| 87 | static void |
| 88 | AddRoute(Ptr<Node> node, const Name& prefix, Ptr<Node> otherNode, int32_t metric); |
| 89 | |
| 90 | /** |
| 91 | * @brief Add forwarding entry to FIB (work only with point-to-point links) |
| 92 | * |
| 93 | * \param nodeName Node name (refer to ns3::Names) |
| 94 | * \param prefix Routing prefix |
| 95 | * \param otherNode The other node name, to which interests (will be |
| 96 | * used to infer face id (refer to ns3::Names) |
| 97 | * \param metric Routing metric |
| 98 | */ |
| 99 | static void |
| 100 | AddRoute(const std::string& nodeName, const Name& prefix, const std::string& otherNodeName, |
| 101 | int32_t metric); |
| 102 | |
Yuanzhi Gao | 24a849d | 2015-05-16 14:32:27 -0700 | [diff] [blame] | 103 | /** |
| 104 | * \brief remove forwarding entry in FIB |
| 105 | * |
| 106 | * \param node Node |
| 107 | * \param prefix Routing prefix |
| 108 | * \param face Face |
| 109 | */ |
| 110 | static void |
| 111 | RemoveRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face); |
| 112 | |
| 113 | /** |
| 114 | * \brief remove forwarding entry in FIB |
| 115 | * |
| 116 | * \param node Node |
| 117 | * \param prefix Routing prefix |
| 118 | * \param faceId Face index |
| 119 | */ |
| 120 | static void |
| 121 | RemoveRoute(Ptr<Node> node, const Name& prefix, uint32_t faceId); |
| 122 | |
| 123 | /** |
| 124 | * \brief remove forwarding entry in FIB |
| 125 | * |
| 126 | * \param nodeName Node name |
| 127 | * \param prefix Routing prefix |
| 128 | * \param faceId Face index |
| 129 | */ |
| 130 | static void |
| 131 | RemoveRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId); |
| 132 | |
| 133 | /** |
| 134 | * @brief remove forwarding entry in FIB (work only with point-to-point links) |
| 135 | * |
| 136 | * \param node Node |
| 137 | * \param prefix Routing prefix |
| 138 | * \param otherNode The other node, to which interests (will be used to infer face id |
| 139 | */ |
| 140 | static void |
| 141 | RemoveRoute(Ptr<Node> node, const Name& prefix, Ptr<Node> otherNode); |
| 142 | |
| 143 | /** |
| 144 | * @brief remove forwarding entry in FIB (work only with point-to-point links) |
| 145 | * |
| 146 | * \param nodeName Node name |
| 147 | * \param prefix Routing prefix |
| 148 | * \param otherNode The other node name, to which interests (will be used to infer face id |
| 149 | */ |
| 150 | static void |
| 151 | RemoveRoute(const std::string& nodeName, const Name& prefix, const std::string& otherNodeName); |
| 152 | |
Spyridon Mastorakis | 588fd10 | 2014-11-20 19:50:02 -0800 | [diff] [blame] | 153 | private: |
| 154 | static void |
| 155 | GenerateCommand(Interest& interest); |
| 156 | |
| 157 | static void |
| 158 | AddNextHop(const ControlParameters& parameters, Ptr<Node> node); |
| 159 | |
| 160 | static void |
| 161 | RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node); |
| 162 | }; |
| 163 | |
| 164 | } // namespace ndn |
| 165 | |
| 166 | } // namespace ns3 |
| 167 | |
| 168 | #endif // NDN_FIB_HELPER_H |