Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 1 | /* -*- 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" |
| 38 | #include "ns3/random-variable.h" |
| 39 | #include <limits> |
| 40 | #include "ns3/pointer.h" |
| 41 | #include "ns3/traced-callback.h" |
| 42 | #include "ns3/ccnx-header-helper.h" |
| 43 | |
| 44 | #include "ns3/packet.h" |
| 45 | #include "ns3/header.h" |
| 46 | |
| 47 | namespace ns3 |
| 48 | { |
| 49 | |
| 50 | class CcnxConsumer: public Application |
| 51 | { |
| 52 | public: |
| 53 | static TypeId GetTypeId (void); |
| 54 | |
| 55 | CcnxConsumer (); |
| 56 | |
| 57 | virtual ~CcnxConsumer (); |
| 58 | |
| 59 | void HandlePacket (const Ptr<CcnxFace> &face, const Ptr<const Packet> &packet); |
| 60 | |
| 61 | protected: |
| 62 | virtual void DoDispose (void); |
| 63 | private: |
| 64 | // inherited from Application base class. |
| 65 | virtual void StartApplication (void); // Called at time specified by Start |
| 66 | virtual void StopApplication (void); // Called at time specified by Stop |
| 67 | |
| 68 | Time m_offTime; |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 69 | CcnxNameComponents m_interestName; |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 70 | Time m_interestLifeTime; |
| 71 | int32_t m_minSuffixComponents; |
| 72 | int32_t m_maxSuffixComponents; |
| 73 | bool m_childSelector; |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 74 | CcnxNameComponents m_exclude; |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 75 | uint32_t m_initialNonce; |
| 76 | |
| 77 | EventId m_sendEvent; // Eventid of pending "send packet" event |
| 78 | TypeId m_tid; |
| 79 | Ptr<CcnxLocalFace> m_face; |
| 80 | |
| 81 | //helpers |
| 82 | void CancelEvents (); |
| 83 | |
| 84 | void Construct (Ptr<Node> n, |
| 85 | std::string tid, |
| 86 | const Time& offtime, |
| 87 | Ptr<CcnxLocalFace> face, |
| 88 | Ptr<CcnxNameComponents> nameComponents, |
| 89 | const Time& lifetime, |
| 90 | const int32_t& minSuffixComponents, |
| 91 | const int32_t& maxSuffixComponents, |
| 92 | const bool childSelector, |
| 93 | Ptr<CcnxNameComponents> exclude, |
| 94 | const uint32_t& initialNonce |
| 95 | ); |
| 96 | |
| 97 | // Event handlers |
| 98 | void StartSending (); |
| 99 | void StopSending (); |
| 100 | void SendPacket (); |
| 101 | //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler; |
| 102 | |
| 103 | private: |
| 104 | void ScheduleNextTx (); |
| 105 | //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler; |
| 106 | |
| 107 | TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_interestsTrace; |
| 108 | TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_contentObjectsTrace; |
| 109 | }; |
| 110 | } |
| 111 | #endif |