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 | /* |
Ilya Moiseenko | 956d054 | 2012-01-02 15:26:40 -0800 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 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 | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 22 | #include "ndn-face.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 24 | #include "ns3/packet.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 25 | #include "ns3/log.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 26 | #include "ns3/node.h" |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 27 | #include "ns3/assert.h" |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 28 | #include "ns3/uinteger.h" |
| 29 | #include "ns3/double.h" |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 30 | #include "ns3/boolean.h" |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 31 | #include "ns3/simulator.h" |
Alexander Afanasyev | 98d85e1 | 2012-08-09 10:06:05 -0700 | [diff] [blame] | 32 | #include "ns3/random-variable.h" |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 33 | #include "ns3/pointer.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 34 | |
Alexander Afanasyev | faa01f9 | 2013-07-10 18:34:31 -0700 | [diff] [blame] | 35 | #include "ns3/ndn-header-helper.h" |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 36 | #include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h" |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 37 | |
| 38 | #include "ns3/ndn-wire.h" |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 39 | |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 40 | #include <boost/ref.hpp> |
| 41 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 42 | NS_LOG_COMPONENT_DEFINE ("ndn.Face"); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 43 | |
| 44 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 45 | namespace ndn { |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 46 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 47 | NS_OBJECT_ENSURE_REGISTERED (Face); |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 49 | TypeId |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | Face::GetTypeId () |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 51 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 52 | static TypeId tid = TypeId ("ns3::ndn::Face") |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 53 | .SetParent<Object> () |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 54 | .SetGroupName ("Ndn") |
| 55 | .AddAttribute ("Id", "Face id (unique integer for the Ndn stack on this node)", |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 56 | TypeId::ATTR_GET, // allow only getting it. |
| 57 | UintegerValue (0), |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 58 | MakeUintegerAccessor (&Face::m_id), |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 59 | MakeUintegerChecker<uint32_t> ()) |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 60 | ; |
| 61 | return tid; |
| 62 | } |
| 63 | |
Alexander Afanasyev | 91d7c7c | 2013-01-31 15:01:08 -0800 | [diff] [blame] | 64 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 65 | * By default, Ndn face are created in the "down" state |
Alexander Afanasyev | 91d7c7c | 2013-01-31 15:01:08 -0800 | [diff] [blame] | 66 | * with no IP addresses. Before becoming useable, the user must |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 67 | * invoke SetUp on them once an Ndn address and mask have been set. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 68 | */ |
Alexander Afanasyev | 91d7c7c | 2013-01-31 15:01:08 -0800 | [diff] [blame] | 69 | Face::Face (Ptr<Node> node) |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 70 | : m_node (node) |
Alexander Afanasyev | faa01f9 | 2013-07-10 18:34:31 -0700 | [diff] [blame] | 71 | , m_upstreamInterestHandler (MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > ()) |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 72 | , m_upstreamDataHandler (MakeNullCallback< void, Ptr<Face>, Ptr<Data> > ()) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 73 | , m_ifup (false) |
| 74 | , m_id ((uint32_t)-1) |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 75 | , m_metric (0) |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 76 | , m_flags (0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 77 | { |
Alexander Afanasyev | f0bda2f | 2013-08-12 16:38:13 -0700 | [diff] [blame^] | 78 | NS_LOG_FUNCTION (this << node); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 79 | |
| 80 | NS_ASSERT_MSG (node != 0, "node cannot be NULL. Check the code"); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 83 | Face::~Face () |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 84 | { |
| 85 | NS_LOG_FUNCTION_NOARGS (); |
| 86 | } |
| 87 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 88 | Face::Face (const Face &) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 89 | { |
| 90 | } |
| 91 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 92 | Face& Face::operator= (const Face &) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 93 | { |
| 94 | return *this; |
| 95 | } |
| 96 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame] | 97 | Ptr<Node> |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 98 | Face::GetNode () const |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame] | 99 | { |
| 100 | return m_node; |
| 101 | } |
| 102 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 103 | void |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 104 | Face::RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 105 | { |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 106 | NS_LOG_FUNCTION_NOARGS (); |
| 107 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 108 | m_upstreamInterestHandler = interestHandler; |
| 109 | m_upstreamDataHandler = dataHandler; |
| 110 | } |
| 111 | |
| 112 | void |
| 113 | Face::UnRegisterProtocolHandlers () |
| 114 | { |
| 115 | NS_LOG_FUNCTION_NOARGS (); |
| 116 | |
Alexander Afanasyev | faa01f9 | 2013-07-10 18:34:31 -0700 | [diff] [blame] | 117 | m_upstreamInterestHandler = MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > (); |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 118 | m_upstreamDataHandler = MakeNullCallback< void, Ptr<Face>, Ptr<Data> > (); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | |
| 122 | bool |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 123 | Face::SendInterest (Ptr<const Interest> interest) |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 124 | { |
Alexander Afanasyev | e4795ae | 2013-07-11 20:01:31 -0700 | [diff] [blame] | 125 | NS_LOG_FUNCTION (this << boost::cref (*this) << interest->GetName ()); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 126 | |
| 127 | if (!IsUp ()) |
| 128 | { |
| 129 | return false; |
| 130 | } |
| 131 | |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 132 | return Send (Wire::FromInterest (interest)); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | bool |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 136 | Face::SendData (Ptr<const Data> data) |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 137 | { |
Alexander Afanasyev | faa01f9 | 2013-07-10 18:34:31 -0700 | [diff] [blame] | 138 | NS_LOG_FUNCTION (this << data); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 139 | |
| 140 | if (!IsUp ()) |
| 141 | { |
| 142 | return false; |
| 143 | } |
| 144 | |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 145 | return Send (Wire::FromData (data)); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 149 | Face::Send (Ptr<Packet> packet) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 150 | { |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 151 | FwHopCountTag hopCount; |
| 152 | bool tagExists = packet->RemovePacketTag (hopCount); |
| 153 | if (tagExists) |
| 154 | { |
| 155 | hopCount.Increment (); |
| 156 | packet->AddPacketTag (hopCount); |
| 157 | } |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 158 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 159 | return true; |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | bool |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 163 | Face::Receive (Ptr<const Packet> p) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 164 | { |
Alexander Afanasyev | faa01f9 | 2013-07-10 18:34:31 -0700 | [diff] [blame] | 165 | NS_LOG_FUNCTION (this << p << p->GetSize ()); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 166 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 167 | if (!IsUp ()) |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 168 | { |
| 169 | // no tracing here. If we were off while receiving, we shouldn't even know that something was there |
| 170 | return false; |
| 171 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 172 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 173 | Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet |
| 174 | try |
| 175 | { |
| 176 | HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (packet); |
| 177 | switch (type) |
| 178 | { |
| 179 | case HeaderHelper::INTEREST_NDNSIM: |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 180 | return ReceiveInterest (Wire::ToInterest (packet, Wire::WIRE_FORMAT_NDNSIM)); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 181 | case HeaderHelper::INTEREST_CCNB: |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 182 | return ReceiveInterest (Wire::ToInterest (packet, Wire::WIRE_FORMAT_CCNB)); |
| 183 | case HeaderHelper::CONTENT_OBJECT_NDNSIM: |
| 184 | return ReceiveData (Wire::ToData (packet, Wire::WIRE_FORMAT_NDNSIM)); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 185 | case HeaderHelper::CONTENT_OBJECT_CCNB: |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 186 | return ReceiveData (Wire::ToData (packet, Wire::WIRE_FORMAT_CCNB)); |
Alexander Afanasyev | 37a6124 | 2013-07-26 11:19:18 -0700 | [diff] [blame] | 187 | default: |
| 188 | NS_FATAL_ERROR ("Not supported NDN header"); |
| 189 | return false; |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | // exception will be thrown if packet is not recognized |
| 193 | } |
| 194 | catch (UnknownHeaderException) |
| 195 | { |
Alexander Afanasyev | 7b923f3 | 2013-07-16 13:23:04 -0700 | [diff] [blame] | 196 | NS_FATAL_ERROR ("Unknown NDN header. Should not happen"); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 197 | return false; |
| 198 | } |
Alexander Afanasyev | 37a6124 | 2013-07-26 11:19:18 -0700 | [diff] [blame] | 199 | |
| 200 | return false; |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | bool |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 204 | Face::ReceiveInterest (Ptr<Interest> interest) |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 205 | { |
| 206 | if (!IsUp ()) |
| 207 | { |
| 208 | // no tracing here. If we were off while receiving, we shouldn't even know that something was there |
| 209 | return false; |
| 210 | } |
| 211 | |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 212 | m_upstreamInterestHandler (this, interest); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 213 | return true; |
| 214 | } |
| 215 | |
| 216 | bool |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 217 | Face::ReceiveData (Ptr<Data> data) |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 218 | { |
| 219 | if (!IsUp ()) |
| 220 | { |
| 221 | // no tracing here. If we were off while receiving, we shouldn't even know that something was there |
| 222 | return false; |
| 223 | } |
| 224 | |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 225 | m_upstreamDataHandler (this, data); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 226 | return true; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 229 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 230 | Face::SetMetric (uint16_t metric) |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 231 | { |
| 232 | NS_LOG_FUNCTION (metric); |
| 233 | m_metric = metric; |
| 234 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 235 | |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 236 | uint16_t |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 237 | Face::GetMetric (void) const |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 238 | { |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 239 | return m_metric; |
| 240 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 241 | |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 242 | void |
| 243 | Face::SetFlags (uint32_t flags) |
| 244 | { |
| 245 | m_flags = flags; |
| 246 | } |
| 247 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 248 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 249 | Face::operator== (const Face &face) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 250 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 251 | NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (), |
Alexander Afanasyev | 91d7c7c | 2013-01-31 15:01:08 -0800 | [diff] [blame] | 252 | "Faces of different nodes should not be compared to each other: " << *this << " == " << face); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 253 | |
| 254 | return (m_id == face.m_id); |
| 255 | } |
| 256 | |
| 257 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 258 | Face::operator< (const Face &face) const |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 259 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 260 | NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (), |
Alexander Afanasyev | 91d7c7c | 2013-01-31 15:01:08 -0800 | [diff] [blame] | 261 | "Faces of different nodes should not be compared to each other: " << *this << " == " << face); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 262 | |
| 263 | return (m_id < face.m_id); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 266 | std::ostream& |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 267 | Face::Print (std::ostream &os) const |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 268 | { |
| 269 | os << "id=" << GetId (); |
| 270 | return os; |
| 271 | } |
| 272 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 273 | std::ostream& |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 274 | operator<< (std::ostream& os, const Face &face) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 275 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 276 | face.Print (os); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 277 | return os; |
| 278 | } |
| 279 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 280 | } // namespace ndn |
| 281 | } // namespace ns3 |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 282 | |