Added Routing Table Structures
diff --git a/nlsr.cpp b/nlsr.cpp
index 99cc450..5a873df 100644
--- a/nlsr.cpp
+++ b/nlsr.cpp
@@ -56,7 +56,6 @@
 
 int 
 main(int argc, char **argv){
-
 	nlsr nlsr;
 	string programName(argv[0]);
 	nlsr.setConfFileName("nlsr.conf");
diff --git a/nlsr.hpp b/nlsr.hpp
index f131ab6..52d5277 100644
--- a/nlsr.hpp
+++ b/nlsr.hpp
@@ -162,6 +162,26 @@
 	{
 		return apiPort;
 	}
+
+	int getIsRoutingTableCalculating()
+	{
+		return isRoutingTableCalculating;
+	}
+
+	void setIsRoutingTableCalculating(int irtc)
+	{
+		isRoutingTableCalculating=irtc;
+	}
+
+	int getIsRouteCalculationScheduled()
+	{
+		return isRouteCalculationScheduled;
+	}
+
+	void setIsRouteCalculationScheduled(int ircs)
+	{
+		isRouteCalculationScheduled=ircs;
+	}
 	
 private:
 	ConfParameter confParam;
diff --git a/nlsr_adl.cpp b/nlsr_adl.cpp
index 0f4be8f..55cbb29 100644
--- a/nlsr_adl.cpp
+++ b/nlsr_adl.cpp
@@ -147,7 +147,7 @@
 	}
 }
 
-std::list<Adjacent> 
+std::list<Adjacent>& 
 Adl::getAdjList(){
 	return adjList;
 }
diff --git a/nlsr_adl.hpp b/nlsr_adl.hpp
index eac8245..70e250d 100644
--- a/nlsr_adl.hpp
+++ b/nlsr_adl.hpp
@@ -17,7 +17,7 @@
 	int insert(Adjacent& adj);
 	int updateAdjacentStatus(string adjName, int s);
 	int updateAdjacentLinkCost(string adjName, double lc);	
-	std::list<Adjacent> getAdjList();
+	std::list<Adjacent>& getAdjList();
 	bool isNeighbor(string adjName);
 	void incrementTimedOutInterestCount(string& neighbor);
 	int getTimedOutInterestCount(string& neighbor);
diff --git a/nlsr_lsdb.cpp b/nlsr_lsdb.cpp
index 062a2b1..ffd49b1 100644
--- a/nlsr_lsdb.cpp
+++ b/nlsr_lsdb.cpp
@@ -346,8 +346,13 @@
 		// add Adj LSA
 		addAdjLsa(alsa);
 		// schedule routing table calculation
-		pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
-							ndn::bind(&RoutingTable::calculate, &pnlsr.getRoutingTable()));
+		if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
+		{
+			pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+								ndn::bind(&RoutingTable::calculate, 
+								&pnlsr.getRoutingTable(),boost::ref(pnlsr)));
+			pnlsr.setIsRouteCalculationScheduled(1);
+		}
 	}
 	else
 	{
@@ -403,6 +408,12 @@
 	return true;
 }
 
