blob: f7d8d139fda60f59617357f85d941fc7ddd5dd28 [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
akmhoque298385a2014-02-13 14:13:09 -060018
akmhoque1fd8c1e2014-02-19 19:41:49 -060019 //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);
akmhoque298385a2014-02-13 14:13:09 -060026
akmhoque1fd8c1e2014-02-19 19:41:49 -060027 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));
akmhoque298385a2014-02-13 14:13:09 -060039
akmhoque1fd8c1e2014-02-19 19:41:49 -060040 //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 }
akmhoque298385a2014-02-13 14:13:09 -060073
74
75
akmhoque1fd8c1e2014-02-19 19:41:49 -060076 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);
akmhoque298385a2014-02-13 14:13:09 -060086
akmhoque1fd8c1e2014-02-19 19:41:49 -060087 }
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 }
akmhoqueb1710aa2014-02-19 17:13:36 -0600107
108}//namespace nlsr
akmhoque1fd8c1e2014-02-19 19:41:49 -0600109