Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 22 | #ifndef NDN_CONSUMER_CBR_H |
| 23 | #define NDN_CONSUMER_CBR_H |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 24 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 26 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 27 | #include "ndn-consumer.hpp" |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 28 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 29 | namespace ns3 { |
| 30 | namespace ndn { |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 31 | |
| 32 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 33 | * @ingroup ndn-apps |
| 34 | * @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] | 35 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 36 | class ConsumerCbr : public Consumer { |
| 37 | public: |
| 38 | static TypeId |
| 39 | GetTypeId(); |
| 40 | |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 41 | /** |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 42 | * \brief Default constructor |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 43 | * Sets up randomizer function and packet sequence number |
| 44 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 45 | ConsumerCbr(); |
| 46 | virtual ~ConsumerCbr(); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 47 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 48 | // From NdnApp |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 49 | // virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 50 | // OnInterest (const shared_ptr<const Interest> &interest); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 51 | |
| 52 | // virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 53 | // OnNack (const shared_ptr<const Interest> &interest); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 54 | |
| 55 | // virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 56 | // OnData (const shared_ptr<const Data> &contentObject, |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 57 | // const Ptr<const Packet> &payload); |
| 58 | |
| 59 | protected: |
| 60 | /** |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN |
| 62 | * protocol |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 63 | */ |
| 64 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | ScheduleNextPacket(); |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 66 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 67 | /** |
| 68 | * @brief Set type of frequency randomization |
| 69 | * @param value Either 'none', 'uniform', or 'exponential' |
| 70 | */ |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 71 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 72 | SetRandomize(const std::string& value); |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 73 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 74 | /** |
| 75 | * @brief Get type of frequency randomization |
| 76 | * @returns either 'none', 'uniform', or 'exponential' |
| 77 | */ |
Alexander Afanasyev | 59e6771 | 2012-02-07 11:49:34 -0800 | [diff] [blame] | 78 | std::string |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 79 | GetRandomize() const; |
| 80 | |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 81 | private: |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 82 | // void |
| 83 | // UpdateMean (); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 84 | |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 85 | // virtual void |
| 86 | // SetPayloadSize (uint32_t payload); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 87 | |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 88 | // void |
| 89 | // SetDesiredRate (DataRate rate); |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 90 | |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 91 | // DataRate |
| 92 | // GetDesiredRate () const; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 93 | |
Shock | 5a35ca8 | 2012-12-25 14:27:18 +0800 | [diff] [blame] | 94 | protected: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 95 | double m_frequency; // Frequency of interest packets (in hertz) |
| 96 | bool m_firstTime; |
| 97 | RandomVariable* m_random; |
| 98 | std::string m_randomType; |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 101 | } // namespace ndn |
Alexander Afanasyev | 029d38d | 2012-01-09 13:50:50 -0800 | [diff] [blame] | 102 | } // namespace ns3 |
| 103 | |
| 104 | #endif |