Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 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> |
| 19 | */ |
| 20 | |
| 21 | #include "ccnx-fib.h" |
| 22 | |
| 23 | #include "ccnx.h" |
| 24 | #include "ccnx-face.h" |
| 25 | #include "ccnx-interest-header.h" |
| 26 | |
| 27 | #include "ns3/node.h" |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 28 | #include "ns3/assert.h" |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 29 | #include "ns3/names.h" |
Ilya Moiseenko | 00b3048 | 2011-11-15 17:58:00 -0800 | [diff] [blame] | 30 | #include "ns3/log.h" |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 31 | |
| 32 | #define NDN_RTO_ALPHA 0.125 |
| 33 | #define NDN_RTO_BETA 0.25 |
| 34 | #define NDN_RTO_K 4 |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 35 | |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 36 | #include <boost/lambda/lambda.hpp> |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 37 | #include <boost/lambda/bind.hpp> |
| 38 | namespace ll = boost::lambda; |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 39 | |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 40 | namespace ns3 { |
| 41 | |
| 42 | |
| 43 | ////////////////////////////////////////////////////////////////////// |
| 44 | // Helpers |
| 45 | ////////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 46 | namespace __ccnx_private { |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 47 | |
| 48 | struct CcnxFibFaceMetricByFace |
| 49 | { |
| 50 | typedef CcnxFibFaceMetricContainer::type::index<i_face>::type |
| 51 | type; |
| 52 | }; |
| 53 | |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 54 | } |
| 55 | ////////////////////////////////////////////////////////////////////// |
| 56 | ////////////////////////////////////////////////////////////////////// |
Ilya Moiseenko | 00b3048 | 2011-11-15 17:58:00 -0800 | [diff] [blame] | 57 | NS_LOG_COMPONENT_DEFINE ("CcnxFib"); |
| 58 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 59 | using namespace __ccnx_private; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 60 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 61 | TypeId |
| 62 | CcnxFib::GetTypeId (void) |
| 63 | { |
| 64 | static TypeId tid = TypeId ("ns3::CcnxFib") |
| 65 | .SetParent<Object> () |
| 66 | .SetGroupName ("Ccnx") |
| 67 | .AddConstructor<CcnxFib> () |
| 68 | |
| 69 | ; |
| 70 | return tid; |
| 71 | } |
| 72 | |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 73 | ///////////////////////////////////////////////////////////////////// |
| 74 | |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 75 | void |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 76 | CcnxFibFaceMetric::UpdateRtt (const Time &rttSample) |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 77 | { |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 78 | // const Time & this->m_rttSample |
| 79 | |
| 80 | //update srtt and rttvar (RFC 2988) |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 81 | if (m_sRtt.IsZero ()) |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 82 | { |
| 83 | //first RTT measurement |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 84 | NS_ASSERT_MSG (m_rttVar.IsZero (), "SRTT is zero, but variation is not"); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 85 | |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 86 | m_sRtt = rttSample; |
| 87 | m_rttVar = Time (m_sRtt / 2.0); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 88 | } |
| 89 | else |
| 90 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 91 | m_rttVar = Time ((1 - NDN_RTO_BETA) * m_rttVar + NDN_RTO_BETA * Abs(m_sRtt - rttSample)); |
| 92 | m_sRtt = Time ((1 - NDN_RTO_ALPHA) * m_sRtt + NDN_RTO_ALPHA * rttSample); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 96 | ///////////////////////////////////////////////////////////////////// |
| 97 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 98 | void |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 99 | CcnxFibEntry::UpdateFaceRtt (Ptr<CcnxFace> face, const Time &sample) |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 100 | { |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 101 | CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face); |
| 102 | NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (), |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 103 | "Update status can be performed only on existing faces of CcxnFibEntry"); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 105 | m_faces.modify (record, |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 106 | ll::bind (&CcnxFibFaceMetric::UpdateRtt, ll::_1, sample)); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 107 | |
| 108 | // reordering random access index same way as by metric index |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 109 | m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ()); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 112 | void |
| 113 | CcnxFibEntry::UpdateStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 114 | { |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 115 | NS_LOG_FUNCTION (this << boost::cref(*face) << status); |
| 116 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 117 | CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face); |
| 118 | NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (), |
| 119 | "Update status can be performed only on existing faces of CcxnFibEntry"); |
| 120 | |
| 121 | m_faces.modify (record, |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 122 | (&ll::_1)->*&CcnxFibFaceMetric::m_status = status); |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 123 | |
| 124 | // reordering random access index same way as by metric index |
| 125 | m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ()); |
| 126 | } |
| 127 | |
| 128 | void |
| 129 | CcnxFibEntry::AddOrUpdateRoutingMetric (Ptr<CcnxFace> face, int32_t metric) |
| 130 | { |
| 131 | NS_LOG_FUNCTION (this); |
| 132 | NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face"); |
| 133 | |
| 134 | CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face); |
| 135 | if (record == m_faces.get<i_face> ().end ()) |
| 136 | { |
| 137 | m_faces.insert (CcnxFibFaceMetric (face, metric)); |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | m_faces.modify (record, |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 142 | (&ll::_1)->*&CcnxFibFaceMetric::m_routingCost = metric); |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // reordering random access index same way as by metric index |
| 146 | m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ()); |
| 147 | } |
| 148 | |
| 149 | const CcnxFibFaceMetric & |
| 150 | CcnxFibEntry::FindBestCandidate (uint32_t skip/* = 0*/) const |
| 151 | { |
| 152 | if (m_faces.size () == 0) throw CcnxFibEntry::NoFaces (); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 153 | skip = skip % m_faces.size(); |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 154 | return m_faces.get<i_nth> () [skip]; |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 158 | CcnxFib::CcnxFib () |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 159 | { |
| 160 | } |
| 161 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 162 | void |
| 163 | CcnxFib::NotifyNewAggregate () |
| 164 | { |
| 165 | if (m_node == 0) |
| 166 | m_node = this->GetObject<Node>(); |
| 167 | Object::NotifyNewAggregate (); |
| 168 | } |
| 169 | |
| 170 | void |
| 171 | CcnxFib::DoDispose (void) |
| 172 | { |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 173 | m_fib.clear (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 174 | m_node = 0; |
| 175 | Object::DoDispose (); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | CcnxFibEntryContainer::type::iterator |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 180 | CcnxFib::LongestPrefixMatch (const CcnxInterestHeader &interest) const |
| 181 | { |
| 182 | const CcnxNameComponents &name = interest.GetName (); |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 183 | for (size_t componentsCount = name.GetComponents ().size ()+1; |
| 184 | componentsCount > 0; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 185 | componentsCount--) |
| 186 | { |
Alexander Afanasyev | a174aa5 | 2011-12-13 01:30:32 -0800 | [diff] [blame] | 187 | CcnxNameComponents subPrefix (name.GetSubComponents (componentsCount-1)); |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 188 | CcnxFibEntryContainer::type::iterator match = m_fib.find (subPrefix); |
| 189 | if (match != m_fib.end()) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 190 | return match; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 193 | return m_fib.end (); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | |
| 197 | CcnxFibEntryContainer::type::iterator |
| 198 | CcnxFib::Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric) |
| 199 | { |
| 200 | // CcnxFibFaceMetric |
Ilya Moiseenko | 00b3048 | 2011-11-15 17:58:00 -0800 | [diff] [blame] | 201 | NS_LOG_FUNCTION(this << prefix << face << metric); |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 202 | CcnxFibEntryContainer::type::iterator entry = m_fib.find (prefix); |
| 203 | if (entry == m_fib.end ()) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 204 | { |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 205 | entry = m_fib.insert (m_fib.end (), CcnxFibEntry (prefix)); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 206 | // insert new |
| 207 | } |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 208 | |
Ilya Moiseenko | 00b3048 | 2011-11-15 17:58:00 -0800 | [diff] [blame] | 209 | NS_ASSERT_MSG (face != NULL, "Trying to modify NULL face"); |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 210 | m_fib.modify (entry, |
| 211 | ll::bind (&CcnxFibEntry::AddOrUpdateRoutingMetric, ll::_1, face, metric)); |
Ilya Moiseenko | 00b3048 | 2011-11-15 17:58:00 -0800 | [diff] [blame] | 212 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 213 | return entry; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 214 | } |
Ilya Moiseenko | 4e47348 | 2011-10-31 17:58:14 -0700 | [diff] [blame] | 215 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 216 | void |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 217 | CcnxFib::Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 218 | { |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 219 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 220 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 221 | m_fib.modify (m_fib.iterator_to (entry), |
| 222 | ll::bind (&CcnxFibEntry::RemoveFace, ll::_1, face)); |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 223 | if (entry.m_faces.size () == 0) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 224 | { |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 225 | m_fib.erase (m_fib.iterator_to (entry)); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | |
| 229 | void |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 230 | CcnxFib::RemoveFromAll (Ptr<CcnxFace> face) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 231 | { |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 232 | NS_LOG_FUNCTION (this); |
| 233 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 234 | for_each (m_fib.begin (), m_fib.end (), |
| 235 | ll::bind (&CcnxFib::Remove, this, ll::_1, face)); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * \brief Get number of FIB entry (for python bindings) |
| 240 | */ |
| 241 | uint32_t |
| 242 | CcnxFib::GetCcnxFibEntryCount () const |
| 243 | { |
| 244 | return m_fib.size (); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * \brief Get FIB entry by index (for python bindings) |
| 249 | */ |
| 250 | const CcnxFibEntry & |
| 251 | CcnxFib::GetCcnxFibEntry (uint32_t index) |
| 252 | { |
| 253 | NS_ASSERT (0 <= index && index < m_fib.size ()); |
| 254 | return m_fib.get <i_nth> () [index]; |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 255 | } |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 256 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 257 | |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 258 | std::ostream& operator<< (std::ostream& os, const CcnxFib &fib) |
| 259 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 260 | os << "Node " << Names::FindName (fib.m_node) << "\n"; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 261 | os << " Dest prefix Interfaces(Costs) \n"; |
| 262 | os << "+-------------+--------------------------------------+\n"; |
| 263 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 264 | for (CcnxFibEntryContainer::type::iterator entry = fib.m_fib.begin (); |
| 265 | entry != fib.m_fib.end (); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 266 | entry++) |
| 267 | { |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 268 | os << entry->GetPrefix () << "\t" << *entry << "\n"; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 269 | } |
| 270 | return os; |
| 271 | } |
| 272 | |
| 273 | std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry) |
| 274 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 275 | for (CcnxFibFaceMetricContainer::type::index<i_nth>::type::iterator metric = |
| 276 | entry.m_faces.get<i_nth> ().begin (); |
| 277 | metric != entry.m_faces.get<i_nth> ().end (); |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 278 | metric++) |
| 279 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 280 | if (metric != entry.m_faces.get<i_nth> ().begin ()) |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 281 | os << ", "; |
| 282 | |
| 283 | os << *metric; |
| 284 | } |
| 285 | return os; |
| 286 | } |
| 287 | |
| 288 | std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric) |
| 289 | { |
| 290 | static const std::string statusString[] = {"","g","y","r"}; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 291 | |
Alexander Afanasyev | 3661e23 | 2012-01-20 17:36:15 -0800 | [diff] [blame^] | 292 | os << *metric.m_face << "(" << metric.m_routingCost << ","<< statusString [metric.m_status] << "," << metric.m_face->GetMetric () << ")"; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 293 | return os; |
| 294 | } |
| 295 | |
| 296 | // void CcnxFib::resetProbing() |
| 297 | // { |
| 298 | // for(FibRangeIterator fib = _fib.begin(); fib != _fib.end(); fib++) |
| 299 | // VALUE(fib).needsProbing = true; |
| 300 | // } |
| 301 | |
| 302 | // void CcnxFib::updateInterfaceStatus( int interface, int status ) |
| 303 | // { |
| 304 | // for( FibRangeIterator fib = _fib.begin(); fib!=_fib.end(); fib++ ) |
| 305 | // { |
| 306 | // VALUE(fib).updateStatus( interface, status ); |
| 307 | // } |
| 308 | // } |
| 309 | |
| 310 | } // namespace ns3 |