blob: 55049dd88eeaa65ecaee7ef4d4a31c36ff06231e [file] [log] [blame]
Ilya Moiseenko8196d2e2011-08-29 13:03:22 -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#ifndef CCNX_PRODUCER_H
22#define CCNX_PRODUCER_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"
38#include "ns3/random-variable.h"
39#include <limits>
40#include "ns3/pointer.h"
41#include "ns3/traced-callback.h"
42#include "ns3/ccnx-header-helper.h"
43
44#include "ns3/packet.h"
45#include "ns3/header.h"
46#include "ns3/ccnx.h"
47#include "ns3/ccnx-content-object-header.h"
48
49namespace ns3
50{
51
52class CcnxProducer: public Application
53{
54public:
55 static TypeId GetTypeId (void);
56
57 CcnxProducer ();
58
59 virtual ~CcnxProducer ();
60
61 void HandlePacket (const Ptr<CcnxFace> &face, const Ptr<const Packet> &packet);
62 uint32_t GetStoreCapacity();
63 void AddContentStoreEntry (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet);
64
65protected:
66 virtual void DoDispose (void);
67private:
68 // inherited from Application base class.
69 virtual void StartApplication (void); // Called at time specified by Start
70 virtual void StopApplication (void); // Called at time specified by Stop
71
72 Ptr<Ccnx> m_ccnx;
73 Time m_offTime;
74 //Ptr<CcnxNameComponents> m_interestName;
75 //Time m_interestLifeTime;
76 //int32_t m_minSuffixComponents;
77 //int32_t m_maxSuffixComponents;
78 //bool m_childSelector;
79 //Ptr<CcnxNameComponents> m_exclude;
80 //uint32_t m_initialNonce;
81
82 //EventId m_sendEvent; // Eventid of pending "send packet" event
83 TypeId m_tid;
84 Ptr<CcnxLocalFace> m_face;
85
86 uint32_t m_storeCapacity;
87
88 //helpers
89 void CancelEvents ();
90
91 void Construct (Ptr<Node> n,
92 std::string tid,
93 const Time& offtime,
94 Ptr<CcnxLocalFace> face,
95 Ptr<CcnxNameComponents> nameComponents,
96 const Time& lifetime,
97 const int32_t& minSuffixComponents,
98 const int32_t& maxSuffixComponents,
99 const bool childSelector,
100 Ptr<CcnxNameComponents> exclude,
101 const uint32_t& initialNonce
102 );
103
104 // Event handlers
105 void StartSending ();
106 void StopSending ();
107 void SendPacket ();
108 //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler;
109
110private:
111 void ScheduleNextTx ();
112 //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler;
113
114 TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_interestsTrace;
115 TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_contentObjectsTrace;
116};
117}
118#endif