blob: d110978bbe83df1b73679ed1714c25f69732a88c [file] [log] [blame]
Alexander Afanasyev19426ef2011-11-23 20:55:28 -08001// /* -*- 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// */
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070020
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080021// #include "ccnx-interest-sender.h"
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070022
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080023// NS_LOG_COMPONENT_DEFINE ("CcnxInterestSender");
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070024
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080025// namespace ns3
26// {
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070027
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080028// NS_OBJECT_ENSURE_REGISTERED (CcnxInterestSender);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070029
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080030// TypeId
31// CcnxInterestSender::GetTypeId (void)
32// {
33// static TypeId tid = TypeId ("ns3::CcnxInterestSender")
34// .SetParent<Application> ()
35// .AddConstructor<CcnxInterestSender> ()
36// .AddAttribute ("OffTime", "Time interval between packets",
37// TimeValue (Seconds (0.1)),
38// MakeTimeAccessor (&CcnxInterestSender::m_offTime),
39// MakeTimeChecker ())
40// // Alex: this is incorrect. SetNode call is not called if face is created using this accessor
41// // .AddAttribute ("Face","Local face to be used",
42// // PointerValue (CreateObject<CcnxLocalFace> ()),
43// // MakePointerAccessor (&CcnxInterestSender::m_face),
44// // MakePointerChecker<CcnxLocalFace> ())
45// .AddAttribute ("NameComponents","CcnxName of the Interest (use CcnxNameComponents)",
46// CcnxNameComponentsValue (CcnxNameComponents (/* root */)),
47// MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_interestName),
48// MakeCcnxNameComponentsChecker ())
49// .AddAttribute ("LifeTime", "LifeTime fo interest packet",
50// TimeValue (Seconds (4.0)),
51// MakeTimeAccessor (&CcnxInterestSender::m_interestLifeTime),
52// MakeTimeChecker ())
53// .AddAttribute ("MinSuffixComponents", "MinSuffixComponents",
54// IntegerValue(-1),
55// MakeIntegerAccessor(&CcnxInterestSender::m_minSuffixComponents),
56// MakeIntegerChecker<int32_t>())
57// .AddAttribute ("MaxSuffixComponents", "MaxSuffixComponents",
58// IntegerValue(-1),
59// MakeIntegerAccessor(&CcnxInterestSender::m_maxSuffixComponents),
60// MakeIntegerChecker<int32_t>())
61// .AddAttribute ("ChildSelector", "ChildSelector",
62// BooleanValue(false),
63// MakeBooleanAccessor(&CcnxInterestSender::m_childSelector),
64// MakeBooleanChecker())
65// .AddAttribute ("Exclude","only simple name matching is supported (use CcnxNameComponents)",
66// CcnxNameComponentsValue (CcnxNameComponents(/* root */)),
67// MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_exclude),
68// MakeCcnxNameComponentsChecker ())
69// .AddAttribute ("Initial Nonce", "If 0 then nonce is not used",
70// UintegerValue(1),
71// MakeUintegerAccessor(&CcnxInterestSender::m_initialNonce),
72// MakeUintegerChecker<uint32_t>())
73// ;
74// /*
75// .AddAttribute ("NoiseModel",
76// "A pointer to the model of the channel ambient noise.",
77// PointerValue (CreateObject<UanNoiseModelDefault> ()),
78// MakePointerAccessor (&UanChannel::m_noise),
79// MakePointerChecker<UanNoiseModel> ())*/
80// return tid;
81// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070082
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080083// CcnxInterestSender::CcnxInterestSender ()
84// {
85// NS_LOG_FUNCTION_NOARGS ();
86// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070087
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080088// CcnxInterestSender::~CcnxInterestSender()
89// {
90// NS_LOG_FUNCTION_NOARGS ();
91// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070092
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080093// void
94// CcnxInterestSender::DoDispose (void)
95// {
96// NS_LOG_FUNCTION_NOARGS ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -070097
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080098// Application::DoDispose ();
99// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700100
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800101// // Application Methods
102// void
103// CcnxInterestSender::StartApplication () // Called at time specified by Start
104// {
105// NS_LOG_FUNCTION_NOARGS ();
106// ScheduleNextTx();
107// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700108
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800109// void
110// CcnxInterestSender::StopApplication () // Called at time specified by Stop
111// {
112// NS_LOG_FUNCTION_NOARGS ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700113
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800114// CancelEvents ();
115// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700116
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800117// void
118// CcnxInterestSender::CancelEvents ()
119// {
120// NS_LOG_FUNCTION_NOARGS ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700121
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800122// Simulator::Cancel (m_sendEvent);
123// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700124
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800125// void
126// CcnxInterestSender::ScheduleNextTx ()
127// {
128// NS_LOG_FUNCTION_NOARGS ();
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700129
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800130// Time nextTime = Seconds(m_offTime);
131// m_sendEvent = Simulator::Schedule (nextTime, &CcnxInterestSender::SendPacket, this);
132// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700133
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800134// void
135// CcnxInterestSender::SendPacket ()
136// {
137// NS_LOG_FUNCTION_NOARGS ();
138// // NS_LOG_INFO ("Sending Interest at " << Simulator::Now ());
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700139
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800140// uint32_t randomNonce = UniformVariable().GetInteger(1, std::numeric_limits<uint32_t>::max ());
141// CcnxInterestHeader interestHeader;
142// interestHeader.SetNonce(randomNonce);
143// //const Ptr<CcnxNameComponents> name = Create<CcnxNameComponents>(m_interestName);
144// interestHeader.SetName(Create<CcnxNameComponents> (m_interestName)); //making a copy of name
145// interestHeader.SetInterestLifetime(m_interestLifeTime);
146// interestHeader.SetChildSelector(m_childSelector);
147// //const Ptr<CcnxNameComponents> exclude = Create<CcnxNameComponents>(m_exclude);
148// interestHeader.SetExclude(Create<CcnxNameComponents> (m_exclude));
149// interestHeader.SetMaxSuffixComponents(m_maxSuffixComponents);
150// interestHeader.SetMinSuffixComponents(m_minSuffixComponents);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700151
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800152// Ptr<Packet> packet = Create<Packet> ();
153// packet->AddHeader (interestHeader);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700154
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800155// m_face->Send(packet);
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700156
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800157// ScheduleNextTx();
158// }
Ilya Moiseenkoc706f262011-08-22 19:50:49 -0700159
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800160// }