blob: 6e8f6c12438e2aa1e58efdc85454cd60397a1c76 [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 Afanasyev029d38d2012-01-09 13:50:50 -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 Afanasyev029d38d2012-01-09 13:50:50 -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 Afanasyev029d38d2012-01-09 13:50:50 -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 Afanasyev029d38d2012-01-09 13:50:50 -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 Afanasyev029d38d2012-01-09 13:50:50 -080019
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_CONSUMER_CBR_H
21#define NDN_CONSUMER_CBR_H
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080022
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-consumer.hpp"
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080026
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070027namespace ns3 {
28namespace ndn {
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080029
30/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070031 * @ingroup ndn-apps
32 * @brief Ndn application for sending out Interest packets at a "constant" rate (Poisson process)
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080033 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034class ConsumerCbr : public Consumer {
35public:
36 static TypeId
37 GetTypeId();
38
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080039 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 * \brief Default constructor
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080041 * Sets up randomizer function and packet sequence number
42 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 ConsumerCbr();
44 virtual ~ConsumerCbr();
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080045
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080046protected:
47 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
49 * protocol
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080050 */
51 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080052 ScheduleNextPacket();
Alexander Afanasyev59e67712012-02-07 11:49:34 -080053
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070054 /**
55 * @brief Set type of frequency randomization
56 * @param value Either 'none', 'uniform', or 'exponential'
57 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080058 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 SetRandomize(const std::string& value);
Alexander Afanasyev59e67712012-02-07 11:49:34 -080060
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070061 /**
62 * @brief Get type of frequency randomization
63 * @returns either 'none', 'uniform', or 'exponential'
64 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080065 std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 GetRandomize() const;
67
Shock5a35ca82012-12-25 14:27:18 +080068protected:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 double m_frequency; // Frequency of interest packets (in hertz)
70 bool m_firstTime;
71 RandomVariable* m_random;
72 std::string m_randomType;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080073};
74
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070075} // namespace ndn
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080076} // namespace ns3
77
78#endif