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-l3-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 | CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (Ptr<Node> node) |
| 34 | : CcnxL3Tracer (node) |
| 35 | { |
| 36 | Reset (); |
| 37 | } |
| 38 | |
| 39 | CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (const std::string &node) |
| 40 | : CcnxL3Tracer (node) |
| 41 | { |
| 42 | Reset (); |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | CcnxAggregateL3Tracer::Stats::Reset () |
| 47 | { |
| 48 | m_inInterests = 0; |
| 49 | m_outInterests = 0; |
| 50 | m_dropInterests = 0; |
| 51 | m_inNacks = 0; |
| 52 | m_outNacks = 0; |
| 53 | m_dropNacks = 0; |
| 54 | m_inData = 0; |
| 55 | m_outData = 0; |
| 56 | m_dropData = 0; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | void |
| 61 | CcnxAggregateL3Tracer::Reset () |
| 62 | { |
| 63 | m_packets.Reset (); |
| 64 | m_bytes.Reset (); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | void |
| 69 | CcnxAggregateL3Tracer::PrintHeader (std::ostream &os) const |
| 70 | { |
| 71 | os << "Node" << "\t" |
| 72 | << "InInterests" << "\t" |
| 73 | << "OutInterests" << "\t" |
| 74 | << "DropInterests" << "\t" |
| 75 | |
| 76 | << "InNacks" << "\t" |
| 77 | << "OutNacks" << "\t" |
| 78 | << "DropNacks" << "\t" |
| 79 | |
| 80 | << "InData" << "\t" |
| 81 | << "OutData" << "\t" |
| 82 | << "DropData" << "\t" |
| 83 | |
| 84 | << "InInterestsBytes" << "\t" |
| 85 | << "OutInterestsBytes" << "\t" |
| 86 | << "DropInterestsBytes" << "\t" |
| 87 | |
| 88 | << "InNacksBytes" << "\t" |
| 89 | << "OutNacksBytes" << "\t" |
| 90 | << "DropNacksBytes" << "\t" |
| 91 | |
| 92 | << "InDataBytes" << "\t" |
| 93 | << "OutDataBytes" << "\t" |
| 94 | << "DropDataBytes"; |
| 95 | } |
| 96 | |
| 97 | void |
| 98 | CcnxAggregateL3Tracer::Print (std::ostream &os) const |
| 99 | { |
| 100 | os << m_node << "\t" |
| 101 | << m_packets.m_inInterests << "\t" |
| 102 | << m_packets.m_outInterests << "\t" |
| 103 | << m_packets.m_dropInterests << "\t" |
| 104 | |
| 105 | << m_packets.m_inNacks << "\t" |
| 106 | << m_packets.m_outNacks << "\t" |
| 107 | << m_packets.m_dropNacks << "\t" |
| 108 | |
| 109 | << m_packets.m_inData << "\t" |
| 110 | << m_packets.m_outData << "\t" |
| 111 | << m_packets.m_dropData << "\t" |
| 112 | |
| 113 | << m_bytes.m_inInterests << "\t" |
| 114 | << m_bytes.m_outInterests << "\t" |
| 115 | << m_bytes.m_dropInterests << "\t" |
| 116 | |
| 117 | << m_bytes.m_inNacks << "\t" |
| 118 | << m_bytes.m_outNacks << "\t" |
| 119 | << m_bytes.m_dropNacks << "\t" |
| 120 | |
| 121 | << m_bytes.m_inData << "\t" |
| 122 | << m_bytes.m_outData << "\t" |
| 123 | << m_bytes.m_dropData; |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | CcnxAggregateL3Tracer::OutInterests (std::string context, |
| 128 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
| 129 | { |
| 130 | m_packets.m_outInterests++; |
| 131 | m_bytes.m_outInterests += header->GetSerializedSize (); |
| 132 | } |
| 133 | |
| 134 | void |
| 135 | CcnxAggregateL3Tracer::InInterests (std::string context, |
| 136 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
| 137 | { |
| 138 | m_packets.m_inInterests++; |
| 139 | m_bytes.m_inInterests += header->GetSerializedSize (); |
| 140 | } |
| 141 | |
| 142 | void |
| 143 | CcnxAggregateL3Tracer::DropInterests (std::string context, |
| 144 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace>) |
| 145 | { |
| 146 | m_packets.m_dropInterests++; |
| 147 | m_bytes.m_dropInterests += header->GetSerializedSize (); |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | CcnxAggregateL3Tracer::OutNacks (std::string context, |
| 152 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
| 153 | { |
| 154 | m_packets.m_outNacks++; |
| 155 | m_bytes.m_outNacks += header->GetSerializedSize (); |
| 156 | } |
| 157 | |
| 158 | void |
| 159 | CcnxAggregateL3Tracer::InNacks (std::string context, |
| 160 | Ptr<const CcnxInterestHeader> header, Ptr<const CcnxFace>) |
| 161 | { |
| 162 | m_packets.m_inNacks++; |
| 163 | m_bytes.m_inNacks += header->GetSerializedSize (); |
| 164 | } |
| 165 | |
| 166 | void |
| 167 | CcnxAggregateL3Tracer::DropNacks (std::string context, |
| 168 | Ptr<const CcnxInterestHeader> header, Ccnx::DropReason, Ptr<const CcnxFace>) |
| 169 | { |
| 170 | m_packets.m_dropNacks++; |
| 171 | m_bytes.m_dropNacks += header->GetSerializedSize (); |
| 172 | } |
| 173 | |
| 174 | void |
| 175 | CcnxAggregateL3Tracer::OutData (std::string context, |
| 176 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 177 | bool fromCache, Ptr<const CcnxFace>) |
| 178 | { |
| 179 | m_packets.m_outData++; |
| 180 | m_bytes.m_outData += header->GetSerializedSize () + payload->GetSize (); |
| 181 | } |
| 182 | |
| 183 | void |
| 184 | CcnxAggregateL3Tracer::InData (std::string context, |
| 185 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 186 | Ptr<const CcnxFace>) |
| 187 | { |
| 188 | m_packets.m_inData++; |
| 189 | m_bytes.m_inData += header->GetSerializedSize () + payload->GetSize (); |
| 190 | } |
| 191 | |
| 192 | void |
| 193 | CcnxAggregateL3Tracer::DropData (std::string context, |
| 194 | Ptr<const CcnxContentObjectHeader> header, Ptr<const Packet> payload, |
| 195 | Ccnx::DropReason, Ptr<const CcnxFace>) |
| 196 | { |
| 197 | m_packets.m_dropData++; |
| 198 | m_bytes.m_dropData += header->GetSerializedSize () + payload->GetSize (); |
| 199 | } |
| 200 | |
| 201 | } // namespace ns3 |