blob: 126560bf0a50106a486fef8f618a6f91403b1581 [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 Afanasyev4aac5572012-08-09 10:49:55 -070048 // From NdnApp
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080049 // virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070050 // OnInterest (const shared_ptr<const Interest> &interest);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080051
52 // virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070053 // OnNack (const shared_ptr<const Interest> &interest);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080054
55 // virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070056 // OnData (const shared_ptr<const Data> &contentObject,
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080057 // const Ptr<const Packet> &payload);
58
59protected:
60 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
62 * protocol
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080063 */
64 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 ScheduleNextPacket();
Alexander Afanasyev59e67712012-02-07 11:49:34 -080066
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070067 /**
68 * @brief Set type of frequency randomization
69 * @param value Either 'none', 'uniform', or 'exponential'
70 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080071 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 SetRandomize(const std::string& value);
Alexander Afanasyev59e67712012-02-07 11:49:34 -080073
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070074 /**
75 * @brief Get type of frequency randomization
76 * @returns either 'none', 'uniform', or 'exponential'
77 */
Alexander Afanasyev59e67712012-02-07 11:49:34 -080078 std::string
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 GetRandomize() const;
80
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080081private:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080082 // void
83 // UpdateMean ();
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080084
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080085 // virtual void
86 // SetPayloadSize (uint32_t payload);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080087
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080088 // void
89 // SetDesiredRate (DataRate rate);
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080090
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080091 // DataRate
92 // GetDesiredRate () const;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093
Shock5a35ca82012-12-25 14:27:18 +080094protected:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 double m_frequency; // Frequency of interest packets (in hertz)
96 bool m_firstTime;
97 RandomVariable* m_random;
98 std::string m_randomType;
Alexander Afanasyev029d38d2012-01-09 13:50:50 -080099};
100
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101} // namespace ndn
Alexander Afanasyev029d38d2012-01-09 13:50:50 -0800102} // namespace ns3
103
104#endif