Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -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-aggregate-app-tracer.h" |
| 22 | #include "ns3/node.h" |
| 23 | #include "ns3/packet.h" |
| 24 | #include "ns3/config.h" |
| 25 | #include "ns3/callback.h" |
| 26 | #include "ns3/ccnx-app.h" |
| 27 | #include "ns3/ccnx-face.h" |
| 28 | #include "ns3/ccnx-interest-header.h" |
| 29 | #include "ns3/ccnx-content-object-header.h" |
| 30 | |
| 31 | namespace ns3 { |
| 32 | |
| 33 | CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId) |
| 34 | : CcnxAppTracer (app, node, appId) |
| 35 | , m_inInterests (0) |
| 36 | , m_outInterests (0) |
| 37 | , m_inNacks (0) |
| 38 | , m_inData (0) |
| 39 | , m_outData (0) |
| 40 | |
| 41 | , m_inInterestsBytes (0) |
| 42 | , m_outInterestsBytes (0) |
| 43 | , m_inNacksBytes (0) |
| 44 | , m_inDataBytes (0) |
| 45 | , m_outDataBytes (0) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, const std::string &node, const std::string &appId) |
| 50 | : CcnxAppTracer (app, node, appId) |
| 51 | , m_inInterests (0) |
| 52 | , m_outInterests (0) |
| 53 | , m_inNacks (0) |
| 54 | , m_inData (0) |
| 55 | , m_outData (0) |
| 56 | |
| 57 | , m_inInterestsBytes (0) |
| 58 | , m_outInterestsBytes (0) |
| 59 | , m_inNacksBytes (0) |
| 60 | , m_inDataBytes (0) |
| 61 | , m_outDataBytes (0) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | CcnxAggregateAppTracer::Reset () |
| 67 | { |
| 68 | m_inInterests = 0; |
| 69 | m_outInterests = 0; |
| 70 | m_inNacks = 0; |
| 71 | m_inData = 0; |
| 72 | m_outData = 0; |
| 73 | |
| 74 | m_inInterestsBytes = 0; |
| 75 | m_outInterestsBytes = 0; |
| 76 | m_inNacksBytes = 0; |
| 77 | m_inDataBytes = 0; |
| 78 | m_outDataBytes = 0; |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | CcnxAggregateAppTracer::PrintHeader (std::ostream &os) const |
| 83 | { |
| 84 | os << "NodeId" << "\t" |
| 85 | << "App" << "\t" |
| 86 | << "AppId" << "\t" |
| 87 | << "InInterests" << "\t" |
| 88 | << "OutInterests" << "\t" |
| 89 | |
| 90 | << "InNacks" << "\t" |
| 91 | |
| 92 | << "InData" << "\t" |
| 93 | << "OutData" << "\t" |
| 94 | |
| 95 | << "InInterestsBytes" << "\t" |
| 96 | << "OutInterestsBytes" << "\t" |
| 97 | |
| 98 | << "InNacksBytes" << "\t" |
| 99 | |
| 100 | << "InDataBytes" << "\t" |
| 101 | << "OutDataBytes"; |
| 102 | } |
| 103 | |
| 104 | void |
| 105 | CcnxAggregateAppTracer::Print (std::ostream &os) const |
| 106 | { |
| 107 | os << m_node << "\t" |
| 108 | << m_app << "\t" |
| 109 | << m_appId << "\t" |
| 110 | |
| 111 | << m_inInterests << "\t" |
| 112 | << m_outInterests << "\t" |
| 113 | |
| 114 | << m_inNacks << "\t" |
| 115 | |
| 116 | << m_inData << "\t" |
| 117 | << m_outData << "\t" |
| 118 | |
| 119 | << m_inInterestsBytes << "\t" |
| 120 | << m_outInterestsBytes << "\t" |
| 121 | |
| 122 | << m_inNacksBytes << "\t" |
| 123 | |
| 124 | << m_inDataBytes << "\t" |
| 125 | << m_outDataBytes; |
| 126 | } |
| 127 | |
| 128 | void |
| 129 | CcnxAggregateAppTracer::OutInterests (std::string context, |
| 130 | Ptr<const CcnxInterestHeader> header, Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 131 | { |
| 132 | m_outInterests++; |
| 133 | m_outInterestsBytes += header->GetSerializedSize (); |
| 134 | } |
| 135 | |
| 136 | void |
| 137 | CcnxAggregateAppTracer::OutData (std::string context, |
| 138 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 139 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 140 | { |
| 141 | m_outData++; |
| 142 | m_outDataBytes += header->GetSerializedSize () + payload->GetSerializedSize (); |
| 143 | } |
| 144 | |
| 145 | void |
| 146 | CcnxAggregateAppTracer::InInterests (std::string context, |
| 147 | Ptr<const CcnxInterestHeader> header, |
| 148 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 149 | { |
| 150 | m_inInterests++; |
| 151 | m_inInterestsBytes += header->GetSerializedSize (); |
| 152 | } |
| 153 | |
| 154 | void |
| 155 | CcnxAggregateAppTracer::InNacks (std::string context, |
| 156 | Ptr<const CcnxInterestHeader> header, |
| 157 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 158 | { |
| 159 | m_inNacks++; |
| 160 | m_inNacksBytes += header->GetSerializedSize (); |
| 161 | } |
| 162 | |
| 163 | void |
| 164 | CcnxAggregateAppTracer::InData (std::string context, |
| 165 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 166 | Ptr<CcnxApp>, Ptr<CcnxFace>) |
| 167 | { |
| 168 | m_inData++; |
| 169 | m_inDataBytes += header->GetSerializedSize () + payload->GetSerializedSize (); |
| 170 | } |
| 171 | |
| 172 | } // namespace ns3 |