blob: 83ddd7e10f9237225aff75d5a7c42b02d7b7b4d6 [file] [log] [blame]
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -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: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
21#include "ccnx-flooding-strategy.h"
22#include "ns3/assert.h"
23
24#include "ccnx-route.h"
25
26NS_LOG_COMPONENT_DEFINE ("CcnxFloodingStrategy");
27
28namespace ns3
29{
30
31NS_OBJECT_ENSURE_REGISTERED (CcnxFloodingStrategy);
32
33TypeId CcnxFloodingStrategy::GetTypeId (void)
34{
35 static TypeId tid = TypeId ("ns3::CcnxFloodingStrategy")
36 .SetGroupName ("Ccnx")
37 .SetParent<Object> ()
38 ;
39 return tid;
40}
41
42CcnxFloodingStrategy::CcnxFloodingStrategy ()
43{
44}
45
46
47bool
Ilya Moiseenkoed8dda32011-10-28 13:19:41 -070048CcnxFloodingStrategy::PropagateInterest (CcnxPitEntryContainer::type::iterator pitEntry,
49 CcnxFibEntryContainer::type::iterator fibEntry,
50 const Ptr<CcnxFace> &incomingFace,
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070051 Ptr<CcnxInterestHeader> &header,
52 const Ptr<const Packet> &packet,
53 SendCallback ucb)
54{
55 //CcnxFibEntryContainer::type::iterator fibEntryArray = GetFib()->LongestPrefixMatch(*header);
56 NS_LOG_FUNCTION(this);
57
Ilya Moiseenkoed8dda32011-10-28 13:19:41 -070058 //CcnxFibEntryContainer::type::iterator fibEntryArray = GetCcnx()->GetObject<CcnxFib>()->LongestPrefixMatch(*header);
59 NS_LOG_INFO(*fibEntry);
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070060
61 int count = 0;
Ilya Moiseenkoed8dda32011-10-28 13:19:41 -070062 for(CcnxFibFaceMetricContainer::type::iterator face = fibEntry->m_faces.begin ();
63 face != fibEntry->m_faces.end ();
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070064 face++)
65 {
66 if(face->m_face == incomingFace)
67 continue;
Ilya Moiseenkoed8dda32011-10-28 13:19:41 -070068 NS_LOG_INFO ("JUST before try add outgoing");
69 //Add new outgoing interest to pit entry
70 // If PIT entry cannot be created (limit reached or interest already sent), nothing will be forwarded
71 //if( _pit.add(VALUE(info.pe), PitOutgoingInterest( *iface, getSimTime(_node), pkt->nonce )) )
72 //{
73 //GetPit()->Add(*header,fibEntry,face->m_face);
74 //GetPit()->modify (GetPit()->end (), CcnxPitEntry::AddOutgoing(face->m_face));
75 bool tryResult = GetPit ()->TryAddOutgoing (pitEntry, face->m_face);
76 if ( tryResult == false )
77 {NS_LOG_INFO("false");
78 continue;
79 }
80 else
81 NS_LOG_INFO("true");
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070082
83 NS_LOG_INFO("count="<<count);
Ilya Moiseenkoed8dda32011-10-28 13:19:41 -070084 ucb (face->m_face, header, packet->Copy());
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070085 count++;
86 }
87
88 /*const CcnxFibEntryContainer& s,
89
90 for (CcnxFibEntryContainer::type::iterator entry = fibEntryArray.begin ();
91 entry != fibEntryArray.end ();
92 entry++)
93 {
94
95 const typename boost::multi_index::index<CcnxFibEntryContainer, Tag>::type& i = get<Tag>(s);
96
97 typedef typename CcnxFibEntryContainer::value_type value_type;
98
99 for(const CcnxFibEntryContainer& c = i.begin(); c != i.end (); c++)
100 {
101 c->
102 }
103
104 for(nth_index<CcnxFibEntryContainer,1>::type::iterator it1=get<i_prefix>(entry).begin();
105 it1!=get<i_prefix>(entry).end();++it1)
106 {
107 //std::cout<<it1->name()<<std::endl;
108
109 CcnxFibFaceMetricContainer faceContainer = it1->m_faces;
110
111 const typename boost::multi_index::index<CcnxFibFaceMetricContainer, __ccnx_private::i_face>::type& i = get<__ccnx_private::i_face>(faceContainer);
112
113 //typedef typename CcnxFibEntryContainer::value_type value_type;
114
115 for(const CcnxFibFaceMetricContainer& c = i.begin(); c != i.end (); c++)
116 {
117 Ptr<CcnxFace> face = c->m_face;
118
119 typedef
120 Callback<void, const Ptr<CcnxFace> &, const Ptr<CcnxInterestHeader> &, const Ptr<Packet> &>
121 SendCallback;
122
123 ucb (face, header, packet);
124 }
125
126 }
127
128
129 // obtain a reference to the index tagged by Tag
130
131 const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& i=
132 get<Tag>(s);
133
134 typedef typename MultiIndexContainer::value_type value_type;
135
136 // dump the elements of the index to cout
137
138 std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
139 */
140
141 if(count == 0)
142 return false;
143 else
144 return true;
145}
146
147} //namespace ns3