blob: 99b01f7533c1b73995e6eaef2215abbc461fed44 [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
akmhoqueb1710aa2014-02-19 17:13:36 -06008namespace nlsr {
9
akmhoque298385a2014-02-13 14:13:09 -060010using namespace std;
11using namespace ndn;
12
13void
akmhoque1a481092014-02-19 16:34:22 -060014NlsrTest::schedlueAddingLsas(Nlsr& pnlsr)
akmhoque298385a2014-02-13 14:13:09 -060015{
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),
akmhoque1a481092014-02-19 16:34:22 -060027 ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060028 boost::ref(pnlsr)
29 ,router,name1,name2,name3));
30 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37),
akmhoque1a481092014-02-19 16:34:22 -060031 ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060032 boost::ref(pnlsr)
33 ,router,123.098,1.875));
34 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47),
akmhoque1a481092014-02-19 16:34:22 -060035 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060036 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),
akmhoque1a481092014-02-19 16:34:22 -060048 ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060049 boost::ref(pnlsr)
50 ,routerMaia,maiaName1,maiaName2,maiaName3));
51 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65),
akmhoque1a481092014-02-19 16:34:22 -060052 ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060053 boost::ref(pnlsr)
54 ,routerMaia,12.098,0.875));
55 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75),
akmhoque1a481092014-02-19 16:34:22 -060056 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060057 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),
akmhoque1a481092014-02-19 16:34:22 -060066 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060067 boost::ref(pnlsr)
68 ,routerPollux,polluxAdj1,polluxAdj2));
69
70
71}
72
73
74
75void
akmhoque1a481092014-02-19 16:34:22 -060076NlsrTest::secheduledAddNameLsa(Nlsr& pnlsr, string router,
akmhoque298385a2014-02-13 14:13:09 -060077 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
88void
akmhoque1a481092014-02-19 16:34:22 -060089NlsrTest::secheduledAddCorLsa(Nlsr& pnlsr,string router, double r, double angle)
akmhoque298385a2014-02-13 14:13:09 -060090{
91 CorLsa corLsa(router,3,1,3600,r,angle);
92 pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
93}
94
95void
akmhoque1a481092014-02-19 16:34:22 -060096NlsrTest::scheduledAddAdjacentLsa(Nlsr& pnlsr, string router,
akmhoque298385a2014-02-13 14:13:09 -060097 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}
akmhoqueb1710aa2014-02-19 17:13:36 -0600106
107}//namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -0600108