blob: ad8de2802bc689139b06acb9a40fad46d6cd6e0d [file] [log] [blame]
Ilya Moiseenkoc706f262011-08-22 19:50:49 -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#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 Moiseenkod26e6822011-08-23 17:48:38 -070030#include "ns3/ccnx-name-components.h"
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070031#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
39namespace ns3
40{
41
42class Socket;
43
44class CcnxInterestSender: public Application
45{
46public:
Alexander Afanasyev152cf112011-08-29 17:58:32 -070047 static TypeId GetTypeId (void);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070048
Alexander Afanasyev152cf112011-08-29 17:58:32 -070049 CcnxInterestSender ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070050
Alexander Afanasyev152cf112011-08-29 17:58:32 -070051 virtual ~CcnxInterestSender ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070052
53protected:
Alexander Afanasyev152cf112011-08-29 17:58:32 -070054 virtual void DoDispose (void);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070055private:
Alexander Afanasyev152cf112011-08-29 17:58:32 -070056 // 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 Moiseenkoc706f262011-08-22 19:50:49 -070059
Alexander Afanasyev152cf112011-08-29 17:58:32 -070060 //Time m_onTime;
61 Time m_offTime;
62 CcnxNameComponents m_interestName;
Alexander Afanasyev7fd74f92011-08-25 19:40:17 -070063
Alexander Afanasyev152cf112011-08-29 17:58:32 -070064 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 Moiseenkoc706f262011-08-22 19:50:49 -070070
Alexander Afanasyev152cf112011-08-29 17:58:32 -070071 //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 Moiseenkoc706f262011-08-22 19:50:49 -070075
Alexander Afanasyev152cf112011-08-29 17:58:32 -070076 //helpers
77 void CancelEvents ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070078
Alexander Afanasyev152cf112011-08-29 17:58:32 -070079 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 Moiseenkoc706f262011-08-22 19:50:49 -070091
Alexander Afanasyev152cf112011-08-29 17:58:32 -070092 // Event handlers
93 void StartSending ();
94 void StopSending ();
95 void SendPacket ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070096
97private:
Alexander Afanasyev152cf112011-08-29 17:58:32 -070098 void ScheduleNextTx ();
99 //void ScheduleStartEvent ();
100 //void ScheduleStopEvent ();
101 void ConnectionSucceeded (Ptr<Socket>);
102 void ConnectionFailed (Ptr<Socket>);
103 void Ignore (Ptr<Socket>);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700104
105};
106}