blob: a4241bc256ae9ea0ce2ed48fd117a63dbd572bd0 [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>
19 */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070020
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070021#include "ccnx-l3-protocol.h"
22
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070023#include "ns3/packet.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070024#include "ns3/node.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070025#include "ns3/log.h"
26#include "ns3/callback.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070027#include "ns3/uinteger.h"
28#include "ns3/trace-source-accessor.h"
29#include "ns3/object-vector.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070030#include "ns3/boolean.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070031
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070032#include "ns3/ccnx-header-helper.h"
33
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070034#include "ccnx-face.h"
35#include "ccnx-route.h"
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070036#include "ccnx-forwarding-strategy.h"
37#include "ccnx-interest-header.h"
38#include "ccnx-content-object-header.h"
39
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070040#include <boost/foreach.hpp>
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070041
42NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
43
44namespace ns3 {
45
Alexander Afanasyev7112f482011-08-17 14:05:57 -070046const uint16_t CcnxL3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070047
48NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol);
49
50TypeId
51CcnxL3Protocol::GetTypeId (void)
52{
53 static TypeId tid = TypeId ("ns3::CcnxL3Protocol")
54 .SetParent<Ccnx> ()
Alexander Afanasyev070aa482011-08-20 00:38:25 -070055 .SetGroupName ("Ccnx")
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070056 .AddConstructor<CcnxL3Protocol> ()
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 // .AddTraceSource ("Tx", "Send ccnx packet to outgoing interface.",
58 // MakeTraceSourceAccessor (&CcnxL3Protocol::m_txTrace))
59 // .AddTraceSource ("Rx", "Receive ccnx packet from incoming interface.",
60 // MakeTraceSourceAccessor (&CcnxL3Protocol::m_rxTrace))
61 // .AddTraceSource ("Drop", "Drop ccnx packet",
62 // MakeTraceSourceAccessor (&CcnxL3Protocol::m_dropTrace))
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070063 // .AddAttribute ("InterfaceList", "The set of Ccnx interfaces associated to this Ccnx stack.",
64 // ObjectVectorValue (),
65 // MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces),
66 // MakeObjectVectorChecker<CcnxFace> ())
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070067
Alexander Afanasyev7112f482011-08-17 14:05:57 -070068 // .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission",
69 // MakeTraceSourceAccessor (&CcnxL3Protocol::m_sendOutgoingTrace))
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070070
71 ;
72 return tid;
73}
74
75CcnxL3Protocol::CcnxL3Protocol()
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070076: m_faceCounter (0)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070077{
78 NS_LOG_FUNCTION (this);
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070079
80 m_rit = CreateObject<CcnxRit> ();
81 m_pit = CreateObject<CcnxPit> ();
82 m_contentStore = CreateObject<CcnxContentStore> ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070083}
84
85CcnxL3Protocol::~CcnxL3Protocol ()
86{
87 NS_LOG_FUNCTION (this);
88}
89
90void
91CcnxL3Protocol::SetNode (Ptr<Node> node)
92{
93 m_node = node;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070094 m_fib = m_node->GetObject<CcnxFib> ();
95 NS_ASSERT_MSG (m_fib != 0, "FIB should be created and aggregated to a node before calling Ccnx::SetNode");
96
97 m_pit->SetFib (m_fib);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070098}
99
100/*
101 * This method is called by AddAgregate and completes the aggregation
102 * by setting the node in the ccnx stack
103 */
104void
105CcnxL3Protocol::NotifyNewAggregate ()
106{
107 if (m_node == 0)
108 {
109 Ptr<Node>node = this->GetObject<Node>();
110 // verify that it's a valid node and that
111 // the node has not been set before
112 if (node != 0)
113 {
114 this->SetNode (node);
115 }
116 }
117 Object::NotifyNewAggregate ();
118}
119
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700120void
121CcnxL3Protocol::DoDispose (void)
122{
123 NS_LOG_FUNCTION (this);
124
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700125 for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700126 {
127 *i = 0;
128 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700129 m_faces.clear ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700130 m_node = 0;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700131 // m_forwardingStrategy = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700132 Object::DoDispose ();
133}
134
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700135void
136CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy)
137{
138 NS_LOG_FUNCTION (this);
139 m_forwardingStrategy = forwardingStrategy;
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700140 // m_forwardingStrategy->SetCcnx (this);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700141}
142
143Ptr<CcnxForwardingStrategy>
144CcnxL3Protocol::GetForwardingStrategy (void) const
145{
146 return m_forwardingStrategy;
147}
148
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700149uint32_t
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700150CcnxL3Protocol::AddFace (const Ptr<CcnxFace> &face)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700151{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700152 NS_LOG_FUNCTION (this << &face);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700153
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700154 face->SetNode (m_node);
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700155 face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700156
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700157 // ask face to register in lower-layer stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700158 face->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this));
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700159
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700160 m_faces.push_back (face);
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700161 m_faceCounter ++;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700162 return face->GetId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700163}
164
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700165void
166CcnxL3Protocol::RemoveFace (Ptr<CcnxFace> face)
167{
168 // ask face to register in lower-layer stack
169 face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ());
170 CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
171 NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist");
172 m_faces.erase (face_it);
173}
174
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700175Ptr<CcnxFace>
Alexander Afanasyev98256102011-08-14 01:00:02 -0700176CcnxL3Protocol::GetFace (uint32_t index) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700177{
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700178 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 -0700179 {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700180 if (face->GetId () == index)
181 return face;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700182 }
183 return 0;
184}
185
186uint32_t
Alexander Afanasyev98256102011-08-14 01:00:02 -0700187CcnxL3Protocol::GetNFaces (void) const
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700188{
Alexander Afanasyev98256102011-08-14 01:00:02 -0700189 return m_faces.size ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700190}
191
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700192void
193CcnxL3Protocol::TransmittedDataTrace (Ptr<Packet> packet,
194 ContentObjectSource type,
195 Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face)
196{
197 // a "small" inefficiency for logging purposes
198 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
199 static CcnxContentObjectTail tail;
200 packet->RemoveHeader (*header);
201 packet->RemoveTrailer (tail);
202
203 m_transmittedDataTrace (header, packet/*payload*/, type, ccnx, face);
204
205 packet->AddHeader (*header);
206 packet->AddTrailer (tail);
207}
208
209
Alexander Afanasyev98256102011-08-14 01:00:02 -0700210// Callback from lower layer
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700211void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700212CcnxL3Protocol::Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700213{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700214 if (!face->IsUp ())
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700215 {
216 NS_LOG_LOGIC ("Dropping received packet -- interface is down");
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700217 // m_dropTrace (p, INTERFACE_DOWN, m_node->GetObject<Ccnx> ()/*this*/, face);
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700218 return;
219 }
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700220 NS_LOG_LOGIC ("Packet from face " << *face << " received on node " << m_node->GetId ());
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700221
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700222 Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700223 try
224 {
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700225 CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700226 switch (type)
227 {
228 case CcnxHeaderHelper::INTEREST:
229 {
230 Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700231
232 // Deserialization. Exception may be thrown
233 packet->RemoveHeader (*header);
234 NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero");
235
236 OnInterest (face, header, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700237 break;
238 }
239 case CcnxHeaderHelper::CONTENT_OBJECT:
240 {
241 Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700242
243 static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object
244
245 // Deserialization. Exception may be thrown
246 packet->RemoveHeader (*header);
247 packet->RemoveTrailer (contentObjectTrailer);
248
249 OnData (face, header, packet/*payload*/, p/*original packet*/);
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700250 break;
251 }
252 }
253
254 // exception will be thrown if packet is not recognized
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700255 }
256 catch (CcnxUnknownHeaderException)
257 {
258 NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
259 }
Alexander Afanasyev98256102011-08-14 01:00:02 -0700260}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700261
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700262// Processing Interests
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700263void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
264 Ptr<CcnxInterestHeader> &header,
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700265 const Ptr<const Packet> &packet)
Alexander Afanasyev98256102011-08-14 01:00:02 -0700266{
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700267 NS_LOG_LOGIC ("Receiving interest from " << &incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700268 m_receivedInterestsTrace (header, m_node->GetObject<Ccnx> ()/*this*/, incomingFace);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700269
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700270 if (m_rit->WasRecentlySatisfied (*header))
271 {
272 m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST,
273 m_node->GetObject<Ccnx> ()/*this*/, incomingFace);
274 // loop?
275 return;
276 }
277 m_rit->SetRecentlySatisfied (*header);
278
279 Ptr<Packet> contentObject = m_contentStore->Lookup (header);
280 if (contentObject != 0)
281 {
282 TransmittedDataTrace (contentObject, CACHED,
283 m_node->GetObject<Ccnx> ()/*this*/, incomingFace);
284 incomingFace->Send (contentObject);
285 return;
286 }
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700287
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700288 CcnxPitEntry pitEntry = m_pit->Lookup (*header);
289
290 CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry.m_incoming.find (incomingFace);
291 CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry.m_outgoing.find (incomingFace);
292
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700293 // // suppress interest if
294 // if (pitEntry.m_incoming.size () != 0 && // not a new PIT entry and
295 // inFace != pitEntry.m_incoming.end ()) // existing entry, but interest received via different face
296 // {
297 // m_droppedInterestsTrace (header, NDN_SUPPRESSED_INTEREST,
298 // m_node->GetObject<Ccnx> ()/*this*/, incomingFace);
299 // return;
300 // }
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700301
302 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
303
304 /*bool propagated = */m_forwardingStrategy->
305 PropagateInterest (incomingFace, header, packet,
306 MakeCallback (&CcnxL3Protocol::SendInterest, this)
307 );
308
309 // // If interest wasn't propagated further (probably, a limit is reached),
310 // // prune and delete PIT entry if there are no outstanding interests.
311 // // Stop processing otherwise.
312 // if( !propagated && pitEntry.numberOfPromisingInterests()==0 )
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700313 // {
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700314 // // printf( "Node %d. Pruning after unsuccessful try to forward an interest\n", _node->nodeId );
315
316 // BOOST_FOREACH (const CcnxPitEntryIncomingFace face, pitEntry.m_incoming)
317 // {
318 // // send prune
319 // }
320 // m_pit->erase (m_pit->iterator_to (pitEntry));
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700321 // }
322}
323
324// Processing ContentObjects
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700325void CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
326 Ptr<CcnxContentObjectHeader> &header,
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700327 Ptr<Packet> &payload,
328 const Ptr<const Packet> &packet)
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700329{
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700330
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700331 NS_LOG_LOGIC ("Receiving contentObject from " << &incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700332 m_receivedDataTrace (header, payload, m_node->GetObject<Ccnx> ()/*this*/, incomingFace);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700333
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700334 // 1. Lookup PIT entry
335 try
336 {
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700337 const CcnxPitEntry &pitEntry = m_pit->Lookup (*header);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700338
339 // Note that with MultiIndex we need to modify entries indirectly
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700340
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700341 // Update metric status for the incoming interface in the corresponding FIB entry
342 m_fib->modify (m_fib->iterator_to (pitEntry.m_fibEntry),
343 CcnxFibEntry::UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700344
345 // Add or update entry in the content store
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700346 m_contentStore->Add (header, payload);
Alexander Afanasyevc74a6022011-08-15 20:01:35 -0700347
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700348 CcnxPitEntryOutgoingFaceContainer::type::iterator
349 out = pitEntry.m_outgoing.find (incomingFace);
350
351 // If we have sent interest for this data via this face, then update stats.
352 if (out != pitEntry.m_outgoing.end ())
353 {
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700354 m_pit->modify (m_pit->iterator_to (pitEntry),
355 CcnxPitEntry::EstimateRttAndRemoveFace(out, m_fib));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700356 // face will be removed in the above call
357 }
358 else
359 {
360 NS_LOG_WARN ("Node "<< m_node->GetId() <<
361 ". PIT entry for "<< header->GetName ()<<" is valid, "
362 "but outgoing entry for interface "<< incomingFace <<" doesn't exist\n");
363 }
364
365 //satisfy all pending incoming Interests
366 BOOST_FOREACH (const CcnxPitEntryIncomingFace &interest, pitEntry.m_incoming)
367 {
368 if (interest.m_face == incomingFace) continue;
369
370 // may not work either because of 'const' thing
371 interest.m_face->Send (packet->Copy ()); // unfortunately, we have to copy packet...
372 m_transmittedDataTrace (header, payload, FORWARDED, m_node->GetObject<Ccnx> (), interest.m_face);
373 }
374
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700375 m_pit->modify (m_pit->iterator_to (pitEntry), CcnxPitEntry::ClearIncoming()); // satisfy all incoming interests
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700376
377 if( pitEntry.m_outgoing.size()==0 ) // remove PIT when all outgoing interests are "satisfied"
378 {
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700379 m_pit->erase (m_pit->iterator_to (pitEntry));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700380 }
381
382 }
383 catch (CcnxPitEntryNotFound)
384 {
385 // 2. Drop data packet if PIT entry is not found
386 // (unsolicited data packets should not "poison" content store)
387
388 //drop dulicated or not requested data packet
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700389 m_droppedDataTrace (header, payload, NDN_UNSOLICITED_DATA, m_node->GetObject<Ccnx> (), incomingFace);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700390 return; // do not process unsoliced data packets
391 }
392}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700393
394void
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700395CcnxL3Protocol::SendInterest (const Ptr<CcnxFace> &face,
396 const Ptr<CcnxInterestHeader> &header,
397 const Ptr<Packet> &packet)
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700398{
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700399 NS_LOG_FUNCTION (this << "packet: " << &packet << ", face: "<< &face);
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700400 NS_ASSERT_MSG (face != 0, "Face should never be NULL");
401
402 if (face->IsUp ())
403 {
404 NS_LOG_LOGIC ("Sending via face " << &face); //
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700405 m_transmittedInterestsTrace (header, m_node->GetObject<Ccnx> (), face);
406 face->Send (packet);
407 }
408 else
409 {
410 NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << &face);
411 m_droppedInterestsTrace (header, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face);
412 }
413}
414
415void
416CcnxL3Protocol::SendContentObject (const Ptr<CcnxFace> &face,
417 const Ptr<CcnxContentObjectHeader> &header,
418 const Ptr<Packet> &packet)
419{
420 NS_LOG_FUNCTION (this << "packet: " << &packet << ", face: "<< &face);
421 NS_ASSERT_MSG (face != 0, "Face should never be NULL");
422
423 NS_ASSERT_MSG (false, "Should not be called for now");
424
425 if (face->IsUp ())
426 {
427 NS_LOG_LOGIC ("Sending via face " << &face); //
Alexander Afanasyeva67e28c2011-08-31 21:16:25 -0700428 // m_txTrace (packet, m_node->GetObject<Ccnx> (), face);
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700429 face->Send (packet);
430 }
431 else
432 {
433 NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << &face);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700434 // m_dropTrace (packet, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face);
Alexander Afanasyev070aa482011-08-20 00:38:25 -0700435 }
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700436}
437
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700438} //namespace ns3