blob: 8d90f40a93de38f61a8636bacc8288516fbebb3e [file] [log] [blame]
Alexander Afanasyev68de7952012-12-12 18:02:29 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011-2012 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// custom-app.h
22
23#ifndef CUSTOM_APP_H_
24#define CUSTOM_APP_H_
25
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070026#include "ns3/ndnSIM/model/ndn-common.hpp"
27
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080028#include "ns3/ndnSIM/apps/ndn-app.hpp"
Alexander Afanasyev68de7952012-12-12 18:02:29 -080029
30namespace ns3 {
31
32/**
33 * @brief A simple custom application
34 *
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070035 * This applications demonstrates how to send Interests and respond with Datas to incoming interests
Alexander Afanasyev68de7952012-12-12 18:02:29 -080036 *
37 * When application starts it "sets interest filter" (install FIB entry) for /prefix/sub, as well as
38 * sends Interest for this prefix
39 *
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070040 * When an Interest is received, it is replied with a Data with 1024-byte fake payload
Alexander Afanasyev68de7952012-12-12 18:02:29 -080041 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042class CustomApp : public ndn::App {
Alexander Afanasyev68de7952012-12-12 18:02:29 -080043public:
44 // register NS-3 type "CustomApp"
45 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 GetTypeId();
47
Alexander Afanasyev68de7952012-12-12 18:02:29 -080048 // (overridden from ndn::App) Processing upon start of the application
49 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 StartApplication();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080051
52 // (overridden from ndn::App) Processing when application is stopped
53 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 StopApplication();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080055
56 // (overridden from ndn::App) Callback that will be called when Interest arrives
57 virtual void
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080058 OnInterest(shared_ptr<const ndn::Interest> interest);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080059
60 // (overridden from ndn::App) Callback that will be called when Data arrives
61 virtual void
Spyridon Mastorakisdb8280f2014-11-21 20:00:17 -080062 OnData(shared_ptr<const ndn::Data> contentObject);
Alexander Afanasyev68de7952012-12-12 18:02:29 -080063
64private:
65 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 SendInterest();
Alexander Afanasyev68de7952012-12-12 18:02:29 -080067};
68
69} // namespace ns3
70
71#endif // CUSTOM_APP_H_