akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 1 | #include <iostream> |
| 2 | #include <cstdlib> |
| 3 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 4 | #include <ndn-cxx/security/identity-certificate.hpp> |
| 5 | #include <ndn-cxx/util/io.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 6 | |
| 7 | #include "nlsr.hpp" |
| 8 | #include "interest-manager.hpp" |
| 9 | #include "data-manager.hpp" |
| 10 | #include "utility/tokenizer.hpp" |
| 11 | #include "lsdb.hpp" |
| 12 | |
| 13 | namespace nlsr { |
| 14 | |
| 15 | using namespace std; |
| 16 | using namespace ndn; |
| 17 | |
| 18 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 19 | InterestManager::processInterest(const ndn::Name& name, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 20 | const ndn::Interest& interest) |
| 21 | { |
| 22 | cout << "<< I: " << interest << endl; |
| 23 | string intName = interest.getName().toUri(); |
| 24 | cout << "Interest Received for Name: " << intName << endl; |
| 25 | Tokenizer nt(intName, "/"); |
| 26 | string chkString("info"); |
| 27 | if (nt.doesTokenExist(chkString)) |
| 28 | { |
| 29 | string nbr = nt.getTokenString(nt.getTokenPosition(chkString) + 1); |
| 30 | cout << "Neighbor: " << nbr << endl; |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 31 | processInterestInfo(nbr, interest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 32 | } |
| 33 | chkString = "LSA"; |
| 34 | if (nt.doesTokenExist(chkString)) |
| 35 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 36 | processInterestLsa(interest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 37 | } |
| 38 | chkString = "keys"; |
| 39 | if (nt.doesTokenExist(chkString)) |
| 40 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 41 | processInterestKeys(interest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
| 45 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 46 | InterestManager::processInterestInfo(const string& neighbor, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 47 | const ndn::Interest& interest) |
| 48 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 49 | if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 50 | { |
| 51 | Data data(ndn::Name(interest.getName()).appendVersion()); |
| 52 | data.setFreshnessPeriod(time::seconds(10)); // 10 sec |
| 53 | data.setContent((const uint8_t*)"info", sizeof("info")); |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 54 | // m_nlsr.getKeyManager().signData(data); |
| 55 | m_keyChain.sign(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 56 | cout << ">> D: " << data << endl; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 57 | m_nlsr.getNlsrFace().put(data); |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 58 | int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 59 | if (status == 0) |
| 60 | { |
| 61 | string intName = neighbor + "/" + "info" + |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 62 | m_nlsr.getConfParameter().getRouterPrefix(); |
| 63 | expressInterest(intName, 2, |
| 64 | m_nlsr.getConfParameter().getInterestResendTime()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 70 | InterestManager::processInterestLsa(const ndn::Interest& interest) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 71 | { |
| 72 | string intName = interest.getName().toUri(); |
| 73 | Tokenizer nt(intName, "/"); |
| 74 | string chkString("LSA"); |
| 75 | string origRouter = nt.getTokenString(nt.getTokenPosition(chkString) + 1, |
| 76 | nt.getTokenNumber() - 3); |
| 77 | string lsTypeString = nt.getToken(nt.getTokenNumber() - 2); |
| 78 | string lsSeqString = nt.getToken(nt.getTokenNumber() - 1); |
| 79 | std::cout << "Router Name: " << origRouter << std::endl; |
| 80 | std::cout << "Ls Type : " << lsTypeString << std::endl; |
| 81 | std::cout << "Ls Seq : " << lsSeqString << endl; |
| 82 | uint8_t interestedLsType; |
| 83 | uint32_t interestedLsSeqNo; |
| 84 | try |
| 85 | { |
| 86 | interestedLsType = boost::lexical_cast<uint8_t>(lsTypeString); |
| 87 | interestedLsSeqNo = boost::lexical_cast<uint32_t>(lsSeqString); |
| 88 | } |
| 89 | catch (std::exception& e) |
| 90 | { |
| 91 | return; |
| 92 | } |
| 93 | std::cout << "Ls Type: " << interestedLsType << std::endl; |
| 94 | if (lsTypeString == "1") //Name Lsa |
| 95 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 96 | processInterestForNameLsa(interest, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 97 | origRouter + "/" + lsTypeString, interestedLsSeqNo); |
| 98 | } |
| 99 | else if (lsTypeString == "2") //Adj Lsa |
| 100 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 101 | processInterestForAdjLsa(interest, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 102 | origRouter + "/" + lsTypeString, interestedLsSeqNo); |
| 103 | } |
| 104 | else if (lsTypeString == "3") //Cor Lsa |
| 105 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 106 | processInterestForCorLsa(interest, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 107 | origRouter + "/" + lsTypeString, interestedLsSeqNo); |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | cout << "Unrecognized LSA Type :(" << endl; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 116 | InterestManager::processInterestForNameLsa(const ndn::Interest& interest, |
| 117 | const string& lsaKey, uint32_t interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 118 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 119 | NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey); |
| 120 | if (nameLsa != 0) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 121 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 122 | if (nameLsa->getLsSeqNo() >= interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 123 | { |
| 124 | Data data(ndn::Name(interest.getName()).appendVersion()); |
| 125 | data.setFreshnessPeriod(time::seconds(10)); // 10 sec |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 126 | string content = nameLsa->getData(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 127 | data.setContent((const uint8_t*)content.c_str(), content.size()); |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 128 | // m_nlsr.getKeyManager().signData(data); |
| 129 | m_keyChain.sign(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 130 | std::cout << ">> D: " << data << std::endl; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 131 | m_nlsr.getNlsrFace().put(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 137 | InterestManager::processInterestForAdjLsa(const ndn::Interest& interest, |
| 138 | const string& lsaKey, uint32_t interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 139 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 140 | AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey); |
| 141 | if (adjLsa != 0) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 142 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 143 | if (adjLsa->getLsSeqNo() >= interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 144 | { |
| 145 | Data data(ndn::Name(interest.getName()).appendVersion()); |
| 146 | data.setFreshnessPeriod(time::seconds(10)); // 10 sec |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 147 | string content = adjLsa->getData(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 148 | data.setContent((const uint8_t*)content.c_str(), content.size()); |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 149 | // m_nlsr.getKeyManager().signData(data); |
| 150 | m_keyChain.sign(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 151 | std::cout << ">> D: " << data << std::endl; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 152 | m_nlsr.getNlsrFace().put(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 158 | InterestManager::processInterestForCorLsa(const ndn::Interest& interest, |
| 159 | const string& lsaKey, uint32_t interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 160 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 161 | CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey); |
| 162 | if (corLsa != 0) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 163 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 164 | if (corLsa->getLsSeqNo() >= interestedlsSeqNo) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 165 | { |
| 166 | Data data(ndn::Name(interest.getName()).appendVersion()); |
| 167 | data.setFreshnessPeriod(time::seconds(10)); // 10 sec |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 168 | string content = corLsa->getData(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 169 | data.setContent((const uint8_t*)content.c_str(), content.size()); |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 170 | // m_nlsr.getKeyManager().signData(data); |
| 171 | m_keyChain.sign(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 172 | std::cout << ">> D: " << data << std::endl; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 173 | m_nlsr.getNlsrFace().put(data); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 179 | InterestManager::processInterestKeys(const ndn::Interest& interest) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 180 | { |
| 181 | std::cout << "processInterestKeys called " << std::endl; |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 182 | // string intName = interest.getName().toUri(); |
| 183 | // std::cout << "Interest Name for Key: " << intName << std::endl; |
| 184 | // Tokenizer nt(intName, "/"); |
| 185 | // std::string chkString("ID-CERT"); |
| 186 | // std::string certName; |
| 187 | // uint32_t seqNum; |
| 188 | // ndn::Name dataName; |
| 189 | // std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> chkCert; |
| 190 | // if (nt.getTokenPosition(chkString) == nt.getTokenNumber() - 1) |
| 191 | // { |
| 192 | // certName = nt.getTokenString(0, nt.getTokenNumber() - 1); |
| 193 | // cout << "Cert Name: " << certName << std::endl; |
| 194 | // chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName); |
| 195 | // } |
| 196 | // else |
| 197 | // { |
| 198 | // certName = nt.getTokenString(0, nt.getTokenNumber() - 2); |
| 199 | // seqNum = boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber() - 1)); |
| 200 | // std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl; |
| 201 | // chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName, seqNum); |
| 202 | // } |
| 203 | // if (chkCert.second) |
| 204 | // { |
| 205 | // if (nt.getTokenPosition(chkString) == nt.getTokenNumber() - 1) |
| 206 | // { |
| 207 | // std::string dn; |
| 208 | // dataName = ndn::Name(interest.getName()).appendVersion(); |
| 209 | // std::pair<uint32_t, bool> seqChk = |
| 210 | // m_nlsr.getKeyManager().getCertificateSeqNum(certName); |
| 211 | // if (seqChk.second) |
| 212 | // { |
| 213 | // dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(seqChk.first); |
| 214 | // dataName = ndn::Name(dn); |
| 215 | // } |
| 216 | // else |
| 217 | // { |
| 218 | // dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(10); |
| 219 | // dataName = ndn::Name(dn); |
| 220 | // } |
| 221 | // } |
| 222 | // else |
| 223 | // { |
| 224 | // dataName = ndn::Name(interest.getName()); |
| 225 | // } |
| 226 | // Data data(dataName.appendVersion()); |
| 227 | // data.setFreshnessPeriod(time::seconds(10)); //10 sec |
| 228 | // data.setContent(chkCert.first->wireEncode()); |
| 229 | // m_nlsr.getKeyManager().signData(data); |
| 230 | // m_nlsr.getNlsrFace()->put(data); |
| 231 | // } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | |
| 235 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 236 | InterestManager::processInterestTimedOut(const ndn::Interest& interest) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 237 | { |
| 238 | std::cout << "Timed out interest : " << interest.getName().toUri() << std::endl; |
| 239 | string intName = interest.getName().toUri(); |
| 240 | Tokenizer nt(intName, "/"); |
| 241 | string chkString("info"); |
| 242 | if (nt.doesTokenExist(chkString)) |
| 243 | { |
| 244 | string nbr = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1); |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 245 | processInterestTimedOutInfo(nbr , interest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 246 | } |
| 247 | chkString = "LSA"; |
| 248 | if (nt.doesTokenExist(chkString)) |
| 249 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 250 | processInterestTimedOutLsa(interest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
| 254 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 255 | InterestManager::processInterestTimedOutInfo(const string& neighbor, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 256 | const ndn::Interest& interest) |
| 257 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 258 | m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor); |
| 259 | int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 260 | uint32_t infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 261 | std::cout << "Neighbor: " << neighbor << std::endl; |
| 262 | std::cout << "Status: " << status << std::endl; |
| 263 | std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl; |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 264 | if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 265 | { |
| 266 | string intName = neighbor + "/" + "info" + |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 267 | m_nlsr.getConfParameter().getRouterPrefix(); |
| 268 | expressInterest(intName, 2, |
| 269 | m_nlsr.getConfParameter().getInterestResendTime()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 270 | } |
| 271 | else if ((status == 1) && |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 272 | (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 273 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 274 | m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0); |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 275 | m_nlsr.incrementAdjBuildCount(); |
| 276 | if (m_nlsr.getIsBuildAdjLsaSheduled() == 0) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 277 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 278 | m_nlsr.setIsBuildAdjLsaSheduled(1); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 279 | // event here |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 280 | m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5), |
| 281 | ndn::bind(&Lsdb::scheduledAdjLsaBuild, |
| 282 | &m_nlsr.getLsdb(), |
| 283 | boost::ref(m_nlsr))); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 289 | InterestManager::processInterestTimedOutLsa(const ndn::Interest& interest) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 290 | { |
| 291 | } |
| 292 | |
| 293 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 294 | InterestManager::expressInterest(const string& interestNamePrefix, |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 295 | int32_t scope, int32_t seconds) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 296 | { |
| 297 | std::cout << "Expressing Interest :" << interestNamePrefix << std::endl; |
| 298 | ndn::Interest i((ndn::Name(interestNamePrefix))); |
| 299 | i.setInterestLifetime(time::seconds(seconds)); |
| 300 | i.setMustBeFresh(true); |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 301 | m_nlsr.getNlsrFace().expressInterest(i, |
| 302 | ndn::bind(&DataManager::processContent, |
| 303 | &m_nlsr.getDataManager(), |
| 304 | _1, _2, boost::ref(*this)), |
| 305 | ndn::bind(&InterestManager::processInterestTimedOut, |
| 306 | this, _1)); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | |
| 310 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 311 | InterestManager::sendScheduledInfoInterest(int32_t seconds) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 312 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 313 | std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 314 | for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end(); |
| 315 | ++it) |
| 316 | { |
| 317 | string adjName = (*it).getName() + "/" + "info" + |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 318 | m_nlsr.getConfParameter().getRouterPrefix(); |
| 319 | expressInterest(adjName, 2, |
| 320 | m_nlsr.getConfParameter().getInterestResendTime()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 321 | } |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 322 | scheduleInfoInterest(m_nlsr.getConfParameter().getInfoInterestInterval()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 326 | InterestManager::scheduleInfoInterest(int32_t seconds) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 327 | { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 328 | EventId eid = m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds), |
| 329 | ndn::bind(&InterestManager::sendScheduledInfoInterest, this, |
| 330 | seconds)); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | |
| 334 | } //namespace nlsr |