blob: 1385e3141c098cd21324f8b43f30358da7dcee7d [file] [log] [blame]
Spyridon Mastorakis588fd102014-11-20 19:50:02 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08003 * Copyright (c) 2011-2015 Regents of the University of California.
Spyridon Mastorakis588fd102014-11-20 19:50:02 -08004 *
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
32namespace ns3 {
33namespace ndn {
34
35using ::ndn::nfd::ControlParameters;
36
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080037/**
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 Mastorakis588fd102014-11-20 19:50:02 -080045class FibHelper {
46public:
47 /**
48 * \brief Add forwarding entry to FIB
49 *
50 * \param nodeName Node name
51 * \param prefix Routing prefix
52 * \param faceId Face index
53 * \param metric Routing metric
54 */
55 static void
56 AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric);
57
58 /**
59 * \brief Add forwarding entry to FIB
60 *
61 * \param nodeName Node
62 * \param prefix Routing prefix
63 * \param faceId Face index
64 * \param metric Routing metric
65 */
66 static void
67 AddRoute(Ptr<Node> node, const Name& prefix, uint32_t faceId, int32_t metric);
68
69 /**
70 * \brief Add forwarding entry to FIB
71 *
72 * \param node Node
73 * \param prefix Routing prefix
74 * \param face Face
75 * \param metric Routing metric
76 */
77 static void
78 AddRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face, int32_t metric);
79
80 /**
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
104private:
105 static void
106 GenerateCommand(Interest& interest);
107
108 static void
109 AddNextHop(const ControlParameters& parameters, Ptr<Node> node);
110
111 static void
112 RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node);
113};
114
115} // namespace ndn
116
117} // namespace ns3
118
119#endif // NDN_FIB_HELPER_H