21 #include "ndn-consumer-cbr.h"
24 #include "ns3/simulator.h"
25 #include "ns3/packet.h"
26 #include "ns3/callback.h"
27 #include "ns3/string.h"
28 #include "ns3/boolean.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/integer.h"
31 #include "ns3/double.h"
33 #include "ns3/ndn-app-face.h"
34 #include "ns3/ndn-interest.h"
35 #include "ns3/ndn-data.h"
37 NS_LOG_COMPONENT_DEFINE (
"ndn.ConsumerCbr");
42 NS_OBJECT_ENSURE_REGISTERED (ConsumerCbr);
45 ConsumerCbr::GetTypeId (
void)
47 static TypeId tid = TypeId (
"ns3::ndn::ConsumerCbr")
50 .AddConstructor<ConsumerCbr> ()
52 .AddAttribute (
"Frequency",
"Frequency of interest packets",
54 MakeDoubleAccessor (&ConsumerCbr::m_frequency),
55 MakeDoubleChecker<double> ())
57 .AddAttribute (
"Randomize",
"Type of send time randomization: none (default), uniform, exponential",
62 .AddAttribute (
"MaxSeq",
63 "Maximum sequence number to request",
64 IntegerValue (std::numeric_limits<uint32_t>::max ()),
66 MakeIntegerChecker<uint32_t> ())
78 NS_LOG_FUNCTION_NOARGS ();
79 m_seqMax = std::numeric_limits<uint32_t>::max ();
82 ConsumerCbr::~ConsumerCbr ()
103 Seconds(1.0 / m_frequency)
105 Seconds(m_random->GetValue ()),
115 if (value ==
"uniform")
117 m_random =
new UniformVariable (0.0, 2 * 1.0 / m_frequency);
119 else if (value ==
"exponential")
121 m_random =
new ExponentialVariable (1.0 / m_frequency, 50 * 1.0 / m_frequency);
126 m_randomType = value;
ConsumerCbr()
Default constructor Sets up randomizer function and packet sequence number.
Consumer()
Default constructor Sets up randomizer function and packet sequence number.
EventId m_sendEvent
EventId of pending "send packet" event.
void SetRandomize(const std::string &value)
Set type of frequency randomization.
uint32_t m_seqMax
maximum number of sequence number
std::string GetRandomize() const
Get type of frequency randomization.
void SendPacket()
Actually send packet.
virtual void ScheduleNextPacket()
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...