blob: 7d72ef38d21a4fde62921d59729f7e74a8c4bc05 [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
46
47 */
48//
49class ConsumerZipfMandelbrot: public ns3::ndn::ConsumerCbr {
50public:
51 static TypeId GetTypeId ();
52
53 /**
54 * \brief Default constructor
55 * Sets up randomized Number Generator (RNG)
56 * Note: m_seq of its parent class ConsumerCbr here is used to record the interest number
57 */
58 ConsumerZipfMandelbrot();
59 virtual ~ConsumerZipfMandelbrot();
60
61 virtual void SendPacket();
62 uint32_t GetNextSeq();
63
64protected:
65 virtual void
66 ScheduleNextPacket ();
67
68private:
69 uint32_t m_N; //number of the contents
70 double m_q; //q in (k+q)^s
71 double m_s; //s in (k+q)^s
72 double * m_Pcum; //cumulative probability
73
74 UniformVariable * m_SeqRng; //RNG
75
76
77
78};
79
80} /* namespace ndn */
81} /* namespace ns3 */
82#endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */