blob: 4303f896007d3a85635fd173ad177c7ac1679847 [file] [log] [blame]
akmhoquedfa4a5b2014-02-03 20:12:29 -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/altair/name3");
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/maia/name3");
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
59
60}
61
62
63
64void
65nlsrTest::secheduledAddNameLsa(nlsr& pnlsr, string router,
66 string name1, string name2, string name3)
67{
68 Npl npl;
69 npl.insertIntoNpl(name1);
70 npl.insertIntoNpl(name2);
71 npl.insertIntoNpl(name3);
72 NameLsa nameLsa(router,1,1,3600,npl);
73 pnlsr.getLsdb().installNameLsa(nameLsa);
74
75}
76
77void
78nlsrTest::secheduledAddCorLsa(nlsr& pnlsr,string router, double r, double angle)
79{
80 CorLsa corLsa(router,3,1,3600,r,angle);
81 pnlsr.getLsdb().installCorLsa(corLsa);
82}
83
84void
85nlsrTest::scheduledAddAdjacentLsa(nlsr& pnlsr, string router,
86 Adjacent adj1, Adjacent adj2)
87{
88 Adl adl;
89 adl.insert(adj1);
90 adl.insert(adj2);
91 AdjLsa adjLsa(router,2,1,3600,2,adl);
92 pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
93
94}
95