blob: cf52c6fc6d8effee5a51e3198550ab4f161cb3af [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevad3757f2012-04-17 10:27:59 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * 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 Afanasyevad3757f2012-04-17 10:27:59 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * 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 Afanasyevad3757f2012-04-17 10:27:59 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * 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 Afanasyevad3757f2012-04-17 10:27:59 -070019
Alexander Afanasyev3898e1b2013-07-27 12:03:17 -070020#if __clang__
21#pragma clang diagnostic push
22#pragma clang diagnostic ignored "-Wunused-variable"
23#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
24#endif
25
Alexander Afanasyev0c395372014-12-20 15:54:02 -080026#include "ndn-global-routing-helper.hpp"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070027
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -080028#include "model/ndn-l3-protocol.hpp"
29#include "helper/ndn-fib-helper.hpp"
30#include "model/ndn-net-device-face.hpp"
31#include "model/ndn-global-router.hpp"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070032
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -080033#include "daemon/table/fib.hpp"
34#include "daemon/fw/forwarder.hpp"
35#include "daemon/table/fib-entry.hpp"
36#include "daemon/table/fib-nexthop.hpp"
37
38#include "ns3/object.h"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070039#include "ns3/node.h"
Alexander Afanasyevce810142012-04-17 15:50:36 -070040#include "ns3/node-container.h"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070041#include "ns3/net-device.h"
42#include "ns3/channel.h"
43#include "ns3/log.h"
44#include "ns3/assert.h"
45#include "ns3/names.h"
46#include "ns3/node-list.h"
47#include "ns3/channel-list.h"
Alexander Afanasyevf5c07742012-10-31 13:13:05 -070048#include "ns3/object-factory.h"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070049
50#include <boost/lexical_cast.hpp>
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -070051#include <boost/foreach.hpp>
Alexander Afanasyeva5abcd92012-04-17 13:34:43 -070052#include <boost/concept/assert.hpp>
Alexander Afanasyeva5abcd92012-04-17 13:34:43 -070053#include <boost/graph/dijkstra_shortest_paths.hpp>
54
Alexander Afanasyev0c395372014-12-20 15:54:02 -080055#include "boost-graph-ndn-global-routing-helper.hpp"
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070056
Alexander Afanasyev73532512012-11-27 00:42:35 -080057#include <math.h>
58
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059NS_LOG_COMPONENT_DEFINE("ndn.GlobalRoutingHelper");
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070060
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070061namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070062namespace ndn {
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070063
64void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065GlobalRoutingHelper::Install(Ptr<Node> node)
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070066{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 NS_LOG_LOGIC("Node: " << node->GetId());
Alexander Afanasyev49165862013-01-31 00:38:20 -080068
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
70 NS_ASSERT_MSG(ndn != 0, "Cannot install GlobalRoutingHelper before Ndn is installed on a node");
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070071
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter>();
73 if (gr != 0) {
74 NS_LOG_DEBUG("GlobalRouter is already installed: " << gr);
75 return; // already installed
76 }
77
78 gr = CreateObject<GlobalRouter>();
79 node->AggregateObject(gr);
80
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -080081 for (auto& i : ndn->getForwarder()->getFaceTable()) {
82 shared_ptr<NetDeviceFace> face = std::dynamic_pointer_cast<NetDeviceFace>(i);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 if (face == 0) {
84 NS_LOG_DEBUG("Skipping non-netdevice face");
85 continue;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070086 }
Alexander Afanasyev49165862013-01-31 00:38:20 -080087
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 Ptr<NetDevice> nd = face->GetNetDevice();
89 if (nd == 0) {
90 NS_LOG_DEBUG("Not a NetDevice associated with NetDeviceFace");
91 continue;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -070092 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093
94 Ptr<Channel> ch = nd->GetChannel();
95
96 if (ch == 0) {
97 NS_LOG_DEBUG("Channel is not associated with NetDevice");
98 continue;
99 }
100
101 if (ch->GetNDevices() == 2) // e.g., point-to-point channel
102 {
103 for (uint32_t deviceId = 0; deviceId < ch->GetNDevices(); deviceId++) {
104 Ptr<NetDevice> otherSide = ch->GetDevice(deviceId);
105 if (nd == otherSide)
106 continue;
107
108 Ptr<Node> otherNode = otherSide->GetNode();
109 NS_ASSERT(otherNode != 0);
110
111 Ptr<GlobalRouter> otherGr = otherNode->GetObject<GlobalRouter>();
112 if (otherGr == 0) {
113 Install(otherNode);
114 }
115 otherGr = otherNode->GetObject<GlobalRouter>();
116 NS_ASSERT(otherGr != 0);
117 gr->AddIncidency(face, otherGr);
118 }
119 }
120 else {
121 Ptr<GlobalRouter> grChannel = ch->GetObject<GlobalRouter>();
122 if (grChannel == 0) {
123 Install(ch);
124 }
125 grChannel = ch->GetObject<GlobalRouter>();
126
127 gr->AddIncidency(face, grChannel);
128 }
129 }
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700130}
131
132void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800133GlobalRoutingHelper::Install(Ptr<Channel> channel)
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700134{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800135 NS_LOG_LOGIC("Channel: " << channel->GetId());
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700136
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800137 Ptr<GlobalRouter> gr = channel->GetObject<GlobalRouter>();
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700138 if (gr != 0)
139 return;
140
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800141 gr = CreateObject<GlobalRouter>();
142 channel->AggregateObject(gr);
Alexander Afanasyev49165862013-01-31 00:38:20 -0800143
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800144 for (uint32_t deviceId = 0; deviceId < channel->GetNDevices(); deviceId++) {
145 Ptr<NetDevice> dev = channel->GetDevice(deviceId);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700146
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800147 Ptr<Node> node = dev->GetNode();
148 NS_ASSERT(node != 0);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700149
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800150 Ptr<GlobalRouter> grOther = node->GetObject<GlobalRouter>();
151 if (grOther == 0) {
152 Install(node);
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700153 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800154 grOther = node->GetObject<GlobalRouter>();
155 NS_ASSERT(grOther != 0);
156
157 gr->AddIncidency(0, grOther);
158 }
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700159}
160
161void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800162GlobalRoutingHelper::Install(const NodeContainer& nodes)
Alexander Afanasyevce810142012-04-17 15:50:36 -0700163{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800164 for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
165 Install(*node);
166 }
167}
168
169void
170GlobalRoutingHelper::InstallAll()
171{
172 Install(NodeContainer::GetGlobal());
173}
174
175void
176GlobalRoutingHelper::AddOrigin(const std::string& prefix, Ptr<Node> node)
177{
178 Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter>();
179 NS_ASSERT_MSG(gr != 0, "GlobalRouter is not installed on the node");
180
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700181 auto name = make_shared<Name>(prefix);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800182 gr->AddLocalPrefix(name);
183}
184
185void
186GlobalRoutingHelper::AddOrigins(const std::string& prefix, const NodeContainer& nodes)
187{
188 for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
189 AddOrigin(prefix, *node);
190 }
191}
192
193void
194GlobalRoutingHelper::AddOrigin(const std::string& prefix, const std::string& nodeName)
195{
196 Ptr<Node> node = Names::Find<Node>(nodeName);
197 NS_ASSERT_MSG(node != 0, nodeName << "is not a Node");
198
199 AddOrigin(prefix, node);
200}
201
202void
203GlobalRoutingHelper::AddOriginsForAll()
204{
205 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
206 Ptr<GlobalRouter> gr = (*node)->GetObject<GlobalRouter>();
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800207 std::string name = Names::FindName(*node);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800208
209 if (gr != 0 && !name.empty()) {
210 AddOrigin("/" + name, *node);
Alexander Afanasyevce810142012-04-17 15:50:36 -0700211 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800212 }
Alexander Afanasyevce810142012-04-17 15:50:36 -0700213}
214
215void
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +0000216GlobalRoutingHelper::CalculateRoutes()
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700217{
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700218 /**
219 * Implementation of route calculation is heavily based on Boost Graph Library
220 * See http://www.boost.org/doc/libs/1_49_0/libs/graph/doc/table_of_contents.html for more details
221 */
Alexander Afanasyev49165862013-01-31 00:38:20 -0800222
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800223 BOOST_CONCEPT_ASSERT((boost::VertexListGraphConcept<boost::NdnGlobalRouterGraph>));
224 BOOST_CONCEPT_ASSERT((boost::IncidenceGraphConcept<boost::NdnGlobalRouterGraph>));
Alexander Afanasyev49165862013-01-31 00:38:20 -0800225
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800226 boost::NdnGlobalRouterGraph graph;
Zongyi Zhaoc8372632014-04-28 15:36:49 -0700227 // typedef graph_traits < NdnGlobalRouterGraph >::vertex_descriptor vertex_descriptor;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700228
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700229 // For now we doing Dijkstra for every node. Can be replaced with Bellman-Ford or Floyd-Warshall.
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800230 // Other algorithms should be faster, but they need additional EdgeListGraph concept provided by
231 // the graph, which
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700232 // is not obviously how implement in an efficient manner
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800233 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
234 Ptr<GlobalRouter> source = (*node)->GetObject<GlobalRouter>();
235 if (source == 0) {
236 NS_LOG_DEBUG("Node " << (*node)->GetId() << " does not export GlobalRouter interface");
237 continue;
238 }
Alexander Afanasyev49165862013-01-31 00:38:20 -0800239
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800240 boost::DistancesMap distances;
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700241
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800242 dijkstra_shortest_paths(graph, source,
243 // predecessor_map (boost::ref(predecessors))
244 // .
245 distance_map(boost::ref(distances))
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800246 .distance_inf(boost::WeightInf)
247 .distance_zero(boost::WeightZero)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800248 .distance_compare(boost::WeightCompare())
249 .distance_combine(boost::WeightCombine()));
250
251 // NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800252
253 Ptr<L3Protocol> L3protocol = (*node)->GetObject<L3Protocol>();
254 shared_ptr<nfd::Forwarder> forwarder = L3protocol->getForwarder();
255
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800256 NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId());
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800257 for (const auto& dist : distances) {
258 if (dist.first == source)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800259 continue;
260 else {
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800261 // cout << " Node " << dist.first->GetObject<Node> ()->GetId ();
262 if (std::get<0>(dist.second) == 0) {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800263 // cout << " is unreachable" << endl;
264 }
265 else {
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800266 for (const auto& prefix : dist.first->GetLocalPrefixes()) {
267 NS_LOG_DEBUG(" prefix " << prefix << " reachable via face " << *std::get<0>(dist.second)
268 << " with distance " << std::get<1>(dist.second) << " with delay "
269 << std::get<2>(dist.second));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800270
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800271 FibHelper::AddRoute(*node, *prefix, std::get<0>(dist.second),
272 std::get<1>(dist.second));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800273 }
274 }
275 }
276 }
277 }
278}
279
280void
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +0000281GlobalRoutingHelper::CalculateAllPossibleRoutes()
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800282{
283 /**
284 * Implementation of route calculation is heavily based on Boost Graph Library
285 * See http://www.boost.org/doc/libs/1_49_0/libs/graph/doc/table_of_contents.html for more details
286 */
287
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800288 BOOST_CONCEPT_ASSERT((boost::VertexListGraphConcept<boost::NdnGlobalRouterGraph>));
289 BOOST_CONCEPT_ASSERT((boost::IncidenceGraphConcept<boost::NdnGlobalRouterGraph>));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800290
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800291 boost::NdnGlobalRouterGraph graph;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800292 // typedef graph_traits < NdnGlobalRouterGraph >::vertex_descriptor vertex_descriptor;
293
294 // For now we doing Dijkstra for every node. Can be replaced with Bellman-Ford or Floyd-Warshall.
295 // Other algorithms should be faster, but they need additional EdgeListGraph concept provided by
296 // the graph, which
297 // is not obviously how implement in an efficient manner
298 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
299 Ptr<GlobalRouter> source = (*node)->GetObject<GlobalRouter>();
300 if (source == 0) {
301 NS_LOG_DEBUG("Node " << (*node)->GetId() << " does not export GlobalRouter interface");
302 continue;
303 }
304
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800305 Ptr<L3Protocol> L3protocol = (*node)->GetObject<L3Protocol>();
306 shared_ptr<nfd::Forwarder> forwarder = L3protocol->getForwarder();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800307
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800308 NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId() << " ("
309 << Names::FindName(source->GetObject<Node>()) << ")");
310
311 Ptr<L3Protocol> l3 = source->GetObject<L3Protocol>();
312 NS_ASSERT(l3 != 0);
313
314 // remember interface statuses
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800315 int faceNumber = 0;
316 std::vector<uint16_t> originalMetric(uint32_t(l3->getForwarder()->getFaceTable().size()));
317 for (auto& i : l3->getForwarder()->getFaceTable()) {
318 faceNumber++;
319 shared_ptr<Face> nfdFace = std::dynamic_pointer_cast<Face>(i);
320 originalMetric[uint32_t(faceNumber)] = nfdFace->getMetric();
321 nfdFace->setMetric(std::numeric_limits<uint16_t>::max() - 1);
322 // value std::numeric_limits<uint16_t>::max () MUST NOT be used (reserved)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800323 }
324
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800325 faceNumber = 0;
326 for (auto& k : l3->getForwarder()->getFaceTable()) {
327 faceNumber++;
328 shared_ptr<NetDeviceFace> face = std::dynamic_pointer_cast<NetDeviceFace>(k);
329 if (face == 0) {
330 NS_LOG_DEBUG("Skipping non-netdevice face");
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800331 continue;
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800332 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800333
334 // enabling only faceId
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800335 face->setMetric(originalMetric[uint32_t(faceNumber)]);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800336
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800337 boost::DistancesMap distances;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800338
339 NS_LOG_DEBUG("-----------");
340
341 dijkstra_shortest_paths(graph, source,
342 // predecessor_map (boost::ref(predecessors))
343 // .
344 distance_map(boost::ref(distances))
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800345 .distance_inf(boost::WeightInf)
346 .distance_zero(boost::WeightZero)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800347 .distance_compare(boost::WeightCompare())
348 .distance_combine(boost::WeightCombine()));
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700349
Alexander Afanasyeva5abcd92012-04-17 13:34:43 -0700350 // NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
Alexander Afanasyev8e2f1122012-04-17 15:01:11 -0700351
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800352 for (const auto& dist : distances) {
353 if (dist.first == source)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800354 continue;
355 else {
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800356 // cout << " Node " << dist.first->GetObject<Node> ()->GetId ();
357 if (std::get<0>(dist.second) == 0) {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800358 // cout << " is unreachable" << endl;
359 }
360 else {
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800361 for (const auto& prefix : dist.first->GetLocalPrefixes()) {
362 NS_LOG_DEBUG(" prefix " << *prefix << " reachable via face "
363 << *std::get<0>(dist.second)
364 << " with distance " << std::get<1>(dist.second)
365 << " with delay " << std::get<2>(dist.second));
Alexander Afanasyev49165862013-01-31 00:38:20 -0800366
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800367 if (std::get<0>(dist.second)->getMetric() == std::numeric_limits<uint16_t>::max() - 1)
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800368 continue;
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800369
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800370 FibHelper::AddRoute(*node, *prefix, std::get<0>(dist.second),
371 std::get<1>(dist.second));
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800372 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800373 }
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800374 }
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800375 }
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800376
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800377 // disabling the face again
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800378 face->setMetric(std::numeric_limits<uint16_t>::max() - 1);
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800379 }
Alexander Afanasyevf484fb92013-03-04 10:37:27 -0800380
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800381 // recover original interface statuses
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -0800382 faceNumber = 0;
383 for (auto& i : l3->getForwarder()->getFaceTable()) {
384 faceNumber++;
385 shared_ptr<Face> face = std::dynamic_pointer_cast<Face>(i);
386 face->setMetric(originalMetric[faceNumber]);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800387 }
388 }
389}
Alexander Afanasyevad3757f2012-04-17 10:27:59 -0700390
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700391} // namespace ndn
392} // namespace ns3