blob: e5c2a44bcd98e19768c21ff06a72e11eb5afee26 [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 Afanasyevb3e4b852011-12-23 15:58:20 -080030#include "ns3/double.h"
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080031
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070032#include "ns3/ndn-app-face.h"
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -080033#include "ns3/ndn-interest.h"
34#include "ns3/ndn-content-object.h"
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -080035#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
Alexander Afanasyevd9a7f192013-03-07 13:58:14 -080036#include "ns3/ndnSIM/utils/ndn-rtt-mean-deviation.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070037
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080038#include <boost/ref.hpp>
Alexander Afanasyev781ea812011-12-15 22:42:09 -080039#include <boost/lexical_cast.hpp>
40#include <boost/lambda/lambda.hpp>
41#include <boost/lambda/bind.hpp>
42
Alexander Afanasyev3661e232012-01-20 17:36:15 -080043#include "ns3/names.h"
44
Alexander Afanasyev781ea812011-12-15 22:42:09 -080045namespace ll = boost::lambda;
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080046
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070047NS_LOG_COMPONENT_DEFINE ("ndn.Consumer");
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070048
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070049namespace ns3 {
50namespace ndn {
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080051
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070052NS_OBJECT_ENSURE_REGISTERED (Consumer);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080053
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070054TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055Consumer::GetTypeId (void)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070056{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070057 static TypeId tid = TypeId ("ns3::ndn::Consumer")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070058 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059 .SetParent<App> ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -080060 .AddAttribute ("StartSeq", "Initial sequence number",
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080061 IntegerValue (0),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070062 MakeIntegerAccessor(&Consumer::m_seq),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080063 MakeIntegerChecker<int32_t>())
Alexander Afanasyev011b8592011-12-21 14:45:27 -080064
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070065 .AddAttribute ("Prefix","Name of the Interest",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080066 StringValue ("/"),
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -070067 MakeNameAccessor (&Consumer::m_interestName),
68 MakeNameChecker ())
Ilya Moiseenko956d0542012-01-02 15:26:40 -080069 .AddAttribute ("LifeTime", "LifeTime for interest packet",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080070 StringValue ("2s"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070071 MakeTimeAccessor (&Consumer::m_interestLifeTime),
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080072 MakeTimeChecker ())
Alexander Afanasyev781ea812011-12-15 22:42:09 -080073
Alexander Afanasyev781ea812011-12-15 22:42:09 -080074 .AddAttribute ("RetxTimer",
75 "Timeout defining how frequent retransmission timeouts should be checked",
Alexander Afanasyev3d0c2e02012-01-22 18:50:05 -080076 StringValue ("50ms"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070077 MakeTimeAccessor (&Consumer::GetRetxTimer, &Consumer::SetRetxTimer),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080078 MakeTimeChecker ())
79
Alexander Afanasyevedf24d92013-01-18 13:35:06 -080080 .AddTraceSource ("LastRetransmittedInterestDataDelay", "Delay between last retransmitted Interest and received Data",
81 MakeTraceSourceAccessor (&Consumer::m_lastRetransmittedInterestDataDelay))
82
83 .AddTraceSource ("FirstInterestDataDelay", "Delay between first transmitted Interest and received Data",
84 MakeTraceSourceAccessor (&Consumer::m_firstInterestDataDelay))
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080085 ;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070086
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080087 return tid;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070088}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -080089
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070090Consumer::Consumer ()
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080091 : m_rand (0, std::numeric_limits<uint32_t>::max ())
92 , m_seq (0)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080093 , m_seqMax (0) // don't request anything
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070094{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080095 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyev011b8592011-12-21 14:45:27 -080096
Alexander Afanasyev94cebd02012-01-16 12:22:34 -080097 m_rtt = CreateObject<RttMeanDeviation> ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070098}
Alexander Afanasyev781ea812011-12-15 22:42:09 -080099
100void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101Consumer::SetRetxTimer (Time retxTimer)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800102{
103 m_retxTimer = retxTimer;
104 if (m_retxEvent.IsRunning ())
Alexander Afanasyevb18ae022012-09-03 21:46:36 -0700105 {
106 // m_retxEvent.Cancel (); // cancel any scheduled cleanup events
107 Simulator::Remove (m_retxEvent); // slower, but better for memory
108 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800109
110 // schedule even with new timeout
111 m_retxEvent = Simulator::Schedule (m_retxTimer,
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800112 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800113}
114
115Time
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700116Consumer::GetRetxTimer () const
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800117{
118 return m_retxTimer;
119}
120
121void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700122Consumer::CheckRetxTimeout ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800123{
124 Time now = Simulator::Now ();
125
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800126 Time rto = m_rtt->RetransmitTimeout ();
Alexander Afanasyev8a237522013-02-01 13:33:38 -0800127 // NS_LOG_DEBUG ("Current RTO: " << rto.ToDouble (Time::S) << "s");
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800128
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800129 while (!m_seqTimeouts.empty ())
130 {
131 SeqTimeoutsContainer::index<i_timestamp>::type::iterator entry =
132 m_seqTimeouts.get<i_timestamp> ().begin ();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800133 if (entry->time + rto <= now) // timeout expired?
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800134 {
Alexander Afanasyeve0e5bd12012-01-21 14:30:52 -0800135 uint32_t seqNo = entry->seq;
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800136 m_seqTimeouts.get<i_timestamp> ().erase (entry);
Alexander Afanasyeve0e5bd12012-01-21 14:30:52 -0800137 OnTimeout (seqNo);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800138 }
139 else
140 break; // nothing else to do. All later packets need not be retransmitted
141 }
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800142
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800143 m_retxEvent = Simulator::Schedule (m_retxTimer,
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800144 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800145}
146
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700147// Application Methods
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800148void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700149Consumer::StartApplication () // Called at time specified by Start
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700150{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800151 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700152
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800153 // do base stuff
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700154 App::StartApplication ();
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800155
156 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700157}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800158
159void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700160Consumer::StopApplication () // Called at time specified by Stop
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700161{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800162 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700163
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800164 // cancel periodic packet generation
165 Simulator::Cancel (m_sendEvent);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700166
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800167 // cleanup base stuff
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700168 App::StopApplication ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700169}
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800170
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700171void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700172Consumer::SendPacket ()
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700173{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800174 if (!m_active) return;
175
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800176 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800177
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800178 uint32_t seq=std::numeric_limits<uint32_t>::max (); //invalid
179
180 while (m_retxSeqs.size ())
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800181 {
182 seq = *m_retxSeqs.begin ();
183 m_retxSeqs.erase (m_retxSeqs.begin ());
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800184 break;
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800185 }
Alexander Afanasyev1ec705f2012-01-23 12:35:10 -0800186
187 if (seq == std::numeric_limits<uint32_t>::max ())
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800188 {
Alexander Afanasyev812f7ab2012-01-24 11:08:04 -0800189 if (m_seqMax != std::numeric_limits<uint32_t>::max ())
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800190 {
191 if (m_seq >= m_seqMax)
192 {
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800193 return; // we are totally done
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800194 }
195 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800196
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800197 seq = m_seq++;
198 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800199
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800200 //
Alexander Afanasyevcfdc14f2013-03-15 14:38:44 -0700201 Ptr<Name> nameWithSequence = Create<Name> (m_interestName);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800202 (*nameWithSequence) (seq);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800203 //
204
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700205 Interest interestHeader;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800206 interestHeader.SetNonce (m_rand.GetValue ());
207 interestHeader.SetName (nameWithSequence);
Alexander Afanasyev1fb9fed2013-02-01 23:18:04 -0800208 interestHeader.SetInterestLifetime (m_interestLifeTime);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800209
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800210 // NS_LOG_INFO ("Requesting Interest: \n" << interestHeader);
211 NS_LOG_INFO ("> Interest for " << seq);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700212
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800213 Ptr<Packet> packet = Create<Packet> ();
214 packet->AddHeader (interestHeader);
Alexander Afanasyev59e67712012-02-07 11:49:34 -0800215 NS_LOG_DEBUG ("Interest packet size: " << packet->GetSize ());
Alexander Afanasyevd02a5d62011-11-21 11:01:51 -0800216
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -0700217 WillSendOutInterest (seq);
Alexander Afanasyeve1aa9b92012-10-11 10:40:02 -0700218
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800219 FwHopCountTag hopCountTag;
220 packet->AddPacketTag (hopCountTag);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800221
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -0700222 m_transmittedInterests (&interestHeader, this, m_face);
Alexander Afanasyeve1aa9b92012-10-11 10:40:02 -0700223 m_protocolHandler (packet);
224
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800225 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700226}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700227
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800228///////////////////////////////////////////////////
229// Process incoming packets //
230///////////////////////////////////////////////////
231
232
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700233void
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700234Consumer::OnContentObject (const Ptr<const ContentObject> &contentObject,
Alexander Afanasyeve9c9d722012-01-19 16:59:30 -0800235 Ptr<Packet> payload)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700236{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800237 if (!m_active) return;
238
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700239 App::OnContentObject (contentObject, payload); // tracing inside
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800240
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800241 NS_LOG_FUNCTION (this << contentObject << payload);
242
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800243 // NS_LOG_INFO ("Received content object: " << boost::cref(*contentObject));
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800244
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800245 uint32_t seq = boost::lexical_cast<uint32_t> (contentObject->GetName ().GetComponents ().back ());
246 NS_LOG_INFO ("< DATA for " << seq);
247
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800248 int hopCount = -1;
249 FwHopCountTag hopCountTag;
250 if (payload->RemovePacketTag (hopCountTag))
251 {
252 hopCount = hopCountTag.Get ();
253 }
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800254
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800255 SeqTimeoutsContainer::iterator entry = m_seqLastDelay.find (seq);
256 if (entry != m_seqLastDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800257 {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800258 m_lastRetransmittedInterestDataDelay (this, seq, Simulator::Now () - entry->time, hopCount);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800259 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800260
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800261 entry = m_seqFullDelay.find (seq);
262 if (entry != m_seqFullDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800263 {
Alexander Afanasyev1a0fff62013-01-19 14:29:51 -0800264 m_firstInterestDataDelay (this, seq, Simulator::Now () - entry->time, m_seqRetxCounts[seq], hopCount);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800265 }
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800266
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800267 m_seqRetxCounts.erase (seq);
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800268 m_seqFullDelay.erase (seq);
269 m_seqLastDelay.erase (seq);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800270
Alexander Afanasyev36d5c2a2012-01-02 19:09:19 -0800271 m_seqTimeouts.erase (seq);
272 m_retxSeqs.erase (seq);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800273
274 m_rtt->AckSeq (SequenceNumber32 (seq));
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800275}
276
277void
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700278Consumer::OnNack (const Ptr<const Interest> &interest, Ptr<Packet> origPacket)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800279{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800280 if (!m_active) return;
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800281
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700282 App::OnNack (interest, origPacket); // tracing inside
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800283
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800284 // NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800285
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800286 // NS_LOG_FUNCTION (interest->GetName ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800287
288 // NS_LOG_INFO ("Received NACK: " << boost::cref(*interest));
289 uint32_t seq = boost::lexical_cast<uint32_t> (interest->GetName ().GetComponents ().back ());
290 NS_LOG_INFO ("< NACK for " << seq);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800291 // std::cout << Simulator::Now ().ToDouble (Time::S) << "s -> " << "NACK for " << seq << "\n";
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800292
293 // put in the queue of interests to be retransmitted
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800294 // NS_LOG_INFO ("Before: " << m_retxSeqs.size ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800295 m_retxSeqs.insert (seq);
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800296 // NS_LOG_INFO ("After: " << m_retxSeqs.size ());
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800297
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800298 m_seqTimeouts.erase (seq);
299
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700300 m_rtt->IncreaseMultiplier (); // Double the next RTO ??
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800301 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700302}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700303
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800304void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700305Consumer::OnTimeout (uint32_t sequenceNumber)
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800306{
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700307 NS_LOG_FUNCTION (sequenceNumber);
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800308 // std::cout << Simulator::Now () << ", TO: " << sequenceNumber << ", current RTO: " << m_rtt->RetransmitTimeout ().ToDouble (Time::S) << "s\n";
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800309
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700310 m_rtt->IncreaseMultiplier (); // Double the next RTO
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800311 m_rtt->SentSeq (SequenceNumber32 (sequenceNumber), 1); // make sure to disable RTT calculation for this sample
Alexander Afanasyev4d66de52012-01-13 00:06:01 -0800312 m_retxSeqs.insert (sequenceNumber);
Alexander Afanasyev3a3ce1a2013-01-31 11:26:11 -0800313 ScheduleNextPacket ();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800314}
315
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -0700316void
317Consumer::WillSendOutInterest (uint32_t sequenceNumber)
318{
319 NS_LOG_DEBUG ("Trying to add " << sequenceNumber << " with " << Simulator::Now () << ". already " << m_seqTimeouts.size () << " items");
320
321 m_seqTimeouts.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
322 m_seqFullDelay.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
323
324 m_seqLastDelay.erase (sequenceNumber);
325 m_seqLastDelay.insert (SeqTimeout (sequenceNumber, Simulator::Now ()));
326
327 m_seqRetxCounts[sequenceNumber] ++;
328
329 m_rtt->SentSeq (SequenceNumber32 (sequenceNumber), 1);
330}
331
332
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700333} // namespace ndn
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800334} // namespace ns3