blob: c06e0cfe44eca339fabb58b977e78c3741fa3caf [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 Afanasyev08d984e2011-08-13 19:20:22 -0700175uint32_t
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700176CcnxL3Protocol::AddFace (const Ptr<CcnxFace> &face)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700177{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700178 NS_LOG_FUNCTION (this << &face);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700179
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700180 face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700181
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700182 // ask face to register in lower-layer stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700183 face->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this));
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700184
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700185 m_faces.push_back (face);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800186 m_faceCounter++;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700187 return face->GetId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700188}
189
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700190void
191CcnxL3Protocol::RemoveFace (Ptr<CcnxFace> face)
192{
193 // ask face to register in lower-layer stack
194 face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ());
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800195
196 // just to be on a safe side. Do the process in two steps
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800197 std::list<boost::reference_wrapper<const CcnxPitEntry> > entriesToRemoves;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800198 BOOST_FOREACH (const CcnxPitEntry &pitEntry, *m_pit)
199 {
200 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800201 ll::bind (&CcnxPitEntry::RemoveAllReferencesToFace, ll::_1, face));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800202
203 // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
204 // Thus, we have to remove the whole PIT entry
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800205 if (pitEntry.m_fibEntry.m_faces.size () == 1 &&
206 pitEntry.m_fibEntry.m_faces.begin ()->m_face == face)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800207 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800208 entriesToRemoves.push_back (boost::cref (pitEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800209 }
210 }
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800211 BOOST_FOREACH (const CcnxPitEntry &removedEntry, entriesToRemoves)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800212 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800213 m_pit->erase (m_pit->iterator_to (removedEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800214 }
215
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700216 CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
217 NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist");
218 m_faces.erase (face_it);
219}
220
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700221Ptr<CcnxFace>
Alexander Afanasyev98256102011-08-14 01:00:02 -0700222CcnxL3Protocol::GetFace (uint32_t index) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700223{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700224 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 -0700225 {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700226 if (face->GetId () == index)
227 return face;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700228 }
229 return 0;
230}
231
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800232Ptr<CcnxFace>
233CcnxL3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
234{
235 BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
236 {
237 Ptr<CcnxNetDeviceFace> netDeviceFace = DynamicCast<CcnxNetDeviceFace> (face);
238 if (netDeviceFace == 0) continue;
239
240 if (netDeviceFace->GetNetDevice () == netDevice)
241 return face;
242 }
243 return 0;
244}
245
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700246uint32_t
Alexander Afanasyev98256102011-08-14 01:00:02 -0700247CcnxL3Protocol::GetNFaces (void) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700248{
Alexander Afanasyev98256102011-08-14 01:00:02 -0700249 return m_faces.size ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700250}
251
Alexander Afanasyev98256102011-08-14 01:00:02 -0700252// Callback from lower layer
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700253void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700254CcnxL3Protocol::Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700255{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700256 NS_LOG_LOGIC ("Packet from face " << *face << " received on node " << m_node->GetId ());
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700257
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700258 Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700259 try
260 {
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700261 CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700262 switch (type)
263 {
264 case CcnxHeaderHelper::INTEREST:
265 {
266 Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700267
268 // Deserialization. Exception may be thrown
269 packet->RemoveHeader (*header);
270 NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800271
272 if (header->GetNack () > 0)
273 OnNack (face, header, p/*original packet*/);
274 else
275 OnInterest (face, header, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700276 break;
277 }
278 case CcnxHeaderHelper::CONTENT_OBJECT:
279 {
280 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700281
282 static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object
283
284 // Deserialization. Exception may be thrown
285 packet->RemoveHeader (*header);
286 packet->RemoveTrailer (contentObjectTrailer);
287
288 OnData (face, header, packet/*payload*/, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700289 break;
290 }
291 }
292
293 // exception will be thrown if packet is not recognized
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700294 }
295 catch (CcnxUnknownHeaderException)
296 {
297 NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
298 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700299}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700300
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800301void
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800302CcnxL3Protocol::OnNack (const Ptr<CcnxFace> &incomingFace,
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800303 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800304 const Ptr<const Packet> &packet)
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800305{
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800306 NS_LOG_FUNCTION (incomingFace << header << packet);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800307 m_inNacks (header, incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800308
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800309 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
310 CcnxPitEntry const& pitEntry = ret.get<0> ();
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800311 bool isNew = ret.get<1> ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800312 bool isDuplicated = ret.get<2> ();
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800313
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800314 if (isNew || !isDuplicated) // potential flow
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800315 {
316 // somebody is doing something bad
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800317 m_dropNacks (header, NON_DUPLICATED, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800318 return;
319 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800320
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800321 // CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
322 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800323
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800324 if (outFace == pitEntry.m_outgoing.end ())
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800325 {
Alexander Afanasyev8f5a9bb2011-12-18 19:49:02 -0800326// NS_ASSERT_MSG (false,
327// "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
328// "size: " << pitEntry.m_outgoing.size ());
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800329
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800330 // m_dropNacks (header, NON_DUPLICATE, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800331 return;
332 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800333
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800334 // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
335 // at least when there is only one client
336 //
337 // incomingFace->LeakBucketByOnePacket ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800338
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800339 NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
340
Alexander Afanasyev5a595072011-11-25 14:49:07 -0800341 m_pit->modify (m_pit->iterator_to (pitEntry),
342 ll::bind (&CcnxPitEntry::SetWaitingInVain, ll::_1, outFace));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800343
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800344 // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
345 // So, if we had an incoming entry to this neighbor, then we can remove it now
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800346
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800347 if (header->GetNack () == CcnxInterestHeader::NACK_GIVEUP_PIT)
348 {
349 m_pit->modify (m_pit->iterator_to (pitEntry),
350 ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
351 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800352
Alexander Afanasyev07827182011-12-13 01:07:32 -0800353 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
354 ll::bind (&CcnxFibEntry::UpdateStatus,
355 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800356
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800357 if (pitEntry.m_incoming.size () == 0) // interest was actually satisfied
358 {
359 // no need to do anything
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800360 m_dropNacks (header, AFTER_SATISFIED, incomingFace);
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800361 return;
362 }
363
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800364 if (!pitEntry.AreAllOutgoingInVain ()) // not all ougtoing are in vain
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800365 {
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800366 NS_LOG_DEBUG ("Not all outgoing are in vain");
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800367 // suppress
368 // Don't do anything, we are still expecting data from some other face
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800369 m_dropNacks (header, SUPPRESSED, incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800370 return;
371 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800372
373 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800374
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800375 Ptr<Packet> nonNackInterest = Create<Packet> ();
376 header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
377 nonNackInterest->AddHeader (*header);
378
379 bool propagated = m_forwardingStrategy->
380 PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
381
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800382 // // ForwardingStrategy will try its best to forward packet to at least one interface.
383 // // If no interests was propagated, then there is not other option for forwarding or
384 // // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800385 if (!propagated)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800386 {
387 m_dropNacks (header, NO_FACES, incomingFace); // this headers doesn't have NACK flag set
388 GiveUpInterest (pitEntry, header);
389 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800390}
391
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700392// Processing Interests
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800393//
394// !!! Key point.
395// !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700396void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
397 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700398 const Ptr<const Packet> &packet)
Alexander Afanasyev98256102011-08-14 01:00:02 -0700399{
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700400 NS_LOG_FUNCTION (incomingFace << header << packet << header->GetName ());
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800401 m_inInterests (header, incomingFace);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700402 // NS_LOG_DEBUG (*m_pit);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700403
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800404 // Lookup of Pit (and associated Fib) entry for this Interest
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800405 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
406 CcnxPitEntry const& pitEntry = ret.get<0> ();
Alexander Afanasyev4e970942012-03-09 10:58:11 -0800407 bool isNew = ret.get<1> ();
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800408 bool isDuplicated = ret.get<2> ();
Ilya Moiseenkod83eb0d2011-11-16 15:23:46 -0800409
Alexander Afanasyev8d11fcc2011-12-30 12:42:31 -0800410 // NS_LOG_DEBUG ("isNew: " << isNew << ", isDup: " << isDuplicated);
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800411
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800412 if (isDuplicated)
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700413 {
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800414 m_dropInterests (header, DUPLICATED, incomingFace);
415
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800416 /**
417 * This condition will handle "routing" loops and also recently satisfied interests.
418 * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
419 * is kept for another small chunk of time.
420 */
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700421
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800422 if (m_nacksEnabled)
423 {
424 NS_LOG_DEBUG ("Sending NACK_LOOP");
425 header->SetNack (CcnxInterestHeader::NACK_LOOP);
426 Ptr<Packet> nack = Create<Packet> ();
427 nack->AddHeader (*header);
428
429 incomingFace->Send (nack);
430 m_outNacks (header, incomingFace);
431 }
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700432
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700433 return;
434 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800435
436 Ptr<Packet> contentObject;
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800437 Ptr<const CcnxContentObjectHeader> contentObjectHeader; // used for tracing
438 Ptr<const Packet> payload; // used for tracing
439 tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800440 if (contentObject != 0)
441 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800442 NS_ASSERT (contentObjectHeader != 0);
443
444 NS_LOG_LOGIC("Found in cache");
445
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800446 incomingFace->Send (contentObject);
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800447 m_outData (contentObjectHeader, payload, true, incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800448
449 // Set pruning timout on PIT entry (instead of deleting the record)
450 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800451 bind (&CcnxPitEntry::SetExpireTime, ll::_1,
452 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
Ilya Moiseenko816de832011-12-15 16:32:24 -0800453
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800454 return;
455 }
456
457 // \todo Detect retransmissions. Not yet sure how...
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700458
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700459 // Data is not in cache
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800460 CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
461 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
462
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800463 bool isRetransmitted = false;
464
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800465 if (inFace != pitEntry.m_incoming.end ())
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700466 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800467 // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800468
469 isRetransmitted = true;
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800470 // this is almost definitely a retransmission. But should we trust the user on that?
471 }
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700472 else
473 {
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800474 m_pit->modify (m_pit->iterator_to (pitEntry),
475 ll::var(inFace) = ll::bind (&CcnxPitEntry::AddIncoming, ll::_1, incomingFace));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800476 }
477
Alexander Afanasyev4e970942012-03-09 10:58:11 -0800478 // NS_LOG_DEBUG ("IsRetx: " << isRetransmitted);
479 // NS_LOG_DEBUG (*m_pit);
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800480
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800481 // update PIT entry lifetime
482 m_pit->modify (m_pit->iterator_to (pitEntry),
483 ll::bind (&CcnxPitEntry::UpdateLifetime, ll::_1,
484 header->GetInterestLifetime ()));
485
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800486 if (outFace != pitEntry.m_outgoing.end ())
487 {
Alexander Afanasyeve192a2a2012-04-09 14:57:54 -0700488 NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800489 // got a non-duplicate interest from the face we have sent interest to
490 // Probably, there is no point in waiting data from that face... Not sure yet
491
492 // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
493 // Mark interface YELLOW, but keep a small hope that data will come eventually.
494
495 // ?? not sure if we need to do that ?? ...
496
Alexander Afanasyev07827182011-12-13 01:07:32 -0800497 m_fib->m_fib.modify(m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
498 ll::bind (&CcnxFibEntry::UpdateStatus,
499 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800500 }
Alexander Afanasyeve192a2a2012-04-09 14:57:54 -0700501 else
502 if (!isNew && !isRetransmitted)
503 {
504 // Suppress this interest if we're still expecting data from some other face
505 NS_LOG_DEBUG ("Suppress interests");
506 m_dropInterests (header, SUPPRESSED, incomingFace);
507 return;
508 }
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800509
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800510 /////////////////////////////////////////////////////////////////////
511 // Propagate
512 /////////////////////////////////////////////////////////////////////
513
514 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
515
516 bool propagated = m_forwardingStrategy->
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800517 PropagateInterest (pitEntry, incomingFace, header, packet);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800518
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800519 if (isRetransmitted) //give another chance if retransmitted
520 {
521 // increase max number of allowed retransmissions
522 m_pit->modify (m_pit->iterator_to (pitEntry),
523 ll::bind (&CcnxPitEntry::IncreaseAllowedRetxCount, ll::_1));
524
525 // try again
526 propagated = m_forwardingStrategy->
527 PropagateInterest (pitEntry, incomingFace, header, packet);
528 }
529
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800530 // ForwardingStrategy will try its best to forward packet to at least one interface.
531 // If no interests was propagated, then there is not other option for forwarding or
532 // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800533 if (!propagated)
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800534 {
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800535 NS_LOG_DEBUG ("Not propagated");
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800536 m_dropInterests (header, NO_FACES, incomingFace);
537 GiveUpInterest (pitEntry, header);
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800538 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800539}
540
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700541void
542CcnxL3Protocol::OnDataDelayed (Ptr<CcnxContentObjectHeader> header,
543 Ptr<Packet> payload,
544 const Ptr<const Packet> &packet)
545{
546 if (m_delayingDataProcessing)
547 {
548 NS_LOG_DEBUG ("Delayed processing " << header->GetName ());
549 // NS_LOG_DEBUG (*m_pit);
550 }
551
552 // 1. Lookup PIT entry
553 try
554 {
555 CcnxPitEntryContainer::type::iterator pitEntry = m_pit->Lookup (*header);
556
557 //satisfy all pending incoming Interests
558 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->m_incoming)
559 {
560 incoming.m_face->Send (packet->Copy ());
561 m_outData (header, payload, false, incoming.m_face);
562 NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
563
564 // successfull forwarded data trace
565 }
566
567 if (pitEntry->m_incoming.size () > 0)
568 {
569 // All incoming interests are satisfied. Remove them
570 m_pit->modify (pitEntry,
571 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
572
573 // Remove all outgoing faces
574 m_pit->modify (pitEntry,
575 ll::bind (&CcnxPitEntry::ClearOutgoing, ll::_1));
576
577 // Set pruning timout on PIT entry (instead of deleting the record)
578 m_pit->modify (pitEntry,
579 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
580 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
581 }
582 }
583 catch (CcnxPitEntryNotFound)
584 {
585 NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
586 return; // do not process unsoliced data packets
587 }
588}
589
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700590// Processing ContentObjects
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800591void
592CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
593 Ptr<CcnxContentObjectHeader> &header,
594 Ptr<Packet> &payload,
595 const Ptr<const Packet> &packet)
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700596{
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700597
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700598 NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800599 m_inData (header, payload, incomingFace);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700600 // NS_LOG_DEBUG (*m_pit);
601
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700602 // 1. Lookup PIT entry
603 try
604 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700605 CcnxPitEntryContainer::type::iterator pitEntry = m_pit->Lookup (*header);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700606
607 // Note that with MultiIndex we need to modify entries indirectly
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700608
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700609 CcnxPitEntryOutgoingFaceContainer::type::iterator out = pitEntry->m_outgoing.find (incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700610
611 // If we have sent interest for this data via this face, then update stats.
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700612 if (out != pitEntry->m_outgoing.end ())
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700613 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700614 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry->m_fibEntry),
Alexander Afanasyev07827182011-12-13 01:07:32 -0800615 ll::bind (&CcnxFibEntry::UpdateFaceRtt,
616 ll::_1,
617 incomingFace,
618 Simulator::Now () - out->m_sendTime));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700619 }
620 else
621 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800622 // Unsolicited data, but we're interested in it... should we get it?
623 // Potential hole for attacks
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800624
Alexander Afanasyevde009992012-02-04 18:54:54 -0800625 if (m_cacheUnsolicitedData)
626 {
627 // Optimistically add or update entry in the content store
628 m_contentStore->Add (header, payload);
629 }
630 else
631 {
632 NS_LOG_ERROR ("Node "<< m_node->GetId() <<
633 ". PIT entry for "<< header->GetName ()<<" is valid, "
634 "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
635 }
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800636 // ignore unsolicited data
637 return;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700638 }
639
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800640 // Update metric status for the incoming interface in the corresponding FIB entry
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700641 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry->m_fibEntry),
Alexander Afanasyev07827182011-12-13 01:07:32 -0800642 ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
643 incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800644
645 // Add or update entry in the content store
646 m_contentStore->Add (header, payload);
647
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700648 m_pit->modify (pitEntry,
649 ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
650
651 if (pitEntry->m_incoming.size () == 0)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700652 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700653 // Set pruning timout on PIT entry (instead of deleting the record)
654 m_pit->modify (pitEntry,
655 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
656 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
657 }
658 else
659 {
660 if (!m_delayingDataProcessing)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800661 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700662 OnDataDelayed (header, payload, packet);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800663 }
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700664 else
665 {
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700666 NS_LOG_DEBUG ("Delaying Data forwarding " << header->GetName ());
667 UniformVariable delay (0.0001, 0.002);
668 Simulator::Schedule (Seconds (delay.GetValue ()),
669 &CcnxL3Protocol::OnDataDelayed, this, header, payload, packet);
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700670 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700671 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700672 }
673 catch (CcnxPitEntryNotFound)
674 {
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700675 NS_LOG_DEBUG ("Pit entry not found");
Alexander Afanasyevde009992012-02-04 18:54:54 -0800676 if (m_cacheUnsolicitedData)
677 {
678 // Optimistically add or update entry in the content store
679 m_contentStore->Add (header, payload);
680 }
681 else
682 {
683 // Drop data packet if PIT entry is not found
684 // (unsolicited data packets should not "poison" content store)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700685
Alexander Afanasyevde009992012-02-04 18:54:54 -0800686 //drop dulicated or not requested data packet
687 m_dropData (header, payload, UNSOLICITED, incomingFace);
688 }
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700689 return; // do not process unsoliced data packets
690 }
691}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700692
693void
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800694CcnxL3Protocol::GiveUpInterest (const CcnxPitEntry &pitEntry,
695 Ptr<CcnxInterestHeader> header)
696{
Alexander Afanasyevde009992012-02-04 18:54:54 -0800697 NS_LOG_FUNCTION (this << &pitEntry);
Alexander Afanasyevff8c5d62012-04-25 15:14:51 -0700698 // NS_LOG_DEBUG (*m_pit);
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800699 if (m_nacksEnabled)
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800700 {
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800701 Ptr<Packet> packet = Create<Packet> ();
702 header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
703 packet->AddHeader (*header);
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800704
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800705 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry.m_incoming)
706 {
Alexander Afanasyevde009992012-02-04 18:54:54 -0800707 NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800708 incoming.m_face->Send (packet->Copy ());
709
710 m_outNacks (header, incoming.m_face);
711 }
Alexander Afanasyevbab81b12012-02-04 14:20:09 -0800712
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700713 // All incoming interests cannot be satisfied. Remove them
714 m_pit->modify (m_pit->iterator_to (pitEntry),
715 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800716
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700717 // Remove also outgoing
718 m_pit->modify (m_pit->iterator_to (pitEntry),
719 ll::bind (&CcnxPitEntry::ClearOutgoing, ll::_1));
Alexander Afanasyev120bf312011-12-19 01:24:47 -0800720
Alexander Afanasyev1aeaf922012-04-23 13:48:09 -0700721 // Set pruning timout on PIT entry (instead of deleting the record)
722 m_pit->modify (m_pit->iterator_to (pitEntry),
723 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
724 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
725 }
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800726}
727
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700728} //namespace ns3