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