+std::list<AdjLsa>& 
+Lsdb::getAdjLsdb()
+{
+		return adjLsdb;
+}
+
 void 
 Lsdb::printAdjLsdb()
 {
diff --git a/nlsr_lsdb.hpp b/nlsr_lsdb.hpp
index 3451c71..1225969 100644
--- a/nlsr_lsdb.hpp
+++ b/nlsr_lsdb.hpp
@@ -29,12 +29,13 @@
 	bool removeCorLsa(string& key);
 	void printCorLsdb(); //debugging
 
-	//function related to Cor LSDB
+	//function related to Adj LSDB
 	void scheduledAdjLsaBuild(nlsr& pnlsr);
 	bool buildAndInstallOwnAdjLsa(nlsr& pnlsr);
 	bool removeAdjLsa(string& key);
 	bool installAdjLsa(nlsr& pnlsr, AdjLsa &alsa);
 	AdjLsa& getAdjLsa(string key);
+	std::list<AdjLsa>& getAdjLsdb();
 	void printAdjLsdb();
 	
 private:
diff --git a/nlsr_map.cpp b/nlsr_map.cpp
new file mode 100644
index 0000000..3c4ee86
--- /dev/null
+++ b/nlsr_map.cpp
@@ -0,0 +1,117 @@
+#include<iostream>
+#include<list>
+
+#include "nlsr.hpp"
+#include "nlsr_adjacent.hpp"
+#include "nlsr_lsa.hpp"
+#include "nlsr_lsdb.hpp"
+#include "nlsr_map.hpp"
+
+
+using namespace std;
+
+ostream&
+operator<<(ostream& os, MapEntry& mpe)
+{
+	os<<"MapEntry: ( Router: "<<mpe.getRouter()<<" Mapping No: ";
+	os<<mpe.getMappingNumber()<<" )"<<endl;
+
+	return os;
+}
+
+static bool
+mapEntryCompareByRouter(MapEntry& mpe1, string& rtrName){
+	return mpe1.getRouter()==rtrName;
+}
+
+static bool
+mapEntryCompareByMappingNo(MapEntry& mpe1, int mappingNo){
+	return mpe1.getMappingNumber()==mappingNo;
+}
+
+void 
+Map::addMapElement(string& rtrName)
+{
+	MapEntry me(rtrName,mappingIndex);
+	if (  addMapElement(me) )
+	{
+		mappingIndex++;
+	}
+}
+
+bool 
+Map::addMapElement(MapEntry& mpe)
+{
+	//cout << mpe;
+	std::list<MapEntry >::iterator it = std::find_if( rMap.begin(), 
+								rMap.end(),	
+   								bind(&mapEntryCompareByRouter, _1, mpe.getRouter()));
+	if ( it == rMap.end() ){
+		rMap.push_back(mpe);
+		return true;
+	}
+	return false;
+}
+
+string 
+Map::getRouterNameByMappingNo(int mn)
+{
+	std::list<MapEntry >::iterator it = std::find_if( rMap.begin(), 
+								rMap.end(),	
+   								bind(&mapEntryCompareByMappingNo, _1, mn));
+	if ( it != rMap.end() ){
+		return (*it).getRouter();
+	}
+	return "";
+}
+
+int 
+Map::getMappingNoByRouterName(string& rName)
+{
+	std::list<MapEntry >::iterator it = std::find_if( rMap.begin(), 
+								rMap.end(),	
+   								bind(&mapEntryCompareByRouter, _1, rName));
+	if ( it != rMap.end() ){
+		return (*it).getMappingNumber();
+	}
+	return -1;
+}
+
+void 
+Map::createMapFromAdjLsdb(nlsr& pnlsr)
+{
+	std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb();
+	for( std::list<AdjLsa>::iterator it=adjLsdb.begin(); 
+	                                                 it!= adjLsdb.end() ; it++)
+	{
+		string linkStartRouter=(*it).getOrigRouter();
+		addMapElement(linkStartRouter);
+		std::list<Adjacent> adl=(*it).getAdl().getAdjList();
+		for( std::list<Adjacent>::iterator itAdl=adl.begin(); 
+																								itAdl!= adl.end() ; itAdl++)
+		{
+			string linkEndRouter=(*itAdl).getAdjacentName();
+			addMapElement(linkEndRouter);
+		}
+		
+	}
+}
+
+void 
+Map::resetMap()
+{
+	rMap.clear();
+	mappingIndex=0;
+}
+
+ostream&
+operator<<(ostream& os, Map& rMap)
+{
+	os<<"---------------Map----------------------"<<endl;
+	std::list< MapEntry > ml=rMap.getMapList();
+	for( std::list<MapEntry>::iterator it=ml.begin(); it!= ml.end() ; it++){
+		os<< (*it);
+	}
+
+	return os;
+}
diff --git a/nlsr_map.hpp b/nlsr_map.hpp
new file mode 100644
index 0000000..c02104a
--- /dev/null
+++ b/nlsr_map.hpp
@@ -0,0 +1,84 @@
+#ifndef NLSR_MAP_HPP
+#define NLSR_MAP_HPP
+
+#include <iostream>
+#include <list>
+
+#include <ndn-cpp-dev/face.hpp>
+
+class nlsr;
+
+using namespace std;
+
+class MapEntry
+{
+public:
+	MapEntry()
+		: router()
+		, mappingNumber(-1)
+	{
+	}
+
+	~MapEntry()
+	{
+	}
+	
+	MapEntry(string rtr, int mn)
+	{
+		router=rtr;
+		mappingNumber=mn;
+	}
+
+	string getRouter()
+	{
+		return router;
+	}
+
+	int getMappingNumber()
+	{
+		return mappingNumber;
+	}
+private:
+	string router;
+	int mappingNumber;
+};
+
+ostream&
+operator<<(ostream& os, MapEntry& mpe);
+
+class Map
+{
+public:
+	Map()
+		: mappingIndex(0)
+	{
+	}
+
+	
+	void addMapElement(string& rtrName);
+	void createMapFromAdjLsdb(nlsr& pnlsr);
+	string getRouterNameByMappingNo(int mn);
+	int getMappingNoByRouterName(string& rName);
+	void resetMap();
+	std::list< MapEntry >& getMapList()
+	{
+		return rMap;
+	}
+
+	int getMapSize()
+	{
+		return rMap.size();
+	}
+
+	
+private:
+	bool addMapElement(MapEntry& mpe);
+	
+	int mappingIndex;
+	std::list< MapEntry > rMap;
+};
+
+ostream&
+operator<<(ostream& os, Map& rMap);
+
+#endif
diff --git a/nlsr_rt.cpp b/nlsr_rt.cpp
index bcf5af0..b2cc8b9 100644
--- a/nlsr_rt.cpp
+++ b/nlsr_rt.cpp
@@ -1,10 +1,112 @@
 #include<iostream>
 #include<string>
+#include<list>
 
 #include "nlsr_rt.hpp"
 #include "nlsr.hpp"
+#include "nlsr_map.hpp"
+#include "nlsr_rtc.hpp"
 
 using namespace std;
 
+void
+RoutingTable::calculate(nlsr& pnlsr)
+{
 
+	if ( 	pnlsr.getIsRoutingTableCalculating() == 0 )
+	{
+		pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
+		
+		if ( pnlsr.getLsdb().doesLsaExist(
+						pnlsr.getConfParameter().getRouterPrefix()+"/"+"2",2) )
+		{
+			if(pnlsr.getIsBuildAdjLsaSheduled() != 1)
+			{
+				clearRoutingTable();
+				clearDryRoutingTable(); // for dry run options
+				// calculate Link State routing
+				if( (pnlsr.getConfParameter().getIsHyperbolicCalc() == 0 ) 
+						|| (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 ) )
+				{
+					calculateLsRoutingTable(pnlsr);
+				}
+				//calculate hyperbolic routing
+				if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 1 )
+				{
+					calculateHypRoutingTable(pnlsr);
+				}
+				//calculate dry hyperbolic routing
+				if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 )
+				{
+					calculateHypDryRoutingTable(pnlsr);
+				}
+
+				//need to update NPT here
+			}
+			else
+			{
+				cout<<"Adjacency building is scheduled, so ";
+				cout<<"routing table can not be calculated :("<<endl;
+			}
+		}
+		else
+		{
+			cout<<"No Adj LSA of router itself,";
+			cout<<	" so Routint table can not be calculated :("<<endl;	
+			clearRoutingTable();
+		  clearDryRoutingTable(); // for dry run options
+		  // need to update NPT here
+		}
+
+		pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
+		pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
+	}
+	else
+	{
+		pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+									 ndn::bind(&RoutingTable::calculate,this,boost::ref(pnlsr)));
+		pnlsr.setIsRouteCalculationScheduled(1);
+	}
+}
+
+
+void 
+RoutingTable::calculateLsRoutingTable(nlsr& pnlsr)
+{
+	Map vMap;
+	vMap.createMapFromAdjLsdb(pnlsr);
+	int numOfRouter=vMap.getMapSize();
+
+	LinkStateRoutingTableCalculator lsrtc(numOfRouter);
+	lsrtc.allocateAdjMatrix();
+	lsrtc.makeAdjMatrix(pnlsr,vMap);
+	lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
+	lsrtc.freeAdjMatrix();
+	
+	
+}
+
+void 
+RoutingTable::calculateHypRoutingTable(nlsr& pnlsr)
+{
+	
+}
+
+void 
+RoutingTable::calculateHypDryRoutingTable(nlsr&pnlsr)
+{
+	
+}
+
+void 
+RoutingTable::clearRoutingTable()
+{
+	rTable.clear();
+}
+
+void 
+RoutingTable::clearDryRoutingTable()
+{
+	dryTable.clear();
+}
 
