akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014 University of Memphis, |
| 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * \author A K M Mahmudul Hoque <ahoque1@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 23 | #include "nlsr.hpp" |
| 24 | #include "lsdb.hpp" |
| 25 | #include "hello-protocol.hpp" |
| 26 | #include "utility/name-helper.hpp" |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 27 | #include "logger.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 28 | |
| 29 | namespace nlsr { |
| 30 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 31 | INIT_LOGGER("HelloProtocol"); |
| 32 | |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 33 | const std::string HelloProtocol::INFO_COMPONENT = "INFO"; |
| 34 | const std::string HelloProtocol::NLSR_COMPONENT = "NLSR"; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 35 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 36 | void |
| 37 | HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds) |
| 38 | { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 39 | _LOG_DEBUG("Expressing Interest :" << interestName); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | ndn::Interest i(interestName); |
| 41 | i.setInterestLifetime(ndn::time::seconds(seconds)); |
| 42 | i.setMustBeFresh(true); |
| 43 | m_nlsr.getNlsrFace().expressInterest(i, |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 44 | ndn::bind(&HelloProtocol::onContent, |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 45 | this, |
| 46 | _1, _2), |
| 47 | ndn::bind(&HelloProtocol::processInterestTimedOut, |
| 48 | this, _1)); |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | HelloProtocol::sendScheduledInterest(uint32_t seconds) |
| 53 | { |
| 54 | std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList(); |
| 55 | for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 56 | ++it) { |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 57 | if((*it).getFaceId() != 0) { |
| 58 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 59 | ndn::Name interestName = (*it).getName() ; |
| 60 | interestName.append(NLSR_COMPONENT); |
| 61 | interestName.append(INFO_COMPONENT); |
| 62 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 63 | expressInterest(interestName, |
| 64 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 65 | } |
| 66 | else { |
| 67 | registerPrefixes((*it).getName(), (*it).getConnectingFaceUri(), |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 68 | (*it).getLinkCost(), ndn::time::milliseconds::max()); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 69 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 70 | } |
| 71 | scheduleInterest(m_nlsr.getConfParameter().getInfoInterestInterval()); |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | HelloProtocol::scheduleInterest(uint32_t seconds) |
| 76 | { |
| 77 | m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds), |
| 78 | ndn::bind(&HelloProtocol::sendScheduledInterest, |
| 79 | this, seconds)); |
| 80 | } |
| 81 | |
| 82 | void |
| 83 | HelloProtocol::processInterest(const ndn::Name& name, |
| 84 | const ndn::Interest& interest) |
| 85 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 86 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 87 | const ndn::Name interestName = interest.getName(); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 88 | _LOG_DEBUG("Interest Received for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 89 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 90 | return; |
| 91 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 92 | ndn::Name neighbor; |
| 93 | neighbor.wireDecode(interestName.get(-1).blockFromValue()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 94 | _LOG_DEBUG("Neighbor: " << neighbor); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 95 | if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) { |
akmhoque | 69c9aa9 | 2014-07-23 15:15:05 -0500 | [diff] [blame] | 96 | ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(); |
| 97 | data->setName(ndn::Name(interest.getName()).appendVersion()); |
| 98 | data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec |
| 99 | data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()), |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 100 | INFO_COMPONENT.size()); |
akmhoque | 69c9aa9 | 2014-07-23 15:15:05 -0500 | [diff] [blame] | 101 | m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName()); |
| 102 | _LOG_DEBUG("Sending out data for name: " << interest.getName()); |
| 103 | m_nlsr.getNlsrFace().put(*data); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 104 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor); |
| 105 | if (adjacent->getStatus() == 0) { |
| 106 | if(adjacent->getFaceId() != 0){ |
| 107 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 108 | ndn::Name interestName(neighbor); |
| 109 | interestName.append(NLSR_COMPONENT); |
| 110 | interestName.append(INFO_COMPONENT); |
| 111 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 112 | expressInterest(interestName, |
| 113 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 114 | } |
| 115 | else { |
| 116 | registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(), |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 117 | adjacent->getLinkCost(), ndn::time::milliseconds::max()); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 118 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | void |
| 124 | HelloProtocol::processInterestTimedOut(const ndn::Interest& interest) |
| 125 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 126 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 127 | const ndn::Name interestName(interest.getName()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 128 | _LOG_DEBUG("Interest timed out for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 129 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 130 | return; |
| 131 | } |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 132 | ndn::Name neighbor = interestName.getPrefix(-3); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 133 | _LOG_DEBUG("Neighbor: " << neighbor); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 134 | m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor); |
| 135 | int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
| 136 | uint32_t infoIntTimedOutCount = |
| 137 | m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 138 | _LOG_DEBUG("Status: " << status); |
| 139 | _LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 140 | if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 141 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 142 | ndn::Name interestName(neighbor); |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 143 | interestName.append(NLSR_COMPONENT); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 144 | interestName.append(INFO_COMPONENT); |
| 145 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 146 | expressInterest(interestName, |
| 147 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 148 | } |
| 149 | else if ((status == 1) && |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 150 | (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 151 | m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0); |
| 152 | m_nlsr.incrementAdjBuildCount(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 153 | if (m_nlsr.getIsBuildAdjLsaSheduled() == false) { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 154 | _LOG_DEBUG("Scheduling scheduledAdjLsaBuild"); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 155 | m_nlsr.setIsBuildAdjLsaSheduled(true); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 156 | // event here |
| 157 | m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5), |
| 158 | ndn::bind(&Lsdb::scheduledAdjLsaBuild, |
| 159 | &m_nlsr.getLsdb())); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 164 | void |
| 165 | HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data) |
| 166 | { |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame^] | 167 | _LOG_DEBUG("Received data for INFO(name): " << data.getName()); |
| 168 | if (data.getSignature().hasKeyLocator()) { |
| 169 | if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) { |
| 170 | _LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName()); |
| 171 | } |
| 172 | } |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 173 | m_nlsr.getValidator().validate(data, |
| 174 | ndn::bind(&HelloProtocol::onContentValidated, this, _1), |
| 175 | ndn::bind(&HelloProtocol::onContentValidationFailed, |
| 176 | this, _1, _2)); |
| 177 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 178 | |
| 179 | void |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 180 | HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 181 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 182 | /* data name: /<neighbor>/NLSR/INFO/<router>/<version> */ |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 183 | ndn::Name dataName = data->getName(); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame^] | 184 | _LOG_DEBUG("Data validation successful for INFO(name): " << dataName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 185 | if (dataName.get(-3).toUri() == INFO_COMPONENT) { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 186 | ndn::Name neighbor = dataName.getPrefix(-4); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 187 | int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 188 | m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 1); |
| 189 | m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0); |
| 190 | int newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 191 | _LOG_DEBUG("Neighbor : " << neighbor); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 192 | _LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 193 | // change in Adjacency list |
| 194 | if ((oldStatus - newStatus) != 0) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 195 | m_nlsr.incrementAdjBuildCount(); |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 196 | // Need to schedule event for Adjacency LSA building |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 197 | if (m_nlsr.getIsBuildAdjLsaSheduled() == false) { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 198 | _LOG_DEBUG("Scheduling scheduledAdjLsaBuild"); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 199 | m_nlsr.setIsBuildAdjLsaSheduled(true); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 200 | // event here |
| 201 | m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5), |
| 202 | ndn::bind(&Lsdb::scheduledAdjLsaBuild, |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 203 | ndn::ref(m_nlsr.getLsdb()))); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 209 | void |
| 210 | HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, |
| 211 | const std::string& msg) |
| 212 | { |
| 213 | _LOG_DEBUG("Validation Error: " << msg); |
| 214 | } |
| 215 | |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 216 | void |
akmhoque | 8e0252b | 2014-07-07 16:04:44 -0500 | [diff] [blame] | 217 | HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& faceUri, |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 218 | double linkCost, const ndn::time::milliseconds& timeout) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 219 | { |
| 220 | ndn::Name broadcastKeyPrefix = DEFAULT_BROADCAST_PREFIX; |
| 221 | broadcastKeyPrefix.append("KEYS"); |
| 222 | m_nlsr.getFib().registerPrefix(adjName, faceUri, linkCost, timeout, |
| 223 | ndn::bind(&HelloProtocol::onRegistrationSuccess, |
akmhoque | 8e0252b | 2014-07-07 16:04:44 -0500 | [diff] [blame] | 224 | this, _1, adjName), |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 225 | ndn::bind(&HelloProtocol::onRegistrationFailure, |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame^] | 226 | this, _1, _2, adjName)); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 227 | m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getChronosyncPrefix(), |
| 228 | faceUri, linkCost, timeout); |
| 229 | m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getLsaPrefix(), |
| 230 | faceUri, linkCost, timeout); |
| 231 | m_nlsr.getFib().registerPrefix(broadcastKeyPrefix, |
| 232 | faceUri, linkCost, timeout); |
akmhoque | 393d4ff | 2014-07-16 14:27:03 -0500 | [diff] [blame] | 233 | m_nlsr.setStrategies(); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | void |
| 237 | HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, |
akmhoque | 8e0252b | 2014-07-07 16:04:44 -0500 | [diff] [blame] | 238 | const ndn::Name& neighbor) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 239 | { |
| 240 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor); |
| 241 | if (adjacent != 0) { |
| 242 | adjacent->setFaceId(commandSuccessResult.getFaceId()); |
| 243 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 244 | ndn::Name interestName(neighbor); |
| 245 | interestName.append(NLSR_COMPONENT); |
| 246 | interestName.append(INFO_COMPONENT); |
| 247 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 248 | expressInterest(interestName, |
| 249 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | void |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame^] | 254 | HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error, |
| 255 | const ndn::Name& name) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 256 | { |
| 257 | _LOG_DEBUG(error << " (code: " << code << ")"); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame^] | 258 | /* |
| 259 | * If NLSR can not create face for given faceUri then it will treat this |
| 260 | * failure as one INFO interest timed out. So that NLSR can move on with |
| 261 | * building Adj Lsa and calculate routing table. NLSR does not build Adj |
| 262 | * Lsa unless all the neighbors are ACTIVE or DEAD. For considering the |
| 263 | * missconfigured(link) neighbour dead this is required. |
| 264 | */ |
| 265 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(name); |
| 266 | if (adjacent != 0) { |
| 267 | adjacent->setInterestTimedOutNo(adjacent->getInterestTimedOutNo() + 1); |
| 268 | int status = adjacent->getStatus(); |
| 269 | uint32_t infoIntTimedOutCount = adjacent->getInterestTimedOutNo(); |
| 270 | |
| 271 | if (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()) { |
| 272 | if ( status == 1) { |
| 273 | adjacent->setStatus(0); |
| 274 | } |
| 275 | m_nlsr.incrementAdjBuildCount(); |
| 276 | if (m_nlsr.getIsBuildAdjLsaSheduled() == false) { |
| 277 | _LOG_DEBUG("Scheduling scheduledAdjLsaBuild"); |
| 278 | m_nlsr.setIsBuildAdjLsaSheduled(true); |
| 279 | // event here |
| 280 | m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5), |
| 281 | ndn::bind(&Lsdb::scheduledAdjLsaBuild, |
| 282 | &m_nlsr.getLsdb())); |
| 283 | } |
| 284 | } |
| 285 | } |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 286 | } |
| 287 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 288 | } //namespace nlsr |