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