blob: b9933f8375d9afb301a2b4c289a8175fd708e44f [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 OnData(shared_ptr<const Data> contentObject);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080054
55 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080056 OnTimeout(uint32_t sequenceNumber);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080057
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070058 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059 WillSendOutInterest(uint32_t sequenceNumber);
Alexander Afanasyev79b2fb32013-04-12 11:24:55 -070060
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080061protected:
62 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
64 * protocol
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080065 */
66 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 ScheduleNextPacket();
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080068
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080069private:
70 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 SetWindow(uint32_t window);
Alexander Afanasyev359bfb72012-01-09 18:42:50 -080072
73 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 GetWindow() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080075
76 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080077 SetPayloadSize(uint32_t payload);
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080078
79 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 GetPayloadSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080081
82 double
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 GetMaxSize() const;
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080084
85 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 SetMaxSize(double size);
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080087
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070088 uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 GetSeqMax() const;
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070090
91 void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080092 SetSeqMax(uint32_t seqMax);
Alexander Afanasyevfdd45412013-05-16 22:24:33 -070093
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070094private:
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080095 uint32_t m_payloadSize; // expected payload size
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 double m_maxSize; // max size to request
Alexander Afanasyevb7ad2322012-01-17 22:54:49 -080097
Alexander Afanasyevd1f7c7b2013-01-31 13:34:37 -080098 uint32_t m_initialWindow;
99 bool m_setInitialWindowOnTimeout;
100
Alexander Afanasyeve4c2ece2012-01-11 10:44:40 -0800101 TracedValue<uint32_t> m_window;
Alexander Afanasyev06b42ec2012-01-11 19:05:36 -0800102 TracedValue<uint32_t> m_inFlight;
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800103};
104
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700105} // namespace ndn
Alexander Afanasyev359bfb72012-01-09 18:42:50 -0800106} // namespace ns3
107
108#endif