blob: 742961f42f19a3f82f56f7090e32d564308baffc [file] [log] [blame]
Alexander Afanasyev86287992012-12-10 16:11:50 -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-cs-tracer.h"
22#include "ns3/node.h"
23#include "ns3/packet.h"
24#include "ns3/config.h"
25#include "ns3/names.h"
26#include "ns3/callback.h"
27
28#include <boost/lexical_cast.hpp>
29
30#include "ns3/ndn-interest.h"
31#include "ns3/ndn-content-object.h"
32
33using namespace std;
34
35namespace ns3 {
36namespace ndn {
37
38CsTracer::CsTracer (Ptr<Node> node)
39: m_nodePtr (node)
40{
41 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
42
43 Connect ();
44
45 string name = Names::FindName (node);
46 if (!name.empty ())
47 {
48 m_node = name;
49 }
50}
51
52CsTracer::CsTracer (const std::string &node)
53: m_node (node)
54{
55 Connect ();
56}
57
58CsTracer::~CsTracer ()
59{
60};
61
62
63void
64CsTracer::Connect ()
65{
66 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ContentStore/CacheHits",
67 MakeCallback (&CsTracer::CacheHits, this));
68 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ContentStore/CacheMisses",
69 MakeCallback (&CsTracer::CacheMisses, this));
70}
71
72} // namespace ndn
73} // namespace ns3