blob: 3df6a27341d342c869c2c8b4d8c258ebfe09703e [file] [log] [blame]
Alexander Afanasyev79a5bd62013-06-23 22:12:39 -07001/* -*- 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 "ndn-api-app.h"
22
23NS_LOG_COMPONENT_DEFINE ("ndn.ApiApp");
24
25namespace ns3 {
26namespace ndn {
27
28// Necessary if you are planning to use ndn::AppHelper
29NS_OBJECT_ENSURE_REGISTERED (ApiApp);
30
31TypeId
32ApiApp::GetTypeId ()
33{
34 static TypeId tid = TypeId ("ns3::ndn::ApiApp")
35 .SetParent<Application> ()
36 .AddConstructor<ApiApp> ()
37 ;
38
39 return tid;
40}
41
42ApiApp::ApiApp ()
43{
44 m_handler = CreateObject<Handler> ();
45}
46
47void
48ApiApp::RequestData ()
49{
50 m_handler->sendInterest ("/test/prefix", boost::bind (&ApiApp::OnData
51}
52
53void
54ApiApp::StartApplication ()
55{
56 m_handler->SetNode (GetNode ());
57 m_handler->StartApplication ();
58
59 Simulator::Schedule (Seconds (1), &::ns3::ndn::ApiApp::RequestData, this);
60}
61
62void
63ApiApp::StopApplication ()
64{
65 m_handler->StopApplication ();
66}
67
68} // namespace ndn
69} // namespace ns3
70