Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 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 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "ccnx-trace-helper.h" |
| 22 | |
| 23 | #include "ns3/ccnx-interest-header.h" |
| 24 | #include "ns3/ccnx-content-object-header.h" |
| 25 | #include "ns3/config.h" |
| 26 | #include "ns3/callback.h" |
| 27 | #include "ns3/ccnx-app.h" |
| 28 | #include "ns3/ccnx-face.h" |
| 29 | #include "ns3/packet.h" |
| 30 | #include "ns3/log.h" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 31 | #include "ns3/assert.h" |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 32 | #include "ns3/node-list.h" |
| 33 | #include "ns3/object-vector.h" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 34 | #include "ns3/simulator.h" |
| 35 | #include "ns3/names.h" |
| 36 | |
| 37 | #include <boost/ref.hpp> |
| 38 | #include <boost/lexical_cast.hpp> |
| 39 | #include <boost/foreach.hpp> |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 40 | |
| 41 | #include <fstream> |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 42 | |
| 43 | using namespace std; |
| 44 | using namespace boost; |
| 45 | |
| 46 | NS_LOG_COMPONENT_DEFINE ("CcnxTraceHelper"); |
| 47 | |
| 48 | namespace ns3 { |
| 49 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 50 | CcnxAppTracer::CcnxAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId) |
| 51 | : m_app (app) |
| 52 | , m_appId (appId) |
| 53 | , m_nodePtr (node) |
| 54 | { |
| 55 | m_node = boost::lexical_cast<string> (m_nodePtr->GetId ()); |
| 56 | |
| 57 | Connect (); |
| 58 | |
| 59 | string name = Names::FindName (node); |
| 60 | if (!name.empty ()) |
| 61 | { |
| 62 | m_node = name; |
| 63 | } |
| 64 | } |
| 65 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 66 | CcnxAppTracer::CcnxAppTracer (const std::string &app, const std::string &node, const std::string &appId) |
| 67 | : m_app (app) |
| 68 | , m_appId (appId) |
| 69 | , m_node (node) |
| 70 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 71 | Connect (); |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | CcnxAppTracer::Connect () |
| 76 | { |
| 77 | Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedInterests", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 78 | MakeCallback (&CcnxAppTracer::OutInterests, this)); |
| 79 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 80 | Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedNacks", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 81 | MakeCallback (&CcnxAppTracer::InNacks, this)); |
| 82 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 83 | Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedInterests", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 84 | MakeCallback (&CcnxAppTracer::InInterests, this)); |
| 85 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 86 | Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedContentObjects", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 87 | MakeCallback (&CcnxAppTracer::OutData, this)); |
| 88 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 89 | Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedContentObjects", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 90 | MakeCallback (&CcnxAppTracer::InData, this)); |
| 91 | } |
| 92 | |
| 93 | //////////////////////////////////////////////////////////////////// |
| 94 | //////////////////////////////////////////////////////////////////// |
| 95 | //////////////////////////////////////////////////////////////////// |
| 96 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 97 | CcnxL3Tracer::CcnxL3Tracer (Ptr<Node> node) |
| 98 | : m_nodePtr (node) |
| 99 | { |
| 100 | m_node = boost::lexical_cast<string> (m_nodePtr->GetId ()); |
| 101 | |
| 102 | Connect (); |
| 103 | |
| 104 | string name = Names::FindName (node); |
| 105 | if (!name.empty ()) |
| 106 | { |
| 107 | m_node = name; |
| 108 | } |
| 109 | } |
| 110 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 111 | CcnxL3Tracer::CcnxL3Tracer (const std::string &node) |
| 112 | : m_node (node) |
| 113 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 114 | Connect (); |
| 115 | } |
| 116 | |
| 117 | void |
| 118 | CcnxL3Tracer::Connect () |
| 119 | { |
| 120 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/ForwardingStrategy/OutInterests", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 121 | MakeCallback (&CcnxL3Tracer::OutInterests, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 122 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InInterests", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 123 | MakeCallback (&CcnxL3Tracer::InInterests, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 124 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropInterests", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 125 | MakeCallback (&CcnxL3Tracer::DropInterests, this)); |
| 126 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 127 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutNacks", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 128 | MakeCallback (&CcnxL3Tracer::OutNacks, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 129 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InNacks", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 130 | MakeCallback (&CcnxL3Tracer::InNacks, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 131 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropNacks", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 132 | MakeCallback (&CcnxL3Tracer::DropNacks, this)); |
| 133 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 134 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutData", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 135 | MakeCallback (&CcnxL3Tracer::OutData, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 136 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InData", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 137 | MakeCallback (&CcnxL3Tracer::InData, this)); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 138 | Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropData", |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 139 | MakeCallback (&CcnxL3Tracer::DropData, this)); |
| 140 | } |
| 141 | |
| 142 | //////////////////////////////////////////////////////////////////// |
| 143 | //////////////////////////////////////////////////////////////////// |
| 144 | //////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 145 | CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId) |
| 146 | : CcnxAppTracer (app, node, appId) |
| 147 | , m_inInterests (0) |
| 148 | , m_outInterests (0) |
| 149 | , m_inNacks (0) |
| 150 | , m_inData (0) |
| 151 | , m_outData (0) |
| 152 | |
| 153 | , m_inInterestsBytes (0) |
| 154 | , m_outInterestsBytes (0) |
| 155 | , m_inNacksBytes (0) |
| 156 | , m_inDataBytes (0) |
| 157 | , m_outDataBytes (0) |
| 158 | { |
| 159 | } |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 160 | |
| 161 | CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, const std::string &node, const std::string &appId) |
| 162 | : CcnxAppTracer (app, node, appId) |
| 163 | , m_inInterests (0) |
| 164 | , m_outInterests (0) |
| 165 | , m_inNacks (0) |
| 166 | , m_inData (0) |
| 167 | , m_outData (0) |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 168 | |
| 169 | , m_inInterestsBytes (0) |
| 170 | , m_outInterestsBytes (0) |
| 171 | , m_inNacksBytes (0) |
| 172 | , m_inDataBytes (0) |
| 173 | , m_outDataBytes (0) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 174 | { |
| 175 | } |
| 176 | |
| 177 | void |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 178 | CcnxAggregateAppTracer::Reset () |
| 179 | { |
| 180 | m_inInterests = 0; |
| 181 | m_outInterests = 0; |
| 182 | m_inNacks = 0; |
| 183 | m_inData = 0; |
| 184 | m_outData = 0; |
| 185 | |
| 186 | m_inInterestsBytes = 0; |
| 187 | m_outInterestsBytes = 0; |
| 188 | m_inNacksBytes = 0; |
| 189 | m_inDataBytes = 0; |
| 190 | m_outDataBytes = 0; |
| 191 | } |
| 192 | |
| 193 | void |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 194 | CcnxAggregateAppTracer::PrintHeader (std::ostream &os) const |
| 195 | { |
| 196 | os << "NodeId" << "\t" |
| 197 | << "App" << "\t" |
| 198 | << "AppId" << "\t" |
| 199 | << "InInterests" << "\t" |
| 200 | << "OutInterests" << "\t" |
| 201 | |
| 202 | << "InNacks" << "\t" |
| 203 | |
| 204 | << "InData" << "\t" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 205 | << "OutData" << "\t" |
| 206 | |
| 207 | << "InInterestsBytes" << "\t" |
| 208 | << "OutInterestsBytes" << "\t" |
| 209 | |
| 210 | << "InNacksBytes" << "\t" |
| 211 | |
| 212 | << "InDataBytes" << "\t" |
| 213 | << "OutDataBytes"; |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void |
| 217 | CcnxAggregateAppTracer::Print (std::ostream &os) const |
| 218 | { |
| 219 | os << m_node << "\t" |
| 220 | << m_app << "\t" |
| 221 | << m_appId << "\t" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 222 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 223 | << m_inInterests << "\t" |
| 224 | << m_outInterests << "\t" |
| 225 | |
| 226 | << m_inNacks << "\t" |
| 227 | |
| 228 | << m_inData << "\t" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 229 | << m_outData << "\t" |
| 230 | |
| 231 | << m_inInterestsBytes << "\t" |
| 232 | << m_outInterestsBytes << "\t" |
| 233 | |
| 234 | << m_inNacksBytes << "\t" |
| 235 | |
| 236 | << m_inDataBytes << "\t" |
| 237 | << m_outDataBytes; |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | void |
| 241 | CcnxAggregateAppTracer::OutInterests (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 242 | Ptr<const CcnxInterestHeader> header, Ptr<CcnxApp>, Ptr<CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 243 | { |
| 244 | m_outInterests++; |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 245 | m_outInterestsBytes += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | void |
| 249 | CcnxAggregateAppTracer::OutData (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 250 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 251 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 252 | { |
| 253 | m_outData++; |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 254 | m_outDataBytes += header->GetSerializedSize () + payload->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | void |
| 258 | CcnxAggregateAppTracer::InInterests (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 259 | Ptr<const CcnxInterestHeader> header, |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 260 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 261 | { |
| 262 | m_inInterests++; |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 263 | m_inInterestsBytes += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void |
| 267 | CcnxAggregateAppTracer::InNacks (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 268 | Ptr<const CcnxInterestHeader> header, |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 269 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 270 | { |
| 271 | m_inNacks++; |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 272 | m_inNacksBytes += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | void |
| 276 | CcnxAggregateAppTracer::InData (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 277 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 278 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 279 | { |
| 280 | m_inData++; |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 281 | m_inDataBytes += header->GetSerializedSize () + payload->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | |
| 285 | //////////////////////////////////////////////////////////////////// |
| 286 | //////////////////////////////////////////////////////////////////// |
| 287 | //////////////////////////////////////////////////////////////////// |
| 288 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 289 | CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (Ptr<Node> node) |
| 290 | : CcnxL3Tracer (node) |
| 291 | { |
| 292 | Reset (); |
| 293 | } |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 294 | |
| 295 | CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (const std::string &node) |
| 296 | : CcnxL3Tracer (node) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 297 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 298 | Reset (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | void |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 302 | CcnxAggregateL3Tracer::Stats::Reset () |
| 303 | { |
| 304 | m_inInterests = 0; |
| 305 | m_outInterests = 0; |
| 306 | m_dropInterests = 0; |
| 307 | m_inNacks = 0; |
| 308 | m_outNacks = 0; |
| 309 | m_dropNacks = 0; |
| 310 | m_inData = 0; |
| 311 | m_outData = 0; |
| 312 | m_dropData = 0; |
| 313 | } |
| 314 | |
| 315 | |
| 316 | void |
| 317 | CcnxAggregateL3Tracer::Reset () |
| 318 | { |
| 319 | m_packets.Reset (); |
| 320 | m_bytes.Reset (); |
| 321 | } |
| 322 | |
| 323 | |
| 324 | void |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 325 | CcnxAggregateL3Tracer::PrintHeader (std::ostream &os) const |
| 326 | { |
| 327 | os << "Node" << "\t" |
| 328 | << "InInterests" << "\t" |
| 329 | << "OutInterests" << "\t" |
| 330 | << "DropInterests" << "\t" |
| 331 | |
| 332 | << "InNacks" << "\t" |
| 333 | << "OutNacks" << "\t" |
| 334 | << "DropNacks" << "\t" |
| 335 | |
| 336 | << "InData" << "\t" |
| 337 | << "OutData" << "\t" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 338 | << "DropData" << "\t" |
| 339 | |
| 340 | << "InInterestsBytes" << "\t" |
| 341 | << "OutInterestsBytes" << "\t" |
| 342 | << "DropInterestsBytes" << "\t" |
| 343 | |
| 344 | << "InNacksBytes" << "\t" |
| 345 | << "OutNacksBytes" << "\t" |
| 346 | << "DropNacksBytes" << "\t" |
| 347 | |
| 348 | << "InDataBytes" << "\t" |
| 349 | << "OutDataBytes" << "\t" |
| 350 | << "DropDataBytes"; |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void |
| 354 | CcnxAggregateL3Tracer::Print (std::ostream &os) const |
| 355 | { |
| 356 | os << m_node << "\t" |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 357 | << m_packets.m_inInterests << "\t" |
| 358 | << m_packets.m_outInterests << "\t" |
| 359 | << m_packets.m_dropInterests << "\t" |
| 360 | |
| 361 | << m_packets.m_inNacks << "\t" |
| 362 | << m_packets.m_outNacks << "\t" |
| 363 | << m_packets.m_dropNacks << "\t" |
| 364 | |
| 365 | << m_packets.m_inData << "\t" |
| 366 | << m_packets.m_outData << "\t" |
| 367 | << m_packets.m_dropData << "\t" |
| 368 | |
| 369 | << m_bytes.m_inInterests << "\t" |
| 370 | << m_bytes.m_outInterests << "\t" |
| 371 | << m_bytes.m_dropInterests << "\t" |
| 372 | |
| 373 | << m_bytes.m_inNacks << "\t" |
| 374 | << m_bytes.m_outNacks << "\t" |
| 375 | << m_bytes.m_dropNacks << "\t" |
| 376 | |
| 377 | << m_bytes.m_inData << "\t" |
| 378 | << m_bytes.m_outData << "\t" |
| 379 | << m_bytes.m_dropData; |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | void |
| 383 | CcnxAggregateL3Tracer::OutInterests (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 384 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 385 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 386 | m_packets.m_outInterests++; |
| 387 | m_bytes.m_outInterests += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | void |
| 391 | CcnxAggregateL3Tracer::InInterests (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 392 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 393 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 394 | m_packets.m_inInterests++; |
| 395 | m_bytes.m_inInterests += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | void |
| 399 | CcnxAggregateL3Tracer::DropInterests (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 400 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 401 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 402 | m_packets.m_dropInterests++; |
| 403 | m_bytes.m_dropInterests += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | void |
| 407 | CcnxAggregateL3Tracer::OutNacks (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 408 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 409 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 410 | m_packets.m_outNacks++; |
| 411 | m_bytes.m_outNacks += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | void |
| 415 | CcnxAggregateL3Tracer::InNacks (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 416 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 417 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 418 | m_packets.m_inNacks++; |
| 419 | m_bytes.m_inNacks += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | void |
| 423 | CcnxAggregateL3Tracer::DropNacks (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 424 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 425 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 426 | m_packets.m_dropNacks++; |
| 427 | m_bytes.m_dropNacks += header->GetSerializedSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | void |
| 431 | CcnxAggregateL3Tracer::OutData (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 432 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 433 | bool fromCache, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 434 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 435 | m_packets.m_outData++; |
| 436 | m_bytes.m_outData += header->GetSerializedSize () + payload->GetSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | void |
| 440 | CcnxAggregateL3Tracer::InData (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 441 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 442 | Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 443 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 444 | m_packets.m_inData++; |
| 445 | m_bytes.m_inData += header->GetSerializedSize () + payload->GetSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | void |
| 449 | CcnxAggregateL3Tracer::DropData (std::string context, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 450 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 451 | Ccnx::DropReason, Ptr<const CcnxFace>) |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 452 | { |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 453 | m_packets.m_dropData++; |
| 454 | m_bytes.m_dropData += header->GetSerializedSize () + payload->GetSize (); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | |
| 458 | //////////////////////////////////////////////////////////////////// |
| 459 | //////////////////////////////////////////////////////////////////// |
| 460 | //////////////////////////////////////////////////////////////////// |
| 461 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 462 | CcnxRateL3Tracer::CcnxRateL3Tracer (std::ostream &os, Ptr<Node> node) |
| 463 | : CcnxL3Tracer (node) |
| 464 | , m_os (os) |
| 465 | { |
| 466 | SetAveragingPeriod (Seconds (1.0)); |
| 467 | } |
| 468 | |
| 469 | CcnxRateL3Tracer::CcnxRateL3Tracer (std::ostream &os, const std::string &node) |
| 470 | : CcnxL3Tracer (node) |
| 471 | , m_os (os) |
| 472 | { |
| 473 | SetAveragingPeriod (Seconds (1.0)); |
| 474 | } |
| 475 | |
| 476 | CcnxRateL3Tracer::~CcnxRateL3Tracer () |
| 477 | { |
| 478 | m_printEvent.Cancel (); |
| 479 | } |
| 480 | |
| 481 | void |
| 482 | CcnxRateL3Tracer::SetAveragingPeriod (const Time &period) |
| 483 | { |
| 484 | m_period = period; |
| 485 | m_printEvent.Cancel (); |
| 486 | m_printEvent = Simulator::Schedule (m_period, &CcnxRateL3Tracer::PeriodicPrinter, this); |
| 487 | } |
| 488 | |
| 489 | void |
| 490 | CcnxRateL3Tracer::PeriodicPrinter () |
| 491 | { |
| 492 | Print (m_os); |
| 493 | Reset (); |
| 494 | |
| 495 | m_printEvent = Simulator::Schedule (m_period, &CcnxRateL3Tracer::PeriodicPrinter, this); |
| 496 | } |
| 497 | |
| 498 | void |
| 499 | CcnxRateL3Tracer::PrintHeader (std::ostream &os) const |
| 500 | { |
| 501 | os << "Time" << "\t" |
| 502 | |
| 503 | << "Node" << "\t" |
| 504 | << "FaceId" << "\t" |
| 505 | << "FaceDescr" << "\t" |
| 506 | |
| 507 | << "Type" << "\t" |
| 508 | << "Packets" << "\t" |
| 509 | << "Kilobytes"; |
| 510 | } |
| 511 | |
| 512 | void |
| 513 | CcnxRateL3Tracer::Reset () |
| 514 | { |
| 515 | for (std::map<Ptr<const CcnxFace>, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin (); |
| 516 | stats != m_stats.end (); |
| 517 | stats++) |
| 518 | { |
| 519 | stats->second.get<0> ().Reset (); |
| 520 | stats->second.get<1> ().Reset (); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | const double alpha = 0.8; |
| 525 | |
| 526 | #define STATS(INDEX) stats->second.get<INDEX> () |
| 527 | #define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble (Time::S) |
| 528 | |
| 529 | #define PRINTER(printName, fieldName) \ |
| 530 | STATS(2).fieldName = /*new value*/alpha * RATE(0, fieldName) + /*old value*/(1-alpha) * STATS(2).fieldName; \ |
| 531 | STATS(3).fieldName = /*new value*/alpha * RATE(1, fieldName) / 1024.0 + /*old value*/(1-alpha) * STATS(3).fieldName; \ |
| 532 | \ |
| 533 | os << time.ToDouble (Time::S) << "\t" \ |
| 534 | << m_node << "\t" \ |
| 535 | << stats->first->GetId () << "\t" \ |
| 536 | << *stats->first << "\t" \ |
| 537 | << printName << "\t" \ |
| 538 | << STATS(2).fieldName << "\t" \ |
| 539 | << STATS(3).fieldName << "\n"; |
| 540 | |
| 541 | void |
| 542 | CcnxRateL3Tracer::Print (std::ostream &os) const |
| 543 | { |
| 544 | for (std::map<Ptr<const CcnxFace>, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin (); |
| 545 | stats != m_stats.end (); |
| 546 | stats++) |
| 547 | { |
| 548 | Time time = Simulator::Now (); |
| 549 | |
| 550 | PRINTER ("InInterests", m_inInterests); |
| 551 | PRINTER ("OutInterests", m_outInterests); |
| 552 | PRINTER ("DropInterests", m_dropInterests); |
| 553 | |
| 554 | PRINTER ("InNacks", m_inNacks); |
| 555 | PRINTER ("OutNacks", m_outNacks); |
| 556 | PRINTER ("DropNacks", m_dropNacks); |
| 557 | |
| 558 | PRINTER ("InData", m_inData); |
| 559 | PRINTER ("OutData", m_outData); |
| 560 | PRINTER ("DropData", m_dropData); |
| 561 | |
| 562 | // os << Simulator::Now ().ToDouble (Time::S) << "\t" |
| 563 | |
| 564 | // << m_node << "\t" |
| 565 | // << stats->first->GetId () << "\t" |
| 566 | // << *stats->first << "\t" |
| 567 | // << "InInterests" << "\t" << |
| 568 | // << stats->second.get<0> ().m_inInterests / m_period.ToDouble (Time::S) << "\t" |
| 569 | // << stats->second.get<1> ().m_inInterests / m_period.ToDouble (Time::S) / 1024.0; |
| 570 | |
| 571 | // << stats->second.get<0> ().m_outInterests / m_period.ToDouble (Time::S) << "\t" |
| 572 | // << stats->second.get<0> ().m_dropInterests / m_period.ToDouble (Time::S) << "\t" |
| 573 | |
| 574 | // << stats->second.get<0> ().m_inNacks / m_period.ToDouble (Time::S) << "\t" |
| 575 | // << stats->second.get<0> ().m_outNacks / m_period.ToDouble (Time::S) << "\t" |
| 576 | // << stats->second.get<0> ().m_dropNacks / m_period.ToDouble (Time::S) << "\t" |
| 577 | |
| 578 | // << stats->second.get<0> ().m_inData / m_period.ToDouble (Time::S) << "\t" |
| 579 | // << stats->second.get<0> ().m_outData / m_period.ToDouble (Time::S) << "\t" |
| 580 | // << stats->second.get<0> ().m_dropData / m_period.ToDouble (Time::S) << "\t" |
| 581 | |
| 582 | // << stats->second.get<1> ().m_outInterests / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 583 | // << stats->second.get<1> ().m_dropInterests / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 584 | |
| 585 | // << stats->second.get<1> ().m_inNacks / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 586 | // << stats->second.get<1> ().m_outNacks / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 587 | // << stats->second.get<1> ().m_dropNacks / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 588 | |
| 589 | // << stats->second.get<1> ().m_inData / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 590 | // << stats->second.get<1> ().m_outData / m_period.ToDouble (Time::S) / 1024.0 << "\t" |
| 591 | // << stats->second.get<1> ().m_dropData / m_period.ToDouble (Time::S) / 1024.0; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | |
| 596 | void |
| 597 | CcnxRateL3Tracer::OutInterests (std::string context, |
| 598 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace> face) |
| 599 | { |
| 600 | m_stats[face].get<0> ().m_outInterests ++; |
| 601 | m_stats[face].get<1> ().m_outInterests += header->GetSerializedSize (); |
| 602 | } |
| 603 | |
| 604 | void |
| 605 | CcnxRateL3Tracer::InInterests (std::string context, |
| 606 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace> face) |
| 607 | { |
| 608 | m_stats[face].get<0> ().m_inInterests ++; |
| 609 | m_stats[face].get<1> ().m_inInterests += header->GetSerializedSize (); |
| 610 | } |
| 611 | |
| 612 | void |
| 613 | CcnxRateL3Tracer::DropInterests (std::string context, |
| 614 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace> face) |
| 615 | { |
| 616 | m_stats[face].get<0> ().m_dropInterests ++; |
| 617 | m_stats[face].get<1> ().m_dropInterests += header->GetSerializedSize (); |
| 618 | } |
| 619 | |
| 620 | void |
| 621 | CcnxRateL3Tracer::OutNacks (std::string context, |
| 622 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace> face) |
| 623 | { |
| 624 | m_stats[face].get<0> ().m_outNacks ++; |
| 625 | m_stats[face].get<1> ().m_outNacks += header->GetSerializedSize (); |
| 626 | } |
| 627 | |
| 628 | void |
| 629 | CcnxRateL3Tracer::InNacks (std::string context, |
| 630 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace> face) |
| 631 | { |
| 632 | m_stats[face].get<0> ().m_inNacks ++; |
| 633 | m_stats[face].get<1> ().m_inNacks += header->GetSerializedSize (); |
| 634 | } |
| 635 | |
| 636 | void |
| 637 | CcnxRateL3Tracer::DropNacks (std::string context, |
| 638 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace> face) |
| 639 | { |
| 640 | m_stats[face].get<0> ().m_dropNacks ++; |
| 641 | m_stats[face].get<1> ().m_dropNacks += header->GetSerializedSize (); |
| 642 | } |
| 643 | |
| 644 | void |
| 645 | CcnxRateL3Tracer::OutData (std::string context, |
| 646 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 647 | bool fromCache, Ptr<const CcnxFace> face) |
| 648 | { |
| 649 | m_stats[face].get<0> ().m_inData ++; |
| 650 | m_stats[face].get<1> ().m_inData += header->GetSerializedSize () + payload->GetSize (); |
| 651 | } |
| 652 | |
| 653 | void |
| 654 | CcnxRateL3Tracer::InData (std::string context, |
| 655 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 656 | Ptr<const CcnxFace> face) |
| 657 | { |
| 658 | m_stats[face].get<0> ().m_outData ++; |
| 659 | m_stats[face].get<1> ().m_outData += header->GetSerializedSize () + payload->GetSize (); |
| 660 | } |
| 661 | |
| 662 | void |
| 663 | CcnxRateL3Tracer::DropData (std::string context, |
| 664 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 665 | Ccnx::DropReason, Ptr<const CcnxFace> face) |
| 666 | { |
| 667 | m_stats[face].get<0> ().m_dropData ++; |
| 668 | m_stats[face].get<1> ().m_dropData += header->GetSerializedSize () + payload->GetSize (); |
| 669 | } |
| 670 | |
| 671 | //////////////////////////////////////////////////////////////////// |
| 672 | //////////////////////////////////////////////////////////////////// |
| 673 | //////////////////////////////////////////////////////////////////// |
| 674 | |
| 675 | CcnxTraceHelper::CcnxTraceHelper () |
| 676 | : m_l3RateTrace (0) |
| 677 | { |
| 678 | } |
| 679 | |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 680 | CcnxTraceHelper::~CcnxTraceHelper () |
| 681 | { |
| 682 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 683 | if (m_l3RateTrace != 0) delete m_l3RateTrace; |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 684 | |
| 685 | if (m_apps.size () > 0) |
| 686 | { |
| 687 | ofstream of; |
| 688 | if (!m_appTrace.empty ()) |
| 689 | { |
| 690 | of.open (m_appTrace.c_str (), ios_base::trunc | ios_base::out); |
| 691 | of << "# "; |
| 692 | m_apps.front ()->PrintHeader (of); |
| 693 | of << "\n"; |
| 694 | } |
| 695 | |
| 696 | for (std::list<Ptr<CcnxAggregateAppTracer> >::iterator app = m_apps.begin (); |
| 697 | app != m_apps.end (); |
| 698 | app++) |
| 699 | { |
| 700 | if (!m_appTrace.empty ()) |
| 701 | { |
| 702 | (*app)->Print (of); |
| 703 | of << "\n"; |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | NS_LOG_INFO (*(*app)); |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | if (m_l3s.size () > 0) |
| 713 | { |
| 714 | ofstream of; |
| 715 | if (!m_l3Trace.empty ()) |
| 716 | { |
| 717 | of.open (m_l3Trace.c_str (), ios_base::trunc | ios_base::out); |
| 718 | of << "# "; |
| 719 | m_l3s.front ()->PrintHeader (of); |
| 720 | of << "\n"; |
| 721 | } |
| 722 | |
| 723 | for (std::list<Ptr<CcnxAggregateL3Tracer> >::iterator l3 = m_l3s.begin (); |
| 724 | l3 != m_l3s.end (); |
| 725 | l3++) |
| 726 | { |
| 727 | if (!m_l3Trace.empty ()) |
| 728 | { |
| 729 | (*l3)->Print (of); |
| 730 | of << "\n"; |
| 731 | } |
| 732 | else |
| 733 | { |
| 734 | NS_LOG_INFO (*(*l3)); |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | void |
| 741 | CcnxTraceHelper::SetAppTraceFile (const std::string &appTrace) |
| 742 | { |
| 743 | NS_LOG_FUNCTION (this << appTrace); |
| 744 | m_appTrace = appTrace; |
| 745 | } |
| 746 | |
| 747 | void |
| 748 | CcnxTraceHelper::SetL3TraceFile (const std::string &l3Trace) |
| 749 | { |
| 750 | NS_LOG_FUNCTION (this << l3Trace); |
| 751 | m_l3Trace = l3Trace; |
| 752 | } |
| 753 | |
| 754 | void |
| 755 | CcnxTraceHelper::EnableAggregateAppAll (const std::string &appName) |
| 756 | { |
| 757 | NS_LOG_FUNCTION (this << appName); |
| 758 | for (NodeList::Iterator node = NodeList::Begin (); |
| 759 | node != NodeList::End (); |
| 760 | node++) |
| 761 | { |
| 762 | ObjectVectorValue apps; |
| 763 | (*node)->GetAttribute ("ApplicationList", apps); |
| 764 | |
| 765 | NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ())); |
| 766 | |
| 767 | uint32_t appId = 0; |
| 768 | for (ObjectVectorValue::Iterator app = apps.Begin (); |
| 769 | app != apps.End (); |
| 770 | app++, appId++) |
| 771 | { |
| 772 | NS_LOG_DEBUG ("App: " << lexical_cast<string> (appId) << ", typeId: " << (*app)->GetInstanceTypeId ().GetName ()); |
| 773 | if ((*app)->GetInstanceTypeId ().GetName () == appName) |
| 774 | { |
| 775 | m_apps.push_back (Create<CcnxAggregateAppTracer> (appName, |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 776 | *node, |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 777 | lexical_cast<string> (appId))); |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | void |
| 784 | CcnxTraceHelper::EnableAggregateL3All () |
| 785 | { |
| 786 | NS_LOG_FUNCTION (this); |
| 787 | |
| 788 | for (NodeList::Iterator node = NodeList::Begin (); |
| 789 | node != NodeList::End (); |
| 790 | node++) |
| 791 | { |
| 792 | NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ())); |
| 793 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 794 | m_l3s.push_back (Create<CcnxAggregateL3Tracer> (*node)); |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame^] | 798 | void |
| 799 | CcnxTraceHelper::EnableRateL3All (const std::string &l3RateTrace) |
| 800 | { |
| 801 | NS_LOG_FUNCTION (this); |
| 802 | m_l3RateTrace = new ofstream (l3RateTrace.c_str (), ios::trunc); |
| 803 | |
| 804 | for (NodeList::Iterator node = NodeList::Begin (); |
| 805 | node != NodeList::End (); |
| 806 | node++) |
| 807 | { |
| 808 | NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ())); |
| 809 | |
| 810 | Ptr<CcnxRateL3Tracer> trace = Create<CcnxRateL3Tracer> (boost::ref(*m_l3RateTrace), *node); |
| 811 | trace->SetAveragingPeriod (Seconds (0.5)); |
| 812 | m_l3Rates.push_back (trace); |
| 813 | } |
| 814 | |
| 815 | if (m_l3Rates.size () > 0) |
| 816 | { |
| 817 | // *m_l3RateTrace << "# "; // not necessary for R's read.table |
| 818 | m_l3Rates.front ()->PrintHeader (*m_l3RateTrace); |
| 819 | *m_l3RateTrace << "\n"; |
| 820 | } |
| 821 | } |
Alexander Afanasyev | 141d131 | 2011-12-18 14:58:35 -0800 | [diff] [blame] | 822 | |
| 823 | } // namespace ns3 |