blob: 847de2ada9deea8088f0c9dc54c5bd22736f4cfe [file] [log] [blame]
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -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-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
28#include <boost/lexical_cast.hpp>
29
30#include "ns3/ndn-face.h"
31#include "ns3/ndn-interest.h"
32#include "ns3/ndn-content-object.h"
33
34using namespace std;
35
36namespace ns3 {
37namespace ndn {
38
39L3Tracer::L3Tracer (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
53L3Tracer::L3Tracer (const std::string &node)
54: m_node (node)
55{
56 Connect ();
57}
58
59L3Tracer::~L3Tracer ()
60{
61};
62
63
64void
65L3Tracer::Connect ()
66{
67 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutInterests",
68 MakeCallback (&L3Tracer::OutInterests, this));
69 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InInterests",
70 MakeCallback (&L3Tracer::InInterests, this));
71 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropInterests",
72 MakeCallback (&L3Tracer::DropInterests, this));
73
74 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutData",
75 MakeCallback (&L3Tracer::OutData, this));
76 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InData",
77 MakeCallback (&L3Tracer::InData, this));
78 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropData",
79 MakeCallback (&L3Tracer::DropData, this));
80
81 // only for some strategies
82 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutNacks",
83 MakeCallback (&L3Tracer::OutNacks, this));
84 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InNacks",
85 MakeCallback (&L3Tracer::InNacks, this));
86 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropNacks",
87 MakeCallback (&L3Tracer::DropNacks, this));
88}
89
90} // namespace ndn
91} // namespace ns3