blob: a3dc05b33751cf7e93eb7b9518233af98d91b0f5 [file] [log] [blame]
Alexander Afanasyevc7597622013-02-28 10:58:52 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
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 "l2-tracer.h"
22#include "ns3/node.h"
23#include "ns3/config.h"
24#include "ns3/names.h"
25#include "ns3/callback.h"
26
27#include <boost/lexical_cast.hpp>
28
29using namespace std;
30
31namespace ns3 {
32
33L2Tracer::L2Tracer (Ptr<Node> node)
34: m_nodePtr (node)
35{
36 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
37
38 Connect ();
39
40 string name = Names::FindName (node);
41 if (!name.empty ())
42 {
43 m_node = name;
44 }
45}
46
47void
48L2Tracer::Connect ()
49{
50 Config::ConnectWithoutContext ("/NodeList/"+m_node+"/DeviceList/*/TxQueue/Drop",
51 MakeCallback (&L2Tracer::Drop, this));
52}
53
54} // namespace ns3