Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -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> |
| 19 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 20 | */ |
| 21 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 22 | #include "ndn-forwarding-strategy.h" |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 24 | #include "ns3/ndn-pit.h" |
| 25 | #include "ns3/ndn-pit-entry.h" |
Alexander Afanasyev | bd9c18e | 2012-11-19 15:23:41 -0800 | [diff] [blame] | 26 | #include "ns3/ndn-interest.h" |
| 27 | #include "ns3/ndn-content-object.h" |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 28 | #include "ns3/ndn-pit.h" |
| 29 | #include "ns3/ndn-fib.h" |
| 30 | #include "ns3/ndn-content-store.h" |
| 31 | #include "ns3/ndn-face.h" |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 32 | |
| 33 | #include "ns3/assert.h" |
| 34 | #include "ns3/ptr.h" |
| 35 | #include "ns3/log.h" |
| 36 | #include "ns3/simulator.h" |
| 37 | #include "ns3/boolean.h" |
| 38 | #include "ns3/string.h" |
| 39 | |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 40 | #include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h" |
| 41 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 42 | #include <boost/ref.hpp> |
| 43 | #include <boost/foreach.hpp> |
| 44 | #include <boost/lambda/lambda.hpp> |
| 45 | #include <boost/lambda/bind.hpp> |
| 46 | #include <boost/tuple/tuple.hpp> |
| 47 | namespace ll = boost::lambda; |
| 48 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 49 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | namespace ndn { |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 51 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 52 | NS_OBJECT_ENSURE_REGISTERED (ForwardingStrategy); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | 042b4a7 | 2012-11-09 17:47:48 -0800 | [diff] [blame] | 54 | NS_LOG_COMPONENT_DEFINE (ForwardingStrategy::GetLogName ().c_str ()); |
| 55 | |
| 56 | std::string |
| 57 | ForwardingStrategy::GetLogName () |
| 58 | { |
| 59 | return "ndn.fw"; |
| 60 | } |
| 61 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 62 | TypeId ForwardingStrategy::GetTypeId (void) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 63 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 64 | static TypeId tid = TypeId ("ns3::ndn::ForwardingStrategy") |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 65 | .SetGroupName ("Ndn") |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 66 | .SetParent<Object> () |
| 67 | |
| 68 | //////////////////////////////////////////////////////////////////// |
| 69 | //////////////////////////////////////////////////////////////////// |
| 70 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 71 | .AddTraceSource ("OutInterests", "OutInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_outInterests)) |
| 72 | .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_inInterests)) |
| 73 | .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropInterests)) |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 74 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 75 | //////////////////////////////////////////////////////////////////// |
| 76 | //////////////////////////////////////////////////////////////////// |
| 77 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 78 | .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&ForwardingStrategy::m_outData)) |
| 79 | .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&ForwardingStrategy::m_inData)) |
| 80 | .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropData)) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 81 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 82 | .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested", |
| 83 | BooleanValue (false), |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 84 | MakeBooleanAccessor (&ForwardingStrategy::m_cacheUnsolicitedData), |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 85 | MakeBooleanChecker ()) |
| 86 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 87 | .AddAttribute ("DetectRetransmissions", "If non-duplicate interest is received on the same face more than once, " |
| 88 | "it is considered a retransmission", |
| 89 | BooleanValue (true), |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 90 | MakeBooleanAccessor (&ForwardingStrategy::m_detectRetransmissions), |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 91 | MakeBooleanChecker ()) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 92 | ; |
| 93 | return tid; |
| 94 | } |
| 95 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 96 | ForwardingStrategy::ForwardingStrategy () |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 97 | { |
| 98 | } |
| 99 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 100 | ForwardingStrategy::~ForwardingStrategy () |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 101 | { |
| 102 | } |
| 103 | |
| 104 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 105 | ForwardingStrategy::NotifyNewAggregate () |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 106 | { |
| 107 | if (m_pit == 0) |
| 108 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 109 | m_pit = GetObject<Pit> (); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 110 | } |
| 111 | if (m_fib == 0) |
| 112 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 113 | m_fib = GetObject<Fib> (); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 114 | } |
| 115 | if (m_contentStore == 0) |
| 116 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 117 | m_contentStore = GetObject<ContentStore> (); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | Object::NotifyNewAggregate (); |
| 121 | } |
| 122 | |
| 123 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 124 | ForwardingStrategy::DoDispose () |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 125 | { |
| 126 | m_pit = 0; |
| 127 | m_contentStore = 0; |
| 128 | m_fib = 0; |
| 129 | |
| 130 | Object::DoDispose (); |
| 131 | } |
| 132 | |
| 133 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 134 | ForwardingStrategy::OnInterest (Ptr<Face> inFace, |
| 135 | Ptr<const InterestHeader> header, |
| 136 | Ptr<const Packet> origPacket) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 137 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 138 | m_inInterests (header, inFace); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 139 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 140 | Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header); |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 141 | bool similarInterest = true; |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 142 | if (pitEntry == 0) |
| 143 | { |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 144 | similarInterest = false; |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 145 | pitEntry = m_pit->Create (header); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 146 | if (pitEntry != 0) |
| 147 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 148 | DidCreatePitEntry (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 149 | } |
| 150 | else |
| 151 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 152 | FailedToCreatePitEntry (inFace, header, origPacket); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 153 | return; |
| 154 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 157 | bool isDuplicated = true; |
| 158 | if (!pitEntry->IsNonceSeen (header->GetNonce ())) |
| 159 | { |
| 160 | pitEntry->AddSeenNonce (header->GetNonce ()); |
| 161 | isDuplicated = false; |
| 162 | } |
| 163 | |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 164 | if (isDuplicated) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 165 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 166 | DidReceiveDuplicateInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 167 | return; |
| 168 | } |
| 169 | |
| 170 | Ptr<Packet> contentObject; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 171 | Ptr<const ContentObjectHeader> contentObjectHeader; // used for tracing |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 172 | Ptr<const Packet> payload; // used for tracing |
| 173 | boost::tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header); |
| 174 | if (contentObject != 0) |
| 175 | { |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 176 | NS_ASSERT (contentObjectHeader != 0); |
| 177 | |
| 178 | FwHopCountTag hopCountTag; |
| 179 | if (origPacket->PeekPacketTag (hopCountTag)) |
| 180 | { |
| 181 | contentObject->AddPacketTag (hopCountTag); |
| 182 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 183 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 184 | pitEntry->AddIncoming (inFace/*, Seconds (1.0)*/); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 185 | |
| 186 | // Do data plane performance measurements |
| 187 | WillSatisfyPendingInterest (0, pitEntry); |
| 188 | |
| 189 | // Actually satisfy pending interest |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 190 | SatisfyPendingInterest (0, contentObjectHeader, payload, contentObject, pitEntry); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 191 | return; |
| 192 | } |
| 193 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 194 | if (similarInterest && ShouldSuppressIncomingInterest (inFace, header, origPacket, pitEntry)) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 195 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 196 | pitEntry->AddIncoming (inFace/*, header->GetInterestLifetime ()*/); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 197 | // update PIT entry lifetime |
| 198 | pitEntry->UpdateLifetime (header->GetInterestLifetime ()); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 199 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 200 | // Suppress this interest if we're still expecting data from some other face |
| 201 | NS_LOG_DEBUG ("Suppress interests"); |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 202 | m_dropInterests (header, inFace); |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 203 | |
| 204 | DidSuppressSimilarInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 205 | return; |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 206 | } |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 207 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 208 | if (similarInterest) |
| 209 | { |
| 210 | DidForwardSimilarInterest (inFace, header, origPacket, pitEntry); |
| 211 | } |
| 212 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 213 | PropagateInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 217 | ForwardingStrategy::OnData (Ptr<Face> inFace, |
| 218 | Ptr<const ContentObjectHeader> header, |
| 219 | Ptr<Packet> payload, |
| 220 | Ptr<const Packet> origPacket) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 221 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 222 | NS_LOG_FUNCTION (inFace << header->GetName () << payload << origPacket); |
| 223 | m_inData (header, payload, inFace); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 224 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 225 | // Lookup PIT entry |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 226 | Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 227 | if (pitEntry == 0) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 228 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 229 | DidReceiveUnsolicitedData (inFace, header, payload, origPacket); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 230 | return; |
| 231 | } |
| 232 | else |
| 233 | { |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 234 | FwHopCountTag hopCountTag; |
| 235 | if (payload->PeekPacketTag (hopCountTag)) |
| 236 | { |
| 237 | Ptr<Packet> payloadCopy = payload->Copy (); |
| 238 | payloadCopy->RemovePacketTag (hopCountTag); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 239 | |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 240 | // Add or update entry in the content store |
| 241 | m_contentStore->Add (header, payloadCopy); |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | // Add or update entry in the content store |
| 246 | m_contentStore->Add (header, payload); // no need for extra copy |
| 247 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 248 | } |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 249 | |
| 250 | while (pitEntry != 0) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 251 | { |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 252 | // Do data plane performance measurements |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 253 | WillSatisfyPendingInterest (inFace, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 254 | |
| 255 | // Actually satisfy pending interest |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 256 | SatisfyPendingInterest (inFace, header, payload, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 257 | |
| 258 | // Lookup another PIT entry |
| 259 | pitEntry = m_pit->Lookup (*header); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 263 | void |
| 264 | ForwardingStrategy::DidCreatePitEntry (Ptr<Face> inFace, |
| 265 | Ptr<const InterestHeader> header, |
| 266 | Ptr<const Packet> origPacket, |
| 267 | Ptr<pit::Entry> pitEntrypitEntry) |
| 268 | { |
| 269 | } |
| 270 | |
| 271 | void |
| 272 | ForwardingStrategy::FailedToCreatePitEntry (Ptr<Face> inFace, |
| 273 | Ptr<const InterestHeader> header, |
| 274 | Ptr<const Packet> origPacket) |
| 275 | { |
| 276 | m_dropInterests (header, inFace); |
| 277 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 278 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 279 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 280 | ForwardingStrategy::DidReceiveDuplicateInterest (Ptr<Face> inFace, |
| 281 | Ptr<const InterestHeader> header, |
| 282 | Ptr<const Packet> origPacket, |
| 283 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 284 | { |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 285 | ///////////////////////////////////////////////////////////////////////////////////////// |
| 286 | // // |
| 287 | // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! // |
| 288 | // // |
| 289 | ///////////////////////////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 290 | pitEntry->AddIncoming (inFace); |
| 291 | m_dropInterests (header, inFace); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | void |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 295 | ForwardingStrategy::DidSuppressSimilarInterest (Ptr<Face> face, |
| 296 | Ptr<const InterestHeader> header, |
| 297 | Ptr<const Packet> origPacket, |
| 298 | Ptr<pit::Entry> pitEntry) |
| 299 | { |
| 300 | } |
| 301 | |
| 302 | void |
| 303 | ForwardingStrategy::DidForwardSimilarInterest (Ptr<Face> inFace, |
| 304 | Ptr<const InterestHeader> header, |
| 305 | Ptr<const Packet> origPacket, |
| 306 | Ptr<pit::Entry> pitEntry) |
| 307 | { |
| 308 | } |
| 309 | |
| 310 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 311 | ForwardingStrategy::DidExhaustForwardingOptions (Ptr<Face> inFace, |
| 312 | Ptr<const InterestHeader> header, |
| 313 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 314 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 315 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 316 | NS_LOG_FUNCTION (this << boost::cref (*inFace)); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 317 | if (pitEntry->AreAllOutgoingInVain ()) |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 318 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 319 | m_dropInterests (header, inFace); |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 320 | |
| 321 | // All incoming interests cannot be satisfied. Remove them |
| 322 | pitEntry->ClearIncoming (); |
| 323 | |
| 324 | // Remove also outgoing |
| 325 | pitEntry->ClearOutgoing (); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 326 | |
Alexander Afanasyev | 6a3bb13 | 2012-08-15 09:47:35 -0700 | [diff] [blame] | 327 | // Set pruning timout on PIT entry (instead of deleting the record) |
| 328 | m_pit->MarkErased (pitEntry); |
| 329 | } |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 330 | } |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 331 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 332 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 333 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 334 | bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 335 | ForwardingStrategy::DetectRetransmittedInterest (Ptr<Face> inFace, |
| 336 | Ptr<const InterestHeader> header, |
| 337 | Ptr<const Packet> packet, |
| 338 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 339 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 340 | pit::Entry::in_iterator existingInFace = pitEntry->GetIncoming ().find (inFace); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 341 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 342 | bool isRetransmitted = false; |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 343 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 344 | if (existingInFace != pitEntry->GetIncoming ().end ()) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 345 | { |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 346 | // this is almost definitely a retransmission. But should we trust the user on that? |
| 347 | isRetransmitted = true; |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 350 | return isRetransmitted; |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 354 | ForwardingStrategy::SatisfyPendingInterest (Ptr<Face> inFace, |
| 355 | Ptr<const ContentObjectHeader> header, |
| 356 | Ptr<const Packet> payload, |
| 357 | Ptr<const Packet> origPacket, |
| 358 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 359 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 360 | if (inFace != 0) |
| 361 | pitEntry->RemoveIncoming (inFace); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 362 | |
| 363 | //satisfy all pending incoming Interests |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 364 | BOOST_FOREACH (const pit::IncomingFace &incoming, pitEntry->GetIncoming ()) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 365 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 366 | bool ok = incoming.m_face->Send (origPacket->Copy ()); |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 367 | if (ok) |
| 368 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 369 | m_outData (header, payload, inFace == 0, incoming.m_face); |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 370 | DidSendOutData (inFace, incoming.m_face, header, payload, origPacket, pitEntry); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 371 | |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 372 | NS_LOG_DEBUG ("Satisfy " << *incoming.m_face); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | m_dropData (header, payload, incoming.m_face); |
| 377 | NS_LOG_DEBUG ("Cannot satisfy data to " << *incoming.m_face); |
| 378 | } |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 379 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 380 | // successfull forwarded data trace |
| 381 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 382 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 383 | // All incoming interests are satisfied. Remove them |
| 384 | pitEntry->ClearIncoming (); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 385 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 386 | // Remove all outgoing faces |
| 387 | pitEntry->ClearOutgoing (); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 388 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 389 | // Set pruning timout on PIT entry (instead of deleting the record) |
| 390 | m_pit->MarkErased (pitEntry); |
| 391 | } |
| 392 | |
| 393 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 394 | ForwardingStrategy::DidReceiveUnsolicitedData (Ptr<Face> inFace, |
| 395 | Ptr<const ContentObjectHeader> header, |
| 396 | Ptr<const Packet> payload, |
| 397 | Ptr<const Packet> origPacket) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 398 | { |
| 399 | if (m_cacheUnsolicitedData) |
| 400 | { |
| 401 | // Optimistically add or update entry in the content store |
| 402 | m_contentStore->Add (header, payload); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 403 | } |
| 404 | else |
| 405 | { |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 406 | // Drop data packet if PIT entry is not found |
| 407 | // (unsolicited data packets should not "poison" content store) |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 408 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 409 | //drop dulicated or not requested data packet |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 410 | m_dropData (header, payload, inFace); |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | |
| 414 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 415 | ForwardingStrategy::WillSatisfyPendingInterest (Ptr<Face> inFace, |
| 416 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 417 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 418 | pit::Entry::out_iterator out = pitEntry->GetOutgoing ().find (inFace); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 419 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 420 | // If we have sent interest for this data via this face, then update stats. |
| 421 | if (out != pitEntry->GetOutgoing ().end ()) |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 422 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 423 | pitEntry->GetFibEntry ()->UpdateFaceRtt (inFace, Simulator::Now () - out->m_sendTime); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 424 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 427 | bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 428 | ForwardingStrategy::ShouldSuppressIncomingInterest (Ptr<Face> inFace, |
| 429 | Ptr<const InterestHeader> header, |
| 430 | Ptr<const Packet> origPacket, |
| 431 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 432 | { |
| 433 | bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0; |
| 434 | |
| 435 | if (isNew) return false; // never suppress new interests |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 436 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 437 | bool isRetransmitted = m_detectRetransmissions && // a small guard |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 438 | DetectRetransmittedInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 439 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 440 | if (pitEntry->GetOutgoing ().find (inFace) != pitEntry->GetOutgoing ().end ()) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 441 | { |
| 442 | NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress"); |
| 443 | // got a non-duplicate interest from the face we have sent interest to |
| 444 | // Probably, there is no point in waiting data from that face... Not sure yet |
| 445 | |
| 446 | // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data) |
| 447 | // Mark interface YELLOW, but keep a small hope that data will come eventually. |
| 448 | |
| 449 | // ?? not sure if we need to do that ?? ... |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 450 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 451 | // pitEntry->GetFibEntry ()->UpdateStatus (inFace, fib::FaceMetric::NDN_FIB_YELLOW); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 452 | } |
| 453 | else |
| 454 | if (!isNew && !isRetransmitted) |
| 455 | { |
| 456 | return true; |
| 457 | } |
| 458 | |
| 459 | return false; |
| 460 | } |
| 461 | |
| 462 | void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 463 | ForwardingStrategy::PropagateInterest (Ptr<Face> inFace, |
| 464 | Ptr<const InterestHeader> header, |
| 465 | Ptr<const Packet> origPacket, |
| 466 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 467 | { |
| 468 | bool isRetransmitted = m_detectRetransmissions && // a small guard |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 469 | DetectRetransmittedInterest (inFace, header, origPacket, pitEntry); |
| 470 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 471 | pitEntry->AddIncoming (inFace/*, header->GetInterestLifetime ()*/); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 472 | /// @todo Make lifetime per incoming interface |
| 473 | pitEntry->UpdateLifetime (header->GetInterestLifetime ()); |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 474 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 475 | bool propagated = DoPropagateInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 476 | |
| 477 | if (!propagated && isRetransmitted) //give another chance if retransmitted |
| 478 | { |
| 479 | // increase max number of allowed retransmissions |
| 480 | pitEntry->IncreaseAllowedRetxCount (); |
| 481 | |
| 482 | // try again |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 483 | propagated = DoPropagateInterest (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 486 | // if (!propagated) |
| 487 | // { |
| 488 | // NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++"); |
| 489 | // NS_LOG_DEBUG ("+++ Not propagated ["<< header->GetName () <<"], but number of outgoing faces: " << pitEntry->GetOutgoing ().size ()); |
| 490 | // NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++"); |
| 491 | // } |
| 492 | |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 493 | // ForwardingStrategy will try its best to forward packet to at least one interface. |
| 494 | // If no interests was propagated, then there is not other option for forwarding or |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 495 | // ForwardingStrategy failed to find it. |
| 496 | if (!propagated && pitEntry->AreAllOutgoingInVain ()) |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 497 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 498 | DidExhaustForwardingOptions (inFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 996b487 | 2012-07-17 17:07:56 -0700 | [diff] [blame] | 499 | } |
| 500 | } |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 501 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 502 | bool |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 503 | ForwardingStrategy::CanSendOutInterest (Ptr<Face> inFace, |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 504 | Ptr<Face> outFace, |
| 505 | Ptr<const InterestHeader> header, |
| 506 | Ptr<const Packet> origPacket, |
| 507 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 508 | { |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 509 | if (outFace == inFace) |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 510 | { |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 511 | // NS_LOG_DEBUG ("Same as incoming"); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 512 | return false; // same face as incoming, don't forward |
| 513 | } |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 514 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 515 | pit::Entry::out_iterator outgoing = |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 516 | pitEntry->GetOutgoing ().find (outFace); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 517 | |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 518 | if (outgoing != pitEntry->GetOutgoing ().end ()) |
| 519 | { |
| 520 | if (!m_detectRetransmissions) |
| 521 | return false; // suppress |
| 522 | else if (outgoing->m_retxCount >= pitEntry->GetMaxRetxCount ()) |
| 523 | { |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 524 | // NS_LOG_DEBUG ("Already forwarded before during this retransmission cycle (" <<outgoing->m_retxCount << " >= " << pitEntry->GetMaxRetxCount () << ")"); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 525 | return false; // already forwarded before during this retransmission cycle |
| 526 | } |
| 527 | } |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 528 | |
| 529 | return true; |
| 530 | } |
| 531 | |
| 532 | |
| 533 | bool |
| 534 | ForwardingStrategy::TrySendOutInterest (Ptr<Face> inFace, |
| 535 | Ptr<Face> outFace, |
| 536 | Ptr<const InterestHeader> header, |
| 537 | Ptr<const Packet> origPacket, |
| 538 | Ptr<pit::Entry> pitEntry) |
| 539 | { |
| 540 | if (!CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry)) |
| 541 | { |
| 542 | return false; |
| 543 | } |
Alexander Afanasyev | 3a3ce1a | 2013-01-31 11:26:11 -0800 | [diff] [blame^] | 544 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 545 | pitEntry->AddOutgoing (outFace); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 546 | |
| 547 | //transmission |
| 548 | Ptr<Packet> packetToSend = origPacket->Copy (); |
| 549 | outFace->Send (packetToSend); |
| 550 | |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 551 | DidSendOutInterest (inFace, outFace, header, origPacket, pitEntry); |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 552 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 553 | return true; |
| 554 | } |
| 555 | |
| 556 | void |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 557 | ForwardingStrategy::DidSendOutInterest (Ptr<Face> inFace, |
| 558 | Ptr<Face> outFace, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 559 | Ptr<const InterestHeader> header, |
| 560 | Ptr<const Packet> origPacket, |
| 561 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 562 | { |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 563 | m_outInterests (header, outFace); |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | void |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 567 | ForwardingStrategy::DidSendOutData (Ptr<Face> inFace, |
| 568 | Ptr<Face> outFace, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 569 | Ptr<const ContentObjectHeader> header, |
| 570 | Ptr<const Packet> payload, |
| 571 | Ptr<const Packet> origPacket, |
| 572 | Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 573 | { |
| 574 | } |
| 575 | |
| 576 | void |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 577 | ForwardingStrategy::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry) |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 578 | { |
| 579 | // do nothing for now. may be need to do some logging |
| 580 | } |
| 581 | |
Alexander Afanasyev | f5c0774 | 2012-10-31 13:13:05 -0700 | [diff] [blame] | 582 | void |
| 583 | ForwardingStrategy::AddFace (Ptr<Face> face) |
| 584 | { |
| 585 | // do nothing here |
| 586 | } |
Alexander Afanasyev | 33364b6 | 2012-07-26 17:53:56 -0700 | [diff] [blame] | 587 | |
| 588 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 589 | ForwardingStrategy::RemoveFace (Ptr<Face> face) |
Alexander Afanasyev | 33364b6 | 2012-07-26 17:53:56 -0700 | [diff] [blame] | 590 | { |
| 591 | // do nothing here |
| 592 | } |
| 593 | |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 594 | void |
| 595 | ForwardingStrategy::DidAddFibEntry (Ptr<fib::Entry> fibEntry) |
| 596 | { |
| 597 | // do nothing here |
| 598 | } |
| 599 | |
| 600 | void |
| 601 | ForwardingStrategy::WillRemoveFibEntry (Ptr<fib::Entry> fibEntry) |
| 602 | { |
| 603 | // do nothing here |
| 604 | } |
| 605 | |
| 606 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 607 | } // namespace ndn |
| 608 | } // namespace ns3 |