Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 19 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 20 | */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 21 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 22 | #include "ccnx-l3-protocol.h" |
| 23 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 24 | #include "ns3/packet.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 25 | #include "ns3/node.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 26 | #include "ns3/log.h" |
| 27 | #include "ns3/callback.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 28 | #include "ns3/uinteger.h" |
| 29 | #include "ns3/trace-source-accessor.h" |
| 30 | #include "ns3/object-vector.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 31 | #include "ns3/boolean.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 32 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 33 | #include "ns3/ccnx-header-helper.h" |
| 34 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 35 | #include "ccnx-face.h" |
| 36 | #include "ccnx-route.h" |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 37 | #include "ccnx-forwarding-strategy.h" |
| 38 | #include "ccnx-interest-header.h" |
| 39 | #include "ccnx-content-object-header.h" |
| 40 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 41 | #include <boost/foreach.hpp> |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 42 | |
| 43 | NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol"); |
| 44 | |
| 45 | namespace ns3 { |
| 46 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 47 | const uint16_t CcnxL3Protocol::ETHERNET_FRAME_TYPE = 0x7777; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 48 | |
| 49 | NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol); |
| 50 | |
| 51 | TypeId |
| 52 | CcnxL3Protocol::GetTypeId (void) |
| 53 | { |
| 54 | static TypeId tid = TypeId ("ns3::CcnxL3Protocol") |
| 55 | .SetParent<Ccnx> () |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 56 | .SetGroupName ("Ccnx") |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 57 | .AddConstructor<CcnxL3Protocol> () |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 58 | // .AddTraceSource ("Tx", "Send ccnx packet to outgoing interface.", |
| 59 | // MakeTraceSourceAccessor (&CcnxL3Protocol::m_txTrace)) |
| 60 | // .AddTraceSource ("Rx", "Receive ccnx packet from incoming interface.", |
| 61 | // MakeTraceSourceAccessor (&CcnxL3Protocol::m_rxTrace)) |
| 62 | // .AddTraceSource ("Drop", "Drop ccnx packet", |
| 63 | // MakeTraceSourceAccessor (&CcnxL3Protocol::m_dropTrace)) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 64 | // .AddAttribute ("InterfaceList", "The set of Ccnx interfaces associated to this Ccnx stack.", |
| 65 | // ObjectVectorValue (), |
| 66 | // MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces), |
| 67 | // MakeObjectVectorChecker<CcnxFace> ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 68 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 69 | // .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission", |
| 70 | // MakeTraceSourceAccessor (&CcnxL3Protocol::m_sendOutgoingTrace)) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 71 | |
| 72 | ; |
| 73 | return tid; |
| 74 | } |
| 75 | |
| 76 | CcnxL3Protocol::CcnxL3Protocol() |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 77 | : m_faceCounter (0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 78 | { |
| 79 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 80 | |
| 81 | m_rit = CreateObject<CcnxRit> (); |
| 82 | m_pit = CreateObject<CcnxPit> (); |
| 83 | m_contentStore = CreateObject<CcnxContentStore> (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | CcnxL3Protocol::~CcnxL3Protocol () |
| 87 | { |
| 88 | NS_LOG_FUNCTION (this); |
| 89 | } |
| 90 | |
| 91 | void |
| 92 | CcnxL3Protocol::SetNode (Ptr<Node> node) |
| 93 | { |
| 94 | m_node = node; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 95 | m_fib = m_node->GetObject<CcnxFib> (); |
| 96 | NS_ASSERT_MSG (m_fib != 0, "FIB should be created and aggregated to a node before calling Ccnx::SetNode"); |
| 97 | |
| 98 | m_pit->SetFib (m_fib); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* |
| 102 | * This method is called by AddAgregate and completes the aggregation |
| 103 | * by setting the node in the ccnx stack |
| 104 | */ |
| 105 | void |
| 106 | CcnxL3Protocol::NotifyNewAggregate () |
| 107 | { |
| 108 | if (m_node == 0) |
| 109 | { |
| 110 | Ptr<Node>node = this->GetObject<Node>(); |
| 111 | // verify that it's a valid node and that |
| 112 | // the node has not been set before |
| 113 | if (node != 0) |
| 114 | { |
| 115 | this->SetNode (node); |
| 116 | } |
| 117 | } |
| 118 | Object::NotifyNewAggregate (); |
| 119 | } |
| 120 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 121 | void |
| 122 | CcnxL3Protocol::DoDispose (void) |
| 123 | { |
| 124 | NS_LOG_FUNCTION (this); |
| 125 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 126 | for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 127 | { |
| 128 | *i = 0; |
| 129 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 130 | m_faces.clear (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 131 | m_node = 0; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 132 | // m_forwardingStrategy = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 133 | Object::DoDispose (); |
| 134 | } |
| 135 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 136 | void |
| 137 | CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) |
| 138 | { |
| 139 | NS_LOG_FUNCTION (this); |
| 140 | m_forwardingStrategy = forwardingStrategy; |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 141 | // m_forwardingStrategy->SetCcnx (this); |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | Ptr<CcnxForwardingStrategy> |
| 145 | CcnxL3Protocol::GetForwardingStrategy (void) const |
| 146 | { |
| 147 | return m_forwardingStrategy; |
| 148 | } |
| 149 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 150 | uint32_t |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 151 | CcnxL3Protocol::AddFace (const Ptr<CcnxFace> &face) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 152 | { |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 153 | NS_LOG_FUNCTION (this << &face); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 154 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 155 | face->SetNode (m_node); |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 156 | face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 157 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 158 | // ask face to register in lower-layer stack |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 159 | face->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this)); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 160 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 161 | m_faces.push_back (face); |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 162 | m_faceCounter ++; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 163 | return face->GetId (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 166 | void |
| 167 | CcnxL3Protocol::RemoveFace (Ptr<CcnxFace> face) |
| 168 | { |
| 169 | // ask face to register in lower-layer stack |
| 170 | face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ()); |
| 171 | CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face); |
| 172 | NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist"); |
| 173 | m_faces.erase (face_it); |
| 174 | } |
| 175 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 176 | Ptr<CcnxFace> |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 177 | CcnxL3Protocol::GetFace (uint32_t index) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 178 | { |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 179 | BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 180 | { |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 181 | if (face->GetId () == index) |
| 182 | return face; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 183 | } |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | uint32_t |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 188 | CcnxL3Protocol::GetNFaces (void) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 189 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 190 | return m_faces.size (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 193 | void |
| 194 | CcnxL3Protocol::TransmittedDataTrace (Ptr<Packet> packet, |
| 195 | ContentObjectSource type, |
| 196 | Ptr<Ccnx> ccnx, Ptr<const CcnxFace> face) |
| 197 | { |
| 198 | // a "small" inefficiency for logging purposes |
| 199 | Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> (); |
| 200 | static CcnxContentObjectTail tail; |
| 201 | packet->RemoveHeader (*header); |
| 202 | packet->RemoveTrailer (tail); |
| 203 | |
| 204 | m_transmittedDataTrace (header, packet/*payload*/, type, ccnx, face); |
| 205 | |
| 206 | packet->AddHeader (*header); |
| 207 | packet->AddTrailer (tail); |
| 208 | } |
| 209 | |
| 210 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 211 | // Callback from lower layer |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 212 | void |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 213 | CcnxL3Protocol::Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 214 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 215 | if (!face->IsUp ()) |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 216 | { |
| 217 | NS_LOG_LOGIC ("Dropping received packet -- interface is down"); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 218 | // m_dropTrace (p, INTERFACE_DOWN, m_node->GetObject<Ccnx> ()/*this*/, face); |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 219 | return; |
| 220 | } |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 221 | NS_LOG_LOGIC ("Packet from face " << *face << " received on node " << m_node->GetId ()); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 222 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 223 | Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 224 | try |
| 225 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 226 | CcnxHeaderHelper::Type type = CcnxHeaderHelper::GetCcnxHeaderType (p); |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 227 | switch (type) |
| 228 | { |
| 229 | case CcnxHeaderHelper::INTEREST: |
| 230 | { |
| 231 | Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> (); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 232 | |
| 233 | // Deserialization. Exception may be thrown |
| 234 | packet->RemoveHeader (*header); |
| 235 | NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero"); |
| 236 | |
| 237 | OnInterest (face, header, p/*original packet*/); |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 238 | break; |
| 239 | } |
| 240 | case CcnxHeaderHelper::CONTENT_OBJECT: |
| 241 | { |
| 242 | Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> (); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 243 | |
| 244 | static CcnxContentObjectTail contentObjectTrailer; //there is no data in this object |
| 245 | |
| 246 | // Deserialization. Exception may be thrown |
| 247 | packet->RemoveHeader (*header); |
| 248 | packet->RemoveTrailer (contentObjectTrailer); |
| 249 | |
| 250 | OnData (face, header, packet/*payload*/, p/*original packet*/); |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 251 | break; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // exception will be thrown if packet is not recognized |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 256 | } |
| 257 | catch (CcnxUnknownHeaderException) |
| 258 | { |
| 259 | NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen"); |
| 260 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 261 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 262 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 263 | // Processing Interests |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 264 | void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace, |
| 265 | Ptr<CcnxInterestHeader> &header, |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 266 | const Ptr<const Packet> &packet) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 267 | { |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 268 | NS_LOG_LOGIC ("Receiving interest from " << &incomingFace); |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 269 | m_receivedInterestsTrace (header, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 270 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 271 | // Lookup of Pit and Fib entries for this Interest |
| 272 | CcnxFibEntryContainer::type::iterator fibEntry; |
| 273 | CcnxPitEntryContainer::type::iterator pitEntry = m_pit->Lookup (*header, fibEntry); |
| 274 | |
| 275 | // No matter is it duplicate or not, if it is a NACK message, remove all possible incoming |
| 276 | // entries for this interface (NACK means that neighbor gave up trying and there is no |
| 277 | // point of sending data in this direction) |
| 278 | if ((header->IsNack()) && (pitEntry != m_pit->end ())) |
| 279 | { |
| 280 | //m_pit->erase (pitEntry); |
| 281 | m_pit->modify(pitEntry, CcnxPitEntry::DeleteIncoming(incomingFace)); |
| 282 | } |
| 283 | |
| 284 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 285 | if (m_rit->WasRecentlySatisfied (*header)) |
| 286 | { |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 287 | // duplicate interests (same nonce) from applications are just ignored |
| 288 | if (incomingFace->IsLocal() == true) |
| 289 | return; |
| 290 | |
| 291 | // Update metric status for the incoming interface in the corresponding FIB entry |
| 292 | if (fibEntry != m_fib->end()) |
| 293 | m_fib->modify (m_fib->iterator_to (pitEntry->m_fibEntry), |
| 294 | CcnxFibEntry::UpdateStatus(incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW)); |
| 295 | |
| 296 | //Trace duplicate interest |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 297 | m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST, |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 298 | m_node->GetObject<Ccnx> (), incomingFace); |
| 299 | |
| 300 | bool isMine = false; |
| 301 | TypeId tid = TypeId ("ns3::CcnxProducer"); |
| 302 | for(uint32_t i=0; i<m_node->GetNApplications();i++) |
| 303 | { |
| 304 | Ptr<Application> app = m_node->GetApplication(i); |
| 305 | if(app->GetTypeId() == tid) |
| 306 | { |
| 307 | if((DynamicCast<CcnxProducer>(app))->GetPrefix () == header->GetName ()) |
| 308 | { |
| 309 | isMine = true; |
| 310 | break; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | Ptr<Packet> contentObject = m_contentStore->Lookup (header); |
| 316 | if ((isMine == true) || (contentObject != NULL)) |
| 317 | { |
| 318 | //never respond with NACK to NACK |
| 319 | if(header->IsNack () ) |
| 320 | return; |
| 321 | |
| 322 | // always return a duplicate packet |
| 323 | header->SetNack(true); |
| 324 | //Trace duplicate interest |
| 325 | m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST, |
| 326 | m_node->GetObject<Ccnx> (), incomingFace); |
| 327 | |
| 328 | SendInterest(incomingFace, header, packet->Copy()); |
| 329 | |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | |
| 334 | // check PIT. or there is no outgoing entry for this interface, |
| 335 | // silently drop the duplicate packet |
| 336 | |
| 337 | // If no entry found, silently drop |
| 338 | if( pitEntry == m_pit->end() ) |
| 339 | return; |
| 340 | |
| 341 | // If PIT entry timed out, silently drop |
| 342 | if( pitEntry->m_timerExpired == true ) |
| 343 | return; |
| 344 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 345 | // loop? |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 346 | |
| 347 | // Check if there is no outgoing entry for the interface or different nonce |
| 348 | // (i.e., got a duplicate packet, but we haven't sent interest to this |
| 349 | // interface) |
| 350 | // |
| 351 | // This case means that there is a loop in the network. |
| 352 | // So, prune this link, but do not remove PIT entry |
| 353 | |
| 354 | // Alex, check this condition!! |
| 355 | if(pitEntry->m_outgoing.size () == 0) |
| 356 | { |
| 357 | //never respond with NACK to NACK |
| 358 | if(header->IsNack () ) |
| 359 | return; |
| 360 | |
| 361 | // always return a duplicate packet |
| 362 | header->SetNack(true); |
| 363 | //Trace duplicate interest |
| 364 | m_droppedInterestsTrace (header, NDN_DUPLICATE_INTEREST, |
| 365 | m_node->GetObject<Ccnx> (), incomingFace); |
| 366 | |
| 367 | SendInterest(incomingFace, header, packet->Copy()); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | |
| 372 | // At this point: |
| 373 | // - there is a non-expired PIT entry, |
| 374 | // - there is an outgoing interest to the interface, and |
| 375 | // - a nonce in outgoing entry is equal to a nonce in the received duplicate packet |
| 376 | |
| 377 | // Should perform: |
| 378 | // Cleaning outgoing entry |
| 379 | // If there are no outgoing interests and available interfaces left (pe->availableInterfaces), |
| 380 | // prune all incoming interests, otherwise allow forwarding of the interest |
| 381 | if( header->IsNack () ) |
| 382 | { |
| 383 | if( header->IsCongested () == false ) |
| 384 | m_pit->LeakBucket(incomingFace,1); |
| 385 | |
| 386 | m_pit->modify(pitEntry, CcnxPitEntry::DeleteOutgoing(incomingFace)); |
| 387 | } |
| 388 | else |
| 389 | { |
| 390 | //poit->waitingInVain = true; |
| 391 | } |
| 392 | |
| 393 | |
| 394 | // prune all incoming interests |
| 395 | if((pitEntry->m_outgoing.size() ==0) && (pitEntry->m_fibEntry.m_faces.size() == 0)) |
| 396 | { |
| 397 | BOOST_FOREACH (const CcnxPitEntryIncomingFace face, pitEntry->m_incoming) |
| 398 | { |
| 399 | if(face.m_face->IsLocal() == false) |
| 400 | { |
| 401 | // check all entries if the name of RIT entry matches the name of interest |
| 402 | for (CcnxRitByNonce::type::iterator it = m_rit->begin(); it != m_rit->end(); it++) |
| 403 | { |
| 404 | if (it->m_prefix == pitEntry->GetPrefix() ) |
| 405 | { |
| 406 | |
| 407 | header->SetNonce(it->m_nonce); |
| 408 | header->SetNack(true); |
| 409 | SendInterest(face.m_face, header, packet->Copy()); |
| 410 | break; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | // Finally, remote the PIT entry |
| 417 | m_pit->erase (pitEntry); |
| 418 | |
| 419 | return; // stop processing |
| 420 | } |
| 421 | |
| 422 | if(pitEntry->m_fibEntry.m_faces.size() == 0) |
| 423 | return; |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 424 | } |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 425 | |
| 426 | // Otherwise, |
| 427 | // propagate the interest |
| 428 | // |
| 429 | // method `propagateInterest' can/should try different interface |
| 430 | // from `availableInterfaces' list |
| 431 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 432 | m_rit->SetRecentlySatisfied (*header); |
| 433 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 434 | NS_LOG_INFO("Cache Lookup for " << header->GetName()); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 435 | Ptr<Packet> contentObject = m_contentStore->Lookup (header); |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 436 | if (contentObject != NULL) |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 437 | { |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 438 | NS_LOG_INFO("Found in cache"); |
| 439 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 440 | TransmittedDataTrace (contentObject, CACHED, |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 441 | m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 442 | incomingFace->Send (contentObject); |
| 443 | return; |
| 444 | } |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 445 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 446 | // Data is not in cache |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 447 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 448 | CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry->m_incoming.find (incomingFace); |
| 449 | CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry->m_outgoing.find (incomingFace); |
| 450 | |
| 451 | if ((pitEntry != m_pit->end()) && (pitEntry->m_timerExpired == false)) |
| 452 | { |
| 453 | //CcnxFibFaceMetricContainer::type m_faces; |
| 454 | //pitEntry->m_fibEntry->m_faces |
| 455 | |
| 456 | // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data) |
| 457 | // Give up this interface, but keep a small hope when the returned packet doesn't have PRUNE status |
| 458 | if( inFace->m_face == outFace->m_face ) |
| 459 | { |
| 460 | if( header->IsCongested() == true ) |
| 461 | { |
| 462 | m_pit->LeakBucket(incomingFace, 1); |
| 463 | m_pit->modify (pitEntry, CcnxPitEntry::DeleteOutgoing(outFace->m_face)); |
| 464 | } |
| 465 | //else |
| 466 | // poit->waitingInVain = true; |
| 467 | |
| 468 | // Update metric status for the incoming interface in the corresponding FIB entry |
| 469 | if(fibEntry != m_fib->end()) |
| 470 | m_fib->modify(m_fib->iterator_to (pitEntry->m_fibEntry), |
| 471 | CcnxFibEntry::UpdateStatus(incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW)); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | |
| 476 | if((pitEntry->m_outgoing.size() == 0) && (pitEntry->m_fibEntry.m_faces.size() == 0)) |
| 477 | // prune all incoming interests |
| 478 | { |
| 479 | |
| 480 | for(CcnxPitEntryContainer::type::iterator iter = m_pit->begin(); |
| 481 | iter != m_pit->end(); |
| 482 | iter++) |
| 483 | { |
| 484 | /*for(CcnxPitEntryIncomingFaceContainer::type::iterator face = iter->m_incoming.begin(); |
| 485 | face != iter->m_incoming.end(); |
| 486 | face++)*/ |
| 487 | BOOST_FOREACH (const CcnxPitEntryIncomingFace face, iter->m_incoming) |
| 488 | { |
| 489 | if(face.m_face->IsLocal() == true) |
| 490 | { |
| 491 | //returnInterestToApp( pkt, -piit->interfaceIndex ); |
| 492 | //continue; |
| 493 | } |
| 494 | |
| 495 | // check all entries if the name of RIT entry matches the name of interest |
| 496 | for (CcnxRitByNonce::type::iterator it = m_rit->begin(); it != m_rit->end(); it++) |
| 497 | { |
| 498 | if (it->m_prefix == iter->GetPrefix() ) |
| 499 | { |
| 500 | header->SetNonce(it->m_nonce); |
| 501 | header->SetNack(true); |
| 502 | SendInterest(face.m_face, header, packet->Copy()); |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | } |
| 508 | |
| 509 | m_pit->erase(pitEntry); |
| 510 | |
| 511 | return; // there is nothing else to do |
| 512 | } |
| 513 | |
| 514 | // Suppress this interest only if we're still expecting data from some other interface |
| 515 | if( pitEntry->m_outgoing.size() > 0 ) |
| 516 | { |
| 517 | return; //ok. Now we can suppress this interest |
| 518 | } |
| 519 | |
| 520 | |
| 521 | // Prune and delete PIT entry if there are no available interfaces to propagate interest |
| 522 | if( pitEntry->m_fibEntry.m_faces.size() == 0) |
| 523 | { |
| 524 | //if no match is found in the FIB, drop packet |
| 525 | //printf( "Node %d: cannot process Interest packet %s (no interfaces left)\n", _node->nodeId, pkt->contentName ); |
| 526 | |
| 527 | if(incomingFace->IsLocal() == false) |
| 528 | { |
| 529 | header->SetNack(true); |
| 530 | m_droppedInterestsTrace (header, NDN_SUPPRESSED_INTEREST, |
| 531 | m_node->GetObject<Ccnx> (), incomingFace); |
| 532 | SendInterest(incomingFace, header, packet->Copy()); |
| 533 | } |
| 534 | |
| 535 | m_pit->erase(pitEntry); |
| 536 | |
| 537 | } |
| 538 | |
| 539 | |
| 540 | |
| 541 | // otherwise, try one of the available interfaces |
| 542 | |
| 543 | // suppress interest if |
| 544 | /*if (pitEntry->m_incoming.size () != 0 && // not a new PIT entry and |
| 545 | inFace != pitEntry->m_incoming.end ()) // existing entry, but interest received via different face |
| 546 | { |
| 547 | m_droppedInterestsTrace (header, NDN_SUPPRESSED_INTEREST, |
| 548 | m_node->GetObject<Ccnx> (), incomingFace); |
| 549 | return; |
| 550 | }*/ |
| 551 | |
| 552 | |
| 553 | //just in case of bug |
| 554 | header->SetNack(false); |
| 555 | header->SetCongested(false); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 556 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 557 | NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets"); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 558 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 559 | m_pit->modify (pitEntry, CcnxPitEntry::AddIncoming(incomingFace)); |
| 560 | |
| 561 | bool propagated = m_forwardingStrategy-> |
| 562 | PropagateInterest (pitEntry, fibEntry,incomingFace, header, packet, |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 563 | MakeCallback (&CcnxL3Protocol::SendInterest, this) |
| 564 | ); |
| 565 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 566 | // If interest wasn't propagated further (probably, a limit is reached), |
| 567 | // prune and delete PIT entry if there are no outstanding interests. |
| 568 | // Stop processing otherwise. |
| 569 | if( (!propagated) && (pitEntry->m_outgoing.size() == 0)) |
| 570 | { |
| 571 | BOOST_FOREACH (const CcnxPitEntryIncomingFace face, pitEntry->m_incoming) |
| 572 | { |
| 573 | |
| 574 | |
| 575 | header->SetNack(true); |
| 576 | header->SetCongested(true); |
| 577 | SendInterest (face.m_face, header, packet->Copy()); |
| 578 | |
| 579 | m_droppedInterestsTrace (header, DROP_CONGESTION, |
| 580 | m_node->GetObject<Ccnx> (), incomingFace); |
| 581 | } |
| 582 | |
| 583 | m_pit->erase (pitEntry); |
| 584 | } |
| 585 | /*} |
| 586 | else |
| 587 | { |
| 588 | m_droppedInterestsTrace (header, NDN_PIT_TIMER_EXPIRED, |
| 589 | m_node->GetObject<Ccnx> (), incomingFace); |
| 590 | return; |
| 591 | }*/ |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | // Processing ContentObjects |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 595 | void CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace, |
| 596 | Ptr<CcnxContentObjectHeader> &header, |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 597 | Ptr<Packet> &payload, |
| 598 | const Ptr<const Packet> &packet) |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 599 | { |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 600 | |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 601 | NS_LOG_LOGIC ("Receiving contentObject from " << &incomingFace); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 602 | m_receivedDataTrace (header, payload, m_node->GetObject<Ccnx> ()/*this*/, incomingFace); |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 603 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 604 | // 1. Lookup PIT entry |
| 605 | try |
| 606 | { |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 607 | const CcnxPitEntry &pitEntry = m_pit->Lookup (*header); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 608 | |
| 609 | // Note that with MultiIndex we need to modify entries indirectly |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 610 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 611 | // Update metric status for the incoming interface in the corresponding FIB entry |
| 612 | m_fib->modify (m_fib->iterator_to (pitEntry.m_fibEntry), |
| 613 | CcnxFibEntry::UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN)); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 614 | |
| 615 | // Add or update entry in the content store |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 616 | NS_LOG_INFO("Cached " << header->GetName()); |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 617 | m_contentStore->Add (header, payload); |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 618 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 619 | CcnxPitEntryOutgoingFaceContainer::type::iterator |
| 620 | out = pitEntry.m_outgoing.find (incomingFace); |
| 621 | |
| 622 | // If we have sent interest for this data via this face, then update stats. |
| 623 | if (out != pitEntry.m_outgoing.end ()) |
| 624 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 625 | m_pit->modify (m_pit->iterator_to (pitEntry), |
| 626 | CcnxPitEntry::EstimateRttAndRemoveFace(out, m_fib)); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 627 | // face will be removed in the above call |
| 628 | } |
| 629 | else |
| 630 | { |
| 631 | NS_LOG_WARN ("Node "<< m_node->GetId() << |
| 632 | ". PIT entry for "<< header->GetName ()<<" is valid, " |
| 633 | "but outgoing entry for interface "<< incomingFace <<" doesn't exist\n"); |
| 634 | } |
| 635 | |
| 636 | //satisfy all pending incoming Interests |
| 637 | BOOST_FOREACH (const CcnxPitEntryIncomingFace &interest, pitEntry.m_incoming) |
| 638 | { |
| 639 | if (interest.m_face == incomingFace) continue; |
| 640 | |
| 641 | // may not work either because of 'const' thing |
| 642 | interest.m_face->Send (packet->Copy ()); // unfortunately, we have to copy packet... |
| 643 | m_transmittedDataTrace (header, payload, FORWARDED, m_node->GetObject<Ccnx> (), interest.m_face); |
| 644 | } |
| 645 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 646 | m_pit->modify (m_pit->iterator_to (pitEntry), CcnxPitEntry::ClearIncoming()); // satisfy all incoming interests |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 647 | |
| 648 | if( pitEntry.m_outgoing.size()==0 ) // remove PIT when all outgoing interests are "satisfied" |
| 649 | { |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 650 | m_pit->erase (m_pit->iterator_to (pitEntry)); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | } |
| 654 | catch (CcnxPitEntryNotFound) |
| 655 | { |
| 656 | // 2. Drop data packet if PIT entry is not found |
| 657 | // (unsolicited data packets should not "poison" content store) |
| 658 | |
| 659 | //drop dulicated or not requested data packet |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 660 | m_droppedDataTrace (header, payload, NDN_UNSOLICITED_DATA, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 661 | return; // do not process unsoliced data packets |
| 662 | } |
| 663 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 664 | |
| 665 | void |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 666 | CcnxL3Protocol::SendInterest (const Ptr<CcnxFace> &face, |
| 667 | const Ptr<CcnxInterestHeader> &header, |
| 668 | const Ptr<Packet> &packet) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 669 | { |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 670 | NS_LOG_FUNCTION (this << "packet: " << &packet << ", face: "<< &face); |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 671 | NS_ASSERT_MSG (face != 0, "Face should never be NULL"); |
| 672 | |
| 673 | if (face->IsUp ()) |
| 674 | { |
| 675 | NS_LOG_LOGIC ("Sending via face " << &face); // |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 676 | m_transmittedInterestsTrace (header, m_node->GetObject<Ccnx> (), face); |
| 677 | face->Send (packet); |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << &face); |
| 682 | m_droppedInterestsTrace (header, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face); |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | void |
| 687 | CcnxL3Protocol::SendContentObject (const Ptr<CcnxFace> &face, |
| 688 | const Ptr<CcnxContentObjectHeader> &header, |
| 689 | const Ptr<Packet> &packet) |
| 690 | { |
| 691 | NS_LOG_FUNCTION (this << "packet: " << &packet << ", face: "<< &face); |
| 692 | NS_ASSERT_MSG (face != 0, "Face should never be NULL"); |
| 693 | |
| 694 | NS_ASSERT_MSG (false, "Should not be called for now"); |
| 695 | |
| 696 | if (face->IsUp ()) |
| 697 | { |
| 698 | NS_LOG_LOGIC ("Sending via face " << &face); // |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 699 | // m_txTrace (packet, m_node->GetObject<Ccnx> (), face); |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 700 | face->Send (packet); |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << &face); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 705 | // m_dropTrace (packet, INTERFACE_DOWN, m_node->GetObject<Ccnx> (), face); |
Alexander Afanasyev | 070aa48 | 2011-08-20 00:38:25 -0700 | [diff] [blame] | 706 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Ilya Moiseenko | 172763c | 2011-10-28 13:21:53 -0700 | [diff] [blame] | 709 | Ptr<CcnxPit> |
| 710 | CcnxL3Protocol::GetPit() |
| 711 | { |
| 712 | return m_pit; |
| 713 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 714 | } //namespace ns3 |