Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -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-pit-entry.h" |
| 22 | #include "ccnx-name-components.h" |
| 23 | #include "ccnx-fib.h" |
| 24 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 25 | #include "ns3/simulator.h" |
| 26 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 27 | namespace ns3 |
| 28 | { |
| 29 | |
| 30 | // struct SearchByFace |
| 31 | // { |
| 32 | // /** |
| 33 | // * \brief To perform effective searches by CcnxFace |
| 34 | // */ |
| 35 | // bool |
| 36 | // operator() (const CcnxPitIncomingInterest &m, const Ptr<CcnxFace> &face) const |
| 37 | // { |
| 38 | // return *(m.m_face) < *face; |
| 39 | // } |
| 40 | |
| 41 | // /** |
| 42 | // * \brief To perform effective searches by CcnxFace |
| 43 | // */ |
| 44 | // bool |
| 45 | // operator() (const Ptr<CcnxFace> &face, const CcnxPitIncomingInterest &m) const |
| 46 | // { |
| 47 | // return *face < *(m.m_face); |
| 48 | // } |
| 49 | |
| 50 | // /** |
| 51 | // * \brief To perform effective searches by CcnxFace |
| 52 | // */ |
| 53 | // bool |
| 54 | // operator() (const CcnxPitOutgoingInterest &m, const Ptr<CcnxFace> &face) const |
| 55 | // { |
| 56 | // return *(m.m_face) < *face; |
| 57 | // } |
| 58 | |
| 59 | // /** |
| 60 | // * \brief To perform effective searches by CcnxFace |
| 61 | // */ |
| 62 | // bool |
| 63 | // operator() (const Ptr<CcnxFace> &face, const CcnxPitOutgoingInterest &m) const |
| 64 | // { |
| 65 | // return *face < *(m.m_face); |
| 66 | // } |
| 67 | // }; |
| 68 | |
| 69 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 70 | CcnxPitEntry::CcnxPitEntry (Ptr<CcnxNameComponents> prefix, const CcnxFibEntry &fibEntry) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 71 | : m_prefix (prefix) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 72 | , m_fibEntry (fibEntry) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 73 | // , m_expireTime (?) |
| 74 | , m_timerExpired (false) |
| 75 | , m_counterExpirations (0) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | const CcnxNameComponents & |
| 80 | CcnxPitEntry::GetPrefix () const |
| 81 | { |
| 82 | return *m_prefix; |
| 83 | } |
| 84 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 85 | // CcnxPitEntry::SetFibEntry::SetFibEntry (Ptr<CcnxFibEntry> fib) |
| 86 | // : m_fib (fib) |
| 87 | // { |
| 88 | // } |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 89 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 90 | // void |
| 91 | // CcnxPitEntry::SetFibEntry::operator() (CcnxPitEntry &entry) |
| 92 | // { |
| 93 | // entry.m_fib = m_fib; |
| 94 | // } |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 95 | |
| 96 | void |
| 97 | CcnxPitEntry::AddIncoming::operator() (CcnxPitEntry &entry) |
| 98 | { |
| 99 | entry.m_incoming.insert (CcnxPitEntryIncomingFace (m_face)); |
| 100 | } |
| 101 | |
| 102 | void |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 103 | CcnxPitEntry::DeleteIncoming::operator() (CcnxPitEntry &entry) |
| 104 | { |
| 105 | entry.m_incoming.erase (m_face); |
| 106 | } |
| 107 | |
| 108 | void |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 109 | CcnxPitEntry::AddOutgoing::operator() (CcnxPitEntry &entry) |
| 110 | { |
| 111 | entry.m_outgoing.insert (CcnxPitEntryOutgoingFace (m_face)); |
| 112 | } |
| 113 | |
| 114 | void |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 115 | CcnxPitEntry::DeleteOutgoing::operator() (CcnxPitEntry &entry) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 116 | { |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 117 | entry.m_outgoing.erase (m_face); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void |
| 121 | CcnxPitEntry::ClearIncoming::operator() (CcnxPitEntry &entry) |
| 122 | { |
| 123 | entry.m_incoming.clear (); |
| 124 | } |
| 125 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 126 | CcnxPitEntry::UpdateFibStatus::UpdateFibStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status) |
| 127 | : m_face (face) |
| 128 | , m_status (status) |
| 129 | { |
| 130 | } |
| 131 | |
| 132 | void |
| 133 | CcnxPitEntry::UpdateFibStatus::operator() (CcnxPitEntry &entry) |
| 134 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 135 | NS_ASSERT_MSG (false, "Broken"); |
| 136 | // entry.m_fib->UpdateStatus (m_face, m_status); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | void |
| 140 | CcnxPitEntry::EstimateRttAndRemoveFace::operator() (CcnxPitEntry &entry) |
| 141 | { |
| 142 | // similar to Karn's Algorithm, we don't use RTT measurements for retx packets |
| 143 | if (m_outFace->m_retxNum>0) |
| 144 | return; |
| 145 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame^] | 146 | m_fib->modify (m_fib->iterator_to (entry.m_fibEntry), |
| 147 | CcnxFibEntry::UpdateFaceRtt (m_outFace->m_face, |
| 148 | Simulator::Now() - m_outFace->m_sendTime)); |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 149 | |
| 150 | entry.m_outgoing.erase (m_outFace); |
| 151 | } |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 152 | |
| 153 | } |