NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ndn-consumer-cbr.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20
#include "
ndn-consumer-cbr.hpp
"
21
#include "ns3/ptr.h"
22
#include "ns3/log.h"
23
#include "ns3/simulator.h"
24
#include "ns3/packet.h"
25
#include "ns3/callback.h"
26
#include "ns3/string.h"
27
#include "ns3/boolean.h"
28
#include "ns3/uinteger.h"
29
#include "ns3/integer.h"
30
#include "ns3/double.h"
31
32
#include "
model/ndn-app-face.hpp
"
33
34
NS_LOG_COMPONENT_DEFINE(
"ndn.ConsumerCbr"
);
35
36
namespace
ns3
{
37
namespace
ndn
{
38
39
NS_OBJECT_ENSURE_REGISTERED
(
ConsumerCbr
);
40
41
TypeId
42
ConsumerCbr::GetTypeId
(
void
)
43
{
44
static
TypeId tid =
45
TypeId(
"ns3::ndn::ConsumerCbr"
)
46
.SetGroupName(
"Ndn"
)
47
.SetParent<
Consumer
>()
48
.AddConstructor<ConsumerCbr>()
49
50
.AddAttribute(
"Frequency"
,
"Frequency of interest packets"
, StringValue(
"1.0"
),
51
MakeDoubleAccessor(&
ConsumerCbr::m_frequency
), MakeDoubleChecker<double>())
52
53
.AddAttribute(
"Randomize"
,
54
"Type of send time randomization: none (default), uniform, exponential"
,
55
StringValue(
"none"
),
56
MakeStringAccessor(&
ConsumerCbr::SetRandomize
, &
ConsumerCbr::GetRandomize
),
57
MakeStringChecker())
58
59
.AddAttribute(
"MaxSeq"
,
"Maximum sequence number to request"
,
60
IntegerValue(std::numeric_limits<uint32_t>::max()),
61
MakeIntegerAccessor(&
ConsumerCbr::m_seqMax
), MakeIntegerChecker<uint32_t>())
62
63
;
64
65
return
tid;
66
}
67
68
ConsumerCbr::ConsumerCbr
()
69
:
m_frequency
(1.0)
70
,
m_firstTime
(true)
71
{
72
NS_LOG_FUNCTION_NOARGS();
73
m_seqMax
= std::numeric_limits<uint32_t>::max();
74
}
75
76
ConsumerCbr::~ConsumerCbr
()
77
{
78
}
79
80
void
81
ConsumerCbr::ScheduleNextPacket
()
82
{
83
// double mean = 8.0 * m_payloadSize / m_desiredRate.GetBitRate ();
84
// std::cout << "next: " << Simulator::Now().ToDouble(Time::S) + mean << "s\n";
85
86
if
(
m_firstTime
) {
87
m_sendEvent
= Simulator::Schedule(Seconds(0.0), &
Consumer::SendPacket
,
this
);
88
m_firstTime
=
false
;
89
}
90
else
if
(!
m_sendEvent
.IsRunning())
91
m_sendEvent
= Simulator::Schedule((
m_random
== 0) ? Seconds(1.0 /
m_frequency
)
92
: Seconds(
m_random
->GetValue()),
93
&
Consumer::SendPacket
,
this
);
94
}
95
96
void
97
ConsumerCbr::SetRandomize
(
const
std::string& value)
98
{
99
if
(value ==
"uniform"
) {
100
m_random
= CreateObject<UniformRandomVariable>();
101
m_random
->SetAttribute(
"Min"
, DoubleValue(0.0));
102
m_random
->SetAttribute(
"Max"
, DoubleValue(2 * 1.0 /
m_frequency
));
103
}
104
else
if
(value ==
"exponential"
) {
105
m_random
= CreateObject<ExponentialRandomVariable>();
106
m_random
->SetAttribute(
"Mean"
, DoubleValue(1.0 /
m_frequency
));
107
m_random
->SetAttribute(
"Bound"
, DoubleValue(50 * 1.0 /
m_frequency
));
108
}
109
else
110
m_random
= 0;
111
112
m_randomType
= value;
113
}
114
115
std::string
116
ConsumerCbr::GetRandomize
()
const
117
{
118
return
m_randomType
;
119
}
120
121
}
// namespace ndn
122
}
// namespace ns3
ConsumerCbr
ndn ConsumerCbr
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-consumer-cbr.cpp:34
ns3::ndn::Consumer::m_seqMax
uint32_t m_seqMax
maximum number of sequence number
Definition:
ndn-consumer.hpp:135
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ns3::ndn::ConsumerCbr::m_random
Ptr< RandomVariableStream > m_random
Definition:
ndn-consumer-cbr.hpp:71
ns3::ndn::ConsumerCbr::m_firstTime
bool m_firstTime
Definition:
ndn-consumer-cbr.hpp:70
ns3::ndn::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(ContentStore)
ns3::ndn::ConsumerCbr::GetTypeId
static TypeId GetTypeId()
Definition:
ndn-consumer-cbr.cpp:42
ns3::ndn::ConsumerCbr::~ConsumerCbr
virtual ~ConsumerCbr()
Definition:
ndn-consumer-cbr.cpp:76
ns3::ndn::ConsumerCbr::m_frequency
double m_frequency
Definition:
ndn-consumer-cbr.hpp:69
ns3::ndn::ConsumerCbr::GetRandomize
std::string GetRandomize() const
Get type of frequency randomization.
Definition:
ndn-consumer-cbr.cpp:116
ns3::ndn::Consumer
NDN application for sending out Interest packets.
Definition:
ndn-consumer.hpp:50
ns3::ndn::Consumer::SendPacket
void SendPacket()
Actually send packet.
Definition:
ndn-consumer.cpp:158
ns3::ndn::ConsumerCbr::SetRandomize
void SetRandomize(const std::string &value)
Set type of frequency randomization.
Definition:
ndn-consumer-cbr.cpp:97
ndn-consumer-cbr.hpp
ns3::ndn::ConsumerCbr::m_randomType
std::string m_randomType
Definition:
ndn-consumer-cbr.hpp:72
ns3::ndn::ConsumerCbr::ScheduleNextPacket
virtual void ScheduleNextPacket()
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...
Definition:
ndn-consumer-cbr.cpp:81
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
content-store-impl.cpp:38
ns3::ndn::ConsumerCbr::ConsumerCbr
ConsumerCbr()
Default constructor Sets up randomizer function and packet sequence number.
Definition:
ndn-consumer-cbr.cpp:68
ndn-app-face.hpp
ns3::ndn::Consumer::m_sendEvent
EventId m_sendEvent
EventId of pending "send packet" event.
Definition:
ndn-consumer.hpp:136
ndnSIM
apps
ndn-consumer-cbr.cpp
Generated on Tue Feb 23 2016 22:18:42 for ndnSIM by
1.8.11