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 | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 2 | // |
| 3 | // Copyright (c) 2006 Georgia Tech Research Corporation |
| 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 | // |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 18 | // Author: |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | // |
| 20 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 21 | #include "ccnx-l3-protocol.h" |
| 22 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 23 | #include "ns3/packet.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 24 | #include "ns3/net-device.h" |
| 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 | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 41 | |
| 42 | NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol"); |
| 43 | |
| 44 | namespace ns3 { |
| 45 | |
| 46 | const uint16_t CcnxL3Protocol::PROT_NUMBER = 0x7777; |
| 47 | |
| 48 | NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol); |
| 49 | |
| 50 | TypeId |
| 51 | CcnxL3Protocol::GetTypeId (void) |
| 52 | { |
| 53 | static TypeId tid = TypeId ("ns3::CcnxL3Protocol") |
| 54 | .SetParent<Ccnx> () |
| 55 | .AddConstructor<CcnxL3Protocol> () |
| 56 | .AddTraceSource ("Tx", "Send ccnx packet to outgoing interface.", |
| 57 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_txTrace)) |
| 58 | .AddTraceSource ("Rx", "Receive ccnx packet from incoming interface.", |
| 59 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_rxTrace)) |
| 60 | .AddTraceSource ("Drop", "Drop ccnx packet", |
| 61 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_dropTrace)) |
| 62 | .AddAttribute ("InterfaceList", "The set of Ccnx interfaces associated to this Ccnx stack.", |
| 63 | ObjectVectorValue (), |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 64 | MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces), |
| 65 | MakeObjectVectorChecker<CcnxFace> ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 66 | |
| 67 | .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission", |
| 68 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_sendOutgoingTrace)) |
| 69 | |
| 70 | ; |
| 71 | return tid; |
| 72 | } |
| 73 | |
| 74 | CcnxL3Protocol::CcnxL3Protocol() |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 75 | { |
| 76 | NS_LOG_FUNCTION (this); |
| 77 | } |
| 78 | |
| 79 | CcnxL3Protocol::~CcnxL3Protocol () |
| 80 | { |
| 81 | NS_LOG_FUNCTION (this); |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | CcnxL3Protocol::SetNode (Ptr<Node> node) |
| 86 | { |
| 87 | m_node = node; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /* |
| 91 | * This method is called by AddAgregate and completes the aggregation |
| 92 | * by setting the node in the ccnx stack |
| 93 | */ |
| 94 | void |
| 95 | CcnxL3Protocol::NotifyNewAggregate () |
| 96 | { |
| 97 | if (m_node == 0) |
| 98 | { |
| 99 | Ptr<Node>node = this->GetObject<Node>(); |
| 100 | // verify that it's a valid node and that |
| 101 | // the node has not been set before |
| 102 | if (node != 0) |
| 103 | { |
| 104 | this->SetNode (node); |
| 105 | } |
| 106 | } |
| 107 | Object::NotifyNewAggregate (); |
| 108 | } |
| 109 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 110 | void |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 111 | CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 112 | { |
| 113 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 114 | m_forwardingStrategy = forwardingStrategy; |
| 115 | m_forwardingStrategy->SetCcnx (this); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 116 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 117 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 118 | Ptr<CcnxForwardingStrategy> |
| 119 | CcnxL3Protocol::GetForwardingStrategy (void) const |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 120 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 121 | return m_forwardingStrategy; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 122 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 123 | |
| 124 | void |
| 125 | CcnxL3Protocol::DoDispose (void) |
| 126 | { |
| 127 | NS_LOG_FUNCTION (this); |
| 128 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 129 | for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 130 | { |
| 131 | *i = 0; |
| 132 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 133 | m_faces.clear (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 134 | m_node = 0; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 135 | // m_forwardingStrategy = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 136 | Object::DoDispose (); |
| 137 | } |
| 138 | |
| 139 | uint32_t |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 140 | CcnxL3Protocol::AddFace (Ptr<CcnxFace> face) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 141 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 142 | NS_LOG_FUNCTION (this << *face); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 143 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 144 | // Ptr<Node> node = GetObject<Node> (); ///< \todo not sure why this thing should be called... |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 145 | face->SetNode (m_node); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 146 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 147 | if (face->GetDevice() != 0) |
| 148 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 149 | m_node->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::ReceiveFromLower, this), |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 150 | CcnxL3Protocol::PROT_NUMBER, face->GetDevice(), true/*promiscuous mode*/); |
| 151 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 152 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 153 | uint32_t index = m_faces.size (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 154 | m_faces.push_back (face); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 155 | return index; |
| 156 | } |
| 157 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 158 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 159 | Ptr<CcnxFace> |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 160 | CcnxL3Protocol::GetFace (uint32_t index) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 161 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 162 | if (index < m_faces.size ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 163 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 164 | return m_faces[index]; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | uint32_t |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 170 | CcnxL3Protocol::GetNFaces (void) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 171 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 172 | return m_faces.size (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 175 | Ptr<CcnxFace> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 176 | CcnxL3Protocol::GetFaceForDevice (Ptr<const NetDevice> device) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 177 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 178 | for (CcnxFaceList::const_iterator i = m_faces.begin (); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 179 | i != m_faces.end (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 180 | i++) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 181 | { |
| 182 | if ((*i)->GetDevice () == device) |
| 183 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 184 | return *i; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 185 | } |
| 186 | } |
| 187 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 188 | NS_ASSERT_MSG (false, "Should never get to this place" ); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 189 | return 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 192 | // Callback from lower layer |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 193 | void |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 194 | CcnxL3Protocol::ReceiveFromLower ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 195 | const Address &to, NetDevice::PacketType packetType) |
| 196 | { |
| 197 | NS_LOG_FUNCTION (this << &device << p << protocol << from); |
| 198 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 199 | NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 200 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 201 | Ptr<CcnxFace> ccnxFace = GetFaceForDevice (device); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 202 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 203 | 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] | 204 | try |
| 205 | { |
| 206 | Ptr<Header> header = CcnxHeaderHelper::CreateCorrectCcnxHeader (p); |
| 207 | ReceiveAndProcess (ccnxFace, header, packet); // header should serve as overloaded method selector... not sure whether it works with this "smart" pointers... |
| 208 | } |
| 209 | catch (CcnxUnknownHeaderException) |
| 210 | { |
| 211 | NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen"); |
| 212 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 213 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 214 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 215 | // Processing Interests |
| 216 | void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<CcnxInterestHeader> header, Ptr<Packet> packet) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 217 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 218 | if (incomingFace->IsUp ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 219 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 220 | NS_LOG_LOGIC ("Dropping received packet -- interface is down"); |
| 221 | m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 222 | return; |
| 223 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 224 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 225 | NS_LOG_LOGIC ("Receiving interest from " << incomingFace); |
| 226 | // m_rxTrace (packet, m_node->GetObject<Ccnx> (), incomingFace); |
| 227 | |
| 228 | // NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets"); |
| 229 | // if (!m_forwardingStrategy->RouteInput (packet, incomingFace, |
| 230 | // MakeCallback (&CcnxL3Protocol::Send, this), |
| 231 | // MakeCallback (&CcnxL3Protocol::RouteInputError, this) |
| 232 | // )) |
| 233 | // { |
| 234 | // NS_LOG_WARN ("No route found for forwarding packet. Drop."); |
| 235 | // m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), incomingFace); |
| 236 | // } |
| 237 | } |
| 238 | |
| 239 | // Processing ContentObjects |
| 240 | void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<CcnxContentObjectHeader> header, Ptr<Packet> packet) |
| 241 | { |
| 242 | if (incomingFace->IsUp ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 243 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 244 | NS_LOG_LOGIC ("Dropping received packet -- interface is down"); |
| 245 | m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), incomingFace); |
| 246 | return; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 247 | } |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 248 | |
| 249 | NS_LOG_LOGIC ("Receiving contentObject from " << incomingFace); |
| 250 | } |
| 251 | |
| 252 | // fake method |
| 253 | void |
| 254 | CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<Header> header, Ptr<Packet> p) |
| 255 | { |
| 256 | NS_ASSERT_MSG (false, "This function should never be called"); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | |
| 260 | void |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 261 | CcnxL3Protocol::Send (Ptr<Packet> packet, Ptr<CcnxRoute> route) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 262 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 263 | NS_LOG_FUNCTION (this << "packet: " << packet << ", route: "<< route); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 264 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 265 | if (route == 0) |
| 266 | { |
| 267 | NS_LOG_WARN ("No route to host. Drop."); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 268 | m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), 0); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 269 | return; |
| 270 | } |
| 271 | Ptr<CcnxFace> outFace = route->GetOutputFace (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 272 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 273 | if (outFace->IsUp ()) |
| 274 | { |
| 275 | NS_LOG_LOGIC ("Sending via face " << *outFace); |
| 276 | m_txTrace (packet, m_node->GetObject<Ccnx> (), outFace); |
| 277 | outFace->Send (packet); |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << *outFace); |
| 282 | m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), outFace); |
| 283 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 287 | void |
| 288 | CcnxL3Protocol::SetMetric (uint32_t i, uint16_t metric) |
| 289 | { |
| 290 | NS_LOG_FUNCTION (this << i << metric); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 291 | Ptr<CcnxFace> face = GetFace (i); |
| 292 | face->SetMetric (metric); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | uint16_t |
| 296 | CcnxL3Protocol::GetMetric (uint32_t i) const |
| 297 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 298 | Ptr<const CcnxFace> face = GetFace (i); |
| 299 | return face->GetMetric (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | uint16_t |
| 303 | CcnxL3Protocol::GetMtu (uint32_t i) const |
| 304 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 305 | Ptr<CcnxFace> face = GetFace (i); |
| 306 | return face->GetDevice ()->GetMtu (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | bool |
| 310 | CcnxL3Protocol::IsUp (uint32_t i) const |
| 311 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 312 | Ptr<CcnxFace> interface = GetFace (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 313 | return interface->IsUp (); |
| 314 | } |
| 315 | |
| 316 | void |
| 317 | CcnxL3Protocol::SetUp (uint32_t i) |
| 318 | { |
| 319 | NS_LOG_FUNCTION (this << i); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 320 | Ptr<CcnxFace> interface = GetFace (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 321 | interface->SetUp (); |
| 322 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 323 | if (m_forwardingStrategy != 0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 324 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 325 | m_forwardingStrategy->NotifyInterfaceUp (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
| 329 | void |
| 330 | CcnxL3Protocol::SetDown (uint32_t ifaceIndex) |
| 331 | { |
| 332 | NS_LOG_FUNCTION (this << ifaceIndex); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 333 | Ptr<CcnxFace> interface = GetFace (ifaceIndex); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 334 | interface->SetDown (); |
| 335 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 336 | if (m_forwardingStrategy != 0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 337 | { |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 338 | m_forwardingStrategy->NotifyInterfaceDown (ifaceIndex); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 342 | void |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 343 | CcnxL3Protocol::RouteInputError (Ptr<Packet> p)//, Socket::SocketErrno sockErrno) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 344 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 345 | // NS_LOG_FUNCTION (this << p << ipHeader << sockErrno); |
| 346 | // NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " with errno " << sockErrno); |
| 347 | m_dropTrace (p, DROP_ROUTE_ERROR, m_node->GetObject<Ccnx> (), 0); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | } //namespace ns3 |