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" |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 38 | #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 | |
| 45 | namespace ns3 |
| 46 | { |
| 47 | |
| 48 | class CcnxConsumer: public Application |
| 49 | { |
| 50 | public: |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 51 | static TypeId GetTypeId (); |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 53 | CcnxConsumer (); |
| 54 | virtual ~CcnxConsumer (); |
| 55 | |
| 56 | void OnContentObject (const Ptr<const CcnxContentObjectHeader> &contentObject, |
| 57 | const Ptr<const Packet> &payload); |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 58 | |
| 59 | protected: |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 60 | virtual void DoDispose (void); |
| 61 | |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 62 | private: |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 63 | // 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 Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 67 | //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 Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 75 | |
| 76 | private: |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 77 | 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 Moiseenko | 82b8eea | 2011-11-02 23:08:47 -0700 | [diff] [blame] | 92 | |
| 93 | uint32_t m_seq; |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 94 | }; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 95 | |
| 96 | } // namespace ns3 |
| 97 | |
Ilya Moiseenko | 8196d2e | 2011-08-29 13:03:22 -0700 | [diff] [blame] | 98 | #endif |