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 | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 22 | #include "ccnx-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 | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 32 | |
Alexander Afanasyev | de7601a | 2012-05-31 12:14:54 -0700 | [diff] [blame] | 33 | // #include "ns3/weights-path-stretch-tag.h" |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 34 | |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 35 | #include <boost/ref.hpp> |
| 36 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 37 | NS_LOG_COMPONENT_DEFINE ("CcnxFace"); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 38 | |
| 39 | namespace ns3 { |
| 40 | |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 41 | NS_OBJECT_ENSURE_REGISTERED (CcnxFace); |
| 42 | |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 43 | TypeId |
| 44 | CcnxFace::GetTypeId () |
| 45 | { |
| 46 | static TypeId tid = TypeId ("ns3::CcnxFace") |
| 47 | .SetParent<Object> () |
| 48 | .SetGroupName ("Ccnx") |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 49 | .AddAttribute ("Id", "Face id (unique integer for the CCNx stack on this node)", |
| 50 | TypeId::ATTR_GET, // allow only getting it. |
| 51 | UintegerValue (0), |
| 52 | MakeUintegerAccessor (&CcnxFace::m_id), |
| 53 | MakeUintegerChecker<uint32_t> ()) |
| 54 | |
| 55 | .AddAttribute ("BucketMax", "Maximum size of leaky bucket", |
| 56 | DoubleValue (-1.0), |
| 57 | MakeDoubleAccessor (&CcnxFace::m_bucketMax), |
| 58 | MakeDoubleChecker<double> ()) |
| 59 | .AddAttribute ("BucketLeak", "Normalized bucket leak size", |
| 60 | DoubleValue (0.0), |
| 61 | MakeDoubleAccessor (&CcnxFace::m_bucketLeak), |
| 62 | MakeDoubleChecker<double> ()) |
| 63 | |
Alexander Afanasyev | de7601a | 2012-05-31 12:14:54 -0700 | [diff] [blame] | 64 | // .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)", |
| 65 | // BooleanValue (false), |
| 66 | // MakeBooleanAccessor (&CcnxFace::m_enableMetricTagging), |
| 67 | // MakeBooleanChecker ()) |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 68 | |
| 69 | .AddTraceSource ("CcnxTx", "Transmitted packet trace", |
| 70 | MakeTraceSourceAccessor (&CcnxFace::m_ccnxTxTrace)) |
| 71 | .AddTraceSource ("CcnxRx", "Received packet trace", |
| 72 | MakeTraceSourceAccessor (&CcnxFace::m_ccnxRxTrace)) |
| 73 | .AddTraceSource ("CcnxDrop", "Dropped packet trace", |
| 74 | MakeTraceSourceAccessor (&CcnxFace::m_ccnxDropTrace)) |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 75 | ; |
| 76 | return tid; |
| 77 | } |
| 78 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 79 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 80 | * By default, Ccnx face are created in the "down" state |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 81 | * with no IP addresses. Before becoming useable, the user must |
| 82 | * invoke SetUp on them once an Ccnx address and mask have been set. |
| 83 | */ |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 84 | CcnxFace::CcnxFace (Ptr<Node> node) |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 85 | : m_node (node) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 86 | , m_bucket (0.0) |
| 87 | , m_bucketMax (-1.0) |
| 88 | , m_bucketLeak (0.0) |
| 89 | , m_protocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ()) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 90 | , m_ifup (false) |
| 91 | , m_id ((uint32_t)-1) |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 92 | , m_lastLeakTime (0) |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 93 | , m_metric (0) |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 94 | // , m_enableMetricTagging (false) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 95 | { |
| 96 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 97 | |
| 98 | NS_ASSERT_MSG (node != 0, "node cannot be NULL. Check the code"); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 101 | CcnxFace::~CcnxFace () |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 102 | { |
| 103 | NS_LOG_FUNCTION_NOARGS (); |
| 104 | } |
| 105 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 106 | CcnxFace::CcnxFace (const CcnxFace &) |
| 107 | { |
| 108 | } |
| 109 | |
| 110 | CcnxFace& CcnxFace::operator= (const CcnxFace &) |
| 111 | { |
| 112 | return *this; |
| 113 | } |
| 114 | |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame] | 115 | Ptr<Node> |
| 116 | CcnxFace::GetNode () const |
| 117 | { |
| 118 | return m_node; |
| 119 | } |
| 120 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 121 | void |
| 122 | CcnxFace::RegisterProtocolHandler (ProtocolHandler handler) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 123 | { |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 124 | NS_LOG_FUNCTION_NOARGS (); |
| 125 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 126 | m_protocolHandler = handler; |
| 127 | } |
| 128 | |
| 129 | bool |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 130 | CcnxFace::IsBelowLimit () |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 131 | { |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 132 | NS_LOG_FUNCTION_NOARGS (); |
| 133 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 134 | /// \todo Implement tracing, if requested |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 135 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 136 | if (!IsUp ()){ |
| 137 | NS_LOG_INFO("CcnxFace is not up."); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 138 | return false; |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 139 | } |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 140 | |
| 141 | LeakBucket (); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 142 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 143 | if (m_bucketMax > 0) |
| 144 | { |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 145 | NS_LOG_DEBUG ("Limits enabled: " << m_bucketMax << ", current: " << m_bucket); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 146 | if (m_bucket+1.0 > m_bucketMax) |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 147 | { |
Alexander Afanasyev | e67a97f | 2011-11-29 14:28:59 -0800 | [diff] [blame] | 148 | //NS_LOG_DEBUG ("Returning false"); |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 149 | return false; |
| 150 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 151 | |
| 152 | m_bucket += 1.0; |
| 153 | } |
| 154 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 155 | return true; |
| 156 | } |
| 157 | |
| 158 | bool |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 159 | CcnxFace::Send (Ptr<Packet> packet) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 160 | { |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 161 | NS_LOG_FUNCTION (boost::cref (*this) << packet << packet->GetSize ()); |
Alexander Afanasyev | d459ec3 | 2012-04-30 13:58:20 -0700 | [diff] [blame] | 162 | NS_LOG_DEBUG (*packet); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 163 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 164 | if (!IsUp ()) |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 165 | { |
| 166 | m_ccnxDropTrace (packet); |
| 167 | return false; |
| 168 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 169 | |
Alexander Afanasyev | de7601a | 2012-05-31 12:14:54 -0700 | [diff] [blame] | 170 | // if (m_enableMetricTagging) |
| 171 | // { |
| 172 | // // update path information |
| 173 | // Ptr<const WeightsPathStretchTag> origTag = packet->RemovePacketTag<WeightsPathStretchTag> (); |
| 174 | // Ptr<WeightsPathStretchTag> tag; |
| 175 | // if (origTag == 0) |
| 176 | // { |
| 177 | // tag = CreateObject<WeightsPathStretchTag> (); // create a new tag |
| 178 | // } |
| 179 | // else |
| 180 | // { |
| 181 | // tag = CreateObject<WeightsPathStretchTag> (*origTag); // will update existing tag |
| 182 | // } |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 183 | |
Alexander Afanasyev | de7601a | 2012-05-31 12:14:54 -0700 | [diff] [blame] | 184 | // tag->AddPathInfo (m_node, GetMetric ()); |
| 185 | // packet->AddPacketTag (tag); |
| 186 | // } |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 187 | |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 188 | bool ok = SendImpl (packet); |
| 189 | if (ok) |
| 190 | { |
| 191 | m_ccnxTxTrace (packet); |
| 192 | return true; |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | m_ccnxDropTrace (packet); |
| 197 | return false; |
| 198 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | bool |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 202 | CcnxFace::Receive (const Ptr<const Packet> &packet) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 203 | { |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 204 | NS_LOG_FUNCTION (boost::cref (*this) << packet << packet->GetSize ()); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 205 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 206 | if (!IsUp ()) |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 207 | { |
| 208 | // no tracing here. If we were off while receiving, we shouldn't even know that something was there |
| 209 | return false; |
| 210 | } |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 211 | |
Alexander Afanasyev | 30c33e3 | 2012-06-05 21:28:44 -0700 | [diff] [blame] | 212 | m_ccnxRxTrace (packet); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 213 | m_protocolHandler (this, packet); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 214 | |
| 215 | return true; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 218 | void |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 219 | CcnxFace::LeakBucket () |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 220 | { |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 221 | if (m_lastLeakTime.IsZero ()) |
| 222 | { |
| 223 | m_lastLeakTime = Simulator::Now (); |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | Time interval = Simulator::Now () - m_lastLeakTime; |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 228 | const double leak = m_bucketLeak * interval.ToDouble (Time::S); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 229 | if (leak >= 1.0) |
| 230 | { |
| 231 | m_bucket = std::max (0.0, m_bucket - leak); |
| 232 | m_lastLeakTime = Simulator::Now (); |
| 233 | } |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 234 | |
| 235 | // NS_LOG_DEBUG ("max: " << m_bucketMax << ", Current bucket: " << m_bucket << ", leak size: " << leak << ", interval: " << interval << ", " << m_bucketLeak); |
| 236 | } |
| 237 | |
| 238 | void |
| 239 | CcnxFace::SetBucketMax (double bucket) |
| 240 | { |
| 241 | NS_LOG_FUNCTION (this << bucket); |
| 242 | m_bucketMax = bucket; |
| 243 | } |
| 244 | |
| 245 | void |
| 246 | CcnxFace::SetBucketLeak (double leak) |
| 247 | { |
| 248 | NS_LOG_FUNCTION (this << leak); |
| 249 | m_bucketLeak = leak; |
| 250 | } |
| 251 | |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 252 | void |
| 253 | CcnxFace::SetMetric (uint16_t metric) |
| 254 | { |
| 255 | NS_LOG_FUNCTION (metric); |
| 256 | m_metric = metric; |
| 257 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 258 | |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 259 | uint16_t |
| 260 | CcnxFace::GetMetric (void) const |
| 261 | { |
| 262 | NS_LOG_FUNCTION_NOARGS (); |
| 263 | return m_metric; |
| 264 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 265 | |
| 266 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 267 | * These are face states and may be distinct from |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 268 | * NetDevice states, such as found in real implementations |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 269 | * (where the device may be down but face state is still up). |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 270 | */ |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 271 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 272 | bool |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 273 | CcnxFace::IsUp (void) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 274 | { |
| 275 | NS_LOG_FUNCTION_NOARGS (); |
| 276 | return m_ifup; |
| 277 | } |
| 278 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 279 | void |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 280 | CcnxFace::SetUp (bool up/* = true*/) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 281 | { |
| 282 | NS_LOG_FUNCTION_NOARGS (); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 283 | m_ifup = up; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 286 | bool |
| 287 | CcnxFace::operator== (const CcnxFace &face) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 288 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 289 | NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (), |
| 290 | "Faces of different nodes should not be compared to each other"); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 291 | |
| 292 | return (m_id == face.m_id); |
| 293 | } |
| 294 | |
| 295 | bool |
| 296 | CcnxFace::operator< (const CcnxFace &face) const |
| 297 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 298 | NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (), |
| 299 | "Faces of different nodes should not be compared to each other"); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 300 | |
| 301 | return (m_id < face.m_id); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 304 | std::ostream& |
| 305 | CcnxFace::Print (std::ostream &os) const |
| 306 | { |
| 307 | os << "id=" << GetId (); |
| 308 | return os; |
| 309 | } |
| 310 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 311 | std::ostream& operator<< (std::ostream& os, const CcnxFace &face) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 312 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 313 | face.Print (os); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 314 | return os; |
| 315 | } |
| 316 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 317 | }; // namespace ns3 |
| 318 | |