blob: c04fd7705f9ecc8734c1c3f4fbfeff7dff685ed1 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#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
akmhoque1fd8c1e2014-02-19 19:41:49 -06008namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -06009{
akmhoque298385a2014-02-13 14:13:09 -060010
akmhoque1fd8c1e2014-02-19 19:41:49 -060011 using namespace std;
12 using namespace ndn;
akmhoque298385a2014-02-13 14:13:09 -060013
akmhoque1fd8c1e2014-02-19 19:41:49 -060014 void
15 NlsrTest::schedlueAddingLsas(Nlsr& pnlsr)
16 {
17 // scheduling adding two name lsas, two Cor Lsas and three Adj LSAs
akmhoque1fd8c1e2014-02-19 19:41:49 -060018 //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);
akmhoque1fd8c1e2014-02-19 19:41:49 -060025 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));
akmhoque1fd8c1e2014-02-19 19:41:49 -060037 //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);
akmhoque1fd8c1e2014-02-19 19:41:49 -060044 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));
akmhoque1fd8c1e2014-02-19 19:41:49 -060056 //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);
akmhoque1fd8c1e2014-02-19 19:41:49 -060060 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(90),
61 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
62 boost::ref(pnlsr)
63 ,routerPollux,polluxAdj1,polluxAdj2));
akmhoque1fd8c1e2014-02-19 19:41:49 -060064 }
akmhoque298385a2014-02-13 14:13:09 -060065
66
67
akmhoque1fd8c1e2014-02-19 19:41:49 -060068 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);
akmhoque1fd8c1e2014-02-19 19:41:49 -060078 }
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);
akmhoque1fd8c1e2014-02-19 19:41:49 -060096 }
akmhoqueb1710aa2014-02-19 17:13:36 -060097
98}//namespace nlsr
akmhoque1fd8c1e2014-02-19 19:41:49 -060099