blob: 792c82946238c7d2b4c74e4ef11483aeb8ae2b62 [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
21#ifndef CCNX_CONSUMER_H
22#define CCNX_CONSUMER_H
23
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080024#include "ccnx-app.h"
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080025#include "ns3/random-variable.h"
26#include "ns3/ccnx-name-components.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070027
28namespace ns3
29{
30
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080031class CcnxConsumer: public CcnxApp
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070032{
33public:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070034 static TypeId GetTypeId ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070035
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070036 CcnxConsumer ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070037
38 void OnContentObject (const Ptr<const CcnxContentObjectHeader> &contentObject,
39 const Ptr<const Packet> &payload);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080040
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070041protected:
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080042 // from CcnxApp
43 virtual void
44 StartApplication ();
45
46 virtual void
47 StopApplication ();
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070048
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070049private:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070050 //helpers
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070051 void SendPacket ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070052
53private:
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080054 UniformVariable m_rand;
55 uint32_t m_seq;
56 EventId m_sendEvent; // Eventid of pending "send packet" event
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070057
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080058 Time m_offTime;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070059 CcnxNameComponents m_interestName;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080060 Time m_interestLifeTime;
61 int32_t m_minSuffixComponents;
62 int32_t m_maxSuffixComponents;
63 bool m_childSelector;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070064 CcnxNameComponents m_exclude;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070065};
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070066
67} // namespace ns3
68
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070069#endif