blob: 71113b2f41aa26395a59e27b1946c010dc5ae8b0 [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;
73
74private:
75 uint32_t m_N; //number of the contents
76 double m_q; //q in (k+q)^s
77 double m_s; //s in (k+q)^s
78 std::vector<double> m_Pcum; //cumulative probability
Shockb0f83152012-12-25 14:16:47 +080079
Alexander Afanasyev13800102012-12-25 00:30:31 -080080 UniformVariable m_SeqRng; //RNG
Shockb0f83152012-12-25 14:16:47 +080081};
82
83} /* namespace ndn */
84} /* namespace ns3 */
85#endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */