blob: e5f29965b3f141421d5acf94d2de2406428ffb41 [file] [log] [blame]
Alexander Afanasyev029d38d2012-01-09 13:50:50 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 */
21
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070022#ifndef NDN_CONSUMER_CBR_H
23#define NDN_CONSUMER_CBR_H
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080024
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070025#include "ns3/ndnSIM/model/ndn-common.hpp"
26
Alexander Afanasyev0c395372014-12-20 15:54:02 -080027#include "ndn-consumer.hpp"
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080028
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070029namespace ns3 {
30namespace ndn {
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080031
32/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070033 * @ingroup ndn-apps
34 * @brief Ndn application for sending out Interest packets at a "constant" rate (Poisson process)
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080035 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080036class ConsumerCbr : public Consumer {
37public:
38 static TypeId
39 GetTypeId();
40
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080041 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042 * \brief Default constructor
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080043 * Sets up randomizer function and packet sequence number
44 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 ConsumerCbr();
46 virtual ~ConsumerCbr();
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080047
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080048protected:
49 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
51 * protocol
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080052 */
53 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 ScheduleNextPacket();
Alexander Afanasyev59e67712012-02-07 11:49:34 -080055
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070056 /**
57 * @brief Set type of frequency randomization
58 * @param value Either 'none', 'uniform', or 'exponential'
59 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080060 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 SetRandomize(const std::string& value);
Alexander Afanasyev59e67712012-02-07 11:49:34 -080062
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070063 /**
64 * @brief Get type of frequency randomization
65 * @returns either 'none', 'uniform', or 'exponential'
66 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080067 std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080068 GetRandomize() const;
69
Shock5a35ca82012-12-25 14:27:18 +080070protected:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 double m_frequency; // Frequency of interest packets (in hertz)
72 bool m_firstTime;
73 RandomVariable* m_random;
74 std::string m_randomType;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080075};
76
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070077} // namespace ndn
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080078} // namespace ns3
79
80#endif