Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 2 | /* |
| 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 Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Ilya Moiseenko | fbd0a8b | 2011-10-28 13:07:16 -0700 | [diff] [blame] | 19 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 22 | #include "ns3/assert.h" |
| 23 | #include "ns3/log.h" |
| 24 | #include "ns3/object.h" |
| 25 | #include "ns3/names.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 26 | #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 Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 34 | #include "ns3/point-to-point-net-device.h" |
| 35 | #include "ns3/point-to-point-helper.h" |
| 36 | |
| 37 | #include "../model/ccnx-forwarding-strategy.h" |
Alexander Afanasyev | f9f4eb0 | 2011-12-16 01:51:14 -0800 | [diff] [blame] | 38 | #include "../model/ccnx-net-device-face.h" |
| 39 | #include "../model/ccnx-l3-protocol.h" |
| 40 | #include "../model/ccnx-fib.h" |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 41 | |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 42 | #include "ns3/node-list.h" |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 43 | // #include "ns3/loopback-net-device.h" |
Alexander Afanasyev | f9f4eb0 | 2011-12-16 01:51:14 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 45 | #include "ns3/data-rate.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 46 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 47 | #include "ccnx-face-container.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 48 | #include "ccnx-stack-helper.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 49 | |
| 50 | #include <limits> |
| 51 | #include <map> |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 52 | #include <boost/foreach.hpp> |
Alexander Afanasyev | b762684 | 2012-01-12 13:43:33 -0800 | [diff] [blame] | 53 | #include <boost/lexical_cast.hpp> |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 54 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 55 | NS_LOG_COMPONENT_DEFINE ("CcnxStackHelper"); |
| 56 | |
| 57 | namespace ns3 { |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 59 | CcnxStackHelper::CcnxStackHelper () |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 60 | : m_limitsEnabled (false) |
| 61 | , m_needSetDefaultRoutes (false) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 62 | { |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 63 | m_ccnxFactory. SetTypeId ("ns3::CcnxL3Protocol"); |
| 64 | m_strategyFactory. SetTypeId ("ns3::CcnxFloodingStrategy"); |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 65 | m_contentStoreFactory.SetTypeId ("ns3::CcnxContentStoreLru"); |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 66 | m_fibFactory. SetTypeId ("ns3::CcnxFib"); |
| 67 | m_pitFactory. SetTypeId ("ns3::CcnxPit"); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 70 | CcnxStackHelper::~CcnxStackHelper () |
| 71 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 74 | void |
| 75 | CcnxStackHelper::SetCcnxAttributes (const std::string &attr1, const std::string &value1, |
| 76 | const std::string &attr2, const std::string &value2, |
| 77 | const std::string &attr3, const std::string &value3, |
| 78 | const std::string &attr4, const std::string &value4) |
| 79 | { |
| 80 | if (attr1 != "") |
| 81 | m_ccnxFactory.Set (attr1, StringValue (value1)); |
| 82 | if (attr2 != "") |
| 83 | m_ccnxFactory.Set (attr2, StringValue (value2)); |
| 84 | if (attr3 != "") |
| 85 | m_ccnxFactory.Set (attr3, StringValue (value3)); |
| 86 | if (attr4 != "") |
| 87 | m_ccnxFactory.Set (attr4, StringValue (value4)); |
| 88 | } |
| 89 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 90 | void |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 91 | CcnxStackHelper::SetForwardingStrategy (const std::string &strategy, |
| 92 | const std::string &attr1, const std::string &value1, |
| 93 | const std::string &attr2, const std::string &value2, |
| 94 | const std::string &attr3, const std::string &value3, |
| 95 | const std::string &attr4, const std::string &value4) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 96 | { |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 97 | m_strategyFactory.SetTypeId (strategy); |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 98 | if (attr1 != "") |
| 99 | m_strategyFactory.Set (attr1, StringValue (value1)); |
| 100 | if (attr2 != "") |
| 101 | m_strategyFactory.Set (attr2, StringValue (value2)); |
| 102 | if (attr3 != "") |
| 103 | m_strategyFactory.Set (attr3, StringValue (value3)); |
| 104 | if (attr4 != "") |
| 105 | m_strategyFactory.Set (attr4, StringValue (value4)); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 106 | } |
| 107 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 108 | void |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 109 | CcnxStackHelper::SetContentStore (const std::string &contentStore, |
| 110 | const std::string &attr1, const std::string &value1, |
| 111 | const std::string &attr2, const std::string &value2, |
| 112 | const std::string &attr3, const std::string &value3, |
| 113 | const std::string &attr4, const std::string &value4) |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 114 | { |
| 115 | m_contentStoreFactory.SetTypeId (contentStore); |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 116 | if (attr1 != "") |
| 117 | m_contentStoreFactory.Set (attr1, StringValue (value1)); |
| 118 | if (attr2 != "") |
| 119 | m_contentStoreFactory.Set (attr2, StringValue (value2)); |
| 120 | if (attr3 != "") |
| 121 | m_contentStoreFactory.Set (attr3, StringValue (value3)); |
| 122 | if (attr4 != "") |
| 123 | m_contentStoreFactory.Set (attr4, StringValue (value4)); |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | CcnxStackHelper::SetPit (const std::string &pitClass, |
| 128 | const std::string &attr1, const std::string &value1, |
| 129 | const std::string &attr2, const std::string &value2, |
| 130 | const std::string &attr3, const std::string &value3, |
| 131 | const std::string &attr4, const std::string &value4) |
| 132 | { |
| 133 | m_pitFactory.SetTypeId (pitClass); |
| 134 | if (attr1 != "") |
| 135 | m_pitFactory.Set (attr1, StringValue (value1)); |
| 136 | if (attr2 != "") |
| 137 | m_pitFactory.Set (attr2, StringValue (value2)); |
| 138 | if (attr3 != "") |
| 139 | m_pitFactory.Set (attr3, StringValue (value3)); |
| 140 | if (attr4 != "") |
| 141 | m_pitFactory.Set (attr4, StringValue (value4)); |
| 142 | } |
| 143 | |
| 144 | void |
| 145 | CcnxStackHelper::SetFib (const std::string &fibClass, |
| 146 | const std::string &attr1, const std::string &value1, |
| 147 | const std::string &attr2, const std::string &value2, |
| 148 | const std::string &attr3, const std::string &value3, |
| 149 | const std::string &attr4, const std::string &value4) |
| 150 | { |
| 151 | m_fibFactory.SetTypeId (fibClass); |
| 152 | if (attr1 != "") |
| 153 | m_fibFactory.Set (attr1, StringValue (value1)); |
| 154 | if (attr2 != "") |
| 155 | m_fibFactory.Set (attr2, StringValue (value2)); |
| 156 | if (attr3 != "") |
| 157 | m_fibFactory.Set (attr3, StringValue (value3)); |
| 158 | if (attr4 != "") |
| 159 | m_fibFactory.Set (attr4, StringValue (value4)); |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 160 | } |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 161 | |
| 162 | void |
| 163 | CcnxStackHelper::SetDefaultRoutes (bool needSet) |
| 164 | { |
| 165 | NS_LOG_FUNCTION (this << needSet); |
| 166 | m_needSetDefaultRoutes = needSet; |
| 167 | } |
| 168 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 169 | void |
Alexander Afanasyev | 33d6231 | 2012-01-09 13:50:20 -0800 | [diff] [blame] | 170 | CcnxStackHelper::EnableLimits (bool enable/* = true*/, |
| 171 | Time avgRtt/*=Seconds(0.1)*/, |
| 172 | uint32_t avgContentObject/*=1100*/, |
| 173 | uint32_t avgInterest/*=40*/) |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 174 | { |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 175 | NS_LOG_INFO ("EnableLimits: " << enable); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 176 | m_limitsEnabled = enable; |
Alexander Afanasyev | 8f5a9bb | 2011-12-18 19:49:02 -0800 | [diff] [blame] | 177 | m_avgRtt = avgRtt; |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 178 | m_avgContentObjectSize = avgContentObject; |
| 179 | m_avgInterestSize = avgInterest; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 182 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 183 | CcnxStackHelper::Install (NodeContainer c) const |
| 184 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 185 | Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 186 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 187 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 188 | faces->AddAll (Install (*i)); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 189 | } |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 190 | return faces; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 193 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 194 | CcnxStackHelper::InstallAll (void) const |
| 195 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 196 | return Install (NodeContainer::GetGlobal ()); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 199 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 200 | CcnxStackHelper::Install (Ptr<Node> node) const |
| 201 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 202 | // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install() method"); |
| 203 | Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 204 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 205 | if (node->GetObject<Ccnx> () != 0) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 206 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 207 | NS_FATAL_ERROR ("CcnxStackHelper::Install (): Installing " |
| 208 | "a CcnxStack to a node with an existing Ccnx object"); |
| 209 | return 0; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 210 | } |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 211 | |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 212 | // Create CcnxL3Protocol |
| 213 | Ptr<Ccnx> ccnx = m_ccnxFactory.Create<Ccnx> (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 214 | |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 215 | // Create and aggregate FIB |
| 216 | ccnx->AggregateObject (m_fibFactory.Create<CcnxFib> ()); |
| 217 | |
| 218 | // Create and aggregate PIT |
| 219 | ccnx->AggregateObject (m_pitFactory.Create<CcnxPit> ()); |
| 220 | |
| 221 | // Create and aggregate forwarding strategy |
| 222 | ccnx->AggregateObject (m_strategyFactory.Create<CcnxForwardingStrategy> ()); |
| 223 | |
| 224 | // Create and aggregate content store |
| 225 | ccnx->AggregateObject (m_contentStoreFactory.Create<CcnxContentStore> ()); |
| 226 | |
| 227 | // Aggregate CcnxL3Protocol on node |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 228 | node->AggregateObject (ccnx); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 229 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 230 | for (uint32_t index=0; index < node->GetNDevices (); index++) |
| 231 | { |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 232 | Ptr<NetDevice> device = node->GetDevice (index); |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 233 | // This check does not make sense: LoopbackNetDevice is installed only if IP stack is installed, |
| 234 | // Normally, ndnSIM works without IP stack, so no reason to check |
| 235 | // if (DynamicCast<LoopbackNetDevice> (device) != 0) |
| 236 | // continue; // don't create face for a LoopbackNetDevice |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 237 | |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 238 | Ptr<CcnxNetDeviceFace> face = CreateObject<CcnxNetDeviceFace> (node, device); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 239 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 240 | ccnx->AddFace (face); |
| 241 | NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcnxNetDeviceFace as face #" << *face); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 242 | |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 243 | if (m_needSetDefaultRoutes) |
| 244 | { |
| 245 | // default route with lowest priority possible |
Alexander Afanasyev | 463fe22 | 2012-05-31 13:46:51 -0700 | [diff] [blame] | 246 | AddRoute (node, "/", face, std::numeric_limits<int32_t>::max ()); |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 249 | if (m_limitsEnabled) |
| 250 | { |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 251 | NS_LOG_INFO ("Limits are enabled"); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 252 | Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice> (device); |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 253 | if (p2p != 0) |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 254 | { |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 255 | // Setup bucket filtering |
| 256 | // Assume that we know average data packet size, and this size is equal default size |
| 257 | // Set maximum buckets (averaging over 1 second) |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 258 | |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 259 | DataRateValue dataRate; device->GetAttribute ("DataRate", dataRate); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 260 | |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 261 | NS_LOG_INFO("DataRate for this link is " << dataRate.Get()); |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 262 | |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 263 | double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / (m_avgContentObjectSize + m_avgInterestSize); |
| 264 | NS_LOG_INFO ("Max packets per second: " << maxInterestPackets); |
| 265 | NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets); |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 266 | |
Alexander Afanasyev | 3f1c8b0 | 2012-01-19 19:41:34 -0800 | [diff] [blame] | 267 | // Set bucket max to BDP |
| 268 | face->SetBucketMax (m_avgRtt.ToDouble (Time::S) * maxInterestPackets); // number of interests allowed |
| 269 | face->SetBucketLeak (maxInterestPackets); |
| 270 | } |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 271 | } |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 272 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 273 | face->SetUp (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 274 | faces->Add (face); |
| 275 | } |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 276 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 277 | return faces; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 280 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 281 | CcnxStackHelper::Install (std::string nodeName) const |
| 282 | { |
| 283 | Ptr<Node> node = Names::Find<Node> (nodeName); |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 284 | return Install (node); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 287 | |
| 288 | void |
Alexander Afanasyev | b762684 | 2012-01-12 13:43:33 -0800 | [diff] [blame] | 289 | CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric) |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 290 | { |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 291 | NS_LOG_LOGIC ("[" << node->GetId () << "]$ route add " << prefix << " via " << *face << " metric " << metric); |
| 292 | |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 293 | Ptr<CcnxFib> fib = node->GetObject<CcnxFib> (); |
| 294 | |
| 295 | CcnxNameComponentsValue prefixValue; |
| 296 | prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ()); |
| 297 | fib->Add (prefixValue.Get (), face, metric); |
| 298 | } |
| 299 | |
| 300 | void |
Alexander Afanasyev | b762684 | 2012-01-12 13:43:33 -0800 | [diff] [blame] | 301 | CcnxStackHelper::AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 302 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 303 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 304 | NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist"); |
Alexander Afanasyev | a4e3f85 | 2011-11-15 20:39:33 -0800 | [diff] [blame] | 305 | |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 306 | Ptr<Ccnx> ccnx = node->GetObject<Ccnx> (); |
| 307 | NS_ASSERT_MSG (ccnx != 0, "Ccnx stack should be installed on the node"); |
| 308 | |
| 309 | Ptr<CcnxFace> face = ccnx->GetFace (faceId); |
| 310 | NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName << "]"); |
| 311 | |
| 312 | AddRoute (node, prefix, face, metric); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 313 | } |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 314 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 315 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 316 | } // namespace ns3 |