blob: 256edd84c31040aca84faa41b5a3d0103fa7de76 [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:
47 static TypeId GetTypeId (void);
48
49 CcnxInterestSender ();
50
51 virtual ~CcnxInterestSender ();
52
53protected:
54 virtual void DoDispose (void);
55private:
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;
Alexander Afanasyev7fd74f92011-08-25 19:40:17 -070062 CcnxNameComponents m_interestName;
63
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070064 Time m_interestLifeTime;
65 int32_t m_minSuffixComponents;
66 int32_t m_maxSuffixComponents;
67 bool m_childSelector;
Alexander Afanasyev7fd74f92011-08-25 19:40:17 -070068 CcnxNameComponents m_exclude;
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070069 uint32_t m_initialNonce;
70
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;
75
76 //helpers
77 void CancelEvents ();
78
79 void Construct (Ptr<Node> n,
80 std::string tid,
81 const Time& offtime,
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070082 Ptr<CcnxLocalFace> face,
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070083 Ptr<CcnxNameComponents> nameComponents,
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070084 const Time& lifetime,
85 const int32_t& minSuffixComponents,
86 const int32_t& maxSuffixComponents,
87 const bool childSelector,
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070088 Ptr<CcnxNameComponents> exclude,
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070089 const uint32_t& initialNonce
90 );
91
92 // Event handlers
93 void StartSending ();
94 void StopSending ();
95 void SendPacket ();
96
97private:
98 void ScheduleNextTx ();
99 //void ScheduleStartEvent ();
100 //void ScheduleStopEvent ();
101 void ConnectionSucceeded (Ptr<Socket>);
102 void ConnectionFailed (Ptr<Socket>);
103 void Ignore (Ptr<Socket>);
104
105};
106}