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" |
Ilya Moiseenko | d26e682 | 2011-08-23 17:48:38 -0700 | [diff] [blame] | 30 | #include "ns3/ccnx-name-components.h" |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 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: |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 47 | static TypeId GetTypeId (void); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 49 | CcnxInterestSender (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 51 | virtual ~CcnxInterestSender (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 52 | |
| 53 | protected: |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 54 | virtual void DoDispose (void); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 55 | private: |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 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 |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 60 | //Time m_onTime; |
| 61 | Time m_offTime; |
| 62 | CcnxNameComponents m_interestName; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 63 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 64 | Time m_interestLifeTime; |
| 65 | int32_t m_minSuffixComponents; |
| 66 | int32_t m_maxSuffixComponents; |
| 67 | bool m_childSelector; |
| 68 | CcnxNameComponents m_exclude; |
| 69 | uint32_t m_initialNonce; |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 71 | //EventId m_startStopEvent; // Event id for next start or stop event |
| 72 | EventId m_sendEvent; // Eventid of pending "send packet" event |
| 73 | TypeId m_tid; |
| 74 | Ptr<CcnxLocalFace> m_face; |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 76 | //helpers |
| 77 | void CancelEvents (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 79 | void Construct (Ptr<Node> n, |
| 80 | std::string tid, |
| 81 | const Time& offtime, |
| 82 | Ptr<CcnxLocalFace> face, |
| 83 | Ptr<CcnxNameComponents> nameComponents, |
| 84 | const Time& lifetime, |
| 85 | const int32_t& minSuffixComponents, |
| 86 | const int32_t& maxSuffixComponents, |
| 87 | const bool childSelector, |
| 88 | Ptr<CcnxNameComponents> exclude, |
| 89 | const uint32_t& initialNonce |
| 90 | ); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 91 | |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 92 | // Event handlers |
| 93 | void StartSending (); |
| 94 | void StopSending (); |
| 95 | void SendPacket (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 96 | |
| 97 | private: |
Alexander Afanasyev | 152cf11 | 2011-08-29 17:58:32 -0700 | [diff] [blame] | 98 | void ScheduleNextTx (); |
| 99 | //void ScheduleStartEvent (); |
| 100 | //void ScheduleStopEvent (); |
| 101 | void ConnectionSucceeded (Ptr<Socket>); |
| 102 | void ConnectionFailed (Ptr<Socket>); |
| 103 | void Ignore (Ptr<Socket>); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 104 | |
| 105 | }; |
| 106 | } |