blob: b9f4d178c514ca8f2a634637955b79e63fa6e295 [file] [log] [blame]
Shockb0f83152012-12-25 14:16:47 +08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2012 Tsinghua University, P.R.China
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: Xiaoke Jiang <shock.jiang@gmail.com>
19 */
20
21
22#ifndef NDN_CONSUMER_ZIPF_MANDELBROT_H_
23#define NDN_CONSUMER_ZIPF_MANDELBROT_H_
24
25#include "ndn-consumer.h"
26#include "ns3/ptr.h"
27#include "ns3/log.h"
28#include "ns3/simulator.h"
29#include "ns3/packet.h"
30#include "ns3/callback.h"
31#include "ns3/string.h"
32#include "ns3/uinteger.h"
33#include "ns3/double.h"
34#include "ndn-consumer-cbr.h"
35#include "ns3/random-variable.h"
36
37namespace ns3 {
38namespace ndn {
39
40/**
41 * @ingroup ndn
42 * @brief NDN app requesting contents following Zipf-Mandelbrot Distbituion
43 *
44 * The class implements an app which requests contents following Zipf-Mandelbrot Distribution
45 * Here is the explaination of Zipf-Mandelbrot Distribution: http://en.wikipedia.org/wiki/Zipf%E2%80%93Mandelbrot_law
Shockb0f83152012-12-25 14:16:47 +080046 */
Alexander Afanasyev13800102012-12-25 00:30:31 -080047class ConsumerZipfMandelbrot: public ConsumerCbr
48{
Shockb0f83152012-12-25 14:16:47 +080049public:
Alexander Afanasyev13800102012-12-25 00:30:31 -080050 static TypeId GetTypeId ();
Shockb0f83152012-12-25 14:16:47 +080051
52 /**
53 * \brief Default constructor
54 * Sets up randomized Number Generator (RNG)
55 * Note: m_seq of its parent class ConsumerCbr here is used to record the interest number
56 */
Alexander Afanasyev13800102012-12-25 00:30:31 -080057 ConsumerZipfMandelbrot ();
58 virtual ~ConsumerZipfMandelbrot ();
Shockb0f83152012-12-25 14:16:47 +080059
Alexander Afanasyev13800102012-12-25 00:30:31 -080060 virtual void SendPacket();
61 uint32_t GetNextSeq();
Shockb0f83152012-12-25 14:16:47 +080062
63protected:
Alexander Afanasyev13800102012-12-25 00:30:31 -080064 virtual void
65 ScheduleNextPacket ();
Shockb0f83152012-12-25 14:16:47 +080066
67private:
Alexander Afanasyev13800102012-12-25 00:30:31 -080068 void
69 SetNumberOfContents (uint32_t numOfContents);
Shockb0f83152012-12-25 14:16:47 +080070
Alexander Afanasyev13800102012-12-25 00:30:31 -080071 uint32_t
72 GetNumberOfContents () const;
Saran Tarnoi5cd9a152013-02-15 15:59:15 -080073
74 void
75 SetQ (double q);
76
77 double
78 GetQ () const;
79
80 void
81 SetS (double s);
82
83 double
84 GetS () const;
85
Alexander Afanasyev13800102012-12-25 00:30:31 -080086private:
87 uint32_t m_N; //number of the contents
88 double m_q; //q in (k+q)^s
89 double m_s; //s in (k+q)^s
90 std::vector<double> m_Pcum; //cumulative probability
Shockb0f83152012-12-25 14:16:47 +080091
Alexander Afanasyev13800102012-12-25 00:30:31 -080092 UniformVariable m_SeqRng; //RNG
Shockb0f83152012-12-25 14:16:47 +080093};
94
95} /* namespace ndn */
96} /* namespace ns3 */
97#endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */