blob: ac21cef09779b70bccf85e0f31280cce671d552b [file] [log] [blame]
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -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#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#include "ns3/ccnx.h"
27
28namespace ns3 {
29
30class Node;
31
32class CcnxL3Tracer : public SimpleRefCount<CcnxL3Tracer>
33{
34public:
35 CcnxL3Tracer (Ptr<Node> node);
36 CcnxL3Tracer (const std::string &node);
37 virtual ~CcnxL3Tracer () { };
38
39 void
40 Connect ();
41
42 virtual void
43 PrintHeader (std::ostream &os) const = 0;
44
45 virtual void
46 Print (std::ostream &os) const = 0;
47
48 virtual void
49 OutInterests (std::string context,
50 Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace>) = 0;
51
52 virtual void
53 InInterests (std::string context,
54 Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace>) = 0;
55
56 virtual void
57 DropInterests (std::string context,
58 Ptr<const CcnxInterestHeader>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
59
60 virtual void
61 OutNacks (std::string context,
62 Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace>) = 0;
63
64 virtual void
65 InNacks (std::string context,
66 Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace>) = 0;
67
68 virtual void
69 DropNacks (std::string context,
70 Ptr<const CcnxInterestHeader>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
71
72
73 virtual void
74 OutData (std::string context,
75 Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, bool fromCache, Ptr<const CcnxFace>) = 0;
76
77 virtual void
78 InData (std::string context,
79 Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, Ptr<const CcnxFace>) = 0;
80
81 virtual void
82 DropData (std::string context,
83 Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
84
85protected:
86 std::string m_node;
87 Ptr<Node> m_nodePtr;
88
89 struct Stats
90 {
91 void Reset ();
92
93 uint64_t m_inInterests;
94 uint64_t m_outInterests;
95 uint64_t m_dropInterests;
96 uint64_t m_inNacks;
97 uint64_t m_outNacks;
98 uint64_t m_dropNacks;
99 uint64_t m_inData;
100 uint64_t m_outData;
101 uint64_t m_dropData;
102 };
103};
104
105inline std::ostream&
106operator << (std::ostream &os, const CcnxL3Tracer &tracer)
107{
108 os << "# ";
109 tracer.PrintHeader (os);
110 os << "\n";
111 tracer.Print (os);
112 return os;
113}
114
115} // namespace ns3
116
117#endif // CCNX_L3_TRACER_H