blob: 730befdb2dc1e988248fef3c63182672473e9b5c [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
8using namespace std;
9using namespace ndn;
10
11void
akmhoque1a481092014-02-19 16:34:22 -060012NlsrTest::schedlueAddingLsas(Nlsr& pnlsr)
akmhoque298385a2014-02-13 14:13:09 -060013{
14 // scheduling adding two name lsas, two Cor Lsas and three Adj LSAs
15
16 //Scheduling Adding LSAs for router altair
17 string router("/ndn/memphis.edu/cs/altair");
18 string name1("/ndn/memphis.edu/cs/altair/name1");
19 string name2("/ndn/memphis.edu/cs/altair/name2");
20 string name3("/ndn/memphis.edu/cs/broadcast");
21 Adjacent adj1("/ndn/memphis.edu/cs/pollux",7,17,1,0);
22 Adjacent adj2("/ndn/memphis.edu/cs/maia",15,27,1,0);
23
24 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(30),
akmhoque1a481092014-02-19 16:34:22 -060025 ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060026 boost::ref(pnlsr)
27 ,router,name1,name2,name3));
28 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37),
akmhoque1a481092014-02-19 16:34:22 -060029 ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060030 boost::ref(pnlsr)
31 ,router,123.098,1.875));
32 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47),
akmhoque1a481092014-02-19 16:34:22 -060033 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060034 boost::ref(pnlsr)
35 ,router,adj1,adj2));
36
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);
44
45 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(55),
akmhoque1a481092014-02-19 16:34:22 -060046 ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060047 boost::ref(pnlsr)
48 ,routerMaia,maiaName1,maiaName2,maiaName3));
49 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65),
akmhoque1a481092014-02-19 16:34:22 -060050 ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060051 boost::ref(pnlsr)
52 ,routerMaia,12.098,0.875));
53 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75),
akmhoque1a481092014-02-19 16:34:22 -060054 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060055 boost::ref(pnlsr)
56 ,routerMaia,maiaAdj1,maiaAdj2));
57
58 //sheduling Adding LSAs for Router itself
59 string routerPollux("/ndn/memphis.edu/cs/pollux");
60 Adjacent polluxAdj1("/ndn/memphis.edu/cs/maia",9,13,1,0);
61 Adjacent polluxAdj2("/ndn/memphis.edu/cs/altair",12,23,1,0);
62
63 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(90),
akmhoque1a481092014-02-19 16:34:22 -060064 ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
akmhoque298385a2014-02-13 14:13:09 -060065 boost::ref(pnlsr)
66 ,routerPollux,polluxAdj1,polluxAdj2));
67
68
69}
70
71
72
73void
akmhoque1a481092014-02-19 16:34:22 -060074NlsrTest::secheduledAddNameLsa(Nlsr& pnlsr, string router,
akmhoque298385a2014-02-13 14:13:09 -060075 string name1, string name2, string name3)
76{
77 Npl npl;
78 npl.insertIntoNpl(name1);
79 npl.insertIntoNpl(name2);
80 npl.insertIntoNpl(name3);
81 NameLsa nameLsa(router,1,1,3600,npl);
82 pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
83
84}
85
86void
akmhoque1a481092014-02-19 16:34:22 -060087NlsrTest::secheduledAddCorLsa(Nlsr& pnlsr,string router, double r, double angle)
akmhoque298385a2014-02-13 14:13:09 -060088{
89 CorLsa corLsa(router,3,1,3600,r,angle);
90 pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
91}
92
93void
akmhoque1a481092014-02-19 16:34:22 -060094NlsrTest::scheduledAddAdjacentLsa(Nlsr& pnlsr, string router,
akmhoque298385a2014-02-13 14:13:09 -060095 Adjacent adj1, Adjacent adj2)
96{
97 Adl adl;
98 adl.insert(adj1);
99 adl.insert(adj2);
100 AdjLsa adjLsa(router,2,1,3600,2,adl);
101 pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
102
103}
104