blob: b7ce657f5294c057a02a04bd38650c28ea82deb9 [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.
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -07004 *
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.
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -07007 *
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.
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070011 *
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.
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070015 *
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 **/
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070019
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_PRODUCER_H
21#define NDN_PRODUCER_H
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
24
Alexander Afanasyev0c395372014-12-20 15:54:02 -080025#include "ndn-app.hpp"
Mickey Sweatt89046c12014-11-16 20:32:27 -080026#include "ns3/ndnSIM/model/ndn-common.hpp"
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080027
Mickey Sweatt89046c12014-11-16 20:32:27 -080028#include "ns3/nstime.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070029#include "ns3/ptr.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070030
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070031namespace ns3 {
32namespace ndn {
Ilya Moiseenkob62c7402011-10-28 13:02:18 -070033
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070034/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070035 * @ingroup ndn-apps
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070036 * @brief A simple Interest-sink applia simple Interest-sink application
37 *
38 * A simple Interest-sink applia simple Interest-sink application,
39 * which replying every incoming Interest with Data packet with a specified
40 * size and name same as in Interest.cation, which replying every incoming Interest
41 * with Data packet with a specified size and name same as in Interest.
42 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043class Producer : public App {
Alexander Afanasyeve7221482013-07-15 18:24:37 -070044public:
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080045 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046 GetTypeId(void);
Alexander Afanasyeve7221482013-07-15 18:24:37 -070047
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 Producer();
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080049
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070050 // inherited from NdnApp
Mickey Sweatt89046c12014-11-16 20:32:27 -080051 virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070052 OnInterest(shared_ptr<const Interest> interest);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080053
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080054protected:
55 // inherited from Application base class.
56 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 StartApplication(); // Called at time specified by Start
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080058
59 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 StopApplication(); // Called at time specified by Stop
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080061
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070062private:
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070063 Name m_prefix;
Alexander Afanasyev79606062013-07-11 00:57:28 -070064 Name m_postfix;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080065 uint32_t m_virtualPayloadSize;
Alexander Afanasyevc3cc0b32012-12-12 18:41:20 -080066 Time m_freshness;
Alexander Afanasyeve7221482013-07-15 18:24:37 -070067
68 uint32_t m_signature;
69 Name m_keyLocator;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070070};
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080071
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070072} // namespace ndn
73} // namespace ns3
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080074
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070075#endif // NDN_PRODUCER_H