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