blob: 08d4b2ca9d9d5a3284eedf4497ae02ca275e70b6 [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 Afanasyevde7601a2012-05-31 12:14:54 -070035// #include "ns3/weights-path-stretch-tag.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070036
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080037#include <boost/ref.hpp>
Alexander Afanasyev781ea812011-12-15 22:42:09 -080038#include <boost/lexical_cast.hpp>
39#include <boost/lambda/lambda.hpp>
40#include <boost/lambda/bind.hpp>
41
Alexander Afanasyev3661e232012-01-20 17:36:15 -080042#include "ns3/names.h"
43
Alexander Afanasyev781ea812011-12-15 22:42:09 -080044namespace ll = boost::lambda;
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080045
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070046NS_LOG_COMPONENT_DEFINE ("ndn.Consumer");
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070047
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048namespace ns3 {
49namespace ndn {
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070050
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051NS_OBJECT_ENSURE_REGISTERED (Consumer);
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070052
53TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070054Consumer::GetTypeId (void)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070055{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056 static TypeId tid = TypeId ("ns3::ndn::Consumer")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070057 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070058 .SetParent<App> ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -080059 .AddAttribute ("StartSeq", "Initial sequence number",
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080060 IntegerValue (0),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070061 MakeIntegerAccessor(&Consumer::m_seq),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080062 MakeIntegerChecker<int32_t>())
Alexander Afanasyev011b8592011-12-21 14:45:27 -080063
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070064 .AddAttribute ("Prefix","Name of the Interest",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080065 StringValue ("/"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066 MakeNameComponentsAccessor (&Consumer::m_interestName),
67 MakeNameComponentsChecker ())
Ilya Moiseenko956d0542012-01-02 15:26:40 -080068 .AddAttribute ("LifeTime", "LifeTime for interest packet",
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080069 StringValue ("2s"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070070 MakeTimeAccessor (&Consumer::m_interestLifeTime),
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080071 MakeTimeChecker ())
Alexander Afanasyev781ea812011-12-15 22:42:09 -080072
Alexander Afanasyev781ea812011-12-15 22:42:09 -080073 .AddAttribute ("RetxTimer",
74 "Timeout defining how frequent retransmission timeouts should be checked",
Alexander Afanasyev3d0c2e02012-01-22 18:50:05 -080075 StringValue ("50ms"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070076 MakeTimeAccessor (&Consumer::GetRetxTimer, &Consumer::SetRetxTimer),
Alexander Afanasyev781ea812011-12-15 22:42:09 -080077 MakeTimeChecker ())
78
Alexander Afanasyev6bff0df2012-01-19 17:51:52 -080079 .AddTraceSource ("PathWeightsTrace", "PathWeightsTrace",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070080 MakeTraceSourceAccessor (&Consumer::m_pathWeightsTrace))
Alexander Afanasyevedf24d92013-01-18 13:35:06 -080081
82 .AddTraceSource ("LastRetransmittedInterestDataDelay", "Delay between last retransmitted Interest and received Data",
83 MakeTraceSourceAccessor (&Consumer::m_lastRetransmittedInterestDataDelay))
84
85 .AddTraceSource ("FirstInterestDataDelay", "Delay between first transmitted Interest and received Data",
86 MakeTraceSourceAccessor (&Consumer::m_firstInterestDataDelay))
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080087 ;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070088
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080089 return tid;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070090}
91
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070092Consumer::Consumer ()
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080093 : m_rand (0, std::numeric_limits<uint32_t>::max ())
94 , m_seq (0)
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080095 , m_seqMax (0) // don't request anything
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070096{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080097 NS_LOG_FUNCTION_NOARGS ();
Alexander Afanasyev011b8592011-12-21 14:45:27 -080098
Alexander Afanasyev94cebd02012-01-16 12:22:34 -080099 m_rtt = CreateObject<RttMeanDeviation> ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700100}
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800101
102void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700103Consumer::SetRetxTimer (Time retxTimer)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800104{
105 m_retxTimer = retxTimer;
106 if (m_retxEvent.IsRunning ())
Alexander Afanasyevb18ae022012-09-03 21:46:36 -0700107 {
108 // m_retxEvent.Cancel (); // cancel any scheduled cleanup events
109 Simulator::Remove (m_retxEvent); // slower, but better for memory
110 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800111
112 // schedule even with new timeout
113 m_retxEvent = Simulator::Schedule (m_retxTimer,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700114 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800115}
116
117Time
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700118Consumer::GetRetxTimer () const
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800119{
120 return m_retxTimer;
121}
122
123void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700124Consumer::CheckRetxTimeout ()
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800125{
126 Time now = Simulator::Now ();
127
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800128 Time rto = m_rtt->RetransmitTimeout ();
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700145 &Consumer::CheckRetxTimeout, this);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800146}
147
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700148// Application Methods
149void
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}
159
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}
171
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 }
197
198 seq = m_seq++;
199 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800200
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800201 //
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700202 Ptr<NameComponents> nameWithSequence = Create<NameComponents> (m_interestName);
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800203 (*nameWithSequence) (seq);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800204 //
205
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700206 InterestHeader interestHeader;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800207 interestHeader.SetNonce (m_rand.GetValue ());
208 interestHeader.SetName (nameWithSequence);
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700209
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 Afanasyevbdc0d982011-12-16 01:15:26 -0800217 NS_LOG_DEBUG ("Trying to add " << seq << " with " << Simulator::Now () << ". already " << m_seqTimeouts.size () << " items");
218
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800219 m_seqTimeouts.insert (SeqTimeout (seq, Simulator::Now ()));
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800220 m_seqFullDelay.insert (SeqTimeout (seq, Simulator::Now ()));
221
222 m_seqLastDelay.erase (seq);
223 m_seqLastDelay.insert (SeqTimeout (seq, Simulator::Now ()));
224
225 m_seqRetxCounts[seq] ++;
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800226
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800227 m_transmittedInterests (&interestHeader, this, m_face);
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800228
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800229 m_rtt->SentSeq (SequenceNumber32 (seq), 1);
Alexander Afanasyeve1aa9b92012-10-11 10:40:02 -0700230
231 m_protocolHandler (packet);
232
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800233 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700234}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700235
Alexander Afanasyev011b8592011-12-21 14:45:27 -0800236///////////////////////////////////////////////////
237// Process incoming packets //
238///////////////////////////////////////////////////
239
240
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700241void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700242Consumer::OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Alexander Afanasyeve9c9d722012-01-19 16:59:30 -0800243 Ptr<Packet> payload)
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700244{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800245 if (!m_active) return;
246
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700247 App::OnContentObject (contentObject, payload); // tracing inside
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800248
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800249 NS_LOG_FUNCTION (this << contentObject << payload);
250
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800251 // NS_LOG_INFO ("Received content object: " << boost::cref(*contentObject));
252
253 uint32_t seq = boost::lexical_cast<uint32_t> (contentObject->GetName ().GetComponents ().back ());
254 NS_LOG_INFO ("< DATA for " << seq);
255
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800256 SeqTimeoutsContainer::iterator entry = m_seqLastDelay.find (seq);
257 if (entry != m_seqLastDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800258 {
259 m_lastRetransmittedInterestDataDelay (this, seq, Simulator::Now () - entry->time);
260 }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800261
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800262 entry = m_seqFullDelay.find (seq);
263 if (entry != m_seqFullDelay.end ())
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800264 {
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800265 m_firstInterestDataDelay (this, seq, Simulator::Now () - entry->time, m_seqRetxCounts[seq]);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800266 }
Alexander Afanasyev400aae12013-01-19 13:27:52 -0800267
268 m_seqRetxCounts.erase (seq);
269 m_seqFullDelay.erase (seq);
270 m_seqLastDelay.erase (seq);
Alexander Afanasyevedf24d92013-01-18 13:35:06 -0800271
Alexander Afanasyev36d5c2a2012-01-02 19:09:19 -0800272 m_seqTimeouts.erase (seq);
273 m_retxSeqs.erase (seq);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800274
275 m_rtt->AckSeq (SequenceNumber32 (seq));
Alexander Afanasyev6bff0df2012-01-19 17:51:52 -0800276
Alexander Afanasyevde7601a2012-05-31 12:14:54 -0700277 // Ptr<const WeightsPathStretchTag> tag = payload->RemovePacketTag<WeightsPathStretchTag> ();
278 // if (tag != 0)
279 // {
280 // // Notify trace about path weights vector (e.g., for path-stretch calculation)
281 // m_pathWeightsTrace (GetNode (), tag->GetSourceNode (), seq, tag->GetTotalWeight ());
282 // // if (Names::FindName (GetNode ()) == "36")// || Names::FindName (GetNode ()) == "40"|| Names::FindName (GetNode ()) == "5")
283 // // std::cout << Simulator::Now () << "\t" << boost::cref(*tag) << " = " << tag->GetTotalWeight () << "\n";
284 // }
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800285}
286
287void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700288Consumer::OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> origPacket)
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800289{
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800290 if (!m_active) return;
291
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700292 App::OnNack (interest, origPacket); // tracing inside
Alexander Afanasyevbdc0d982011-12-16 01:15:26 -0800293
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800294 // NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800295
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800296 // NS_LOG_FUNCTION (interest->GetName ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800297
298 // NS_LOG_INFO ("Received NACK: " << boost::cref(*interest));
299 uint32_t seq = boost::lexical_cast<uint32_t> (interest->GetName ().GetComponents ().back ());
300 NS_LOG_INFO ("< NACK for " << seq);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800301 // std::cout << Simulator::Now ().ToDouble (Time::S) << "s -> " << "NACK for " << seq << "\n";
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800302
303 // put in the queue of interests to be retransmitted
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800304 // NS_LOG_INFO ("Before: " << m_retxSeqs.size ());
Alexander Afanasyev781ea812011-12-15 22:42:09 -0800305 m_retxSeqs.insert (seq);
Alexander Afanasyeve1b2a2d2012-11-16 11:53:42 -0800306 // NS_LOG_INFO ("After: " << m_retxSeqs.size ());
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800307
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700308 m_rtt->IncreaseMultiplier (); // Double the next RTO ??
Alexander Afanasyev3183b5a2011-12-23 20:48:20 -0800309 ScheduleNextPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -0700310}
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700311
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800312void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700313Consumer::OnTimeout (uint32_t sequenceNumber)
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800314{
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700315 NS_LOG_FUNCTION (sequenceNumber);
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800316 // std::cout << Simulator::Now () << ", TO: " << sequenceNumber << ", current RTO: " << m_rtt->RetransmitTimeout ().ToDouble (Time::S) << "s\n";
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800317
Alexander Afanasyev92d5be12012-08-13 18:56:52 -0700318 m_rtt->IncreaseMultiplier (); // Double the next RTO
Alexander Afanasyev8e0d2812012-01-19 22:38:14 -0800319 m_rtt->SentSeq (SequenceNumber32 (sequenceNumber), 1); // make sure to disable RTT calculation for this sample
Alexander Afanasyev4d66de52012-01-13 00:06:01 -0800320 m_retxSeqs.insert (sequenceNumber);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800321 ScheduleNextPacket ();
322}
323
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700324} // namespace ndn
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800325} // namespace ns3