blob: 923cae0f9edc4c28490c96000531a690057c21a2 [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
Alexander Afanasyev0c395372014-12-20 15:54:02 -080025#include "ndn-consumer.hpp"
Alexander Afanasyeve4c2ece2012-01-11 10:44:40 -080026#include "ns3/traced-value.h"
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080027
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028namespace ns3 {
29namespace ndn {
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080030
31/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070032 * @ingroup ndn-apps
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033 * \brief Ndn application for sending out Interest packets (window-based)
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070034 *
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035 * !!! ATTENTION !!! This is highly experimental and relies on experimental features of the
36 *simulator.
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070037 * Behavior may be unpredictable if used incorrectly.
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080038 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080039class ConsumerWindow : public Consumer {
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080040public:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041 static TypeId
42 GetTypeId();
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080043
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080044 /**
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080045 * \brief Default constructor
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080046 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047 ConsumerWindow();
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080048
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070049 // From App
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080050 // virtual void
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070051 // OnInterest (const Ptr<const Interest> &interest);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080052
53 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 OnNack(Ptr<const Interest> interest);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080055
56 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 OnData(Ptr<const Data> contentObject);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080058
59 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 OnTimeout(uint32_t sequenceNumber);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080061
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070062 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 WillSendOutInterest(uint32_t sequenceNumber);
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070064
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080065protected:
66 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
68 * protocol
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080069 */
70 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 ScheduleNextPacket();
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080072
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080073private:
74 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 SetWindow(uint32_t window);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080076
77 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080078 GetWindow() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080079
80 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 SetPayloadSize(uint32_t payload);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080082
83 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 GetPayloadSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080085
86 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 GetMaxSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080088
89 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 SetMaxSize(double size);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080091
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070092 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 GetSeqMax() const;
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070094
95 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 SetSeqMax(uint32_t seqMax);
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070097
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070098private:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080099 uint32_t m_payloadSize; // expected payload size
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800100 double m_maxSize; // max size to request
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -0800101
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -0800102 uint32_t m_initialWindow;
103 bool m_setInitialWindowOnTimeout;
104
Alexander Afanasyeve4c2ece2012-01-11 10:44:40 -0800105 TracedValue<uint32_t> m_window;
Alexander Afanasyev06b42ec2012-01-11 19:05:36 -0800106 TracedValue<uint32_t> m_inFlight;
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800107};
108
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700109} // namespace ndn
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800110} // namespace ns3
111
112#endif