blob: a2bbbdd0eed7e15f3fd11230f87e78dc36115e7d [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#include "ccnx-app-tracer.h"
22#include "ns3/node.h"
23#include "ns3/packet.h"
24#include "ns3/config.h"
25#include "ns3/callback.h"
26#include "ns3/names.h"
27
28#include "ns3/ccnx-app.h"
29#include "ns3/ccnx-face.h"
30
31#include <boost/lexical_cast.hpp>
32
33#include "ns3/ccnx-interest-header.h"
34#include "ns3/ccnx-content-object-header.h"
35
36using namespace std;
37using namespace boost;
38
39namespace ns3 {
40
41CcnxAppTracer::CcnxAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId)
42 : m_app (app)
43 , m_appId (appId)
44 , m_nodePtr (node)
45{
46 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
47
48 Connect ();
49
50 string name = Names::FindName (node);
51 if (!name.empty ())
52 {
53 m_node = name;
54 }
55}
56
57CcnxAppTracer::CcnxAppTracer (const std::string &app, const std::string &node, const std::string &appId)
58 : m_app (app)
59 , m_appId (appId)
60 , m_node (node)
61{
62 Connect ();
63}
64
65void
66CcnxAppTracer::Connect ()
67{
68 Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedInterests",
69 MakeCallback (&CcnxAppTracer::OutInterests, this));
70
71 Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedNacks",
72 MakeCallback (&CcnxAppTracer::InNacks, this));
73
74 Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedInterests",
75 MakeCallback (&CcnxAppTracer::InInterests, this));
76
77 Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedContentObjects",
78 MakeCallback (&CcnxAppTracer::OutData, this));
79
80 Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedContentObjects",
81 MakeCallback (&CcnxAppTracer::InData, this));
82}
83
84} // namespace ns3