blob: 415105bd047bbc1498fc815f10b6901665d4e389 [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-l3-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#include "ns3/ccnx-app.h"
28#include "ns3/ccnx-face.h"
29
30#include <boost/lexical_cast.hpp>
31
32#include "ns3/ccnx-interest-header.h"
33#include "ns3/ccnx-content-object-header.h"
34
35using namespace std;
36
37namespace ns3 {
38
39CcnxL3Tracer::CcnxL3Tracer (Ptr<Node> node)
40: m_nodePtr (node)
41{
42 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
43
44 Connect ();
45
46 string name = Names::FindName (node);
47 if (!name.empty ())
48 {
49 m_node = name;
50 }
51}
52
53CcnxL3Tracer::CcnxL3Tracer (const std::string &node)
54: m_node (node)
55{
56 Connect ();
57}
58
59void
60CcnxL3Tracer::Connect ()
61{
62 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/ForwardingStrategy/OutInterests",
63 MakeCallback (&CcnxL3Tracer::OutInterests, this));
64 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InInterests",
65 MakeCallback (&CcnxL3Tracer::InInterests, this));
66 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropInterests",
67 MakeCallback (&CcnxL3Tracer::DropInterests, this));
68
69 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutNacks",
70 MakeCallback (&CcnxL3Tracer::OutNacks, this));
71 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InNacks",
72 MakeCallback (&CcnxL3Tracer::InNacks, this));
73 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropNacks",
74 MakeCallback (&CcnxL3Tracer::DropNacks, this));
75
76 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutData",
77 MakeCallback (&CcnxL3Tracer::OutData, this));
78 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InData",
79 MakeCallback (&CcnxL3Tracer::InData, this));
80 Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropData",
81 MakeCallback (&CcnxL3Tracer::DropData, this));
82}
83
84} // namespace ns3