blob: d0cd4f11b123ca57580b8b9be0a71e93a4d31f8e [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"
Shockb0f83152012-12-25 14:16:47 +080038#include "ns3/random-variable.h"
39
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();
66 uint32_t
67 GetNextSeq();
Shockb0f83152012-12-25 14:16:47 +080068
69protected:
Alexander Afanasyev13800102012-12-25 00:30:31 -080070 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 ScheduleNextPacket();
Shockb0f83152012-12-25 14:16:47 +080072
73private:
Alexander Afanasyev13800102012-12-25 00:30:31 -080074 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 SetNumberOfContents(uint32_t numOfContents);
Shockb0f83152012-12-25 14:16:47 +080076
Alexander Afanasyev13800102012-12-25 00:30:31 -080077 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 GetNumberOfContents() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080079
80 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 SetQ(double q);
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080082
83 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 GetQ() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080085
86 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 SetS(double s);
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080088
89 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 GetS() const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080091
Alexander Afanasyev13800102012-12-25 00:30:31 -080092private:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 uint32_t m_N; // number of the contents
94 double m_q; // q in (k+q)^s
95 double m_s; // s in (k+q)^s
96 std::vector<double> m_Pcum; // cumulative probability
Shockb0f83152012-12-25 14:16:47 +080097
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 UniformVariable m_SeqRng; // RNG
Shockb0f83152012-12-25 14:16:47 +080099};
100
101} /* namespace ndn */
102} /* namespace ns3 */
103#endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */