blob: 74c0ef9bfd3fd4980298e74a3e95fafacb39aff5 [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-2012 University of California, Los Angeles
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#ifndef CCNX_L3_TRACER_H
22#define CCNX_L3_TRACER_H
23
24#include "ns3/ptr.h"
25#include "ns3/simple-ref-count.h"
26
27namespace ns3 {
28
29class Node;
30class Packet;
31
32namespace ndn {
33
34class InterestHeader;
35class Face;
36class ContentObjectHeader;
37
38class L3Tracer : public SimpleRefCount<L3Tracer>
39{
40public:
41 L3Tracer (Ptr<Node> node);
42 L3Tracer (const std::string &node);
43 virtual ~L3Tracer ();
44
45 void
46 Connect ();
47
48 virtual void
49 PrintHeader (std::ostream &os) const = 0;
50
51 virtual void
52 Print (std::ostream &os) const = 0;
53
54 virtual void
55 OutInterests (std::string context,
56 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
57
58 virtual void
59 InInterests (std::string context,
60 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
61
62 virtual void
63 DropInterests (std::string context,
64 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
65
66 virtual void
67 OutNacks (std::string context,
68 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
69
70 virtual void
71 InNacks (std::string context,
72 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
73
74 virtual void
75 DropNacks (std::string context,
76 Ptr<const InterestHeader>, Ptr<const Face>) = 0;
77
78
79 virtual void
80 OutData (std::string context,
81 Ptr<const ContentObjectHeader>, Ptr<const Packet>, bool fromCache, Ptr<const Face>) = 0;
82
83 virtual void
84 InData (std::string context,
85 Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>) = 0;
86
87 virtual void
88 DropData (std::string context,
89 Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>) = 0;
90
91protected:
92 std::string m_node;
93 Ptr<Node> m_nodePtr;
94
95 struct Stats
96 {
97 inline void Reset ()
98 {
99 m_inInterests = 0;
100 m_outInterests = 0;
101 m_dropInterests = 0;
102 m_inNacks = 0;
103 m_outNacks = 0;
104 m_dropNacks = 0;
105 m_inData = 0;
106 m_outData = 0;
107 m_dropData = 0;
108 }
109
110 double m_inInterests;
111 double m_outInterests;
112 double m_dropInterests;
113 double m_inNacks;
114 double m_outNacks;
115 double m_dropNacks;
116 double m_inData;
117 double m_outData;
118 double m_dropData;
119 };
120};
121
122inline std::ostream&
123operator << (std::ostream &os, const L3Tracer &tracer)
124{
125 os << "# ";
126 tracer.PrintHeader (os);
127 os << "\n";
128 tracer.Print (os);
129 return os;
130}
131
132} // namespace ndn
133} // namespace ns3
134
135#endif // CCNX_L3_TRACER_H