blob: 1280edea515580fe3fbf3791e43aae1464f2598c [file] [log] [blame]
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08001/* -*- 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 "ndn-l3-aggregate-tracer.h"
22
23#include "ns3/node.h"
24#include "ns3/packet.h"
25#include "ns3/config.h"
26#include "ns3/callback.h"
27#include "ns3/ndn-app.h"
28#include "ns3/ndn-face.h"
29#include "ns3/ndn-interest.h"
30#include "ns3/ndn-content-object.h"
31
32namespace ns3 {
33namespace ndn {
34
35L3AggregateTracer::L3AggregateTracer (Ptr<Node> node)
36: L3Tracer (node)
37{
38 Reset ();
39}
40
41L3AggregateTracer::L3AggregateTracer (const std::string &node)
42: L3Tracer (node)
43{
44 Reset ();
45}
46
47L3AggregateTracer::~L3AggregateTracer ()
48{
49};
50
51void
52L3AggregateTracer::Reset ()
53{
54 m_packets.Reset ();
55 m_bytes.Reset ();
56}
57
58
59void
60L3AggregateTracer::PrintHeader (std::ostream &os) const
61{
62 os << "Node" << "\t"
63 << "InInterests" << "\t"
64 << "OutInterests" << "\t"
65 << "DropInterests" << "\t"
66
67 << "InNacks" << "\t"
68 << "OutNacks" << "\t"
69 << "DropNacks" << "\t"
70
71 << "InData" << "\t"
72 << "OutData" << "\t"
73 << "DropData" << "\t"
74
75 << "InInterestsBytes" << "\t"
76 << "OutInterestsBytes" << "\t"
77 << "DropInterestsBytes" << "\t"
78
79 << "InNacksBytes" << "\t"
80 << "OutNacksBytes" << "\t"
81 << "DropNacksBytes" << "\t"
82
83 << "InDataBytes" << "\t"
84 << "OutDataBytes" << "\t"
85 << "DropDataBytes";
86}
87
88void
89L3AggregateTracer::Print (std::ostream &os) const
90{
91 os << m_node << "\t"
92 << m_packets.m_inInterests << "\t"
93 << m_packets.m_outInterests << "\t"
94 << m_packets.m_dropInterests << "\t"
95
96 << m_packets.m_inNacks << "\t"
97 << m_packets.m_outNacks << "\t"
98 << m_packets.m_dropNacks << "\t"
99
100 << m_packets.m_inData << "\t"
101 << m_packets.m_outData << "\t"
102 << m_packets.m_dropData << "\t"
103
104 << m_bytes.m_inInterests << "\t"
105 << m_bytes.m_outInterests << "\t"
106 << m_bytes.m_dropInterests << "\t"
107
108 << m_bytes.m_inNacks << "\t"
109 << m_bytes.m_outNacks << "\t"
110 << m_bytes.m_dropNacks << "\t"
111
112 << m_bytes.m_inData << "\t"
113 << m_bytes.m_outData << "\t"
114 << m_bytes.m_dropData;
115}
116
117void
118L3AggregateTracer::OutInterests (std::string context,
119 Ptr<const InterestHeader> header, Ptr<const Face>)
120{
121 m_packets.m_outInterests++;
122 m_bytes.m_outInterests += header->GetSerializedSize ();
123}
124
125void
126L3AggregateTracer::InInterests (std::string context,
127 Ptr<const InterestHeader> header, Ptr<const Face>)
128{
129 m_packets.m_inInterests++;
130 m_bytes.m_inInterests += header->GetSerializedSize ();
131}
132
133void
134L3AggregateTracer::DropInterests (std::string context,
135 Ptr<const InterestHeader> header, Ptr<const Face>)
136{
137 m_packets.m_dropInterests++;
138 m_bytes.m_dropInterests += header->GetSerializedSize ();
139}
140
141void
142L3AggregateTracer::OutNacks (std::string context,
143 Ptr<const InterestHeader> header, Ptr<const Face>)
144{
145 m_packets.m_outNacks++;
146 m_bytes.m_outNacks += header->GetSerializedSize ();
147}
148
149void
150L3AggregateTracer::InNacks (std::string context,
151 Ptr<const InterestHeader> header, Ptr<const Face>)
152{
153 m_packets.m_inNacks++;
154 m_bytes.m_inNacks += header->GetSerializedSize ();
155}
156
157void
158L3AggregateTracer::DropNacks (std::string context,
159 Ptr<const InterestHeader> header, Ptr<const Face>)
160{
161 m_packets.m_dropNacks++;
162 m_bytes.m_dropNacks += header->GetSerializedSize ();
163}
164
165void
166L3AggregateTracer::OutData (std::string context,
167 Ptr<const ContentObjectHeader> header, Ptr<const Packet> payload,
168 bool fromCache, Ptr<const Face>)
169{
170 m_packets.m_outData++;
171 m_bytes.m_outData += header->GetSerializedSize () + payload->GetSize ();
172}
173
174void
175L3AggregateTracer::InData (std::string context,
176 Ptr<const ContentObjectHeader> header, Ptr<const Packet> payload,
177 Ptr<const Face>)
178{
179 m_packets.m_inData++;
180 m_bytes.m_inData += header->GetSerializedSize () + payload->GetSize ();
181}
182
183void
184L3AggregateTracer::DropData (std::string context,
185 Ptr<const ContentObjectHeader> header, Ptr<const Packet> payload,
186 Ptr<const Face>)
187{
188 m_packets.m_dropData++;
189 m_bytes.m_dropData += header->GetSerializedSize () + payload->GetSize ();
190}
191
192} // namespace ndn
193} // namespace ns3