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