Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [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 | // */ |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 21 | // #include "ccnx-interest-sender.h" |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 23 | // NS_LOG_COMPONENT_DEFINE ("CcnxInterestSender"); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 25 | // namespace ns3 |
| 26 | // { |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 27 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 28 | // NS_OBJECT_ENSURE_REGISTERED (CcnxInterestSender); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 30 | // 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 Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 83 | // CcnxInterestSender::CcnxInterestSender () |
| 84 | // { |
| 85 | // NS_LOG_FUNCTION_NOARGS (); |
| 86 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 87 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 88 | // CcnxInterestSender::~CcnxInterestSender() |
| 89 | // { |
| 90 | // NS_LOG_FUNCTION_NOARGS (); |
| 91 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 92 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 93 | // void |
| 94 | // CcnxInterestSender::DoDispose (void) |
| 95 | // { |
| 96 | // NS_LOG_FUNCTION_NOARGS (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 97 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 98 | // Application::DoDispose (); |
| 99 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 100 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 101 | // // Application Methods |
| 102 | // void |
| 103 | // CcnxInterestSender::StartApplication () // Called at time specified by Start |
| 104 | // { |
| 105 | // NS_LOG_FUNCTION_NOARGS (); |
| 106 | // ScheduleNextTx(); |
| 107 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 108 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 109 | // void |
| 110 | // CcnxInterestSender::StopApplication () // Called at time specified by Stop |
| 111 | // { |
| 112 | // NS_LOG_FUNCTION_NOARGS (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 113 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 114 | // CancelEvents (); |
| 115 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 116 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 117 | // void |
| 118 | // CcnxInterestSender::CancelEvents () |
| 119 | // { |
| 120 | // NS_LOG_FUNCTION_NOARGS (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 121 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 122 | // Simulator::Cancel (m_sendEvent); |
| 123 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 124 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 125 | // void |
| 126 | // CcnxInterestSender::ScheduleNextTx () |
| 127 | // { |
| 128 | // NS_LOG_FUNCTION_NOARGS (); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 129 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 130 | // Time nextTime = Seconds(m_offTime); |
| 131 | // m_sendEvent = Simulator::Schedule (nextTime, &CcnxInterestSender::SendPacket, this); |
| 132 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 133 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 134 | // void |
| 135 | // CcnxInterestSender::SendPacket () |
| 136 | // { |
| 137 | // NS_LOG_FUNCTION_NOARGS (); |
| 138 | // // NS_LOG_INFO ("Sending Interest at " << Simulator::Now ()); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 139 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 140 | // 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 Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 151 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 152 | // Ptr<Packet> packet = Create<Packet> (); |
| 153 | // packet->AddHeader (interestHeader); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 154 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 155 | // m_face->Send(packet); |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 156 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 157 | // ScheduleNextTx(); |
| 158 | // } |
Ilya Moiseenko | c706f26 | 2011-08-22 19:50:49 -0700 | [diff] [blame] | 159 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 160 | // } |