akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #include <ndn-cpp-dev/face.hpp> |
| 2 | #include <ndn-cpp-dev/security/key-chain.hpp> |
| 3 | #include <ndn-cpp-dev/util/scheduler.hpp> |
| 4 | |
| 5 | #include "nlsr.hpp" |
| 6 | #include "nlsr_test.hpp" |
| 7 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 8 | namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 9 | { |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 10 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 11 | using namespace std; |
| 12 | using namespace ndn; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 13 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 14 | void |
| 15 | NlsrTest::schedlueAddingLsas(Nlsr& pnlsr) |
| 16 | { |
| 17 | // scheduling adding two name lsas, two Cor Lsas and three Adj LSAs |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 18 | //Scheduling Adding LSAs for router altair |
| 19 | string router("/ndn/memphis.edu/cs/altair"); |
| 20 | string name1("/ndn/memphis.edu/cs/altair/name1"); |
| 21 | string name2("/ndn/memphis.edu/cs/altair/name2"); |
| 22 | string name3("/ndn/memphis.edu/cs/broadcast"); |
| 23 | Adjacent adj1("/ndn/memphis.edu/cs/pollux",7,17,1,0); |
| 24 | Adjacent adj2("/ndn/memphis.edu/cs/maia",15,27,1,0); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 25 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(30), |
| 26 | ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(), |
| 27 | boost::ref(pnlsr) |
| 28 | ,router,name1,name2,name3)); |
| 29 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37), |
| 30 | ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(), |
| 31 | boost::ref(pnlsr) |
| 32 | ,router,123.098,1.875)); |
| 33 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47), |
| 34 | ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(), |
| 35 | boost::ref(pnlsr) |
| 36 | ,router,adj1,adj2)); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 37 | //Scheduling Adding LSAs for router Maia |
| 38 | string routerMaia("/ndn/memphis.edu/cs/maia"); |
| 39 | string maiaName1("/ndn/memphis.edu/maia/name1"); |
| 40 | string maiaName2("/ndn/memphis.edu/maia/name2"); |
| 41 | string maiaName3("/ndn/memphis.edu/cs/broadcast"); |
| 42 | Adjacent maiaAdj1("/ndn/memphis.edu/cs/pollux",8,25,1,0); |
| 43 | Adjacent maiaAdj2("/ndn/memphis.edu/cs/altair",11,15,1,0); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 44 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(55), |
| 45 | ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(), |
| 46 | boost::ref(pnlsr) |
| 47 | ,routerMaia,maiaName1,maiaName2,maiaName3)); |
| 48 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65), |
| 49 | ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(), |
| 50 | boost::ref(pnlsr) |
| 51 | ,routerMaia,12.098,0.875)); |
| 52 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75), |
| 53 | ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(), |
| 54 | boost::ref(pnlsr) |
| 55 | ,routerMaia,maiaAdj1,maiaAdj2)); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 56 | //sheduling Adding LSAs for Router itself |
| 57 | string routerPollux("/ndn/memphis.edu/cs/pollux"); |
| 58 | Adjacent polluxAdj1("/ndn/memphis.edu/cs/maia",9,13,1,0); |
| 59 | Adjacent polluxAdj2("/ndn/memphis.edu/cs/altair",12,23,1,0); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 60 | pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(90), |
| 61 | ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(), |
| 62 | boost::ref(pnlsr) |
| 63 | ,routerPollux,polluxAdj1,polluxAdj2)); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 64 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 65 | |
| 66 | |
| 67 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 68 | void |
| 69 | NlsrTest::secheduledAddNameLsa(Nlsr& pnlsr, string router, |
| 70 | string name1, string name2, string name3) |
| 71 | { |
| 72 | Npl npl; |
| 73 | npl.insertIntoNpl(name1); |
| 74 | npl.insertIntoNpl(name2); |
| 75 | npl.insertIntoNpl(name3); |
| 76 | NameLsa nameLsa(router,1,1,3600,npl); |
| 77 | pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | void |
| 81 | NlsrTest::secheduledAddCorLsa(Nlsr& pnlsr,string router, double r, double angle) |
| 82 | { |
| 83 | CorLsa corLsa(router,3,1,3600,r,angle); |
| 84 | pnlsr.getLsdb().installCorLsa(pnlsr, corLsa); |
| 85 | } |
| 86 | |
| 87 | void |
| 88 | NlsrTest::scheduledAddAdjacentLsa(Nlsr& pnlsr, string router, |
| 89 | Adjacent adj1, Adjacent adj2) |
| 90 | { |
| 91 | Adl adl; |
| 92 | adl.insert(adj1); |
| 93 | adl.insert(adj2); |
| 94 | AdjLsa adjLsa(router,2,1,3600,2,adl); |
| 95 | pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 96 | } |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 97 | |
| 98 | }//namespace nlsr |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 99 | |