Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * 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 Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * 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 Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * 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 Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 20 | #ifndef NDN_CONSUMER_CBR_H |
| 21 | #define NDN_CONSUMER_CBR_H |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 22 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 24 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 25 | #include "ndn-consumer.hpp" |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 27 | namespace ns3 { |
| 28 | namespace ndn { |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 29 | |
| 30 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 31 | * @ingroup ndn-apps |
| 32 | * @brief Ndn application for sending out Interest packets at a "constant" rate (Poisson process) |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 33 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 34 | class ConsumerCbr : public Consumer { |
| 35 | public: |
| 36 | static TypeId |
| 37 | GetTypeId(); |
| 38 | |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 39 | /** |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 40 | * \brief Default constructor |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 41 | * Sets up randomizer function and packet sequence number |
| 42 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 43 | ConsumerCbr(); |
| 44 | virtual ~ConsumerCbr(); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 45 | |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 46 | protected: |
| 47 | /** |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 48 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN |
| 49 | * protocol |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 50 | */ |
| 51 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 52 | ScheduleNextPacket(); |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 54 | /** |
| 55 | * @brief Set type of frequency randomization |
| 56 | * @param value Either 'none', 'uniform', or 'exponential' |
| 57 | */ |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 58 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 59 | SetRandomize(const std::string& value); |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 60 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 61 | /** |
| 62 | * @brief Get type of frequency randomization |
| 63 | * @returns either 'none', 'uniform', or 'exponential' |
| 64 | */ |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 65 | std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | GetRandomize() const; |
| 67 | |
Shock | 5a35ca8 | 2012-12-25 14:27:18 +0800 | [diff] [blame] | 68 | protected: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | double m_frequency; // Frequency of interest packets (in hertz) |
| 70 | bool m_firstTime; |
Alexander Afanasyev | d6453cd | 2015-08-20 21:45:36 -0700 | [diff] [blame^] | 71 | Ptr<RandomVariableStream> m_random; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | std::string m_randomType; |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 75 | } // namespace ndn |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 76 | } // namespace ns3 |
| 77 | |
| 78 | #endif |