blob: ef19e630f5d0ea0cfd2b9c6d417f03413e09e4b2 [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
12nlsrTest::schedlueAddingLsas(nlsr& pnlsr)
13{
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),
25 ndn::bind(&nlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
26 boost::ref(pnlsr)
27 ,router,name1,name2,name3));
28 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37),
29 ndn::bind(&nlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
30 boost::ref(pnlsr)
31 ,router,123.098,1.875));
32 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47),
33 ndn::bind(&nlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
34 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),
46 ndn::bind(&nlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
47 boost::ref(pnlsr)
48 ,routerMaia,maiaName1,maiaName2,maiaName3));
49 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65),
50 ndn::bind(&nlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
51 boost::ref(pnlsr)
52 ,routerMaia,12.098,0.875));
53 pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75),
54 ndn::bind(&nlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
55 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),
64 ndn::bind(&nlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
65 boost::ref(pnlsr)
66 ,routerPollux,polluxAdj1,polluxAdj2));
67
68
69}
70
71
72
73void
74nlsrTest::secheduledAddNameLsa(nlsr& pnlsr, string router,
75 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
87nlsrTest::secheduledAddCorLsa(nlsr& pnlsr,string router, double r, double angle)
88{
89 CorLsa corLsa(router,3,1,3600,r,angle);
90 pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
91}
92
93void
94nlsrTest::scheduledAddAdjacentLsa(nlsr& pnlsr, string router,
95 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