blob: c7a433c0f01c534dab744cddb70ea97413de57d7 [file] [log] [blame]
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 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_APP_DELAY_TRACER_H
22#define CCNX_APP_DELAY_TRACER_H
23
24#include "ns3/ptr.h"
25#include "ns3/simple-ref-count.h"
26#include <ns3/nstime.h>
27#include <ns3/event-id.h>
28
29#include <boost/tuple/tuple.hpp>
30#include <boost/shared_ptr.hpp>
31#include <list>
32
33namespace ns3 {
34
35class Node;
36class Packet;
37
38namespace ndn {
39
40class App;
41
42/**
43 * @ingroup ndn
44 * @brief network-layer tracer for aggregate packet counts
45 */
46class AppDelayTracer : public SimpleRefCount<AppDelayTracer>
47{
48public:
49 /**
50 * @brief Helper method to install tracers on all simulation nodes
51 *
52 * @param file File to which traces will be written
53 * @param averagingPeriod How often data will be written into the trace file (default, every half second)
54 *
55 * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
56 * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
57 *
58 */
59 static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<AppDelayTracer> > >
60 InstallAll (const std::string &file);
61
62 /**
63 * @brief Trace constructor that attaches to all applications on the node using node's pointer
64 * @param os reference to the output stream
65 * @param node pointer to the node
66 */
67 AppDelayTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
68
69 /**
70 * @brief Trace constructor that attaches to all applications on the node using node's name
71 * @param os reference to the output stream
72 * @param nodeName name of the node registered using Names::Add
73 */
74 AppDelayTracer (boost::shared_ptr<std::ostream> os, const std::string &node);
75
76 /**
77 * @brief Destructor
78 */
79 ~AppDelayTracer ();
80
81 /**
82 * @brief Print head of the trace (e.g., for post-processing)
83 *
84 * @param os reference to output stream
85 */
86 void
87 PrintHeader (std::ostream &os) const;
88
89private:
90 void
91 Connect ();
92
93 void
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080094 LastRetransmittedInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080095
96 void
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080097 FirstInterestDataDelay (Ptr<App> app, uint32_t seqno, Time delay, uint32_t rextCount, int32_t hopCount);
Alexander Afanasyevdb64ff12013-01-18 16:37:31 -080098
99private:
100 std::string m_node;
101 Ptr<Node> m_nodePtr;
102
103 boost::shared_ptr<std::ostream> m_os;
104};
105
106} // namespace ndn
107} // namespace ns3
108
109#endif // CCNX_CS_TRACER_H