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