Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include "per-fib-limits.h" |
| 22 | |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 23 | #include "ns3/ndn-l3-protocol.h" |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 24 | #include "ns3/ndn-interest-header.h" |
| 25 | #include "ns3/ndn-content-object-header.h" |
| 26 | #include "ns3/ndn-pit.h" |
| 27 | #include "ns3/ndn-pit-entry.h" |
| 28 | |
| 29 | #include "ns3/assert.h" |
| 30 | #include "ns3/log.h" |
| 31 | #include "ns3/simulator.h" |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 32 | #include "ns3/random-variable.h" |
Alexander Afanasyev | ccbd834 | 2012-08-16 16:54:39 -0700 | [diff] [blame] | 33 | #include "ns3/double.h" |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 34 | |
| 35 | #include <boost/foreach.hpp> |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 36 | #include <boost/lexical_cast.hpp> |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 37 | #include <boost/lambda/lambda.hpp> |
| 38 | #include <boost/lambda/bind.hpp> |
| 39 | namespace ll = boost::lambda; |
| 40 | |
| 41 | NS_LOG_COMPONENT_DEFINE ("ndn.fw.PerFibLimits"); |
| 42 | |
| 43 | namespace ns3 { |
| 44 | namespace ndn { |
| 45 | namespace fw { |
| 46 | |
| 47 | NS_OBJECT_ENSURE_REGISTERED (PerFibLimits); |
| 48 | |
| 49 | TypeId |
| 50 | PerFibLimits::GetTypeId (void) |
| 51 | { |
| 52 | static TypeId tid = TypeId ("ns3::ndn::fw::PerFibLimits") |
| 53 | .SetGroupName ("Ndn") |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 54 | .SetParent <super> () |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 55 | .AddConstructor <PerFibLimits> () |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 56 | |
Alexander Afanasyev | 0f83f90 | 2012-09-03 13:30:12 -0700 | [diff] [blame] | 57 | .AddAttribute ("QueueDropNotifications", "Enable explicit notifications (using nacks) that packet was dropped from queue", |
| 58 | BooleanValue (true), |
| 59 | MakeBooleanAccessor (&PerFibLimits::m_queueDropNotifications), |
| 60 | MakeBooleanChecker ()) |
Alexander Afanasyev | caeade2 | 2012-09-04 16:31:12 -0700 | [diff] [blame] | 61 | |
| 62 | .AddAttribute ("WeightedRobin", "Enable weighted round robin for output queues", |
| 63 | BooleanValue (false), |
| 64 | MakeBooleanAccessor (&PerFibLimits::m_weightedRoundRobin), |
| 65 | MakeBooleanChecker ()) |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 66 | ; |
| 67 | return tid; |
| 68 | } |
| 69 | |
| 70 | PerFibLimits::PerFibLimits () |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | PerFibLimits::DoDispose () |
| 76 | { |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 77 | m_announceEvent.Cancel (); |
| 78 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 79 | super::DoDispose (); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 82 | void |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 83 | PerFibLimits::NotifyNewAggregate () |
| 84 | { |
| 85 | super::NotifyNewAggregate (); |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | void |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 89 | PerFibLimits::RemoveFace (Ptr<Face> face) |
| 90 | { |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 91 | for (PitQueueMap::iterator item = m_pitQueues.begin (); |
| 92 | item != m_pitQueues.end (); |
| 93 | item ++) |
| 94 | { |
| 95 | item->second.Remove (face); |
| 96 | } |
| 97 | m_pitQueues.erase (face); |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 98 | |
| 99 | super::RemoveFace (face); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 102 | bool |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 103 | PerFibLimits::TrySendOutInterest (Ptr<Face> inFace, |
| 104 | Ptr<Face> outFace, |
| 105 | Ptr<const InterestHeader> header, |
| 106 | Ptr<const Packet> origPacket, |
| 107 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 108 | { |
| 109 | NS_LOG_FUNCTION (this << pitEntry->GetPrefix ()); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 110 | // totally override all (if any) parent processing |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 111 | |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 112 | if (pitEntry->GetFwTag<PitQueueTag> () != boost::shared_ptr<PitQueueTag> ()) |
| 113 | { |
| 114 | pitEntry->UpdateLifetime (Seconds (0.10)); |
| 115 | NS_LOG_DEBUG ("Packet is still in queue and is waiting for its processing"); |
| 116 | return true; // already in the queue |
| 117 | } |
| 118 | |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 119 | if (header->GetInterestLifetime () < Seconds (0.1)) |
| 120 | { |
Alexander Afanasyev | caeade2 | 2012-09-04 16:31:12 -0700 | [diff] [blame] | 121 | NS_LOG_DEBUG( "Interest lifetime is so short? [" << header->GetInterestLifetime ().ToDouble (Time::S) << "s]"); |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 122 | } |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 123 | |
| 124 | pit::Entry::out_iterator outgoing = |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 125 | pitEntry->GetOutgoing ().find (outFace); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 126 | |
| 127 | if (outgoing != pitEntry->GetOutgoing ().end ()) |
| 128 | { |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 129 | // just suppress without any other action |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 130 | return false; |
| 131 | } |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 132 | |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 133 | NS_LOG_DEBUG ("Limit: " << outFace->GetLimits ().m_curMaxLimit << ", outstanding: " << outFace->GetLimits ().m_outstanding); |
| 134 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 135 | if (outFace->GetLimits ().IsBelowLimit ()) |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 136 | { |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 137 | pitEntry->AddOutgoing (outFace); |
| 138 | |
| 139 | //transmission |
| 140 | Ptr<Packet> packetToSend = origPacket->Copy (); |
| 141 | outFace->Send (packetToSend); |
| 142 | |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 143 | DidSendOutInterest (outFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 144 | return true; |
| 145 | } |
| 146 | else |
| 147 | { |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 148 | NS_LOG_DEBUG ("Face limit for " << header->GetName ()); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 149 | } |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 150 | |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 151 | // hack |
| 152 | // offset lifetime, so we don't keep entries in queue for too long |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 153 | // pitEntry->OffsetLifetime (Seconds (0.010) + ); |
| 154 | // std::cerr << (pitEntry->GetExpireTime () - Simulator::Now ()).ToDouble (Time::S) * 1000 << "ms" << std::endl; |
| 155 | pitEntry->OffsetLifetime (Seconds (-pitEntry->GetInterest ()->GetInterestLifetime ().ToDouble (Time::S))); |
| 156 | pitEntry->UpdateLifetime (Seconds (0.10)); |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 157 | |
Alexander Afanasyev | caeade2 | 2012-09-04 16:31:12 -0700 | [diff] [blame] | 158 | double weight = 1.0; |
| 159 | if (m_weightedRoundRobin) |
| 160 | { |
| 161 | // const ndnSIM::LoadStatsFace &stats = GetStatsTree ()[header->GetName ()].incoming ().find (inFace)->second; |
| 162 | const ndnSIM::LoadStatsFace &stats = GetStatsTree ()["/"].incoming ().find (inFace)->second; |
| 163 | weight = std::min (1.0, stats.GetSatisfiedRatio ().get<0> ()); |
| 164 | // std::cout << ">>>> stats: " << stats << std::endl; |
| 165 | } |
| 166 | bool enqueued = m_pitQueues[outFace].Enqueue (inFace, pitEntry, weight); |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 167 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 168 | if (enqueued) |
| 169 | { |
| 170 | NS_LOG_DEBUG ("PIT entry is enqueued for delayed processing. Telling that we forwarding possible"); |
| 171 | return true; |
| 172 | } |
| 173 | else |
| 174 | return false; |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | void |
| 178 | PerFibLimits::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry) |
| 179 | { |
| 180 | NS_LOG_FUNCTION (this << pitEntry->GetPrefix ()); |
| 181 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 182 | if (pitEntry->GetOutgoing ().size () == 0) |
| 183 | { |
| 184 | super::DidReceiveValidNack (0, 0, pitEntry); // semi safe |
Alexander Afanasyev | 0f83f90 | 2012-09-03 13:30:12 -0700 | [diff] [blame] | 185 | |
| 186 | if (m_queueDropNotifications) |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 187 | { |
Alexander Afanasyev | 0f83f90 | 2012-09-03 13:30:12 -0700 | [diff] [blame] | 188 | Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ()); |
| 189 | |
| 190 | NS_ASSERT (pitEntry->GetFwTag<PitQueueTag> () != boost::shared_ptr<PitQueueTag> ()); |
| 191 | if (pitEntry->GetFwTag<PitQueueTag> ()->IsLastOneInQueues ()) |
| 192 | { |
| 193 | nackHeader->SetNack (100); |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | nackHeader->SetNack (101); |
| 198 | } |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 199 | |
Alexander Afanasyev | 0f83f90 | 2012-09-03 13:30:12 -0700 | [diff] [blame] | 200 | Ptr<Packet> pkt = Create<Packet> (); |
| 201 | pkt->AddHeader (*nackHeader); |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 202 | |
Alexander Afanasyev | 0f83f90 | 2012-09-03 13:30:12 -0700 | [diff] [blame] | 203 | for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin (); |
| 204 | face != pitEntry->GetIncoming ().end (); |
| 205 | face ++) |
| 206 | { |
| 207 | face->m_face->Send (pkt->Copy ()); |
| 208 | } |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | else |
| 212 | { |
| 213 | // make bad stats only for "legitimately" timed out interests |
| 214 | super::WillEraseTimedOutPendingInterest (pitEntry); |
| 215 | } |
Alexander Afanasyev | 187cba2 | 2012-08-28 11:16:52 -0700 | [diff] [blame] | 216 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 217 | PitQueue::Remove (pitEntry); |
| 218 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 219 | for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin (); |
| 220 | face != pitEntry->GetOutgoing ().end (); |
| 221 | face ++) |
| 222 | { |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 223 | face->m_face->GetLimits ().RemoveOutstanding (); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 224 | } |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 225 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 226 | ProcessFromQueue (); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | |
| 230 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 231 | PerFibLimits::WillSatisfyPendingInterest (Ptr<Face> inFace, |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 232 | Ptr<pit::Entry> pitEntry) |
| 233 | { |
| 234 | NS_LOG_FUNCTION (this << pitEntry->GetPrefix ()); |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 235 | super::WillSatisfyPendingInterest (inFace, pitEntry); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 236 | |
| 237 | PitQueue::Remove (pitEntry); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 238 | |
| 239 | for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin (); |
| 240 | face != pitEntry->GetOutgoing ().end (); |
| 241 | face ++) |
| 242 | { |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 243 | face->m_face->GetLimits ().RemoveOutstanding (); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 244 | } |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 245 | |
| 246 | ProcessFromQueue (); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 250 | void |
| 251 | PerFibLimits::ProcessFromQueue () |
| 252 | { |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 253 | NS_LOG_FUNCTION (this); |
| 254 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 255 | for (PitQueueMap::iterator queue = m_pitQueues.begin (); |
| 256 | queue != m_pitQueues.end (); |
| 257 | queue++) |
| 258 | { |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 259 | Ptr<Face> outFace = queue->first; |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 260 | |
| 261 | NS_LOG_DEBUG ("Processing " << *outFace); |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 262 | |
| 263 | while (!queue->second.IsEmpty () && outFace->GetLimits ().IsBelowLimit ()) |
| 264 | { |
| 265 | // now we have enqueued packet and have slot available. Send out delayed packet |
| 266 | Ptr<pit::Entry> pitEntry = queue->second.Pop (); |
Alexander Afanasyev | 187cba2 | 2012-08-28 11:16:52 -0700 | [diff] [blame] | 267 | if (pitEntry == 0) |
| 268 | { |
| 269 | outFace->GetLimits ().RemoveOutstanding (); |
| 270 | NS_LOG_DEBUG ("Though there are Interests in queue, weighted round robin decided that packet is not allowed yet"); |
| 271 | break; |
| 272 | } |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 273 | |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 274 | // hack |
| 275 | // offset lifetime back, so PIT entry wouldn't prematurely expire |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 276 | |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 277 | // std::cerr << Simulator::GetContext () << ", Lifetime before " << (pitEntry->GetExpireTime () - Simulator::Now ()).ToDouble (Time::S) << "s" << std::endl; |
| 278 | pitEntry->OffsetLifetime (Seconds (-0.10) + Seconds (pitEntry->GetInterest ()->GetInterestLifetime ().ToDouble (Time::S))); |
| 279 | // std::cerr << Simulator::GetContext () << ", Lifetime after " << (pitEntry->GetExpireTime () - Simulator::Now ()).ToDouble (Time::S) << "s" << std::endl; |
| 280 | |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 281 | pitEntry->AddOutgoing (outFace); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 282 | |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 283 | Ptr<Packet> packetToSend = Create<Packet> (); |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 284 | Ptr<InterestHeader> header = Create<InterestHeader> (*pitEntry->GetInterest ()); |
| 285 | NS_LOG_DEBUG ("Adjust interest lifetime to " << pitEntry->GetExpireTime () - Simulator::Now () << "s"); |
| 286 | // header->SetInterestLifetime ( |
| 287 | // // header->GetInterestLifetime () - () |
| 288 | // pitEntry->GetExpireTime () - Simulator::Now () |
| 289 | // ); |
| 290 | // std::cerr << "New lifetime: " << (pitEntry->GetExpireTime () - Simulator::Now ()).ToDouble (Time::S) << "s" << std::endl; |
| 291 | packetToSend->AddHeader (*header); |
Alexander Afanasyev | 0ffa716 | 2012-08-21 22:39:22 -0700 | [diff] [blame] | 292 | |
| 293 | NS_LOG_DEBUG ("Delayed sending for " << pitEntry->GetPrefix ()); |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 294 | outFace->Send (packetToSend); |
| 295 | DidSendOutInterest (outFace, pitEntry->GetInterest (), packetToSend, pitEntry); |
| 296 | } |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 300 | void |
| 301 | PerFibLimits::DidReceiveValidNack (Ptr<Face> inFace, |
| 302 | uint32_t nackCode, |
| 303 | Ptr<pit::Entry> pitEntry) |
| 304 | { |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 305 | super::DidReceiveValidNack (inFace, nackCode, pitEntry); // will reset count stats |
Alexander Afanasyev | 187cba2 | 2012-08-28 11:16:52 -0700 | [diff] [blame] | 306 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 307 | // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ()); |
| 308 | PitQueue::Remove (pitEntry); |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 309 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 310 | Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ()); |
| 311 | nackHeader->SetNack (100); |
| 312 | Ptr<Packet> pkt = Create<Packet> (); |
| 313 | pkt->AddHeader (*nackHeader); |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 314 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 315 | for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin (); |
| 316 | face != pitEntry->GetIncoming ().end (); |
| 317 | face ++) |
| 318 | { |
| 319 | face->m_face->Send (pkt->Copy ()); |
| 320 | } |
Alexander Afanasyev | 98c16e0 | 2012-08-28 00:02:02 -0700 | [diff] [blame] | 321 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 322 | for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin (); |
| 323 | face != pitEntry->GetOutgoing ().end (); |
| 324 | face ++) |
| 325 | { |
| 326 | face->m_face->GetLimits ().RemoveOutstanding (); |
| 327 | } |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 328 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 329 | m_pit->MarkErased (pitEntry); |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 330 | |
Alexander Afanasyev | c771961 | 2012-08-30 17:42:20 -0700 | [diff] [blame] | 331 | ProcessFromQueue (); |
Alexander Afanasyev | b1ec249 | 2012-08-28 17:33:33 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 334 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 335 | |
| 336 | } // namespace fw |
| 337 | } // namespace ndn |
| 338 | } // namespace ns3 |