blob: 1b1971f9efd74563ea76c15d73a80d687796a2c5 [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
24#include "ns3/application.h"
25#include "ns3/log.h"
26#include "ns3/random-variable.h"
27#include "ns3/nstime.h"
28#include "ns3/event-id.h"
29#include "ns3/ptr.h"
30#include "ns3/simulator.h"
31#include "ns3/ccnx-interest-header.h"
32#include "ns3/ccnx-local-face.h"
33#include "ns3/ccnx-name-components.h"
34#include "ns3/packet.h"
35#include "ns3/boolean.h"
36#include "ns3/integer.h"
37#include "ns3/uinteger.h"
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070038#include "ns3/pointer.h"
39#include "ns3/traced-callback.h"
40#include "ns3/ccnx-header-helper.h"
41
42#include "ns3/packet.h"
43#include "ns3/header.h"
44
45namespace ns3
46{
47
48class CcnxConsumer: public Application
49{
50public:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070051 static TypeId GetTypeId ();
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070052
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070053 CcnxConsumer ();
54 virtual ~CcnxConsumer ();
55
56 void OnContentObject (const Ptr<const CcnxContentObjectHeader> &contentObject,
57 const Ptr<const Packet> &payload);
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070058
59protected:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070060 virtual void DoDispose (void);
61
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070062private:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070063 // inherited from Application base class.
64 virtual void StartApplication (void); // Called at time specified by Start
65 virtual void StopApplication (void); // Called at time specified by Stop
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070066
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070067 //helpers
68 void CancelEvents ();
69
70 // Event handlers
71 // void StartSending ();
72 // void StopSending ();
73 void SendPacket ();
74 //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070075
76private:
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070077 TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_interestsTrace;
78 TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_contentObjectsTrace;
79
80 Time m_offTime;
81 CcnxNameComponents m_interestName;
82 Time m_interestLifeTime;
83 int32_t m_minSuffixComponents;
84 int32_t m_maxSuffixComponents;
85 bool m_childSelector;
86 CcnxNameComponents m_exclude;
87 uint32_t m_initialNonce;
88
89 EventId m_sendEvent; // Eventid of pending "send packet" event
90 TypeId m_tid;
91 Ptr<CcnxLocalFace> m_face;
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070092};
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070093
94} // namespace ns3
95
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -070096#endif