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 | |
| 22 | /** |
| 23 | * \ingroup ccnx |
| 24 | * \defgroup CcnxStackModel Ccnx Stack Model |
| 25 | * |
| 26 | * \section CcnxStackTracingModel Tracing in the Ccnx Stack |
| 27 | * |
| 28 | * The ccnx stack provides a number of trace sources in its various |
| 29 | * protocol implementations. These trace sources can be hooked using your own |
| 30 | * custom trace code, or you can use our helper functions in some cases to |
| 31 | * arrange for tracing to be enabled. |
| 32 | * |
| 33 | * \subsection CcnxStackCcnxTracingModel Tracing in Ccnx |
| 34 | * |
| 35 | * The Ccnx layer three protocol provides three trace hooks. These are the |
| 36 | * "Tx" (ns3::CcnxL3Protocol::m_txTrace), "Rx" (ns3::CcnxL3Protocol::m_rxTrace) |
| 37 | * and "Drop" (ns3::CcnxL3Protocol::m_dropTrace) trace sources. |
| 38 | * |
| 39 | * The "Tx" trace is fired in a number of situations, all of which indicate that |
| 40 | * a given packet is about to be sent down to a given ns3::CcnxFace. |
| 41 | * |
| 42 | * - \todo list Tx trace events |
| 43 | * |
| 44 | * The "Rx" trace is fired when a packet is passed from the device up to the |
| 45 | * ns3::CcnxL3Protocol::Receive function. |
| 46 | * |
| 47 | * - In the receive function, the CcnxFaceList is iterated, and if the |
| 48 | * CcnxFace corresponding to the receiving device is found to be in the |
| 49 | * UP state, the trace is fired. |
| 50 | * |
| 51 | * The "Drop" trace is fired in any case where the packet is dropped (in both |
| 52 | * the transmit and receive paths). |
| 53 | * |
| 54 | * - \todo list Drop trace events |
| 55 | */ |
| 56 | |
| 57 | #include "ns3/assert.h" |
| 58 | #include "ns3/log.h" |
| 59 | #include "ns3/object.h" |
| 60 | #include "ns3/names.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 61 | #include "ns3/packet-socket-factory.h" |
| 62 | #include "ns3/config.h" |
| 63 | #include "ns3/simulator.h" |
| 64 | #include "ns3/string.h" |
| 65 | #include "ns3/net-device.h" |
| 66 | #include "ns3/callback.h" |
| 67 | #include "ns3/node.h" |
| 68 | #include "ns3/core-config.h" |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 69 | #include "ns3/ccnx-forwarding-strategy.h" |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 70 | #include "ns3/ccnx-net-device-face.h" |
| 71 | #include "ns3/ccnx-l3-protocol.h" |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 72 | #include "ns3/ccnx-fib.h" |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 73 | #include "ns3/node-list.h" |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 74 | #include "ns3/loopback-net-device.h" |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 75 | #include "ns3/global-router-interface.h" |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 76 | #include "ns3/ipv4.h" |
| 77 | #include "ns3/ipv4-global-routing.h" |
| 78 | #include "ns3/ipv4-global-routing-ordered-nexthops.h" |
| 79 | #include "ns3/ipv4-routing-helper.h" |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 80 | #include "ns3/ipv4-global-routing-helper.h" |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 81 | #include "ns3/data-rate.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 83 | #include "ccnx-face-container.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 84 | #include "ccnx-stack-helper.h" |
| 85 | #include "ccnx-forwarding-helper.h" |
| 86 | |
| 87 | #include <limits> |
| 88 | #include <map> |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 89 | #include <boost/foreach.hpp> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 91 | #define NDN_DEFAULT_DATA_SIZE 1024 |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 93 | NS_LOG_COMPONENT_DEFINE ("CcnxStackHelper"); |
| 94 | |
| 95 | namespace ns3 { |
| 96 | |
| 97 | // Things are going to work differently here with respect to trace |
| 98 | // file handling than in most places because the Tx and Rx trace |
| 99 | // sources we are interested in are going to multiplex receive and |
| 100 | // transmit callbacks for all Ccnx and face pairs through one |
| 101 | // callback. We want packets to or from each distinct pair to go to |
| 102 | // an individual file, so we have got to demultiplex the Ccnx and face |
| 103 | // pair into a corresponding Ptr<PcapFileWrapper> at the callback. |
| 104 | // |
| 105 | // A complication in this situation is that the trace sources are |
| 106 | // hooked on a protocol basis. There is no trace source hooked by an |
| 107 | // Ccnx and face pair. This means that if we naively proceed to hook, |
| 108 | // say, a drop trace for a given Ccnx with face 0, and then hook for |
| 109 | // Ccnx with face 1 we will hook the drop trace twice and get two |
| 110 | // callbacks per event. What we need to do is to hook the event once, |
| 111 | // and that will result in a single callback per drop event, and the |
| 112 | // trace source will provide the face which we filter on in the trace |
| 113 | // sink. |
| 114 | // |
| 115 | // This has got to continue to work properly after the helper has been |
| 116 | // destroyed; but must be cleaned up at the end of time to avoid |
| 117 | // leaks. Global maps of protocol/face pairs to file objects seems to |
| 118 | // fit the bill. |
| 119 | // |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 120 | // typedef std::pair<Ptr<Ccnx>, uint32_t> FacePairCcnx; |
| 121 | // typedef std::map<FacePairCcnx, Ptr<PcapFileWrapper> > FaceFileMapCcnx; |
| 122 | // typedef std::map<FacePairCcnx, Ptr<OutputStreamWrapper> > FaceStreamMapCcnx; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 123 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 124 | // static FaceFileMapCcnx g_faceFileMapCcnx; /**< A mapping of Ccnx/face pairs to pcap files */ |
| 125 | // static FaceStreamMapCcnx g_faceStreamMapCcnx; /**< A mapping of Ccnx/face pairs to ascii streams */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 126 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 127 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 128 | CcnxStackHelper::CcnxStackHelper () |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 129 | { |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 130 | m_strategyFactory.SetTypeId ("ns3::CcnxFloodingStrategy"); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 133 | CcnxStackHelper::~CcnxStackHelper () |
| 134 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 137 | void |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 138 | CcnxStackHelper::SetForwardingStrategy (std::string strategy) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 139 | { |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 140 | m_strategyFactory.SetTypeId (strategy); |
| 141 | } |
| 142 | |
| 143 | void |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 144 | CcnxStackHelper::EnableLimits (bool enable/* = true*/, Time avgRtt/*=Seconds(0.1)*/, uint32_t avgContentObject/*=1100*/, uint32_t avgInterest/*=40*/) |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 145 | { |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 146 | NS_LOG_INFO ("EnableLimits: " << enable); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 147 | m_limitsEnabled = enable; |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 148 | m_avgContentObjectSize = avgContentObject; |
| 149 | m_avgInterestSize = avgInterest; |
| 150 | m_avgRtt = avgRtt; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 153 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 154 | CcnxStackHelper::Install (NodeContainer c) const |
| 155 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 156 | Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 157 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 158 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 159 | faces->AddAll (Install (*i)); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 160 | } |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 161 | return faces; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 164 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 165 | CcnxStackHelper::InstallAll (void) const |
| 166 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 167 | return Install (NodeContainer::GetGlobal ()); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 170 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 171 | CcnxStackHelper::Install (Ptr<Node> node) const |
| 172 | { |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 173 | // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install() method"); |
| 174 | Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 175 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 176 | if (node->GetObject<Ccnx> () != 0) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 177 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 178 | NS_FATAL_ERROR ("CcnxStackHelper::Install (): Installing " |
| 179 | "a CcnxStack to a node with an existing Ccnx object"); |
| 180 | return 0; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 181 | } |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 182 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 183 | Ptr<CcnxFib> fib = CreateObject<CcnxFib> (); |
| 184 | node->AggregateObject (fib); |
| 185 | |
Ilya Moiseenko | fbd0a8b | 2011-10-28 13:07:16 -0700 | [diff] [blame] | 186 | Ptr<CcnxL3Protocol> ccnx = CreateObject<CcnxL3Protocol> (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 187 | node->AggregateObject (ccnx); |
| 188 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 189 | ccnx->SetForwardingStrategy |
| 190 | (DynamicCast<CcnxForwardingStrategy> (m_strategyFactory.Create<Object> ())); |
| 191 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 192 | for (uint32_t index=0; index < node->GetNDevices (); index++) |
| 193 | { |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 194 | Ptr<NetDevice> device = node->GetDevice (index); |
| 195 | if (DynamicCast<LoopbackNetDevice> (device) != 0) |
| 196 | continue; // don't create face for a LoopbackNetDevice |
| 197 | |
| 198 | Ptr<CcnxNetDeviceFace> face = Create<CcnxNetDeviceFace> (node, device); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 199 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 200 | uint32_t __attribute__ ((unused)) face_id = ccnx->AddFace (face); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 201 | NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcnxNetDeviceFace as face #" << face_id); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 202 | |
| 203 | if (m_limitsEnabled) |
| 204 | { |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 205 | NS_LOG_INFO ("Limits are enabled"); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 206 | Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice> (device); |
| 207 | if (p2p == 0) |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 208 | { |
| 209 | NS_LOG_INFO ("Non p2p interface"); |
| 210 | continue; // only PointToPointNetDevice supports limits |
| 211 | } |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 212 | |
| 213 | // Setup bucket filtering |
| 214 | // Assume that we know average data packet size, and this size is equal default size |
| 215 | // Set maximum buckets (averaging over 1 second) |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 216 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 217 | DataRateValue dataRate; device->GetAttribute ("DataRate", dataRate); |
| 218 | |
| 219 | NS_LOG_INFO("DataRate for this link is " << dataRate.Get()); |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame^] | 220 | |
| 221 | double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / m_avgContentObjectSize; |
| 222 | NS_LOG_INFO ("BucketMax: " << maxInterestPackets); |
| 223 | |
| 224 | // Set bucket max to BDP |
| 225 | face->SetBucketMax (m_avgRtt.ToDouble (Time::S) * maxInterestPackets); // number of interests allowed |
| 226 | face->SetBucketLeak (maxInterestPackets); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 227 | } |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 228 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 229 | face->SetUp (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 230 | faces->Add (face); |
| 231 | } |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 232 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 233 | return faces; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 236 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 237 | CcnxStackHelper::Install (std::string nodeName) const |
| 238 | { |
| 239 | Ptr<Node> node = Names::Find<Node> (nodeName); |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 240 | return Install (node); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 243 | |
| 244 | void |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 245 | CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric) |
| 246 | { |
| 247 | Ptr<CcnxFib> fib = node->GetObject<CcnxFib> (); |
| 248 | |
| 249 | CcnxNameComponentsValue prefixValue; |
| 250 | prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ()); |
| 251 | fib->Add (prefixValue.Get (), face, metric); |
| 252 | } |
| 253 | |
| 254 | void |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 255 | CcnxStackHelper::AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric) |
| 256 | { |
| 257 | NS_LOG_LOGIC ("[" << nodeName << "]$ route add " << prefix << " via " << faceId << " metric " << metric); |
| 258 | |
| 259 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 260 | NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist"); |
Alexander Afanasyev | a4e3f85 | 2011-11-15 20:39:33 -0800 | [diff] [blame] | 261 | |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 262 | Ptr<Ccnx> ccnx = node->GetObject<Ccnx> (); |
| 263 | NS_ASSERT_MSG (ccnx != 0, "Ccnx stack should be installed on the node"); |
| 264 | |
| 265 | Ptr<CcnxFace> face = ccnx->GetFace (faceId); |
| 266 | NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName << "]"); |
| 267 | |
| 268 | AddRoute (node, prefix, face, metric); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 269 | } |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 270 | /* |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 271 | void |
| 272 | CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, uint32_t faceId, int32_t metric) |
| 273 | { |
| 274 | NS_LOG_LOGIC ("[" << nodeName << "]$ route add " << prefix << " via " << faceId << " metric " << metric); |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 275 | |
| 276 | NS_ASSERT_MSG (node != 0, "Node does not exist"); |
| 277 | |
| 278 | Ptr<Ccnx> ccnx = node->GetObject<Ccnx> (); |
| 279 | Ptr<CcnxFib> fib = node->GetObject<CcnxFib> (); |
| 280 | Ptr<CcnxFace> face = ccnx->GetFace (faceId); |
| 281 | NS_ASSERT_MSG (node != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName << "]"); |
| 282 | |
| 283 | CcnxNameComponentsValue prefixValue; |
| 284 | prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ()); |
| 285 | fib->Add (prefixValue.Get (), face, metric); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 286 | } |
Ilya Moiseenko | c926604 | 2011-11-02 17:49:21 -0700 | [diff] [blame] | 287 | */ |
Ilya Moiseenko | ae39487 | 2011-11-15 17:56:36 -0800 | [diff] [blame] | 288 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 289 | // static void |
| 290 | // CcnxL3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ccnx> ccnx, uint32_t face) |
| 291 | // { |
| 292 | // NS_LOG_FUNCTION (p << ccnx << face); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 293 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 294 | // // |
| 295 | // // Since trace sources are independent of face, if we hook a source |
| 296 | // // on a particular protocol we will get traces for all of its faces. |
| 297 | // // We need to filter this to only report faces for which the user |
| 298 | // // has expressed interest. |
| 299 | // // |
| 300 | // FacePairCcnx pair = std::make_pair (ccnx, face); |
| 301 | // if (g_faceFileMapCcnx.find (pair) == g_faceFileMapCcnx.end ()) |
| 302 | // { |
| 303 | // NS_LOG_INFO ("Ignoring packet to/from face " << face); |
| 304 | // return; |
| 305 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 306 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 307 | // Ptr<PcapFileWrapper> file = g_faceFileMapCcnx[pair]; |
| 308 | // file->Write (Simulator::Now (), p); |
| 309 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 310 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 311 | // bool |
| 312 | // CcnxStackHelper::PcapHooked (Ptr<Ccnx> ccnx) |
| 313 | // { |
| 314 | // for (FaceFileMapCcnx::const_iterator i = g_faceFileMapCcnx.begin (); |
| 315 | // i != g_faceFileMapCcnx.end (); |
| 316 | // ++i) |
| 317 | // { |
| 318 | // if ((*i).first.first == ccnx) |
| 319 | // { |
| 320 | // return true; |
| 321 | // } |
| 322 | // } |
| 323 | // return false; |
| 324 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 325 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 326 | // void |
| 327 | // CcnxStackHelper::EnablePcapCcnxInternal (std::string prefix, Ptr<Ccnx> ccnx, uint32_t face, bool explicitFilename) |
| 328 | // { |
| 329 | // NS_LOG_FUNCTION (prefix << ccnx << face); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 330 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 331 | // // |
| 332 | // // We have to create a file and a mapping from protocol/face to file |
| 333 | // // irrespective of how many times we want to trace a particular protocol. |
| 334 | // // |
| 335 | // PcapHelper pcapHelper; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 336 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 337 | // std::string filename; |
| 338 | // if (explicitFilename) |
| 339 | // { |
| 340 | // filename = prefix; |
| 341 | // } |
| 342 | // else |
| 343 | // { |
| 344 | // filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ccnx, face); |
| 345 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 346 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 347 | // Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 348 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 349 | // // |
| 350 | // // However, we only hook the trace source once to avoid multiple trace sink |
| 351 | // // calls per event (connect is independent of face). |
| 352 | // // |
| 353 | // if (!PcapHooked (ccnx)) |
| 354 | // { |
| 355 | // // |
| 356 | // // Ptr<Ccnx> is aggregated to node and CcnxL3Protocol is aggregated to |
| 357 | // // node so we can get to CcnxL3Protocol through Ccnx. |
| 358 | // // |
| 359 | // Ptr<CcnxL3Protocol> ccnxL3Protocol = ccnx->GetObject<CcnxL3Protocol> (); |
| 360 | // NS_ASSERT_MSG (ccnxL3Protocol, "CcnxStackHelper::EnablePcapCcnxInternal(): " |
| 361 | // "m_ccnxEnabled and ccnxL3Protocol inconsistent"); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 362 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 363 | // bool result = ccnxL3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&CcnxL3ProtocolRxTxSink)); |
| 364 | // NS_ASSERT_MSG (result == true, "CcnxStackHelper::EnablePcapCcnxInternal(): " |
| 365 | // "Unable to connect ccnxL3Protocol \"Tx\""); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 366 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 367 | // result = ccnxL3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&CcnxL3ProtocolRxTxSink)); |
| 368 | // NS_ASSERT_MSG (result == true, "CcnxStackHelper::EnablePcapCcnxInternal(): " |
| 369 | // "Unable to connect ccnxL3Protocol \"Rx\""); |
| 370 | // // cast result to void, to suppress ‘result’ set but not used compiler-warning |
| 371 | // // for optimized builds |
| 372 | // (void) result; |
| 373 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 374 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 375 | // g_faceFileMapCcnx[std::make_pair (ccnx, face)] = file; |
| 376 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 377 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 378 | // static void |
| 379 | // CcnxL3ProtocolDropSinkWithoutContext ( |
| 380 | // Ptr<OutputStreamWrapper> stream, |
| 381 | // Ptr<const Packet> packet, |
| 382 | // CcnxL3Protocol::DropReason reason, |
| 383 | // Ptr<Ccnx> ccnx, |
| 384 | // uint32_t face) |
| 385 | // { |
| 386 | // // |
| 387 | // // Since trace sources are independent of face, if we hook a source |
| 388 | // // on a particular protocol we will get traces for all of its faces. |
| 389 | // // We need to filter this to only report faces for which the user |
| 390 | // // has expressed interest. |
| 391 | // // |
| 392 | // FacePairCcnx pair = std::make_pair (ccnx, face); |
| 393 | // if (g_faceStreamMapCcnx.find (pair) == g_faceStreamMapCcnx.end ()) |
| 394 | // { |
| 395 | // NS_LOG_INFO ("Ignoring packet to/from face " << face); |
| 396 | // return; |
| 397 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 398 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 399 | // *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl; |
| 400 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 401 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 402 | // static void |
| 403 | // CcnxL3ProtocolDropSinkWithContext ( |
| 404 | // Ptr<OutputStreamWrapper> stream, |
| 405 | // std::string context, |
| 406 | // Ptr<const Packet> packet, |
| 407 | // CcnxL3Protocol::DropReason reason, |
| 408 | // Ptr<Ccnx> ccnx, |
| 409 | // uint32_t face) |
| 410 | // { |
| 411 | // // |
| 412 | // // Since trace sources are independent of face, if we hook a source |
| 413 | // // on a particular protocol we will get traces for all of its faces. |
| 414 | // // We need to filter this to only report faces for which the user |
| 415 | // // has expressed interest. |
| 416 | // // |
| 417 | // FacePairCcnx pair = std::make_pair (ccnx, face); |
| 418 | // if (g_faceStreamMapCcnx.find (pair) == g_faceStreamMapCcnx.end ()) |
| 419 | // { |
| 420 | // NS_LOG_INFO ("Ignoring packet to/from face " << face); |
| 421 | // return; |
| 422 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 423 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 424 | // *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << face << ") " |
| 425 | // << *packet << std::endl; |
| 426 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 427 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 428 | // bool |
| 429 | // CcnxStackHelper::AsciiHooked (Ptr<Ccnx> ccnx) |
| 430 | // { |
| 431 | // for ( FaceStreamMapCcnx::const_iterator i = g_faceStreamMapCcnx.begin (); |
| 432 | // i != g_faceStreamMapCcnx.end (); |
| 433 | // ++i) |
| 434 | // { |
| 435 | // if ((*i).first.first == ccnx) |
| 436 | // { |
| 437 | // return true; |
| 438 | // } |
| 439 | // } |
| 440 | // return false; |
| 441 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 442 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 443 | // void |
| 444 | // CcnxStackHelper::EnableAsciiCcnxInternal ( |
| 445 | // Ptr<OutputStreamWrapper> stream, |
| 446 | // std::string prefix, |
| 447 | // Ptr<Ccnx> ccnx, |
| 448 | // uint32_t face, |
| 449 | // bool explicitFilename) |
| 450 | // { |
| 451 | // // |
| 452 | // // Our trace sinks are going to use packet printing, so we have to |
| 453 | // // make sure that is turned on. |
| 454 | // // |
| 455 | // Packet::EnablePrinting (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 456 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 457 | // // |
| 458 | // // If we are not provided an OutputStreamWrapper, we are expected to create |
| 459 | // // one using the usual trace filename conventions and hook WithoutContext |
| 460 | // // since there will be one file per context and therefore the context would |
| 461 | // // be redundant. |
| 462 | // // |
| 463 | // if (stream == 0) |
| 464 | // { |
| 465 | // // |
| 466 | // // Set up an output stream object to deal with private ofstream copy |
| 467 | // // constructor and lifetime issues. Let the helper decide the actual |
| 468 | // // name of the file given the prefix. |
| 469 | // // |
| 470 | // // We have to create a stream and a mapping from protocol/face to |
| 471 | // // stream irrespective of how many times we want to trace a particular |
| 472 | // // protocol. |
| 473 | // // |
| 474 | // AsciiTraceHelper asciiTraceHelper; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 475 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 476 | // std::string filename; |
| 477 | // if (explicitFilename) |
| 478 | // { |
| 479 | // filename = prefix; |
| 480 | // } |
| 481 | // else |
| 482 | // { |
| 483 | // filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ccnx, face); |
| 484 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 485 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 486 | // Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 487 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 488 | // // |
| 489 | // // However, we only hook the trace sources once to avoid multiple trace sink |
| 490 | // // calls per event (connect is independent of face). |
| 491 | // // |
| 492 | // if (!AsciiHooked (ccnx)) |
| 493 | // { |
| 494 | // // |
| 495 | // // The drop sink for the CcnxL3Protocol uses a different signature than |
| 496 | // // the default sink, so we have to cook one up for ourselves. We can get |
| 497 | // // to the Ptr<CcnxL3Protocol> through our Ptr<Ccnx> since they must both |
| 498 | // // be aggregated to the same node. |
| 499 | // // |
| 500 | // Ptr<CcnxL3Protocol> ccnxL3Protocol = ccnx->GetObject<CcnxL3Protocol> (); |
| 501 | // bool __attribute__ ((unused)) result = ccnxL3Protocol->TraceConnectWithoutContext ("Drop", |
| 502 | // MakeBoundCallback (&CcnxL3ProtocolDropSinkWithoutContext, theStream)); |
| 503 | // NS_ASSERT_MSG (result == true, "CcnxStackHelper::EanableAsciiCcnxInternal(): " |
| 504 | // "Unable to connect ccnxL3Protocol \"Drop\""); |
| 505 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 506 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 507 | // g_faceStreamMapCcnx[std::make_pair (ccnx, face)] = theStream; |
| 508 | // return; |
| 509 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 510 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 511 | // // |
| 512 | // // If we are provided an OutputStreamWrapper, we are expected to use it, and |
| 513 | // // to provide a context. We are free to come up with our own context if we |
| 514 | // // want, and use the AsciiTraceHelper Hook*WithContext functions, but for |
| 515 | // // compatibility and simplicity, we just use Config::Connect and let it deal |
| 516 | // // with the context. |
| 517 | // // |
| 518 | // // We need to associate the ccnx/face with a stream to express interest |
| 519 | // // in tracing events on that pair, however, we only hook the trace sources |
| 520 | // // once to avoid multiple trace sink calls per event (connect is independent |
| 521 | // // of face). |
| 522 | // // |
| 523 | // if (!AsciiHooked (ccnx)) |
| 524 | // { |
| 525 | // Ptr<Node> node = ccnx->GetObject<Node> (); |
| 526 | // std::ostringstream oss; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 527 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 528 | // // |
| 529 | // // This has all kinds of parameters coming with, so we have to cook up our |
| 530 | // // own sink. |
| 531 | // // |
| 532 | // oss.str (""); |
| 533 | // oss << "/NodeList/" << node->GetId () << "/$ns3::CcnxL3Protocol/Drop"; |
| 534 | // Config::Connect (oss.str (), MakeBoundCallback (&CcnxL3ProtocolDropSinkWithContext, stream)); |
| 535 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 536 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 537 | // g_faceStreamMapCcnx[std::make_pair (ccnx, face)] = stream; |
| 538 | // } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 539 | |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 540 | void |
| 541 | CcnxStackHelper::InstallFakeGlobalRoutes () |
| 542 | { |
| 543 | for (NodeList::Iterator node = NodeList::Begin (); |
| 544 | node != NodeList::End (); |
| 545 | node ++) |
| 546 | { |
| 547 | NS_ASSERT_MSG ((*node)->GetObject<Ipv4> () != 0, |
| 548 | "InternetStack should be installed on all nodes"); |
| 549 | |
| 550 | NS_ASSERT_MSG (Ipv4RoutingHelper::GetRouting<Ipv4GlobalRoutingOrderedNexthops> |
| 551 | ( |
| 552 | (*node)->GetObject<Ipv4> ()->GetRoutingProtocol () |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 553 | ), |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 554 | "InternetStack should have Ipv4GlobalRoutingOrderedNexthops as routing protocol"); |
| 555 | // Example: |
| 556 | // |
| 557 | // Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingUnorderedNexthops"); |
| 558 | // stack.SetRoutingHelper (ipv4RoutingHelper); |
| 559 | // |
| 560 | |
| 561 | Ptr<GlobalRouter> globalRouter = (*node)->GetObject<GlobalRouter> (); |
| 562 | if (globalRouter == 0) continue; |
| 563 | |
| 564 | globalRouter->InjectRoute (Ipv4Address((*node)->GetId ()), Ipv4Mask("255.255.255.255")); |
| 565 | } |
| 566 | |
| 567 | Ipv4GlobalRoutingHelper::PopulateAllPossibleRoutingTables (); |
| 568 | } |
| 569 | |
| 570 | void |
| 571 | CcnxStackHelper::InstallRouteTo (Ptr<Node> destNode) |
| 572 | { |
| 573 | std::ostringstream destPrefix; |
| 574 | destPrefix << "/" << destNode->GetId (); |
| 575 | |
| 576 | Ipv4Address destIpv4 = Ipv4Address(destNode->GetId ()); |
| 577 | |
| 578 | for (NodeList::Iterator node = NodeList::Begin (); |
| 579 | node != NodeList::End (); |
| 580 | node ++) |
| 581 | { |
| 582 | if (destNode == *node) continue; |
| 583 | |
| 584 | Ptr<Ccnx> ccnx = (*node)->GetObject<Ccnx> (); |
| 585 | NS_ASSERT_MSG (ccnx != 0, "CCNx stack should be installed on all nodes"); |
| 586 | |
| 587 | Ptr<Ipv4> ipv4 = (*node)->GetObject<Ipv4> (); |
| 588 | NS_ASSERT_MSG (ipv4 != 0, |
| 589 | "InternetStack should be installed on all nodes"); |
| 590 | |
| 591 | Ptr<Ipv4GlobalRoutingOrderedNexthops> routing = |
| 592 | Ipv4RoutingHelper::GetRouting<Ipv4GlobalRoutingOrderedNexthops> (ipv4->GetRoutingProtocol ()); |
| 593 | NS_ASSERT_MSG (routing != 0, "Ipv4GlobalRoutingOrderedNexthops should be used in InternetStack"); |
| 594 | |
| 595 | Ptr<Ipv4GlobalRoutingOrderedNexthops::EntryContainer> |
| 596 | routes = routing->Lookup (destIpv4); |
| 597 | |
| 598 | NS_ASSERT_MSG (routes != 0, "Should not happen... Call the developer"); |
| 599 | |
| 600 | BOOST_FOREACH (const Ipv4RoutingTableEntry &entry, *routes) |
| 601 | { |
| 602 | Ptr<NetDevice> netDevice = ipv4->GetNetDevice (entry.GetInterface ()); |
| 603 | NS_ASSERT_MSG (netDevice != 0, "Should never happen. Call the popos"); |
| 604 | |
| 605 | Ptr<CcnxFace> face = ccnx->GetFaceByNetDevice (netDevice); |
| 606 | NS_ASSERT_MSG (face != 0, "Definitely should never happen. Call the president"); |
| 607 | |
| 608 | AddRoute (*node, destPrefix.str(), face, entry.GetMetric ()); |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | void |
| 614 | CcnxStackHelper::InstallRoutesToAll () |
| 615 | { |
| 616 | for (NodeList::Iterator node = NodeList::Begin (); |
| 617 | node != NodeList::End (); |
| 618 | node ++) |
| 619 | { |
| 620 | InstallRouteTo (*node); |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 625 | } // namespace ns3 |