Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -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 | #include "ns3/application.h" |
| 22 | #include "ns3/log.h" |
| 23 | #include "ns3/random-variable.h" |
| 24 | #include "ns3/nstime.h" |
| 25 | #include "ns3/event-id.h" |
| 26 | #include "ns3/ptr.h" |
| 27 | #include "ns3/simulator.h" |
| 28 | #include "ns3/ccnx-interest-header.h" |
| 29 | #include "ns3/ccnx-local-face.h" |
| 30 | #include "ns3/name-components.h" |
| 31 | #include "ns3/packet.h" |
| 32 | #include "ns3/boolean.h" |
| 33 | #include "ns3/integer.h" |
| 34 | #include "ns3/uinteger.h" |
| 35 | #include "ns3/random-variable.h" |
| 36 | #include <limits> |
| 37 | #include "ns3/pointer.h" |
| 38 | |
| 39 | namespace ns3 |
| 40 | { |
| 41 | |
| 42 | class Socket; |
| 43 | |
| 44 | class CcnxInterestSender: public Application |
| 45 | { |
| 46 | public: |
| 47 | static TypeId GetTypeId (void); |
| 48 | |
| 49 | CcnxInterestSender (); |
| 50 | |
| 51 | virtual ~CcnxInterestSender (); |
| 52 | |
| 53 | protected: |
| 54 | virtual void DoDispose (void); |
| 55 | private: |
| 56 | // inherited from Application base class. |
| 57 | virtual void StartApplication (void); // Called at time specified by Start |
| 58 | virtual void StopApplication (void); // Called at time specified by Stop |
| 59 | |
| 60 | //Time m_onTime; |
| 61 | Time m_offTime; |
Ilya Moiseenko | 2bd1bc3 | 2011-08-23 16:01:35 -0700 | [diff] [blame] | 62 | Ptr<CcnxNameComponents> m_interestName; |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 63 | Time m_interestLifeTime; |
| 64 | int32_t m_minSuffixComponents; |
| 65 | int32_t m_maxSuffixComponents; |
| 66 | bool m_childSelector; |
Ilya Moiseenko | 2bd1bc3 | 2011-08-23 16:01:35 -0700 | [diff] [blame] | 67 | Ptr<CcnxNameComponents> m_exclude; |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 68 | uint32_t m_initialNonce; |
| 69 | |
| 70 | //EventId m_startStopEvent; // Event id for next start or stop event |
| 71 | EventId m_sendEvent; // Eventid of pending "send packet" event |
| 72 | TypeId m_tid; |
| 73 | Ptr<CcnxLocalFace> m_face; |
| 74 | |
| 75 | //helpers |
| 76 | void CancelEvents (); |
| 77 | |
| 78 | void Construct (Ptr<Node> n, |
| 79 | std::string tid, |
| 80 | const Time& offtime, |
Ilya Moiseenko | 2bd1bc3 | 2011-08-23 16:01:35 -0700 | [diff] [blame] | 81 | Ptr<CcnxNameComponents> nameComponents, |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 82 | const Time& lifetime, |
| 83 | const int32_t& minSuffixComponents, |
| 84 | const int32_t& maxSuffixComponents, |
| 85 | const bool childSelector, |
Ilya Moiseenko | 2bd1bc3 | 2011-08-23 16:01:35 -0700 | [diff] [blame] | 86 | Ptr<CcnxNameComponents> exclude, |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 87 | const uint32_t& initialNonce |
| 88 | ); |
| 89 | |
| 90 | // Event handlers |
| 91 | void StartSending (); |
| 92 | void StopSending (); |
| 93 | void SendPacket (); |
| 94 | |
| 95 | private: |
| 96 | void ScheduleNextTx (); |
| 97 | //void ScheduleStartEvent (); |
| 98 | //void ScheduleStopEvent (); |
| 99 | void ConnectionSucceeded (Ptr<Socket>); |
| 100 | void ConnectionFailed (Ptr<Socket>); |
| 101 | void Ignore (Ptr<Socket>); |
| 102 | |
| 103 | }; |
| 104 | } |