blob: a79f6b72e61c299f34712318a00254fb3339339f [file] [log] [blame]
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -07001/* -*- 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 Afanasyev78cf0c92011-09-01 19:57:14 -070025#include "ns3/simulator.h"
26
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070027namespace 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 Afanasyevc5a23e22011-09-07 00:37:36 -070070CcnxPitEntry::CcnxPitEntry (Ptr<CcnxNameComponents> prefix, const CcnxFibEntry &fibEntry)
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070071 : m_prefix (prefix)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070072 , m_fibEntry (fibEntry)
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070073 // , m_expireTime (?)
74 , m_timerExpired (false)
75 , m_counterExpirations (0)
76{
77}
78
79const CcnxNameComponents &
80CcnxPitEntry::GetPrefix () const
81{
82 return *m_prefix;
83}
84
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070085// CcnxPitEntry::SetFibEntry::SetFibEntry (Ptr<CcnxFibEntry> fib)
86// : m_fib (fib)
87// {
88// }
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070089
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070090// void
91// CcnxPitEntry::SetFibEntry::operator() (CcnxPitEntry &entry)
92// {
93// entry.m_fib = m_fib;
94// }
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070095
96void
97CcnxPitEntry::AddIncoming::operator() (CcnxPitEntry &entry)
98{
99 entry.m_incoming.insert (CcnxPitEntryIncomingFace (m_face));
100}
101
102void
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700103CcnxPitEntry::DeleteIncoming::operator() (CcnxPitEntry &entry)
104{
105 entry.m_incoming.erase (m_face);
106}
107
108void
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -0700109CcnxPitEntry::AddOutgoing::operator() (CcnxPitEntry &entry)
110{
111 entry.m_outgoing.insert (CcnxPitEntryOutgoingFace (m_face));
112}
113
114void
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700115CcnxPitEntry::DeleteOutgoing::operator() (CcnxPitEntry &entry)
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -0700116{
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700117 entry.m_outgoing.erase (m_face);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -0700118}
119
120void
121CcnxPitEntry::ClearIncoming::operator() (CcnxPitEntry &entry)
122{
123 entry.m_incoming.clear ();
124}
125
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700126CcnxPitEntry::UpdateFibStatus::UpdateFibStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status)
127 : m_face (face)
128 , m_status (status)
129{
130}
131
132void
133CcnxPitEntry::UpdateFibStatus::operator() (CcnxPitEntry &entry)
134{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700135 NS_ASSERT_MSG (false, "Broken");
136 // entry.m_fib->UpdateStatus (m_face, m_status);
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700137}
138
139void
140CcnxPitEntry::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 Afanasyevc5a23e22011-09-07 00:37:36 -0700146 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 Afanasyev78cf0c92011-09-01 19:57:14 -0700149
150 entry.m_outgoing.erase (m_outFace);
151}
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -0700152
153}