blob: 6b567c88e0b5cb03a99b03b11cc7919174f8d065 [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 Afanasyev08d984e2011-08-13 19:20:22 -070031#include "ns3/boolean.h"
Alexander Afanasyev07827182011-12-13 01:07:32 -080032#include "ns3/string.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070033
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070034#include "ns3/ccnx-header-helper.h"
35
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070036#include "ccnx-face.h"
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070037#include "ccnx-forwarding-strategy.h"
38#include "ccnx-interest-header.h"
39#include "ccnx-content-object-header.h"
40
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -080041#include "ccnx-net-device-face.h"
42
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070043#include <boost/foreach.hpp>
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080044#include <boost/lambda/lambda.hpp>
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080045#include <boost/lambda/bind.hpp>
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080046
47using namespace boost::tuples;
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080048namespace ll = boost::lambda;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070049
50NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
51
52namespace ns3 {
53
Alexander Afanasyev7112f482011-08-17 14:05:57 -070054const uint16_t CcnxL3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070055
Alexander Afanasyev07827182011-12-13 01:07:32 -080056
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070057NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol);
58
59TypeId
60CcnxL3Protocol::GetTypeId (void)
61{
62 static TypeId tid = TypeId ("ns3::CcnxL3Protocol")
63 .SetParent<Ccnx> ()
Alexander Afanasyev070aa482011-08-20 00:38:25 -070064 .SetGroupName ("Ccnx")
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070065 .AddConstructor<CcnxL3Protocol> ()
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080066 .AddAttribute ("BucketLeakInterval",
67 "Interval to leak buckets",
68 StringValue ("10ms"),
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080069 MakeTimeAccessor (&CcnxL3Protocol::GetBucketLeakInterval,
70 &CcnxL3Protocol::SetBucketLeakInterval),
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080071 MakeTimeChecker ())
Ilya Moiseenko816de832011-12-15 16:32:24 -080072
73 .AddTraceSource ("TransmittedInterestTrace", "Interests that were transmitted",
74 MakeTraceSourceAccessor (&CcnxL3Protocol::m_transmittedInterestsTrace))
75
76 .AddTraceSource ("ReceivedInterestTrace", "Interests that were received",
77 MakeTraceSourceAccessor (&CcnxL3Protocol::m_receivedInterestsTrace))
78
79 .AddTraceSource ("DroppedInterestTrace", "Interests that were dropped",
80 MakeTraceSourceAccessor (&CcnxL3Protocol::m_droppedInterestsTrace))
81
82 .AddTraceSource ("ReceivedDataTrace", "Data that were received",
83 MakeTraceSourceAccessor (&CcnxL3Protocol::m_receivedDataTrace))
84
85 .AddTraceSource ("TransmittedDataTrace", "Data that were transmitted",
86 MakeTraceSourceAccessor (&CcnxL3Protocol::m_transmittedDataTrace))
87
88 .AddTraceSource ("DroppedDataTrace", "Data that were dropped",
89 MakeTraceSourceAccessor (&CcnxL3Protocol::m_droppedDataTrace))
90
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 Afanasyev09c7deb2011-11-23 14:50:10 -0800144 if (m_bucketLeakEvent.IsRunning ())
145 m_bucketLeakEvent.Cancel ();
146
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700147 for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700148 {
149 *i = 0;
150 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700151 m_faces.clear ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700152 m_node = 0;
Alexander Afanasyevd02a5d62011-11-21 11:01:51 -0800153
154 // Force delete on objects
Alexander Afanasyev18252852011-11-21 13:35:31 -0800155 m_forwardingStrategy = 0; // there is a reference to PIT stored in here
Alexander Afanasyevd02a5d62011-11-21 11:01:51 -0800156 m_pit = 0;
157 m_contentStore = 0;
Alexander Afanasyev18252852011-11-21 13:35:31 -0800158 m_fib = 0;
159
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700160 // m_forwardingStrategy = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700161 Object::DoDispose ();
162}
163
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700164void
165CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy)
166{
167 NS_LOG_FUNCTION (this);
168 m_forwardingStrategy = forwardingStrategy;
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800169 m_forwardingStrategy->SetPit (m_pit);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700170}
171
172Ptr<CcnxForwardingStrategy>
173CcnxL3Protocol::GetForwardingStrategy (void) const
174{
175 return m_forwardingStrategy;
176}
177
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700178uint32_t
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700179CcnxL3Protocol::AddFace (const Ptr<CcnxFace> &face)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700180{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700181 NS_LOG_FUNCTION (this << &face);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700182
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700183 face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700184
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700185 // ask face to register in lower-layer stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700186 face->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this));
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700187
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700188 m_faces.push_back (face);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800189 m_faceCounter++;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700190 return face->GetId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700191}
192
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700193void
194CcnxL3Protocol::RemoveFace (Ptr<CcnxFace> face)
195{
196 // ask face to register in lower-layer stack
197 face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ());
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800198
199 // just to be on a safe side. Do the process in two steps
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800200 std::list<boost::reference_wrapper<const CcnxPitEntry> > entriesToRemoves;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800201 BOOST_FOREACH (const CcnxPitEntry &pitEntry, *m_pit)
202 {
203 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800204 ll::bind (&CcnxPitEntry::RemoveAllReferencesToFace, ll::_1, face));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800205
206 // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
207 // Thus, we have to remove the whole PIT entry
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800208 if (pitEntry.m_fibEntry.m_faces.size () == 1 &&
209 pitEntry.m_fibEntry.m_faces.begin ()->m_face == face)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800210 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800211 entriesToRemoves.push_back (boost::cref (pitEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800212 }
213 }
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800214 BOOST_FOREACH (const CcnxPitEntry &removedEntry, entriesToRemoves)
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800215 {
Alexander Afanasyev4a5c2c12011-12-12 18:50:57 -0800216 m_pit->erase (m_pit->iterator_to (removedEntry));
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800217 }
218
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700219 CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
220 NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist");
221 m_faces.erase (face_it);
222}
223
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700224Ptr<CcnxFace>
Alexander Afanasyev98256102011-08-14 01:00:02 -0700225CcnxL3Protocol::GetFace (uint32_t index) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700226{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700227 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 -0700228 {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700229 if (face->GetId () == index)
230 return face;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700231 }
232 return 0;
233}
234
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800235Ptr<CcnxFace>
236CcnxL3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
237{
238 BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
239 {
240 Ptr<CcnxNetDeviceFace> netDeviceFace = DynamicCast<CcnxNetDeviceFace> (face);
241 if (netDeviceFace == 0) continue;
242
243 if (netDeviceFace->GetNetDevice () == netDevice)
244 return face;
245 }
246 return 0;
247}
248
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700249uint32_t
Alexander Afanasyev98256102011-08-14 01:00:02 -0700250CcnxL3Protocol::GetNFaces (void) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700251{
Alexander Afanasyev98256102011-08-14 01:00:02 -0700252 return m_faces.size ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700253}
254
Alexander Afanasyev98256102011-08-14 01:00:02 -0700255// Callback from lower layer
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700256void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700257CcnxL3Protocol::Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700258{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700259 if (!face->IsUp ())
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700260 {
261 NS_LOG_LOGIC ("Dropping received packet -- interface is down");
Ilya Moiseenko816de832011-12-15 16:32:24 -0800262
263 //m_droppedDTrace (p, INTERFACE_DOWN, m_node->GetObject<Ccnx> ()/*this*/, face);
264
265 Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
266 try
267 {
268 CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p);
269 switch (type)
270 {
271 case CcnxHeaderHelper::INTEREST:
272 {
273 Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
274 m_droppedInterestsTrace (header, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face);
275 break;
276 }
277 case CcnxHeaderHelper::CONTENT_OBJECT:
278 {
279 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
280
281 static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object
282
283 // Deserialization. Exception may be thrown
284 packet->RemoveHeader (*header);
285 packet->RemoveTrailer (contentObjectTrailer);
286
287 m_droppedDataTrace (header, packet, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face);
288 break;
289 }
290 }
291
292 // exception will be thrown if packet is not recognized
293 }
294 catch (CcnxUnknownHeaderException)
295 {
296 NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
297 }
298
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700299 return;
300 }
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700301 NS_LOG_LOGIC ("Packet from face " << *face << " received on node " << m_node->GetId ());
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700302
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700303 Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700304 try
305 {
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700306 CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700307 switch (type)
308 {
309 case CcnxHeaderHelper::INTEREST:
310 {
311 Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700312
313 // Deserialization. Exception may be thrown
314 packet->RemoveHeader (*header);
315 NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800316
317 if (header->GetNack () > 0)
318 OnNack (face, header, p/*original packet*/);
319 else
320 OnInterest (face, header, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700321 break;
322 }
323 case CcnxHeaderHelper::CONTENT_OBJECT:
324 {
325 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700326
327 static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object
328
329 // Deserialization. Exception may be thrown
330 packet->RemoveHeader (*header);
331 packet->RemoveTrailer (contentObjectTrailer);
332
333 OnData (face, header, packet/*payload*/, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700334 break;
335 }
336 }
337
338 // exception will be thrown if packet is not recognized
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700339 }
340 catch (CcnxUnknownHeaderException)
341 {
342 NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
343 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700344}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700345
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800346void
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800347CcnxL3Protocol::OnNack (const Ptr<CcnxFace> &incomingFace,
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800348 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800349 const Ptr<const Packet> &packet)
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800350{
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800351 NS_LOG_FUNCTION (incomingFace << header << packet);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800352
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800353 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
354 CcnxPitEntry const& pitEntry = ret.get<0> ();
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800355 bool isNew = ret.get<1> ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800356 bool isDuplicated = ret.get<2> ();
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800357
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800358 // NS_ASSERT_MSG (isDuplicated,
359 // "NACK should be a duplicated interest");
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800360 if (isNew || !isDuplicated) // potential flow
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800361 {
362 // somebody is doing something bad
Ilya Moiseenko816de832011-12-15 16:32:24 -0800363 m_droppedInterestsTrace (header, NACK_NONDUPLICATE, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800364 return;
365 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800366
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800367 // CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
368 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800369
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800370 if (outFace == pitEntry.m_outgoing.end ())
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800371 {
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800372 NS_ASSERT_MSG (false,
373 "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
374 "size: " << pitEntry.m_outgoing.size ());
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800375
376 return;
377 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800378
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800379 // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
380 // at least when there is only one client
381 //
382 // incomingFace->LeakBucketByOnePacket ();
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800383
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800384 NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
385
Alexander Afanasyev5a595072011-11-25 14:49:07 -0800386 m_pit->modify (m_pit->iterator_to (pitEntry),
387 ll::bind (&CcnxPitEntry::SetWaitingInVain, ll::_1, outFace));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800388
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800389 // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
390 // So, if we had an incoming entry to this neighbor, then we can remove it now
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800391
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800392 if (header->GetNack () == CcnxInterestHeader::NACK_GIVEUP_PIT)
393 {
394 m_pit->modify (m_pit->iterator_to (pitEntry),
395 ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
396 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800397
Alexander Afanasyev07827182011-12-13 01:07:32 -0800398 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
399 ll::bind (&CcnxFibEntry::UpdateStatus,
400 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800401
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800402 if (pitEntry.m_incoming.size () == 0) // interest was actually satisfied
403 {
404 // no need to do anything
Ilya Moiseenko816de832011-12-15 16:32:24 -0800405 m_droppedInterestsTrace (header, NACK_AFTER_SATISFIED, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800406 return;
407 }
408
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800409 if (!pitEntry.AreAllOutgoingInVain ()) // not all ougtoing are in vain
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800410 {
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800411 NS_LOG_DEBUG ("Not all outgoing are in vain");
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800412 // suppress
413 // Don't do anything, we are still expecting data from some other face
Ilya Moiseenko816de832011-12-15 16:32:24 -0800414 m_droppedInterestsTrace (header, NACK_SUPPRESSED, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800415 return;
416 }
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800417
418 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800419
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800420 Ptr<Packet> nonNackInterest = Create<Packet> ();
421 header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
422 nonNackInterest->AddHeader (*header);
423
424 bool propagated = m_forwardingStrategy->
425 PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
426
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800427 // // ForwardingStrategy will try its best to forward packet to at least one interface.
428 // // If no interests was propagated, then there is not other option for forwarding or
429 // // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800430 if (!propagated)
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800431 GiveUpInterest (pitEntry, header);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800432}
433
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700434// Processing Interests
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800435//
436// !!! Key point.
437// !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700438void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
439 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700440 const Ptr<const Packet> &packet)
Alexander Afanasyev98256102011-08-14 01:00:02 -0700441{
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800442 NS_LOG_FUNCTION (incomingFace << header << packet);
Ilya Moiseenko816de832011-12-15 16:32:24 -0800443 //m_receivedInterestsTrace (header, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700444
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800445 // Lookup of Pit (and associated Fib) entry for this Interest
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800446 tuple<const CcnxPitEntry&,bool,bool> ret = m_pit->Lookup (*header);
447 CcnxPitEntry const& pitEntry = ret.get<0> ();
448 // bool isNew = ret.get<1> ();
449 bool isDuplicated = ret.get<2> ();
Ilya Moiseenkod83eb0d2011-11-16 15:23:46 -0800450
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800451 if (isDuplicated)
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700452 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800453 /**
454 * This condition will handle "routing" loops and also recently satisfied interests.
455 * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
456 * is kept for another small chunk of time.
457 */
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700458
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800459 // //Trace duplicate interest
460 // m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST, m_node->GetObject<Ccnx> (), incomingFace);
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700461
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800462 NS_LOG_DEBUG ("Sending NACK_LOOP");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800463 header->SetNack (CcnxInterestHeader::NACK_LOOP);
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800464 Ptr<Packet> nack = Create<Packet> ();
465 nack->AddHeader (*header);
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700466
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800467 incomingFace->Send (nack);
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700468
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800469 // //Trace duplicate interest
Ilya Moiseenko816de832011-12-15 16:32:24 -0800470 m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700471 return;
472 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800473
474 Ptr<Packet> contentObject;
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800475 Ptr<const CcnxContentObjectHeader> contentObjectHeader; // unused for now
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800476 tie (contentObject, contentObjectHeader) = m_contentStore->Lookup (header);
477 if (contentObject != 0)
478 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800479 NS_ASSERT (contentObjectHeader != 0);
480
481 NS_LOG_LOGIC("Found in cache");
482
Ilya Moiseenko816de832011-12-15 16:32:24 -0800483 m_transmittedDataTrace (contentObjectHeader, contentObject, CACHED, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800484 incomingFace->Send (contentObject);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800485
486 // Set pruning timout on PIT entry (instead of deleting the record)
487 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800488 bind (&CcnxPitEntry::SetExpireTime, ll::_1,
489 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
Ilya Moiseenko816de832011-12-15 16:32:24 -0800490
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800491 return;
492 }
493
494 // \todo Detect retransmissions. Not yet sure how...
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700495
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700496 // Data is not in cache
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800497 CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
498 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
499
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800500 bool isRetransmitted = false;
501
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800502 if (inFace != pitEntry.m_incoming.end ())
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700503 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800504 // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800505
506 isRetransmitted = true;
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800507 // this is almost definitely a retransmission. But should we trust the user on that?
508 }
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700509 else
510 {
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800511 m_pit->modify (m_pit->iterator_to (pitEntry),
512 ll::var(inFace) = ll::bind (&CcnxPitEntry::AddIncoming, ll::_1, incomingFace));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800513 }
514
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800515 // update PIT entry lifetime
516 m_pit->modify (m_pit->iterator_to (pitEntry),
517 ll::bind (&CcnxPitEntry::UpdateLifetime, ll::_1,
518 header->GetInterestLifetime ()));
519
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800520 if (outFace != pitEntry.m_outgoing.end ())
521 {
522 // got a non-duplicate interest from the face we have sent interest to
523 // Probably, there is no point in waiting data from that face... Not sure yet
524
525 // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
526 // Mark interface YELLOW, but keep a small hope that data will come eventually.
527
528 // ?? not sure if we need to do that ?? ...
529
Alexander Afanasyev07827182011-12-13 01:07:32 -0800530 m_fib->m_fib.modify(m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
531 ll::bind (&CcnxFibEntry::UpdateStatus,
532 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800533 }
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800534
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800535 if (!isRetransmitted &&
536 pitEntry.AreTherePromisingOutgoingFacesExcept (incomingFace))
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800537 { // Suppress this interest if we're still expecting data from some other face
538
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800539 // We are already expecting data later in future. Suppress the interest
Ilya Moiseenko816de832011-12-15 16:32:24 -0800540 m_droppedInterestsTrace (header, NDN_SUPPRESSED_INTEREST, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800541 return;
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800542 }
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800543
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800544 /////////////////////////////////////////////////////////////////////
545 // Propagate
546 /////////////////////////////////////////////////////////////////////
547
548 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
549
550 bool propagated = m_forwardingStrategy->
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800551 PropagateInterest (pitEntry, incomingFace, header, packet);
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800552
Alexander Afanasyev0a61c342011-12-06 12:48:55 -0800553 if (isRetransmitted) //give another chance if retransmitted
554 {
555 // increase max number of allowed retransmissions
556 m_pit->modify (m_pit->iterator_to (pitEntry),
557 ll::bind (&CcnxPitEntry::IncreaseAllowedRetxCount, ll::_1));
558
559 // try again
560 propagated = m_forwardingStrategy->
561 PropagateInterest (pitEntry, incomingFace, header, packet);
562 }
563
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800564 // ForwardingStrategy will try its best to forward packet to at least one interface.
565 // If no interests was propagated, then there is not other option for forwarding or
566 // ForwardingStrategy failed to find it.
Alexander Afanasyeve67a97f2011-11-29 14:28:59 -0800567 if (!propagated)
Alexander Afanasyeva7a2b8b2011-11-28 18:19:09 -0800568 GiveUpInterest (pitEntry, header);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700569}
570
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800571void
572CcnxL3Protocol::GiveUpInterest (const CcnxPitEntry &pitEntry,
573 Ptr<CcnxInterestHeader> header)
574{
575 Ptr<Packet> packet = Create<Packet> ();
576 header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
577 packet->AddHeader (*header);
578
579 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry.m_incoming)
580 {
581 incoming.m_face->Send (packet->Copy ());
582
Ilya Moiseenko816de832011-12-15 16:32:24 -0800583 //m_droppedInterestsTrace (header, DROP_CONGESTION,
584 // m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyev9d313d42011-11-25 13:36:15 -0800585 }
586 // All incoming interests cannot be satisfied. Remove them
587 m_pit->modify (m_pit->iterator_to (pitEntry),
588 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
589
590 // Set pruning timout on PIT entry (instead of deleting the record)
591 m_pit->modify (m_pit->iterator_to (pitEntry),
592 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
593 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
594}
595
596
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700597// Processing ContentObjects
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800598void
599CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
600 Ptr<CcnxContentObjectHeader> &header,
601 Ptr<Packet> &payload,
602 const Ptr<const Packet> &packet)
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700603{
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700604
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800605 NS_LOG_FUNCTION (incomingFace << header << payload << packet);
Ilya Moiseenko816de832011-12-15 16:32:24 -0800606 m_receivedDataTrace (header, payload, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700607
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700608 // 1. Lookup PIT entry
609 try
610 {
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700611 const CcnxPitEntry &pitEntry = m_pit->Lookup (*header);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700612
613 // Note that with MultiIndex we need to modify entries indirectly
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700614
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800615 CcnxPitEntryOutgoingFaceContainer::type::iterator out = pitEntry.m_outgoing.find (incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700616
617 // If we have sent interest for this data via this face, then update stats.
618 if (out != pitEntry.m_outgoing.end ())
619 {
Alexander Afanasyev07827182011-12-13 01:07:32 -0800620 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
621 ll::bind (&CcnxFibEntry::UpdateFaceRtt,
622 ll::_1,
623 incomingFace,
624 Simulator::Now () - out->m_sendTime));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700625 }
626 else
627 {
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800628 // Unsolicited data, but we're interested in it... should we get it?
629 // Potential hole for attacks
630
631 NS_LOG_ERROR ("Node "<< m_node->GetId() <<
632 ". PIT entry for "<< header->GetName ()<<" is valid, "
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800633 "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800634
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800635 // ignore unsolicited data
636 return;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700637 }
638
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800639 // Update metric status for the incoming interface in the corresponding FIB entry
Alexander Afanasyev07827182011-12-13 01:07:32 -0800640 m_fib->m_fib.modify (m_fib->m_fib.iterator_to (pitEntry.m_fibEntry),
641 ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
642 incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800643
644 // Add or update entry in the content store
645 m_contentStore->Add (header, payload);
646
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700647 //satisfy all pending incoming Interests
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800648 BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry.m_incoming)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700649 {
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800650 if (incoming.m_face != incomingFace)
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800651 incoming.m_face->Send (packet->Copy ());
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700652
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800653 // successfull forwarded data trace
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700654 }
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800655 // All incoming interests are satisfied. Remove them
656 m_pit->modify (m_pit->iterator_to (pitEntry),
657 ll::bind (&CcnxPitEntry::ClearIncoming, ll::_1));
658
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800659 // Set pruning timout on PIT entry (instead of deleting the record)
660 m_pit->modify (m_pit->iterator_to (pitEntry),
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800661 ll::bind (&CcnxPitEntry::SetExpireTime, ll::_1,
Alexander Afanasyeva46844b2011-11-21 19:13:26 -0800662 Simulator::Now () + m_pit->GetPitEntryPruningTimeout ()));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700663 }
664 catch (CcnxPitEntryNotFound)
665 {
666 // 2. Drop data packet if PIT entry is not found
667 // (unsolicited data packets should not "poison" content store)
668
669 //drop dulicated or not requested data packet
Ilya Moiseenko816de832011-12-15 16:32:24 -0800670 m_droppedDataTrace (header, payload, NDN_UNSOLICITED_DATA, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700671 return; // do not process unsoliced data packets
672 }
673}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700674
675void
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800676CcnxL3Protocol::SetBucketLeakInterval (Time interval)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700677{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800678 m_bucketLeakInterval = interval;
679
680 if (m_bucketLeakEvent.IsRunning ())
681 m_bucketLeakEvent.Cancel ();
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700682
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800683 m_bucketLeakEvent = Simulator::Schedule (m_bucketLeakInterval,
684 &CcnxL3Protocol::LeakBuckets, this);
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700685}
686
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800687Time
688CcnxL3Protocol::GetBucketLeakInterval () const
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700689{
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800690 return m_bucketLeakInterval;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700691}
692
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800693void
Alexander Afanasyev19426ef2011-11-23 20:55:28 -0800694CcnxL3Protocol::LeakBuckets ()
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700695{
Alexander Afanasyev23d2b542011-12-07 18:54:46 -0800696 // NS_LOG_FUNCTION (this);
Alexander Afanasyevc39f0b42011-11-28 12:51:12 -0800697
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -0800698 BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces)
699 {
700 face->LeakBucket (m_bucketLeakInterval);
701 }
702
703 m_bucketLeakEvent = Simulator::Schedule (m_bucketLeakInterval,
Alexander Afanasyevb5703a92011-11-25 16:46:15 -0800704 &CcnxL3Protocol::LeakBuckets,
705 this);
Ilya Moiseenko172763c2011-10-28 13:21:53 -0700706}
Ilya Moiseenkod83eb0d2011-11-16 15:23:46 -0800707
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700708} //namespace ns3