blob: 3efc6653c4668c5cc5f512ccc6cc6109d55a778b [file] [log] [blame]
akmhoque79d355f2014-02-04 15:11:16 -06001#ifndef NLSR_RTC_HPP
2#define NLSR_RTC_HPP
3
4#include <list>
5#include <iostream>
6
7
8
9class Map;
10class RoutingTable;
11class nlsr;
12
13
14using namespace std;
15
16class RoutingTableCalculator
17{
18public:
19 RoutingTableCalculator()
20 {
21 }
22 RoutingTableCalculator(int rn)
23 {
24 numOfRouter=rn;
25 }
akmhoque3fdf7612014-02-04 21:18:23 -060026protected:
akmhoque79d355f2014-02-04 15:11:16 -060027 void allocateAdjMatrix();
28 void makeAdjMatrix(nlsr& pnlsr,Map pMap);
akmhoque3fdf7612014-02-04 21:18:23 -060029 void printAdjMatrix();
30 int getNumOfLinkfromAdjMatrix(int sRouter);
akmhoque79d355f2014-02-04 15:11:16 -060031 void freeAdjMatrix();
akmhoque3fdf7612014-02-04 21:18:23 -060032 void adjustAdMatrix(int source, int link, double linkCost);
33 void getLinksFromAdjMatrix(int *links, double *linkCosts, int source);
akmhoque79d355f2014-02-04 15:11:16 -060034
35protected:
36 double ** adjMatrix;
37 int numOfRouter;
38};
39
40class LinkStateRoutingTableCalculator: public RoutingTableCalculator
41{
42public:
43 LinkStateRoutingTableCalculator(int rn)
akmhoque3fdf7612014-02-04 21:18:23 -060044 : EMPTY_PARENT(-12345)
45 , INF_DISTANCE(2147483647)
46 , NO_MAPPING_NUM(-1)
akmhoque79d355f2014-02-04 15:11:16 -060047 {
48 numOfRouter=rn;
49 }
akmhoque3fdf7612014-02-04 21:18:23 -060050 void setNoLink(int nl)
51 {
52 vNoLink=nl;
53 }
akmhoque79d355f2014-02-04 15:11:16 -060054
55 void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
akmhoque3fdf7612014-02-04 21:18:23 -060056
57
58private:
59 void doDijkstraPathCalculation(int sourceRouter);
60 void sortQueueByDistance(int *Q, double *dist,int start,int element);
61 int isNotExplored(int *Q, int u,int start, int element);
62 void printAllLsPath(int sourceRouter);
63 void printLsPath(int destRouter);
64
65 void allocateParent();
66 void allocateDistance();
67 void freeParent();
68 void freeDistance();
69
70 void allocateLinks();
71 void allocateLinkCosts();
72 void freeLinks();
73 void freeLinksCosts();
74
75
76private:
77 int *parent;
78 double *distance;
79
80 int vNoLink;
81 int *links;
82 double *linkCosts;
83 const int EMPTY_PARENT;
84 const double INF_DISTANCE;
85 const int NO_MAPPING_NUM;
akmhoque79d355f2014-02-04 15:11:16 -060086
87};
88
89class HypRoutingTableCalculator: public RoutingTableCalculator
90{
91public:
92 HypRoutingTableCalculator(int rn)
93 {
94 numOfRouter=rn;
95 }
96
97 void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
98
99};
100
101class HypDryRoutingTableCalculator: public RoutingTableCalculator
102{
103 public:
104 HypDryRoutingTableCalculator(int rn)
105 {
106 numOfRouter=rn;
107 }
108
109 void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
110
111};
112
113#endif