blob: 57fb612a214f7ff78bbf52d3a9c22788103629c1 [file] [log] [blame]
Alexander Afanasyevc4f88282012-01-03 11:27:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 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 "ipv4-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 <boost/lexical_cast.hpp>
29
30using namespace std;
31using namespace boost;
32
33namespace ns3 {
34
35Ipv4AppTracer::Ipv4AppTracer (Ptr<Node> node, const std::string &appId)
36 : m_appId (appId)
37 , m_nodePtr (node)
38{
39 m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
40
41 Connect ();
42
43 string name = Names::FindName (node);
44 if (!name.empty ())
45 {
46 m_node = name;
47 }
48}
49
50void
51Ipv4AppTracer::Connect ()
52{
53 Config::Connect ("/NodeList/"+m_node+"/$ns3::Ipv4L3Protocol/SendOutgoing",
54 MakeCallback (&Ipv4AppTracer::Tx, this));
55
56 Config::Connect ("/NodeList/"+m_node+"/$ns3::Ipv4L3Protocol/LocalDeliver",
57 MakeCallback (&Ipv4AppTracer::Rx, this));
58
59 // Config::Connect ("/NodeList/"+m_node+"/$ns3::Ipv4L3Protocol/Tx",
60 // MakeCallback (&Ipv4AppTracer::Rx, this));
61
62 // Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$ns3::PacketSink/Rx",
63 // MakeCallback (&Ipv4AppTracer::InData, this));
64
65 // Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$ns3::BulkSendApplication/Tx",
66 // MakeCallback (&Ipv4AppTracer::OutData, this));
67}
68
69
70} // namespace ns3