blob: ddc471edf8a202dc245d67f16a4586ce32506c7d [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 Afanasyev8accdf62011-09-20 11:33:59 -0700126CcnxPitEntry::UpdateFibStatus::UpdateFibStatus (Ptr<CcnxFace> face,
127 CcnxFibFaceMetric::Status status,
128 Ptr<CcnxFib> fib)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700129 : m_face (face)
130 , m_status (status)
Alexander Afanasyev8accdf62011-09-20 11:33:59 -0700131 , m_fib (fib)
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700132{
133}
134
135void
136CcnxPitEntry::UpdateFibStatus::operator() (CcnxPitEntry &entry)
137{
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700138 NS_ASSERT_MSG (false, "Broken");
Alexander Afanasyev8accdf62011-09-20 11:33:59 -0700139 m_fib->modify (m_fib->iterator_to (entry.m_fibEntry),
140 CcnxFibEntry::UpdateStatus (m_face, m_status));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700141}
142
143void
144CcnxPitEntry::EstimateRttAndRemoveFace::operator() (CcnxPitEntry &entry)
145{
146 // similar to Karn's Algorithm, we don't use RTT measurements for retx packets
147 if (m_outFace->m_retxNum>0)
148 return;
149
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700150 m_fib->modify (m_fib->iterator_to (entry.m_fibEntry),
151 CcnxFibEntry::UpdateFaceRtt (m_outFace->m_face,
152 Simulator::Now() - m_outFace->m_sendTime));
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -0700153
154 entry.m_outgoing.erase (m_outFace);
155}
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -0700156
157}