blob: adbce0f79744c0debcd5b912a856b892e19784ab [file] [log] [blame]
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
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: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021#include "ndn-consumer.h"
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070022#include "ns3/ptr.h"
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080023#include "ns3/log.h"
24#include "ns3/simulator.h"
25#include "ns3/packet.h"
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070026#include "ns3/callback.h"
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080027#include "ns3/string.h"
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080028#include "ns3/boolean.h"
29#include "ns3/uinteger.h"
Alexander Afanasyeva89bc102013-07-16 10:17:31 -070030#include "ns3/integer.h"
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080031#include "ns3/double.h"
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080032
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033#include "ns3/ndn-app-face.h"
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -080034#include "ns3/ndn-interest.h"
35#include "ns3/ndn-content-object.h"
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080036#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
Alexander Afanasyevd9a7f192013-03-07 13:58:14 -080037#include "ns3/ndnSIM/utils/ndn-rtt-mean-deviation.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070038
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080039#include <boost/ref.hpp>
Alexander Afanasyev781ea812011-12-15 22:42:09 -080040#include <boost/lexical_cast.hpp>
41#include <boost/lambda/lambda.hpp>
42#include <boost/lambda/bind.hpp>
43
Alexander Afanasyev3661e232012-01-20 17:36:15 -080044#include "ns3/names.h"
45
Alexander Afanasyev781ea812011-12-15 22:42:09 -080046namespace ll = boost::lambda;
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080047
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048NS_LOG_COMPONENT_DEFINE ("ndn.Consumer");
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070049
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070050namespace ns3 {
51namespace ndn {
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080052
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070053NS_OBJECT_ENSURE_REGISTERED (Consumer);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080054
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070055TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056Consumer::GetTypeId (void)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070057{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070058 static TypeId tid = TypeId ("ns3::ndn::Consumer")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070059 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 .SetParent<App> ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -080061 .AddAttribute ("StartSeq", "Initial sequence number",
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080062 IntegerValue (0),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 MakeIntegerAccessor(&Consumer::m_seq),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080064 MakeIntegerChecker<int32_t>())
Alexander Afanasyev011b8592011-12-21 14:45:27 -080065
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066 .AddAttribute ("Prefix","Name of the Interest",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080067 StringValue ("/"),
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070068 MakeNameAccessor (&Consumer::m_interestName),
69 MakeNameChecker ())
Ilya Moiseenko956d0542012-01-02 15:26:40 -080070 .AddAttribute ("LifeTime", "LifeTime for interest packet",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080071 StringValue ("2s"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070072 MakeTimeAccessor (&Consumer::m_interestLifeTime),
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080073 MakeTimeChecker ())
Alexander Afanasyev781ea812011-12-15 22:42:09 -080074
Alexander Afanasyev781ea812011-12-15 22:42:09 -080075 .AddAttribute ("RetxTimer",
76 "Timeout defining how frequent retransmission timeouts should be checked",
Alexander Afanasyev3d0c2e02012-01-22 18:50:05 -080077 StringValue ("50ms"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070078 MakeTimeAccessor (&Consumer::GetRetxTimer, &Consumer::SetRetxTimer),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080079 MakeTimeChecker ())
80
Alexander Afanasyevedf24d92013-01-18 13:35:06 -080081 .AddTraceSource ("LastRetransmittedInterestDataDelay", "Delay between last retransmitted Interest and received Data",
82 MakeTraceSourceAccessor (&Consumer::m_lastRetransmittedInterestDataDelay))
83
84 .AddTraceSource ("FirstInterestDataDelay", "Delay between first transmitted Interest and received Data",
85 MakeTraceSourceAccessor (&Consumer::m_firstInterestDataDelay))
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080086 ;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070087
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080088 return tid;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070089}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080090
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070091Consumer::Consumer ()
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080092 : m_rand (0, std::numeric_limits<uint32_t>::max ())
93 , m_seq (0)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080094 , m_seqMax (0) // don't request anything
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070095{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080096 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyev011b8592011-12-21 14:45:27 -080097
Alexander Afanasyev94cebd02012-01-16 12:22:34 -080098 m_rtt = CreateObject<RttMeanDeviation> ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070099}
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800100
101void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700102Consumer::SetRetxTimer (Time retxTimer)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800103{
104 m_retxTimer = retxTimer;
105 if (m_retxEvent.IsRunning ())
Alexander Afanasyevb18ae022012-09-03 21:46:36 -0700106 {
107 // m_retxEvent.Cancel (); // cancel any scheduled cleanup events
108 Simulator::Remove (m_retxEvent); // slower, but better for memory
109 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800110
111 // schedule even with new timeout
112 m_retxEvent = Simulator::Schedule (m_retxTimer,
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800113 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800114}
115
116Time
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700117Consumer::GetRetxTimer () const
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800118{
119 return m_retxTimer;
120}
121
122void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700123Consumer::CheckRetxTimeout ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800124{
125 Time now = Simulator::Now ();
126
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800127 Time rto = m_rtt->RetransmitTimeout ();
Alexander Afanasyev8a237522013-02-01 13:33:38 -0800128 // NS_LOG_DEBUG ("Current RTO: " << rto.ToDouble (Time::S) << "s");
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800129
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800130 while (!m_seqTimeouts.empty ())
131 {
132 SeqTimeoutsContainer::index<i_timestamp>::type::iterator entry =
133 m_seqTimeouts.get<i_timestamp> ().begin ();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800134 if (entry->time + rto <= now) // timeout expired?
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800135 {
Alexander Afanasyeve0e5bd12012-01-21 14:30:52 -0800136 uint32_t seqNo = entry->seq;
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800137 m_seqTimeouts.get<i_timestamp> ().erase (entry);
Alexander Afanasyeve0e5bd12012-01-21 14:30:52 -0800138 OnTimeout (seqNo);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800139 }
140 else
141 break; // nothing else to do. All later packets need not be retransmitted
142 }
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800143
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800144 m_retxEvent = Simulator::Schedule (m_retxTimer,
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800145 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800146}
147
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700148// Application Methods
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800149void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700150Consumer::StartApplication () // Called at time specified by Start
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700151{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800152 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700153
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800154 // do base stuff
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700155 App::StartApplication ();
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800156
157 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700158}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800159
160void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700161Consumer::StopApplication () // Called at time specified by Stop
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700162{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800163 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700164
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800165 // cancel periodic packet generation
166 Simulator::Cancel (m_sendEvent);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700167
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800168 // cleanup base stuff
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700169 App::StopApplication ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700170}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800171
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700172void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700173Consumer::SendPacket ()
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700174{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800175 if (!m_active) return;
176
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800177 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800178
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800179 uint32_t seq=std::numeric_limits<uint32_t>::max (); //invalid
180
181 while (m_retxSeqs.size ())
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800182 {
183 seq = *m_retxSeqs.begin ();
184 m_retxSeqs.erase (m_retxSeqs.begin ());
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800185 break;
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800186 }
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800187
188 if (seq == std::numeric_limits<uint32_t>::max ())
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800189 {
Alexander Afanasyev812f7ab2012-01-24 11:08:04 -0800190 if (m_seqMax != std::numeric_limits<uint32_t>::max ())
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800191 {
192 if (m_seq >= m_seqMax)
193 {
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800194 return; // we are totally done
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800195 }
196 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800197
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800198 seq = m_seq++;
199 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800200
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800201 //
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -0700202 Ptr<Name> nameWithSequence = Create<Name> (m_interestName);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800203 (*nameWithSequence) (seq);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800204 //
205
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700206 Ptr<Interest> interest = Create<Interest> ();
207 interest->SetNonce (m_rand.GetValue ());
208 interest->SetName (nameWithSequence);
209 interest->SetInterestLifetime (m_interestLifeTime);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800210
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700211 // NS_LOG_INFO ("Requesting Interest: \n" << *interest);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800212 NS_LOG_INFO ("> Interest for " << seq);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700213
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -0700214 WillSendOutInterest (seq);
Alexander Afanasyeve1aa9b92012-10-11 10:40:02 -0700215
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800216 FwHopCountTag hopCountTag;
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700217 interest->GetPayload ()->AddPacketTag (hopCountTag);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800218
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700219 m_transmittedInterests (interest, this, m_face);
220 m_face->ReceiveInterest (interest);
Alexander Afanasyeve1aa9b92012-10-11 10:40:02 -0700221
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800222 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700223}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700224
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800225///////////////////////////////////////////////////
226// Process incoming packets //
227///////////////////////////////////////////////////
228
229
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700230void
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700231Consumer::OnContentObject (Ptr<const ContentObject> data)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700232{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800233 if (!m_active) return;
234
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700235 App::OnContentObject (data); // tracing inside
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800236
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700237 NS_LOG_FUNCTION (this << data);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800238
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700239 // NS_LOG_INFO ("Received content object: " << boost::cref(*data));
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800240
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700241 uint32_t seq = boost::lexical_cast<uint32_t> (data->GetName ().GetComponents ().back ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800242 NS_LOG_INFO ("< DATA for " << seq);
243
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800244 int hopCount = -1;
245 FwHopCountTag hopCountTag;
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700246 if (data->GetPayload ()->PeekPacketTag (hopCountTag))
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800247 {
248 hopCount = hopCountTag.Get ();
249 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800250
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800251 SeqTimeoutsContainer::iterator entry = m_seqLastDelay.find (seq);
252 if (entry != m_seqLastDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800253 {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800254 m_lastRetransmittedInterestDataDelay (this, seq, Simulator::Now () - entry->time, hopCount);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800255 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800256
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800257 entry = m_seqFullDelay.find (seq);
258 if (entry != m_seqFullDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800259 {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800260 m_firstInterestDataDelay (this, seq, Simulator::Now () - entry->time, m_seqRetxCounts[seq], hopCount);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800261 }
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800262
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800263 m_seqRetxCounts.erase (seq);
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800264 m_seqFullDelay.erase (seq);
265 m_seqLastDelay.erase (seq);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800266
Alexander Afanasyev36d5c2a2012-01-02 19:09:19 -0800267 m_seqTimeouts.erase (seq);
268 m_retxSeqs.erase (seq);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800269
270 m_rtt->AckSeq (SequenceNumber32 (seq));
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800271}
272
273void
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700274Consumer::OnNack (Ptr<const Interest> interest)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800275{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800276 if (!m_active) return;
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800277
Alexander Afanasyevfaa01f92013-07-10 18:34:31 -0700278 App::OnNack (interest); // tracing inside
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800279
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800280 // NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800281
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800282 // NS_LOG_FUNCTION (interest->GetName ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800283
284 // NS_LOG_INFO ("Received NACK: " << boost::cref(*interest));
285 uint32_t seq = boost::lexical_cast<uint32_t> (interest->GetName ().GetComponents ().back ());
286 NS_LOG_INFO ("< NACK for " << seq);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800287 // std::cout << Simulator::Now ().ToDouble (Time::S) << "s -> " << "NACK for " << seq << "\n";
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800288
289 // put in the queue of interests to be retransmitted
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800290 // NS_LOG_INFO ("Before: " << m_retxSeqs.size ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800291 m_retxSeqs.insert (seq);
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800292 // NS_LOG_INFO ("After: " << m_retxSeqs.size ());
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800293
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800294 m_seqTimeouts.erase (seq);
295
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700296 m_rtt->IncreaseMultiplier (); // Double the next RTO ??
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800297 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700298}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700299
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800300void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700301Consumer::OnTimeout (uint32_t sequenceNumber)
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800302{
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700303 NS_LOG_FUNCTION (sequenceNumber);
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800304 // std::cout << Simulator::Now () << ", TO: " << sequenceNumber << ", current RTO: " << m_rtt->RetransmitTimeout ().ToDouble (Time::S) << "s\n";
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800305
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700306 m_rtt->IncreaseMultiplier (); // Double the next RTO
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800307 m_rtt->SentSeq (SequenceNumber32 (sequenceNumber), 1); // make sure to disable RTT calculation for this sample
Alexander Afanasyev4d66de52012-01-13 00:06:01 -0800308 m_retxSeqs.insert (sequenceNumber);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800309 ScheduleNextPacket ();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800310}
311
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -0700312void
313Consumer::WillSendOutInterest (uint32_t sequenceNumber)
314{
315 NS_LOG_DEBUG ("Trying to add " << sequenceNumber << " with " << Simulator::Now () << ". already " << m_seqTimeouts.size () << " items");
316
317 m_seqTimeouts.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
318 m_seqFullDelay.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
319
320 m_seqLastDelay.erase (sequenceNumber);
321 m_seqLastDelay.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
322
323 m_seqRetxCounts[sequenceNumber] ++;
324
325 m_rtt->SentSeq (SequenceNumber32 (sequenceNumber), 1);
326}
327
328
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700329} // namespace ndn
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800330} // namespace ns3