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-batches.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20
#include "
ndn-consumer-batches.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/uinteger.h"
28
#include "ns3/double.h"
29
30
#include "
utils/batches.hpp
"
31
32
NS_LOG_COMPONENT_DEFINE(
"ndn.ConsumerBatches"
);
33
34
namespace
ns3
{
35
namespace
ndn
{
36
37
NS_OBJECT_ENSURE_REGISTERED
(
ConsumerBatches
);
38
39
TypeId
40
ConsumerBatches::GetTypeId
(
void
)
41
{
42
static
TypeId tid =
43
TypeId(
"ns3::ndn::ConsumerBatches"
)
44
.SetGroupName(
"Ndn"
)
45
.SetParent<
Consumer
>()
46
.AddConstructor<ConsumerBatches>()
47
48
.AddAttribute(
"Batches"
,
49
"Batches to schedule. Should be vector, containing pairs of time and amount"
,
50
// TypeId::ATTR_SET,
51
StringValue(
""
),
MakeBatchesAccessor
(&ConsumerBatches::m_batches),
52
MakeBatchesChecker
());
53
54
return
tid;
55
}
56
57
ConsumerBatches::ConsumerBatches
()
58
: m_initial(true)
59
{
60
}
61
62
void
63
ConsumerBatches::StartApplication()
64
{
65
Consumer::StartApplication
();
66
67
// std::cout << "Batches: " << batches << "\n";
68
for
(Batches::const_iterator i = m_batches.begin(); i != m_batches.end(); i++) {
69
Simulator::ScheduleWithContext(GetNode()->
GetId
(), std::get<0>(*i), &ConsumerBatches::AddBatch,
70
this
, std::get<1>(*i));
71
}
72
}
73
74
void
75
ConsumerBatches::AddBatch(uint32_t amount)
76
{
77
// std::cout << Simulator::Now () << " adding batch of " << amount << "\n";
78
m_seqMax
+= amount;
79
m_rtt
->ClearSent();
// this is important, otherwise RTT estimation for the new batch will be
80
// affected by previous batch history
81
m_initial =
true
;
82
ScheduleNextPacket
();
83
}
84
85
void
86
ConsumerBatches::ScheduleNextPacket
()
87
{
88
if
(!
m_sendEvent
.IsRunning()) {
89
Time delay = Seconds(0);
90
if
(!m_initial)
91
delay =
m_rtt
->RetransmitTimeout();
92
93
m_initial =
false
;
94
m_sendEvent
= Simulator::Schedule(delay, &
Consumer::SendPacket
,
this
);
95
}
96
}
97
98
}
// namespace ndn
99
}
// namespace ns3
ns3::ndn::Consumer::m_seqMax
uint32_t m_seqMax
maximum number of sequence number
Definition:
ndn-consumer.hpp:135
ns3::ndn::ConsumerBatches::GetTypeId
static TypeId GetTypeId()
Definition:
ndn-consumer-batches.cpp:40
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ns3::MakeBatchesAccessor
Ptr< const AttributeAccessor > MakeBatchesAccessor(T1 a1)
Definition:
batches.hpp:55
batches.hpp
ns3::ndn::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(ContentStore)
ns3::ndn::Consumer::m_rtt
Ptr< RttEstimator > m_rtt
RTT estimator.
Definition:
ndn-consumer.hpp:140
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::ConsumerBatches::ScheduleNextPacket
virtual void ScheduleNextPacket()
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...
Definition:
ndn-consumer-batches.cpp:86
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
content-store-impl.cpp:38
ns3::ndn::ConsumerBatches::ConsumerBatches
ConsumerBatches()
Default constructor.
Definition:
ndn-consumer-batches.cpp:57
ns3::ndn::Consumer::m_sendEvent
EventId m_sendEvent
EventId of pending "send packet" event.
Definition:
ndn-consumer.hpp:136
ndn-consumer-batches.hpp
ns3::MakeBatchesChecker
Ptr< const AttributeChecker > MakeBatchesChecker(void)
ns3::ndn::App::GetId
uint32_t GetId() const
Get application ID (ID of applications face)
Definition:
ndn-app.cpp:99
ns3::ndn::Consumer::StartApplication
virtual void StartApplication()
Called at time specified by Start.
Definition:
ndn-consumer.cpp:135
ConsumerBatches
ndn ConsumerBatches
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-consumer-batches.cpp:32
ndnSIM
apps
ndn-consumer-batches.cpp
Generated on Tue Feb 23 2016 22:18:42 for ndnSIM by
1.8.11