blob: 0d0536fad127c963f4ff3749ce8c55cff4c02ac0 [file] [log] [blame]
Alexander Afanasyev359bfb72012-01-09 18:42:50 -08001/* -*- 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 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 */
21
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070022#ifndef NDN_CONSUMER_WINDOW_H
23#define NDN_CONSUMER_WINDOW_H
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080024
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070025#include "ns3/ndnSIM/model/ndn-common.hpp"
26
Alexander Afanasyev0c395372014-12-20 15:54:02 -080027#include "ndn-consumer.hpp"
Alexander Afanasyeve4c2ece2012-01-11 10:44:40 -080028#include "ns3/traced-value.h"
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080029
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030namespace ns3 {
31namespace ndn {
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080032
33/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070034 * @ingroup ndn-apps
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035 * \brief Ndn application for sending out Interest packets (window-based)
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070036 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080037 * !!! ATTENTION !!! This is highly experimental and relies on experimental features of the
38 *simulator.
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070039 * Behavior may be unpredictable if used incorrectly.
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080040 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041class ConsumerWindow : public Consumer {
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080042public:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 static TypeId
44 GetTypeId();
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080045
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080046 /**
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080047 * \brief Default constructor
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080048 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 ConsumerWindow();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080050
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051 // From App
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080052 // virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070053 // OnInterest (const shared_ptr<const Interest> &interest);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080054
55 virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070056 OnNack(shared_ptr<const Interest> interest);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080057
58 virtual void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070059 OnData(shared_ptr<const Data> contentObject);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080060
61 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062 OnTimeout(uint32_t sequenceNumber);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080063
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070064 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 WillSendOutInterest(uint32_t sequenceNumber);
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070066
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080067protected:
68 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
70 * protocol
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080071 */
72 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 ScheduleNextPacket();
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080074
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080075private:
76 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080077 SetWindow(uint32_t window);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080078
79 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 GetWindow() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080081
82 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 SetPayloadSize(uint32_t payload);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080084
85 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 GetPayloadSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080087
88 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 GetMaxSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080090
91 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080092 SetMaxSize(double size);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080093
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070094 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 GetSeqMax() const;
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070096
97 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 SetSeqMax(uint32_t seqMax);
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070099
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -0700100private:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800101 uint32_t m_payloadSize; // expected payload size
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800102 double m_maxSize; // max size to request
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800103
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -0800104 uint32_t m_initialWindow;
105 bool m_setInitialWindowOnTimeout;
106
Alexander Afanasyeve4c2ece2012-01-11 10:44:40 -0800107 TracedValue<uint32_t> m_window;
Alexander Afanasyev06b42ec2012-01-11 19:05:36 -0800108 TracedValue<uint32_t> m_inFlight;
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800109};
110
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700111} // namespace ndn
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800112} // namespace ns3
113
114#endif