blob: cfa6f3e0d8150740eab162b18961480dc9fbe376 [file] [log] [blame]
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07002/*
3 * Copyright (c) 2011 UCLA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Ilya Moiseenkofbd0a8b2011-10-28 13:07:16 -070019 * Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070020 */
21
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070022#include "ns3/assert.h"
23#include "ns3/log.h"
24#include "ns3/object.h"
25#include "ns3/names.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026#include "ns3/packet-socket-factory.h"
27#include "ns3/config.h"
28#include "ns3/simulator.h"
29#include "ns3/string.h"
30#include "ns3/net-device.h"
31#include "ns3/callback.h"
32#include "ns3/node.h"
33#include "ns3/core-config.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080034#include "ns3/point-to-point-net-device.h"
35#include "ns3/point-to-point-helper.h"
36
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037#include "../model/ndn-net-device-face.h"
38#include "../model/ndn-l3-protocol.h"
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070039
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070040#include "ns3/ndn-forwarding-strategy.h"
41#include "ns3/ndn-fib.h"
42#include "ns3/ndn-pit.h"
43#include "ns3/ndn-name-components.h"
44#include "ns3/ndn-content-store.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080045
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -080046#include "ns3/node-list.h"
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070047// #include "ns3/loopback-net-device.h"
Alexander Afanasyevf9f4eb02011-12-16 01:51:14 -080048
Alexander Afanasyev11453142011-11-25 16:13:33 -080049#include "ns3/data-rate.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070050
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070051#include "ndn-face-container.h"
52#include "ndn-stack-helper.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070053
54#include <limits>
55#include <map>
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -080056#include <boost/foreach.hpp>
Alexander Afanasyevb7626842012-01-12 13:43:33 -080057#include <boost/lexical_cast.hpp>
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080058
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059NS_LOG_COMPONENT_DEFINE ("ndn.StackHelper");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070060
61namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070062namespace ndn {
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070063
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070064StackHelper::StackHelper ()
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -080065 : m_limitsEnabled (false)
66 , m_needSetDefaultRoutes (false)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070067{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070068 m_ndnFactory. SetTypeId ("ns3::ndn::L3Protocol");
69 m_strategyFactory. SetTypeId ("ns3::ndn::fw::Flooding");
70 m_contentStoreFactory.SetTypeId ("ns3::ndn::cs::Lru");
71 m_fibFactory. SetTypeId ("ns3::ndn::fib::Default");
72 m_pitFactory. SetTypeId ("ns3::ndn::pit::Persistent");
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070073}
74
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070075StackHelper::~StackHelper ()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076{
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070077}
78
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070079void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070080StackHelper::SetStackAttributes (const std::string &attr1, const std::string &value1,
81 const std::string &attr2, const std::string &value2,
82 const std::string &attr3, const std::string &value3,
83 const std::string &attr4, const std::string &value4)
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070084{
85 if (attr1 != "")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070086 m_ndnFactory.Set (attr1, StringValue (value1));
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070087 if (attr2 != "")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070088 m_ndnFactory.Set (attr2, StringValue (value2));
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070089 if (attr3 != "")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070090 m_ndnFactory.Set (attr3, StringValue (value3));
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070091 if (attr4 != "")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070092 m_ndnFactory.Set (attr4, StringValue (value4));
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070093}
94
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070095void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070096StackHelper::SetForwardingStrategy (const std::string &strategy,
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -070097 const std::string &attr1, const std::string &value1,
98 const std::string &attr2, const std::string &value2,
99 const std::string &attr3, const std::string &value3,
100 const std::string &attr4, const std::string &value4)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700101{
Alexander Afanasyev11453142011-11-25 16:13:33 -0800102 m_strategyFactory.SetTypeId (strategy);
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700103 if (attr1 != "")
104 m_strategyFactory.Set (attr1, StringValue (value1));
105 if (attr2 != "")
106 m_strategyFactory.Set (attr2, StringValue (value2));
107 if (attr3 != "")
108 m_strategyFactory.Set (attr3, StringValue (value3));
109 if (attr4 != "")
110 m_strategyFactory.Set (attr4, StringValue (value4));
Alexander Afanasyev11453142011-11-25 16:13:33 -0800111}
112
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700113void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700114StackHelper::SetContentStore (const std::string &contentStore,
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700115 const std::string &attr1, const std::string &value1,
116 const std::string &attr2, const std::string &value2,
117 const std::string &attr3, const std::string &value3,
118 const std::string &attr4, const std::string &value4)
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700119{
120 m_contentStoreFactory.SetTypeId (contentStore);
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700121 if (attr1 != "")
122 m_contentStoreFactory.Set (attr1, StringValue (value1));
123 if (attr2 != "")
124 m_contentStoreFactory.Set (attr2, StringValue (value2));
125 if (attr3 != "")
126 m_contentStoreFactory.Set (attr3, StringValue (value3));
127 if (attr4 != "")
128 m_contentStoreFactory.Set (attr4, StringValue (value4));
129}
130
131void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700132StackHelper::SetPit (const std::string &pitClass,
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700133 const std::string &attr1, const std::string &value1,
134 const std::string &attr2, const std::string &value2,
135 const std::string &attr3, const std::string &value3,
136 const std::string &attr4, const std::string &value4)
137{
138 m_pitFactory.SetTypeId (pitClass);
139 if (attr1 != "")
140 m_pitFactory.Set (attr1, StringValue (value1));
141 if (attr2 != "")
142 m_pitFactory.Set (attr2, StringValue (value2));
143 if (attr3 != "")
144 m_pitFactory.Set (attr3, StringValue (value3));
145 if (attr4 != "")
146 m_pitFactory.Set (attr4, StringValue (value4));
147}
148
149void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700150StackHelper::SetFib (const std::string &fibClass,
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700151 const std::string &attr1, const std::string &value1,
152 const std::string &attr2, const std::string &value2,
153 const std::string &attr3, const std::string &value3,
154 const std::string &attr4, const std::string &value4)
155{
156 m_fibFactory.SetTypeId (fibClass);
157 if (attr1 != "")
158 m_fibFactory.Set (attr1, StringValue (value1));
159 if (attr2 != "")
160 m_fibFactory.Set (attr2, StringValue (value2));
161 if (attr3 != "")
162 m_fibFactory.Set (attr3, StringValue (value3));
163 if (attr4 != "")
164 m_fibFactory.Set (attr4, StringValue (value4));
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700165}
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800166
167void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700168StackHelper::SetDefaultRoutes (bool needSet)
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800169{
170 NS_LOG_FUNCTION (this << needSet);
171 m_needSetDefaultRoutes = needSet;
172}
173
Alexander Afanasyev11453142011-11-25 16:13:33 -0800174void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700175StackHelper::EnableLimits (bool enable/* = true*/,
Alexander Afanasyev33d62312012-01-09 13:50:20 -0800176 Time avgRtt/*=Seconds(0.1)*/,
177 uint32_t avgContentObject/*=1100*/,
178 uint32_t avgInterest/*=40*/)
Alexander Afanasyev11453142011-11-25 16:13:33 -0800179{
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800180 NS_LOG_INFO ("EnableLimits: " << enable);
Alexander Afanasyev11453142011-11-25 16:13:33 -0800181 m_limitsEnabled = enable;
Alexander Afanasyev8f5a9bb2011-12-18 19:49:02 -0800182 m_avgRtt = avgRtt;
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800183 m_avgContentObjectSize = avgContentObject;
184 m_avgInterestSize = avgInterest;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700185}
186
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700187Ptr<FaceContainer>
188StackHelper::Install (NodeContainer c) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700189{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700190 Ptr<FaceContainer> faces = Create<FaceContainer> ();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700191 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
192 {
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700193 faces->AddAll (Install (*i));
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700194 }
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700195 return faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700196}
197
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700198Ptr<FaceContainer>
199StackHelper::InstallAll (void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700200{
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700201 return Install (NodeContainer::GetGlobal ());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700202}
203
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700204Ptr<FaceContainer>
205StackHelper::Install (Ptr<Node> node) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700206{
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700207 // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install() method");
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700208 Ptr<FaceContainer> faces = Create<FaceContainer> ();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700209
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700210 if (node->GetObject<L3Protocol> () != 0)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700211 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700212 NS_FATAL_ERROR ("StackHelper::Install (): Installing "
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700213 "a NdnStack to a node with an existing Ndn object");
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700214 return 0;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700215 }
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700216
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700217 // Create L3Protocol
218 Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol> ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700219
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700220 // Create and aggregate FIB
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700221 Ptr<Fib> fib = m_fibFactory.Create<Fib> ();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700222 ndn->AggregateObject (fib);
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700223
224 // Create and aggregate PIT
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700225 ndn->AggregateObject (m_pitFactory.Create<Pit> ());
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700226
227 // Create and aggregate forwarding strategy
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700228 ndn->AggregateObject (m_strategyFactory.Create<ForwardingStrategy> ());
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700229
230 // Create and aggregate content store
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700231 ndn->AggregateObject (m_contentStoreFactory.Create<ContentStore> ());
Alexander Afanasyev3a4a0b32012-06-28 14:14:22 -0700232
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700233 // Aggregate L3Protocol on node
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700234 node->AggregateObject (ndn);
Alexander Afanasyev11453142011-11-25 16:13:33 -0800235
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700236 for (uint32_t index=0; index < node->GetNDevices (); index++)
237 {
Alexander Afanasyev11453142011-11-25 16:13:33 -0800238 Ptr<NetDevice> device = node->GetDevice (index);
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700239 // This check does not make sense: LoopbackNetDevice is installed only if IP stack is installed,
240 // Normally, ndnSIM works without IP stack, so no reason to check
241 // if (DynamicCast<LoopbackNetDevice> (device) != 0)
242 // continue; // don't create face for a LoopbackNetDevice
Alexander Afanasyev11453142011-11-25 16:13:33 -0800243
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700244 Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace> (node, device);
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800245
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700246 ndn->AddFace (face);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700247 NS_LOG_LOGIC ("Node " << node->GetId () << ": added NetDeviceFace as face #" << *face);
Alexander Afanasyev11453142011-11-25 16:13:33 -0800248
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800249 if (m_needSetDefaultRoutes)
250 {
251 // default route with lowest priority possible
Alexander Afanasyev463fe222012-05-31 13:46:51 -0700252 AddRoute (node, "/", face, std::numeric_limits<int32_t>::max ());
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800253 }
254
Alexander Afanasyev11453142011-11-25 16:13:33 -0800255 if (m_limitsEnabled)
256 {
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800257 NS_LOG_INFO ("Limits are enabled");
Alexander Afanasyev11453142011-11-25 16:13:33 -0800258 Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice> (device);
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800259 if (p2p != 0)
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800260 {
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800261 // Setup bucket filtering
262 // Assume that we know average data packet size, and this size is equal default size
263 // Set maximum buckets (averaging over 1 second)
Ilya Moiseenkoc9266042011-11-02 17:49:21 -0700264
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800265 DataRateValue dataRate; device->GetAttribute ("DataRate", dataRate);
Alexander Afanasyev11453142011-11-25 16:13:33 -0800266
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800267 NS_LOG_INFO("DataRate for this link is " << dataRate.Get());
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800268
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800269 double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / (m_avgContentObjectSize + m_avgInterestSize);
270 NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
271 NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800272
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700273 // Set max to BDP
Alexander Afanasyev6a3bb132012-08-15 09:47:35 -0700274 face->GetLimits ().SetMaxLimit (m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
Alexander Afanasyev3f1c8b02012-01-19 19:41:34 -0800275 }
Alexander Afanasyev11453142011-11-25 16:13:33 -0800276 }
Ilya Moiseenkoc9266042011-11-02 17:49:21 -0700277
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -0700278 face->SetUp ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700279 faces->Add (face);
280 }
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -0700281
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700282 return faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700283}
284
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700285Ptr<FaceContainer>
286StackHelper::Install (std::string nodeName) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700287{
288 Ptr<Node> node = Names::Find<Node> (nodeName);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700289 return Install (node);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700290}
291
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700292
293void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700294StackHelper::AddRoute (Ptr<Node> node, std::string prefix, Ptr<Face> face, int32_t metric)
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800295{
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800296 NS_LOG_LOGIC ("[" << node->GetId () << "]$ route add " << prefix << " via " << *face << " metric " << metric);
297
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700298 Ptr<Fib> fib = node->GetObject<Fib> ();
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800299
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700300 NameComponentsValue prefixValue;
301 prefixValue.DeserializeFromString (prefix, MakeNameComponentsChecker ());
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800302 fib->Add (prefixValue.Get (), face, metric);
303}
304
305void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700306StackHelper::AddRoute (Ptr<Node> node, std::string prefix, uint32_t faceId, int32_t metric)
Alexander Afanasyev8bedcaf2012-07-20 15:30:44 -0700307{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700308 Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700309 NS_ASSERT_MSG (ndn != 0, "Ndn stack should be installed on the node");
Alexander Afanasyev8bedcaf2012-07-20 15:30:44 -0700310
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700311 Ptr<Face> face = ndn->GetFace (faceId);
Alexander Afanasyev8bedcaf2012-07-20 15:30:44 -0700312 NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << node->GetId () << "]");
313
314 AddRoute (node, prefix, face, metric);
315}
316
317void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700318StackHelper::AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700319{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700320 Ptr<Node> node = Names::Find<Node> (nodeName);
321 NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist");
Alexander Afanasyeva4e3f852011-11-15 20:39:33 -0800322
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700323 Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700324 NS_ASSERT_MSG (ndn != 0, "Ndn stack should be installed on the node");
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800325
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700326 Ptr<Face> face = ndn->GetFace (faceId);
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800327 NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName << "]");
328
329 AddRoute (node, prefix, face, metric);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700330}
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800331
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700332} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700333} // namespace ns3