blob: 455f684ba3f398d84400ef1be8762cf7ffca63a7 [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"
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070033#include "ns3/ndn-pit-entry.h"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080034
35using namespace std;
36
37namespace ns3 {
38namespace ndn {
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070039
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080040L3Tracer::L3Tracer (Ptr<Node> node)
41: m_nodePtr (node)
42{
43 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
44
45 Connect ();
46
47 string name = Names::FindName (node);
48 if (!name.empty ())
49 {
50 m_node = name;
51 }
52}
53
54L3Tracer::L3Tracer (const std::string &node)
55: m_node (node)
56{
57 Connect ();
58}
59
60L3Tracer::~L3Tracer ()
61{
62};
63
64
65void
66L3Tracer::Connect ()
67{
68 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutInterests",
69 MakeCallback (&L3Tracer::OutInterests, this));
70 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InInterests",
71 MakeCallback (&L3Tracer::InInterests, this));
72 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropInterests",
73 MakeCallback (&L3Tracer::DropInterests, this));
74
75 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutData",
76 MakeCallback (&L3Tracer::OutData, this));
77 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InData",
78 MakeCallback (&L3Tracer::InData, this));
79 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropData",
80 MakeCallback (&L3Tracer::DropData, this));
81
82 // only for some strategies
83 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/OutNacks",
84 MakeCallback (&L3Tracer::OutNacks, this));
85 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/InNacks",
86 MakeCallback (&L3Tracer::InNacks, this));
87 Config::Connect ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/DropNacks",
88 MakeCallback (&L3Tracer::DropNacks, this));
Alexander Afanasyev37b84c52013-04-26 13:38:52 -070089
90 // satisfied/timed out PIs
91 Config::ConnectWithoutContext ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/SatisfiedInterests",
92 MakeCallback (&L3Tracer::SatisfiedInterests, this));
93 Config::ConnectWithoutContext ("/NodeList/"+m_node+"/$ns3::ndn::ForwardingStrategy/TimedOutInterests",
94 MakeCallback (&L3Tracer::TimedOutInterests, this));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080095}
96
97} // namespace ndn
98} // namespace ns3