diff --git a/nlsr_rt.hpp b/nlsr_rt.hpp
index ac9ccfa..05beda4 100644
--- a/nlsr_rt.hpp
+++ b/nlsr_rt.hpp
@@ -6,6 +6,8 @@
 
 #include "nlsr_rte.hpp"
 
+class nlsr;
+
 using namespace std;
 
 class RoutingTable
@@ -14,13 +16,18 @@
 	RoutingTable()
 	{
 	}
-	void calculate()
-	{
-		cout<<"Routing Table Calculating......"<<endl;
-	}
+	void calculate(nlsr& pnlsr);
 
 private:
+	void calculateLsRoutingTable(nlsr& pnlsr);
+	void calculateHypRoutingTable(nlsr& pnlsr);
+	void calculateHypDryRoutingTable(nlsr&pnlsr);
+	
+	void clearRoutingTable();
+	void clearDryRoutingTable();
+	
 	std::list< RoutingTableEntry > rTable;
+	std::list< RoutingTableEntry > dryTable;
 };
 
 #endif
diff --git a/nlsr_rtc.cpp b/nlsr_rtc.cpp
new file mode 100644
index 0000000..fecc6bc
--- /dev/null
+++ b/nlsr_rtc.cpp
@@ -0,0 +1,69 @@
+#include <iostream>
+#include "nlsr_lsdb.hpp"
+#include "nlsr_rtc.hpp"
+#include "nlsr_map.hpp"
+#include "nlsr_lsa.hpp"
+#include "nlsr.hpp"
+
+using namespace std;
+
+void 
+RoutingTableCalculator::allocateAdjMatrix()
+{
+	adjMatrix = new double*[numOfRouter];
+	for(int i = 0; i < numOfRouter; ++i) 
+	{
+    adjMatrix[i] = new double[numOfRouter];
+	}
+}
+
+void
+RoutingTableCalculator::makeAdjMatrix(nlsr& pnlsr, Map pMap)
+{
+	std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb();
+	for( std::list<AdjLsa>::iterator it=adjLsdb.begin(); 
+	                                                 it!= adjLsdb.end() ; it++)
+	{
+		string linkStartRouter=(*it).getOrigRouter();
+		int row=pMap.getMappingNoByRouterName(linkStartRouter);
+		std::list<Adjacent> adl=(*it).getAdl().getAdjList();
+		for( std::list<Adjacent>::iterator itAdl=adl.begin(); 
+																								itAdl!= adl.end() ; itAdl++)
+		{
+			string linkEndRouter=(*itAdl).getAdjacentName();
+			int col=pMap.getMappingNoByRouterName(linkEndRouter);
+			double cost=(*itAdl).getLinkCost();
+			if ( (row >= 0 && row<numOfRouter) && (col >= 0 && col<numOfRouter) )
+			{
+				adjMatrix[row][col]=cost;
+			}
+		}
+		
+	}
+}
+
+void 
+RoutingTableCalculator::freeAdjMatrix()
+{
+	for(int i = 0; i < numOfRouter; ++i) 
+	{
+    	delete [] adjMatrix[i];
+	}
+	delete [] adjMatrix;
+}
+
+void
+LinkStateRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr)
+{
+}
+
+void
+HypRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr)
+{
+}
+
+void
+HypDryRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr)
+{
+}
+
diff --git a/nlsr_rtc.hpp b/nlsr_rtc.hpp
new file mode 100644
index 0000000..5b5cc3b
--- /dev/null
+++ b/nlsr_rtc.hpp
@@ -0,0 +1,72 @@
+#ifndef NLSR_RTC_HPP
+#define NLSR_RTC_HPP
+
+#include <list>
+#include <iostream>
+
+
+
+class Map;
+class RoutingTable;
+class nlsr;
+
+
+using namespace std;
+
+class RoutingTableCalculator
+{
+public:
+	RoutingTableCalculator()
+	{
+	}
+	RoutingTableCalculator(int rn)
+	{
+		numOfRouter=rn;
+	}
+
+	void allocateAdjMatrix();
+	void makeAdjMatrix(nlsr& pnlsr,Map pMap);
+	void freeAdjMatrix();
+
+protected:
+	double ** adjMatrix;
+	int numOfRouter;
+};
+
+class LinkStateRoutingTableCalculator: public RoutingTableCalculator
+{
+public:
+	LinkStateRoutingTableCalculator(int rn)
+	{
+		numOfRouter=rn;
+	}
+
+	void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
+
+};
+
+class HypRoutingTableCalculator: public RoutingTableCalculator
+{
+public:
+	HypRoutingTableCalculator(int rn)
+	{
+		numOfRouter=rn;
+	}
+
+	void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
+
+};
+
+class HypDryRoutingTableCalculator: public RoutingTableCalculator
+{
+	public:
+	HypDryRoutingTableCalculator(int rn)
+	{
+		numOfRouter=rn;
+	}
+
+	void calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr);
+
+};
+
+#endif
diff --git a/nlsr_rte.hpp b/nlsr_rte.hpp
index eeaf48c..6f64836 100644
--- a/nlsr_rte.hpp
+++ b/nlsr_rte.hpp
@@ -17,6 +17,10 @@
 		
 	}
 
+	~RoutingTableEntry()
+	{
+	}
+
 	RoutingTableEntry(string dest)
 		: nhl()
 	{