basic framework, waiting for Alex's comments
diff --git a/tools/NameServer.cpp b/tools/NameServer.cpp
new file mode 100644
index 0000000..41e3397
--- /dev/null
+++ b/tools/NameServer.cpp
@@ -0,0 +1,188 @@
+/*
+ *  NameServer.cpp
+ *
+ *  Created on: 18 Jul, 2014
+ *      Author: Xiaoke JIANG
+ *
+ */
+
+#include <boost/asio.hpp>
+#include <boost/noncopyable.hpp>
+
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+
+
+
+using namespace std;
+using namespace ndn;
+
+
+namespace ndn{
+class NameServer : boost::noncopyable
+{
+public:
+explicit
+NameServer(char *programName)
+: m_programName(programName)
+, m_hasError(false)
+, m_freshnessPeriod(time::milliseconds(1000))
+, m_face(m_ioService)
+{
+
+}//NameServer Construction
+
+
+void
+onInterest(const Name &name, const Interest &interest)
+{
+
+	cout<<"-> Interest: "<<name<<std::endl;
+
+}
+void
+onData(const ndn::Interest& interest, Data& data)
+{
+	Name dName = data.getName();
+	if (not m_name.isPrefixOf(dName) )
+	{
+		cout<<"!! ILLEGAL data: "<<dName<<", which does not starts with "<<m_name<<endl;
+		return;
+	}
+
+	cout<<"-> Data: "<<dName<<endl;
+
+	Name iName = interest.getName();
+	unsigned long seq = (unsigned long)iName.get(iName.size()-1).toNumber();
+
+
+	this->tryExpress();
+
+}
+void
+onTimeout(const ndn::Interest& interest)
+{
+	cout<<"!- Interest Timeout"<<interest.getName()<<endl;
+	Name iName = interest.getName();
+	unsigned long seq = (unsigned long)iName.get(iName.size()-1).toNumber();
+
+
+
+	this->tryExpress();
+}
+
+void
+onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
+{
+  std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
+  std::cerr << "REASON: " << reason << std::endl;
+  m_hasError = true;
+  this->stop();
+}
+
+void
+DoExpress()
+{
+	Name name = this->m_name;
+
+
+	Selectors selector;
+	selector.setMustBeFresh(true);
+
+	Interest interest = Interest(name, selector, -1, this->m_freshnessPeriod, 1);
+
+	m_face.expressInterest(interest, boost::bind(&NameServer::onData, this, _1, _2),
+			boost::bind(&NameServer::onTimeout, this, _1));
+
+
+	//m_face.expressInterest(interest, boost::bind(&MyPing::OnData, this, _1, _2),
+	//		boost::bind(&MyPing::OnTimeout, this, _1));
+}
+
+void
+tryExpress()
+{
+	this->DoExpress();
+}
+
+void
+singalHandler()
+{
+	cout<<"Fail to Register"<<endl;
+	this->stop();
+	exit(1);
+}
+
+void
+stop()
+{
+	cout<<"program "<<this->m_programName<<" stops"<<endl;
+	this->m_face.shutdown();
+	this->m_ioService.stop();
+}
+
+
+
+
+void
+run()
+{
+	std::cout << "\n=== NDNS Server for Zone " << m_prefix <<" starts===\n" << std::endl;
+
+	boost::asio::signal_set signalSet(m_ioService, SIGINT, SIGTERM);
+	signalSet.async_wait(bind(&NameServer::singalHandler, this));
+
+	m_name.set(m_prefix);
+
+	m_face.setInterestFilter(m_name,
+							 bind(&NameServer::onInterest,
+								  this, _1, _2),
+							 bind(&NameServer::onRegisterFailed,
+								  this, _1,_2));
+	try {
+	  m_face.processEvents();
+	}
+	catch (std::exception& e) {
+	  std::cerr << "ERROR: " << e.what() << std::endl;
+	  m_hasError = true;
+	  m_ioService.stop();
+	}
+
+}
+
+	bool hasError() const {
+		return m_hasError;
+	}
+
+
+public:
+	KeyChain m_keyChain;
+	bool m_hasError;
+
+	time::milliseconds m_freshnessPeriod;
+	char* m_programName;
+	char* m_prefix;
+	Name m_name;
+	boost::asio::io_service m_ioService;
+	Face m_face;
+
+};//clcass NameServer
+}//namespace ndn
+
+
+int main(int argc, char * argv[])
+{
+	NameServer server;
+	server.run();
+
+	cout<<"the server ends with hasError="<<server.hasError()<<endl;
+
+	if (server.hasError()){
+		return 0;
+	} else {
+		return 1;
+	}
+
+}
+
diff --git a/tools/Resolver.cpp b/tools/Resolver.cpp
new file mode 100644
index 0000000..a64a184
--- /dev/null
+++ b/tools/Resolver.cpp
@@ -0,0 +1,229 @@
+/*
+ * myping.cc
+ *
+ *  Created on: 21 Jun, 2014
+ *      Author: shock
+ */
+
+#include <boost/noncopyable.hpp>
+#include <boost/asio.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/selectors.hpp>
+
+#include <query.h>
+#include <rr.h>
+
+#include <unistd.h>
+#include <stdlib.h> //atoi
+
+
+
+#include <map>
+#include <vector>
+#include <sstream>
+
+//using std::cout;
+//using std::cin;
+//using std::cerr;
+//using std::endl;
+//using std::map;
+//using std::vector;
+//using std::exception;
+//using std::pair;
+//using std::string;
+
+using namespace std;
+
+namespace ndn{
+
+
+class Resolver : boost::noncopyable
+{
+
+	class RequestInfo
+	{
+	public:
+		RequestInfo(unsigned long seq)
+		: m_seq(seq)
+		{
+		}
+
+		void
+		SendInterest()
+		{
+			//m_sentT = time::system_clock::now();
+		}
+		void
+		GetData()
+		{
+			//this->m_receT = time::system_clock::now();
+		}
+
+		string
+		toString()
+		{
+			stringstream str;
+			str<<"m_seq="<<m_seq;
+			//s +="m_seq="+m_seq+" m_sentT="+" m_receT=";
+			return str.str();
+		}
+
+	public:
+		unsigned long m_seq;
+		time::milliseconds m_sentT;
+		time::milliseconds m_receT;
+	};
+
+public:
+Resolver(char *programName, char *scope, char *domain)
+: m_programName (programName)
+, m_authorityZone (scope)
+, m_rrLabel(domain)
+, m_interestLifetime (time::milliseconds(4000))
+, m_face (m_ioService)
+{
+	cout<<"Create "<<m_programName<<endl;
+}
+
+void
+onInterest(const Name &name, const Interest &interest)
+{
+
+	cout<<"-> Interest: "<<name<<std::endl;
+
+}
+void
+onData(const ndn::Interest& interest, Data& data)
+{
+	Response response(data);
+	response
+}
+void
+onTimeout(const ndn::Interest& interest)
+{
+	cout<<"!- Interest Timeout"<<interest.getName()<<endl;
+	Name iName = interest.getName();
+	unsigned long seq = (unsigned long)iName.get(iName.size()-1).toNumber();
+
+	this->tryExpress();
+
+
+}
+
+
+void
+doExpress(Interest interest)
+{
+	m_face.expressInterest(interest, boost::bind(&onData, this, _1, _2),
+			boost::bind(&onTimeout, this, _1));
+}
+
+void
+tryExpress()
+{
+
+	this->doExpress();
+
+}
+
+
+void
+singalHandler()
+{
+	this->stop();
+}
+
+void
+stop()
+{
+	cout<<"resolve stops"<<endl;
+	this->m_face.shutdown();
+	this->m_ioService.stop();
+}
+
+void
+run()
+{
+
+	boost::asio::signal_set signalSet(m_ioService, SIGINT, SIGTERM);
+	signalSet.async_wait(boost::bind(&singalHandler, this));
+
+	this->m_query.setAuthorityZone(this->m_authorityZone);
+	this->m_query.setRrLabel(this->m_rrLabel);
+	this->m_query.setRrType(RRType::NS);
+
+	Interest interest = m_query.toWire();
+	this->doExpress(interest);
+
+	try{
+		m_face.processEvents();
+	} catch (exception &e){
+		cerr<<"Error: "<<e.what()<<endl;
+		this->stop();
+	}
+
+}
+
+
+void
+resolve()
+{
+
+}
+
+
+private:
+	char *m_programName;
+	Name m_authorityZone;
+	Name m_rrLabel;
+	//Name m_name;
+	time::milliseconds m_interestLifetime;
+
+
+	Query m_query;
+
+	boost::asio::io_service m_ioService;
+	//This line MUST be before m_face declaration, or leads to segment error: 11
+
+	Face m_face;
+
+
+};//class MyPing
+
+}//namespace
+
+
+void
+usage()
+{
+	cout<<"-h to show the hint"<<endl;
+}
+
+int
+main(int argc, char *argv[])
+{
+
+	if (argc < 2)
+	{
+		cout<<"You must have at least one parameter: resolve domain [scope]"<<endl;
+		return 0;
+	}
+
+
+	char * domain = argv[1];
+	char * scope;
+	if (argc == 3)
+		scope = argv[2];
+	else
+		scope = "/";
+
+
+	ndn::Resolver resolver(argv[0], scope, domain);
+	resolver.run();
+
+	return 0;
+}//main
+
+