blob: cdf58a24ecc543885fce5d5199710f47576532ff [file] [log] [blame]
Shockb0f83152012-12-25 14:16:47 +08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08002/**
3 * Copyright (c) 2011-2015 Tsinghua University, P.R.China.
Shockb0f83152012-12-25 14:16:47 +08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Shockb0f83152012-12-25 14:16:47 +08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * 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.
Shockb0f83152012-12-25 14:16:47 +080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * 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.
Shockb0f83152012-12-25 14:16:47 +080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * 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 *
19 * @author Xiaoke Jiang <shock.jiang@gmail.com>
20 **/
Shockb0f83152012-12-25 14:16:47 +080021
Shockb0f83152012-12-25 14:16:47 +080022#ifndef NDN_CONSUMER_ZIPF_MANDELBROT_H_
23#define NDN_CONSUMER_ZIPF_MANDELBROT_H_
24
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"
Mickey Sweatt89046c12014-11-16 20:32:27 -080028#include "ndn-consumer-cbr.hpp"
29
Shockb0f83152012-12-25 14:16:47 +080030#include "ns3/ptr.h"
31#include "ns3/log.h"
32#include "ns3/simulator.h"
33#include "ns3/packet.h"
34#include "ns3/callback.h"
35#include "ns3/string.h"
36#include "ns3/uinteger.h"
37#include "ns3/double.h"
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -070038#include "ns3/random-variable-stream.h"
Shockb0f83152012-12-25 14:16:47 +080039
40namespace ns3 {
41namespace ndn {
42
43/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070044 * @ingroup ndn-apps
Shockb0f83152012-12-25 14:16:47 +080045 * @brief NDN app requesting contents following Zipf-Mandelbrot Distbituion
46 *
47 * The class implements an app which requests contents following Zipf-Mandelbrot Distribution
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 * Here is the explaination of Zipf-Mandelbrot Distribution:
49 *http://en.wikipedia.org/wiki/Zipf%E2%80%93Mandelbrot_law
Shockb0f83152012-12-25 14:16:47 +080050 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051class ConsumerZipfMandelbrot : public ConsumerCbr {
Shockb0f83152012-12-25 14:16:47 +080052public:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 static TypeId
54 GetTypeId();
Shockb0f83152012-12-25 14:16:47 +080055
56 /**
57 * \brief Default constructor
58 * Sets up randomized Number Generator (RNG)
59 * Note: m_seq of its parent class ConsumerCbr here is used to record the interest number
60 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 ConsumerZipfMandelbrot();
62 virtual ~ConsumerZipfMandelbrot();
Shockb0f83152012-12-25 14:16:47 +080063
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 virtual void
65 SendPacket();
Spyridon Mastorakis7f2fd422016-12-07 14:33:59 -080066
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 uint32_t
68 GetNextSeq();
Shockb0f83152012-12-25 14:16:47 +080069
70protected:
Alexander Afanasyev13800102012-12-25 00:30:31 -080071 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 ScheduleNextPacket();
Shockb0f83152012-12-25 14:16:47 +080073
74private:
Alexander Afanasyev13800102012-12-25 00:30:31 -080075 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076 SetNumberOfContents(uint32_t numOfContents);
Shockb0f83152012-12-25 14:16:47 +080077
Alexander Afanasyev13800102012-12-25 00:30:31 -080078 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 GetNumberOfContents() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080080
81 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 SetQ(double q);
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080083
84 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 GetQ() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080086
87 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 SetS(double s);
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080089
90 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 GetS() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080092
Alexander Afanasyev13800102012-12-25 00:30:31 -080093private:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 uint32_t m_N; // number of the contents
95 double m_q; // q in (k+q)^s
96 double m_s; // s in (k+q)^s
97 std::vector<double> m_Pcum; // cumulative probability
Shockb0f83152012-12-25 14:16:47 +080098
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -070099 Ptr<UniformRandomVariable> m_seqRng; // RNG
Shockb0f83152012-12-25 14:16:47 +0800100};
101
102} /* namespace ndn */
103} /* namespace ns3 */
104#endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */