blob: ebe015f619d253a5301da58a99ef1460a33f30c0 [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
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 Afanasyev2b4c9472012-08-09 15:00:38 -070034class ConsumerCbr: public Consumer
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080035{
36public:
37 static TypeId GetTypeId ();
38
39 /**
40 * \brief Default constructor
41 * Sets up randomizer function and packet sequence number
42 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070043 ConsumerCbr ();
44 virtual ~ConsumerCbr ();
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080045
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070046 // From NdnApp
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080047 // virtual void
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070048 // OnInterest (const Ptr<const Interest> &interest);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080049
50 // virtual void
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070051 // OnNack (const Ptr<const Interest> &interest);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080052
53 // virtual void
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070054 // OnData (const Ptr<const Data> &contentObject,
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080055 // const Ptr<const Packet> &payload);
56
57protected:
58 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080060 */
61 virtual void
62 ScheduleNextPacket ();
Alexander Afanasyev59e67712012-02-07 11:49:34 -080063
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070064 /**
65 * @brief Set type of frequency randomization
66 * @param value Either 'none', 'uniform', or 'exponential'
67 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080068 void
69 SetRandomize (const std::string &value);
70
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070071 /**
72 * @brief Get type of frequency randomization
73 * @returns either 'none', 'uniform', or 'exponential'
74 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080075 std::string
76 GetRandomize () const;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080077
78private:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080079 // void
80 // UpdateMean ();
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080081
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080082 // virtual void
83 // SetPayloadSize (uint32_t payload);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080084
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080085 // void
86 // SetDesiredRate (DataRate rate);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080087
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080088 // DataRate
89 // GetDesiredRate () const;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080090
Shock5a35ca82012-12-25 14:27:18 +080091protected:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080092 double m_frequency; // Frequency of interest packets (in hertz)
Alexander Afanasyev59e67712012-02-07 11:49:34 -080093 bool m_firstTime;
94 RandomVariable *m_random;
95 std::string m_randomType;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080096};
97
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070098} // namespace ndn
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080099} // namespace ns3
100
101#endif