blob: 83ab9d28be52f756554a33203bed6de201690f35 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyevab1d5602011-08-17 19:17:18 -07002/*
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>
Ilya Moiseenko172763c2011-10-28 13:21:53 -070019 * Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070020 */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070021
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070022#include "ccnx-l3-protocol.h"
23
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070024#include "ns3/packet.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070025#include "ns3/node.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070026#include "ns3/log.h"
27#include "ns3/callback.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070028#include "ns3/uinteger.h"
29#include "ns3/trace-source-accessor.h"
30#include "ns3/object-vector.h"
Alexander Afanasyevcbe92ae2011-12-16 13:06:18 -080031#include "ns3/pointer.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070032#include "ns3/boolean.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080033#include "ns3/string.h"
Alexander Afanasyev4975f732011-12-20 17:52:19 -080034#include "ns3/simulator.h"
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -070035#include "ns3/random-variable.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070036
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070037#include "ns3/ccnx-header-helper.h"
38
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070039#include "ccnx-face.h"
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070040#include "ccnx-forwarding-strategy.h"
41#include "ccnx-interest-header.h"
42#include "ccnx-content-object-header.h"
43
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -080044#include "ccnx-net-device-face.h"
45
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070046#include <boost/foreach.hpp>
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080047#include <boost/lambda/lambda.hpp>
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080048#include <boost/lambda/bind.hpp>
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080049
50using namespace boost::tuples;
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080051namespace ll = boost::lambda;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070052
53NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
54
55namespace ns3 {
56
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057const uint16_t CcnxL3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070058
Alexander Afanasyev07827182011-12-13 01:07:32 -080059
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070060NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol);
61
62TypeId
63CcnxL3Protocol::GetTypeId (void)
64{
65 static TypeId tid = TypeId ("ns3::CcnxL3Protocol")
66 .SetParent<Ccnx> ()
Alexander Afanasyev070aa482011-08-20 00:38:25 -070067 .SetGroupName ("Ccnx")
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070068 .AddConstructor<CcnxL3Protocol> ()
Alexander Afanasyevcbe92ae2011-12-16 13:06:18 -080069 .AddAttribute ("FaceList", "List of faces associated with CCNx stack",
70 ObjectVectorValue (),
71 MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces),
72 MakeObjectVectorChecker<CcnxFace> ())
73
74 .AddAttribute ("ForwardingStrategy", "Forwarding strategy used by CCNx stack",
75 PointerValue (),
76 MakePointerAccessor (&CcnxL3Protocol::SetForwardingStrategy, &CcnxL3Protocol::GetForwardingStrategy),
77 MakePointerChecker<CcnxForwardingStrategy> ())
78
Alexander Afanasyevbab81b12012-02-04 14:20:09 -080079 .AddAttribute ("EnableNACKs", "Enabling support of NACKs",
Alexander Afanasyev082dbca2012-02-14 18:43:13 -080080 BooleanValue (false),
Alexander Afanasyevbab81b12012-02-04 14:20:09 -080081 MakeBooleanAccessor (&CcnxL3Protocol::m_nacksEnabled),
82 MakeBooleanChecker ())
Alexander Afanasyevde009992012-02-04 18:54:54 -080083 .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
84 BooleanValue (false),
85 MakeBooleanAccessor (&CcnxL3Protocol::m_cacheUnsolicitedData),
86 MakeBooleanChecker ())
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -070087 .AddAttribute ("RandomDataDelaying", "Delaying data processing",
88 BooleanValue (false),
89 MakeBooleanAccessor (&CcnxL3Protocol::m_delayingDataProcessing),
90 MakeBooleanChecker ())
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070091 ;
92 return tid;
93}
94
95CcnxL3Protocol::CcnxL3Protocol()
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070096: m_faceCounter (0)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070097{
98 NS_LOG_FUNCTION (this);
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070099
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700100 m_pit = CreateObject<CcnxPit> ();
101 m_contentStore = CreateObject<CcnxContentStore> ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700102}
103
104CcnxL3Protocol::~CcnxL3Protocol ()
105{
106 NS_LOG_FUNCTION (this);
107}
108
109void
110CcnxL3Protocol::SetNode (Ptr<Node> node)
111{
112 m_node = node;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700113 m_fib = m_node->GetObject<CcnxFib> ();
114 NS_ASSERT_MSG (m_fib != 0, "FIB should be created and aggregated to a node before calling Ccnx::SetNode");
115
116 m_pit->SetFib (m_fib);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700117}
118
119/*
120 * This method is called by AddAgregate and completes the aggregation
121 * by setting the node in the ccnx stack
122 */
123void
124CcnxL3Protocol::NotifyNewAggregate ()
125{
126 if (m_node == 0)
127 {
128 Ptr<Node>node = this->GetObject<Node>();
129 // verify that it's a valid node and that
130 // the node has not been set before
131 if (node != 0)
132 {
133 this->SetNode (node);
134 }
135 }
136 Object::NotifyNewAggregate ();
137}
138
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700139void
140CcnxL3Protocol::DoDispose (void)
141{
142 NS_LOG_FUNCTION (this);
143
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700144 for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700145 {
146 *i = 0;
147 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700148 m_faces.clear ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700149 m_node = 0;
Alexander Afanasyevd02a5d62011-11-21 11:01:51 -0800150
151 // Force delete on objects
Alexander Afanasyev18252852011-11-21 13:35:31 -0800152 m_forwardingStrategy = 0; // there is a reference to PIT stored in here
Alexander Afanasyevd02a5d62011-11-21 11:01:51 -0800153 m_pit = 0;
154 m_contentStore = 0;
Alexander Afanasyev18252852011-11-21 13:35:31 -0800155 m_fib = 0;
156
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700157 // m_forwardingStrategy = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700158 Object::DoDispose ();
159}
160
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700161void
162CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy)
163{
164 NS_LOG_FUNCTION (this);
165 m_forwardingStrategy = forwardingStrategy;
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800166 m_forwardingStrategy->SetPit (m_pit);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700167}
168
169Ptr<CcnxForwardingStrategy>
170CcnxL3Protocol::GetForwardingStrategy (void) const
171{
172 return m_forwardingStrategy;
173}
174
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700175Ptr<CcnxPit>
176CcnxL3Protocol::GetPit () const
177{
178 return m_pit;
179}
180
181
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700182uint32_t
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700183CcnxL3Protocol::AddFace (const Ptr<CcnxFace> &face)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700184{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700185 NS_LOG_FUNCTION (this << &face);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700186
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700187 face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700188
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700189 // ask face to register in lower-layer stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700190 face->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this));
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700191
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700192 m_faces.push_back (face);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800193 m_faceCounter++;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700194 return face->GetId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700195}
196
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700197void
198CcnxL3Protocol::RemoveFace (Ptr<CcnxFace> face)
199{
200 // ask face to register in lower-layer stack
201 face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ());
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800202
203 // just to be on a safe side. Do the process in two steps
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800204 std::list<boost::reference_wrapper<const CcnxPitEntry> > entriesToRemoves;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800205 BOOST_FOREACH (const CcnxPitEntry &pitEntry, *m_pit)
206 {
207 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800208 ll::bind (&CcnxPitEntry::RemoveAllReferencesToFace, ll::_1, face));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800209
210 // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
211 // Thus, we have to remove the whole PIT entry
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800212 if (pitEntry.m_fibEntry.m_faces.size () == 1 &&
213 pitEntry.m_fibEntry.m_faces.begin ()->m_face == face)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800214 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800215 entriesToRemoves.push_back (boost::cref (pitEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800216 }
217 }
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800218 BOOST_FOREACH (const CcnxPitEntry &removedEntry, entriesToRemoves)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800219 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800220 m_pit->erase (m_pit->iterator_to (removedEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800221 }
222
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700223 CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
224 NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist");
225 m_faces.erase (face_it);
226}
227
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700228Ptr<CcnxFace>
Alexander Afanasyev98256102011-08-14 01:00:02 -0700229CcnxL3Protocol::GetFace (uint32_t index) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700230{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700231 BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700232 {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700233 if (face->GetId () == index)
234 return face;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700235 }
236 return 0;
237}
238
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800239Ptr<CcnxFace>
240CcnxL3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
241{
242 BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
243 {
244 Ptr<CcnxNetDeviceFace> netDeviceFace = DynamicCast<CcnxNetDeviceFace> (face);
245 if (netDeviceFace == 0) continue;
246
247 if (netDeviceFace->GetNetDevice () == netDevice)
248 return face;
249 }
250 return 0;
251}
252
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700253uint32_t
Alexander Afanasyev98256102011-08-14 01:00:02 -0700254CcnxL3Protocol::GetNFaces (void) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700255{
Alexander Afanasyev98256102011-08-14 01:00:02 -0700256 return m_faces.size ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700257}
258
Alexander Afanasyev98256102011-08-14 01:00:02 -0700259// Callback from lower layer
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700260void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700261CcnxL3Protocol::Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700262{
Alexander Afanasyevd459ec32012-04-30 13:58:20 -0700263 if (!face->IsUp ())
264 return;
265
266 NS_LOG_DEBUG (*p);
267
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700268 NS_LOG_LOGIC ("Packet from face " << *face << " received on node " << m_node->GetId ());
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700269
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700270 Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700271 try
272 {
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700273 CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700274 switch (type)
275 {
276 case CcnxHeaderHelper::INTEREST:
277 {
278 Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700279
280 // Deserialization. Exception may be thrown
281 packet->RemoveHeader (*header);
282 NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800283
284 if (header->GetNack () > 0)
285 OnNack (face, header, p/*original packet*/);
286 else
287 OnInterest (face, header, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700288 break;
289 }
290 case CcnxHeaderHelper::CONTENT_OBJECT:
291 {
292 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700293
294 static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object
295
296 // Deserialization. Exception may be thrown
297 packet->RemoveHeader (*header);
298 packet->RemoveTrailer (contentObjectTrailer);
299
300 OnData (face, header, packet/*payload*/, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700301 break;
302 }
303 }
304
305 // exception will be thrown if packet is not recognized
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700306 }
307 catch (CcnxUnknownHeaderException)
308 {
309 NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
Alexander Afanasyevd459ec32012-04-30 13:58:20 -0700310 NS_LOG_ERROR ("Unknown CCNx header. Should not happen");
311 return;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700312 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700313}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700314
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800315void
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800316CcnxL3Protocol::OnNack (const Ptr<CcnxFace> &incomingFace,
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800317 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800318 const Ptr<const Packet> &packet)
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800319{
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800320 NS_LOG_FUNCTION (incomingFace << header << packet);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800321 m_inNacks (header, incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800322
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800323 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
324 CcnxPitEntry const& pitEntry = ret.get<0> ();
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800325 bool isNew = ret.get<1> ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800326 bool isDuplicated = ret.get<2> ();
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800327
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800328 if (isNew || !isDuplicated) // potential flow
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800329 {
330 // somebody is doing something bad
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800331 m_dropNacks (header, NON_DUPLICATED, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800332 return;
333 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800334
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800335 // CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
336 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800337
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800338 if (outFace == pitEntry.m_outgoing.end ())
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800339 {
Alexander Afanasyev8f5a9bb2011-12-18 19:49:02 -0800340// NS_ASSERT_MSG (false,
341// "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
342// "size: " << pitEntry.m_outgoing.size ());
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800343
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800344 // m_dropNacks (header, NON_DUPLICATE, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800345 return;
346 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800347
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800348 // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
349 // at least when there is only one client
350 //
351 // incomingFace->LeakBucketByOnePacket ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800352
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800353 NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
354
Alexander Afanasyev5a595072011-11-25 14:49:07 -0800355 m_pit->modify (m_pit->iterator_to (pitEntry),
356 ll::bind (&CcnxPitEntry::SetWaitingInVain, ll::_1, outFace));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800357
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800358 // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
359 // So, if we had an incoming entry to this neighbor, then we can remove it now
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800360
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800361 if (header->GetNack () == CcnxInterestHeader::NACK_GIVEUP_PIT)
362 {
363 m_pit->modify (m_pit->iterator_to (pitEntry),
364 ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
365 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800366
Alexander Afanasyev07827182011-12-13 01:07:32 -0800367 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
368 ll::bind (&CcnxFibEntry::UpdateStatus,
369 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800370
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800371 if (pitEntry.m_incoming.size () == 0) // interest was actually satisfied
372 {
373 // no need to do anything
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800374 m_dropNacks (header, AFTER_SATISFIED, incomingFace);
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800375 return;
376 }
377
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800378 if (!pitEntry.AreAllOutgoingInVain ()) // not all ougtoing are in vain
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800379 {
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800380 NS_LOG_DEBUG ("Not all outgoing are in vain");
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800381 // suppress
382 // Don't do anything, we are still expecting data from some other face
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800383 m_dropNacks (header, SUPPRESSED, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800384 return;
385 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800386
387 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800388
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800389 Ptr<Packet> nonNackInterest = Create<Packet> ();
390 header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
391 nonNackInterest->AddHeader (*header);
392
393 bool propagated = m_forwardingStrategy->
394 PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
395
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800396 // // ForwardingStrategy will try its best to forward packet to at least one interface.
397 // // If no interests was propagated, then there is not other option for forwarding or
398 // // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800399 if (!propagated)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800400 {
401 m_dropNacks (header, NO_FACES, incomingFace); // this headers doesn't have NACK flag set
402 GiveUpInterest (pitEntry, header);
403 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800404}
405
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700406// Processing Interests
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800407//
408// !!! Key point.
409// !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700410void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
411 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700412 const Ptr<const Packet> &packet)
Alexander Afanasyev98256102011-08-14 01:00:02 -0700413{
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800414 m_inInterests (header, incomingFace);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700415 // NS_LOG_DEBUG (*m_pit);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700416
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800417 // Lookup of Pit (and associated Fib) entry for this Interest
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800418 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
419 CcnxPitEntry const& pitEntry = ret.get<0> ();
Alexander Afanasyev4e970942012-03-09 10:58:11 -0800420 bool isNew = ret.get<1> ();
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800421 bool isDuplicated = ret.get<2> ();
Ilya Moiseenkod83eb0d2011-11-16 15:23:46 -0800422
Alexander Afanasyev8d11fcc2011-12-30 12:42:31 -0800423 // NS_LOG_DEBUG ("isNew: " << isNew << ", isDup: " << isDuplicated);
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800424
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700425 NS_LOG_FUNCTION (header->GetName () << header->GetNonce () << boost::cref (*incomingFace) << isDuplicated);
426
427 /////////////////////////////////////////////////////////////////////////////////////////
428 /////////////////////////////////////////////////////////////////////////////////////////
429 /////////////////////////////////////////////////////////////////////////////////////////
430 // //
431 // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
432 // //
433 /////////////////////////////////////////////////////////////////////////////////////////
434 /////////////////////////////////////////////////////////////////////////////////////////
435 /////////////////////////////////////////////////////////////////////////////////////////
436
437 // Data is not in cache
438 CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
439 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
440
441 bool isRetransmitted = false;
442
443 if (inFace != pitEntry.m_incoming.end ())
444 {
445 // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
446
447 isRetransmitted = true;
448 // this is almost definitely a retransmission. But should we trust the user on that?
449 }
450 else
451 {
452 m_pit->modify (m_pit->iterator_to (pitEntry),
453 ll::var(inFace) = ll::bind (&CcnxPitEntry::AddIncoming, ll::_1, incomingFace));
454 }
455 //////////////////////////////////////////////////////////////////////////////////
456 //////////////////////////////////////////////////////////////////////////////////
457 //////////////////////////////////////////////////////////////////////////////////
458
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800459 if (isDuplicated)
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700460 {
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700461 NS_LOG_DEBUG ("Received duplicatie interest on " << *incomingFace);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800462 m_dropInterests (header, DUPLICATED, incomingFace);
463
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800464 /**
465 * This condition will handle "routing" loops and also recently satisfied interests.
466 * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
467 * is kept for another small chunk of time.
468 */
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700469
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800470 if (m_nacksEnabled)
471 {
472 NS_LOG_DEBUG ("Sending NACK_LOOP");
473 header->SetNack (CcnxInterestHeader::NACK_LOOP);
474 Ptr<Packet> nack = Create<Packet> ();
475 nack->AddHeader (*header);
476
477 incomingFace->Send (nack);
478 m_outNacks (header, incomingFace);
479 }
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700480
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700481 return;
482 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800483
484 Ptr<Packet> contentObject;
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800485 Ptr<const CcnxContentObjectHeader> contentObjectHeader; // used for tracing
486 Ptr<const Packet> payload; // used for tracing
487 tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800488 if (contentObject != 0)
489 {
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700490 NS_ASSERT (contentObjectHeader != 0);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800491 NS_LOG_LOGIC("Found in cache");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800492
Alexander Afanasyevd459ec32012-04-30 13:58:20 -0700493 OnDataDelayed (contentObjectHeader, payload, contentObject);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800494 return;
495 }
496
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800497 // update PIT entry lifetime
498 m_pit->modify (m_pit->iterator_to (pitEntry),
499 ll::bind (&CcnxPitEntry::UpdateLifetime, ll::_1,
500 header->GetInterestLifetime ()));
501
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800502 if (outFace != pitEntry.m_outgoing.end ())
503 {
Alexander Afanasyeve192a2a2012-04-09 14:57:54 -0700504 NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800505 // got a non-duplicate interest from the face we have sent interest to
506 // Probably, there is no point in waiting data from that face... Not sure yet
507
508 // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
509 // Mark interface YELLOW, but keep a small hope that data will come eventually.
510
511 // ?? not sure if we need to do that ?? ...
512
Alexander Afanasyev07827182011-12-13 01:07:32 -0800513 m_fib->m_fib.modify(m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
514 ll::bind (&CcnxFibEntry::UpdateStatus,
515 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800516 }
Alexander Afanasyeve192a2a2012-04-09 14:57:54 -0700517 else
518 if (!isNew && !isRetransmitted)
519 {
520 // Suppress this interest if we're still expecting data from some other face
521 NS_LOG_DEBUG ("Suppress interests");
522 m_dropInterests (header, SUPPRESSED, incomingFace);
523 return;
524 }
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800525
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800526 /////////////////////////////////////////////////////////////////////
527 // Propagate
528 /////////////////////////////////////////////////////////////////////
529
530 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
531
532 bool propagated = m_forwardingStrategy->
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800533 PropagateInterest (pitEntry, incomingFace, header, packet);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800534
Alexander Afanasyevd459ec32012-04-30 13:58:20 -0700535 if (!propagated && isRetransmitted) //give another chance if retransmitted
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800536 {
537 // increase max number of allowed retransmissions
538 m_pit->modify (m_pit->iterator_to (pitEntry),
539 ll::bind (&CcnxPitEntry::IncreaseAllowedRetxCount, ll::_1));
540
541 // try again
542 propagated = m_forwardingStrategy->
543 PropagateInterest (pitEntry, incomingFace, header, packet);
544 }
545
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800546 // ForwardingStrategy will try its best to forward packet to at least one interface.
547 // If no interests was propagated, then there is not other option for forwarding or
548 // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800549 if (!propagated)
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800550 {
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800551 NS_LOG_DEBUG ("Not propagated");
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800552 m_dropInterests (header, NO_FACES, incomingFace);
553 GiveUpInterest (pitEntry, header);
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800554 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800555}
556
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700557void
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700558CcnxL3Protocol::OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
559 Ptr<const Packet> payload,
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700560 const Ptr<const Packet> &packet)
561{
562 if (m_delayingDataProcessing)
563 {
564 NS_LOG_DEBUG ("Delayed processing " << header->GetName ());
565 // NS_LOG_DEBUG (*m_pit);
566 }
567
568 // 1. Lookup PIT entry
569 try
570 {
571 CcnxPitEntryContainer::type::iterator pitEntry = m_pit->Lookup (*header);
572
573 //satisfy all pending incoming Interests
574 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->m_incoming)
575 {
576 incoming.m_face->Send (packet->Copy ());
577 m_outData (header, payload, false, incoming.m_face);
578 NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
579
580 // successfull forwarded data trace
581 }
582
583 if (pitEntry->m_incoming.size () > 0)
584 {
585 // All incoming interests are satisfied. Remove them
586 m_pit->modify (pitEntry,
587 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
588
589 // Remove all outgoing faces
590 m_pit->modify (pitEntry,
591 ll::bind (&CcnxPitEntry::ClearOutgoing, ll::_1));
592
593 // Set pruning timout on PIT entry (instead of deleting the record)
594 m_pit->modify (pitEntry,
595 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
596 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
597 }
598 }
599 catch (CcnxPitEntryNotFound)
600 {
601 NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
602 return; // do not process unsoliced data packets
603 }
604}
605
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700606// Processing ContentObjects
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800607void
608CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
609 Ptr<CcnxContentObjectHeader> &header,
610 Ptr<Packet> &payload,
611 const Ptr<const Packet> &packet)
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700612{
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700613
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700614 NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800615 m_inData (header, payload, incomingFace);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700616 // NS_LOG_DEBUG (*m_pit);
617
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700618 // 1. Lookup PIT entry
619 try
620 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700621 CcnxPitEntryContainer::type::iterator pitEntry = m_pit->Lookup (*header);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700622
623 // Note that with MultiIndex we need to modify entries indirectly
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700624
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700625 CcnxPitEntryOutgoingFaceContainer::type::iterator out = pitEntry->m_outgoing.find (incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700626
627 // If we have sent interest for this data via this face, then update stats.
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700628 if (out != pitEntry->m_outgoing.end ())
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700629 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700630 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry->m_fibEntry),
Alexander Afanasyev07827182011-12-13 01:07:32 -0800631 ll::bind (&CcnxFibEntry::UpdateFaceRtt,
632 ll::_1,
633 incomingFace,
634 Simulator::Now () - out->m_sendTime));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700635 }
636 else
637 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800638 // Unsolicited data, but we're interested in it... should we get it?
639 // Potential hole for attacks
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800640
Alexander Afanasyevde009992012-02-04 18:54:54 -0800641 if (m_cacheUnsolicitedData)
642 {
643 // Optimistically add or update entry in the content store
644 m_contentStore->Add (header, payload);
645 }
646 else
647 {
648 NS_LOG_ERROR ("Node "<< m_node->GetId() <<
649 ". PIT entry for "<< header->GetName ()<<" is valid, "
650 "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
651 }
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800652 // ignore unsolicited data
653 return;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700654 }
655
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800656 // Update metric status for the incoming interface in the corresponding FIB entry
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700657 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry->m_fibEntry),
Alexander Afanasyev07827182011-12-13 01:07:32 -0800658 ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
659 incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800660
661 // Add or update entry in the content store
662 m_contentStore->Add (header, payload);
663
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700664 m_pit->modify (pitEntry,
665 ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
666
667 if (pitEntry->m_incoming.size () == 0)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700668 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700669 // Set pruning timout on PIT entry (instead of deleting the record)
670 m_pit->modify (pitEntry,
671 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
672 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
673 }
674 else
675 {
676 if (!m_delayingDataProcessing)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800677 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700678 OnDataDelayed (header, payload, packet);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800679 }
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700680 else
681 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700682 NS_LOG_DEBUG ("Delaying Data forwarding " << header->GetName ());
683 UniformVariable delay (0.0001, 0.002);
684 Simulator::Schedule (Seconds (delay.GetValue ()),
685 &CcnxL3Protocol::OnDataDelayed, this, header, payload, packet);
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700686 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700687 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700688 }
689 catch (CcnxPitEntryNotFound)
690 {
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700691 NS_LOG_DEBUG ("Pit entry not found");
Alexander Afanasyevde009992012-02-04 18:54:54 -0800692 if (m_cacheUnsolicitedData)
693 {
694 // Optimistically add or update entry in the content store
695 m_contentStore->Add (header, payload);
696 }
697 else
698 {
699 // Drop data packet if PIT entry is not found
700 // (unsolicited data packets should not "poison" content store)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700701
Alexander Afanasyevde009992012-02-04 18:54:54 -0800702 //drop dulicated or not requested data packet
703 m_dropData (header, payload, UNSOLICITED, incomingFace);
704 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700705 return; // do not process unsoliced data packets
706 }
707}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700708
709void
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800710CcnxL3Protocol::GiveUpInterest (const CcnxPitEntry &pitEntry,
711 Ptr<CcnxInterestHeader> header)
712{
Alexander Afanasyevde009992012-02-04 18:54:54 -0800713 NS_LOG_FUNCTION (this << &pitEntry);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700714 // NS_LOG_DEBUG (*m_pit);
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800715 if (m_nacksEnabled)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800716 {
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800717 Ptr<Packet> packet = Create<Packet> ();
718 header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
719 packet->AddHeader (*header);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800720
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800721 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry.m_incoming)
722 {
Alexander Afanasyevde009992012-02-04 18:54:54 -0800723 NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800724 incoming.m_face->Send (packet->Copy ());
725
726 m_outNacks (header, incoming.m_face);
727 }
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800728
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700729 // All incoming interests cannot be satisfied. Remove them
730 m_pit->modify (m_pit->iterator_to (pitEntry),
731 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800732
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700733 // Remove also outgoing
734 m_pit->modify (m_pit->iterator_to (pitEntry),
735 ll::bind (&CcnxPitEntry::ClearOutgoing, ll::_1));
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800736
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700737 // Set pruning timout on PIT entry (instead of deleting the record)
738 m_pit->modify (m_pit->iterator_to (pitEntry),
739 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
740 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
741 }
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800742}
743
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700744} //namespace ns3