blob: 01a5b72deec60000176d8164867a2379812592c6 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080019
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080020// dumb-requester.hpp
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080021
22#ifndef DUMB_REQUESTER_H_
23#define DUMB_REQUESTER_H_
24
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070025#include "ns3/ndnSIM/model/ndn-common.hpp"
26
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080027#include "ns3/ndnSIM/apps/ndn-app.hpp"
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080028
29namespace ns3 {
30
31/**
32 * @brief A dumb requester application
33 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034 * This app keeps requesting every second the same content object
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080035 */
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080036class OneInterestRequester : public ndn::App {
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080037public:
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080038 // register NS-3 type "OneInterestRequester"
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080039 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 GetTypeId();
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080041
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080042 OneInterestRequester();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080044 // (overridden from ndn::App) Processing upon start of the application
45 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 StartApplication();
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080047
48 // (overridden from ndn::App) Processing when application is stopped
49 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 StopApplication();
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080051
52 // (overridden from ndn::App) Callback that will be called when Data arrives
53 virtual void
Alexander Afanasyevafe47fe2015-01-06 18:29:39 -080054 OnData(std::shared_ptr<const ndn::Data> data);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080056private:
57 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058 SendInterest();
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080059
60private:
61 bool m_isRunning;
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070062 ndn::Name m_name;
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080063};
64
65} // namespace ns3
66
67#endif // DUMB_REQUESTER_H_