blob: 1ae1f4f7316d0aa37443d8d8e2afe2f6474821a3 [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
26#include "ns3/ndn-app.h"
27
28namespace ns3 {
29
30/**
31 * @brief A simple custom application
32 *
33 * This applications demonstrates how to send Interests and respond with ContentObjects to incoming interests
34 *
35 * When application starts it "sets interest filter" (install FIB entry) for /prefix/sub, as well as
36 * sends Interest for this prefix
37 *
38 * When an Interest is received, it is replied with a ContentObject with 1024-byte fake payload
39 */
40class CustomApp : public ndn::App
41{
42public:
43 // register NS-3 type "CustomApp"
44 static TypeId
45 GetTypeId ();
46
47 // (overridden from ndn::App) Processing upon start of the application
48 virtual void
49 StartApplication ();
50
51 // (overridden from ndn::App) Processing when application is stopped
52 virtual void
53 StopApplication ();
54
55 // (overridden from ndn::App) Callback that will be called when Interest arrives
56 virtual void
57 OnInterest (const Ptr<const ndn::InterestHeader> &interest, Ptr<Packet> origPacket);
58
59 // (overridden from ndn::App) Callback that will be called when Data arrives
60 virtual void
61 OnContentObject (const Ptr<const ndn::ContentObjectHeader> &contentObject,
62 Ptr<Packet> payload);
63
64private:
65 void
66 SendInterest ();
67};
68
69} // namespace ns3
70
71#endif // CUSTOM_APP_H_