Index: trash/pingpong/Makefile.am
===================================================================
--- trash/pingpong/Makefile.am	(revision 2409)
+++ trash/pingpong/Makefile.am	(revision 2409)
@@ -0,0 +1,60 @@
+# sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+if OMNET
+lib_LTLIBRARIES = libpingpong.la
+else
+bin_PROGRAMS 	= pingpong
+endif
+
+# compiler flags ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+AM_CPPFLAGS     = -DLINUX -D_LINUX -I../../source -D_REENTRANT
+AM_CPPFLAGS    += $(BOOST_CPPFLAGS)
+
+if DEBUG
+AM_CPPFLAGS    += -ggdb -DDEBUG -D_DEBUG -O0
+endif
+
+if PROFILING
+AM_CPPFLAGS    += -pg
+endif
+
+if OMNET
+AM_CPPFLAGS    += -fPIC -DUNDERLAY_OMNET
+endif
+
+# linker flags ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+AM_LDFLAGS      = -L../../source/ariba -lariba
+
+if PROFILING
+AM_LDFLAGS     += -pg
+endif
+
+if OMNET
+AM_LDFLAGS     += -shared -rdynamic
+endif
+
+# sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+if OMNET
+
+libpingpong_la_SOURCES = \
+  PingPong.cpp \
+  PingPong.h \
+  PingPongMessage.cpp \
+  PingPongMessage.h
+
+else
+
+#needed to fix autotools bug
+pingpong_CPPFLAGS = $(AM_CPPFLAGS)
+
+pingpong_SOURCES = \
+  PingPong.cpp \
+  PingPong.h \
+  PingPongMessage.cpp \
+  PingPongMessage.h \
+  main.cpp
+
+endif
Index: trash/pingpong/PingPong.cpp
===================================================================
--- trash/pingpong/PingPong.cpp	(revision 2409)
+++ trash/pingpong/PingPong.cpp	(revision 2409)
@@ -0,0 +1,173 @@
+#include "PingPong.h"
+
+#include "ariba/interface/UnderlayAbstraction.h"
+
+namespace ariba {
+namespace appplication {
+namespace pingpong {
+
+use_logging_cpp(PingPong);
+ServiceID PingPong::PINGPONG_ID = ServiceID(111);
+
+PingPong::PingPong() : pingid( 0 ) {
+}
+
+PingPong::~PingPong(){
+}
+
+void PingPong::setMode(bool startingNode){
+	startping = startingNode;
+}
+
+void PingPong::startup(){
+	abstraction = new UnderlayAbstraction();
+
+	logging_info( "starting up PingPong service ... " );
+
+	SpoVNetID spovnetid (Identifier(5000));
+
+	setMode( !Configuration::instance().read<bool>("GENERAL_Initiator") );
+
+	NodeID nodeid = (Configuration::instance().exists("BASE_nodeid") ?
+			NodeID(Identifier(Configuration::instance().read<unsigned long>("BASE_nodeid"))) :
+			NodeID::UNSPECIFIED);
+
+	IPv4Locator* locallocator = (Configuration::instance().exists("BASE_localLocator") ?
+					&(IPv4Locator::fromString(Configuration::instance().read<string>("BASE_localLocator"))) :
+					NULL);
+
+	uint16_t localport = Configuration::instance().exists("BASE_port") ?
+				Configuration::instance().read<uint16_t>("BASE_port") :
+				ARIBA_DEFAULT_PORT;
+
+	if( !startping ){
+
+		context = abstraction->createSpoVNet(
+			spovnetid, nodeid, locallocator, localport );
+
+	} else {
+
+		if( !Configuration::instance().exists("BASE_bootstrapIP")){
+			logging_fatal( "no bootstrap address found" );
+			return;
+		}
+
+		logging_info( "using bootstrap point " <<
+			Configuration::instance().read<string>("BASE_bootstrapIP") );
+
+		EndpointDescriptor bootstrap(
+		new IPv4Locator(IPv4Locator::fromString(
+			Configuration::instance().read<string>("BASE_bootstrapIP"))));
+
+		context = abstraction->joinSpoVNet(
+			spovnetid, bootstrap, nodeid, locallocator, localport );
+
+	}
+
+	overlay = &context->getOverlay();
+	overlay->bind( this, PingPong::PINGPONG_ID );
+
+	logging_info( "PingPong started up" );
+
+	// trigger the creation of the pathload measurement module
+	//PathloadMeasurement::instance( overlay );
+}
+
+void PingPong::shutdown(){
+	logging_info( "shutting down PingPong service ..." );
+
+	overlay->unbind( this, PingPong::PINGPONG_ID );
+	Timer::stop();
+
+	if( !startping ) abstraction->destroySpoVNet( context );
+	else             abstraction->leaveSpoVNet( context );
+
+	delete abstraction;
+
+	logging_info( "PingPong service shut down" );
+}
+
+bool PingPong::receiveMessage(const Message* message, const LinkID& link, const NodeID& node){
+
+	PingPongMessage* incoming = ((Message*)message)->decapsulate<PingPongMessage>();
+
+	logging_info( "received ping message on link " << link.toString() <<
+				 " from node with id " << (int)incoming->getid());
+
+// 	if( ((int)incoming->getid() % 5) == 0 )
+// 		PathloadMeasurement::instance().measure( node, this );
+}
+
+void PingPong::eventFunction(){
+
+	logging_info( "pinging our remote nodes" );
+
+	RemoteNodes::iterator i = remoteNodes.begin();
+	RemoteNodes::iterator iend = remoteNodes.end();
+
+	pingid++;
+
+	for( ; i != iend; i++ ){
+		logging_info( "     -> pinging " << i->first );
+
+		PingPongMessage pingmsg( pingid );
+		overlay->sendMessage( &pingmsg, i->second );
+	}
+}
+
+void PingPong::onMeasurement(NodeID node, double mbps){
+	logging_info( "pingpong received measurement for node " << node.toString() << " with result " << mbps );
+}
+
+void PingPong::onJoinSuccess( const SpoVNetID& spovnetid ){
+}
+
+void PingPong::onOverlayCreate( const SpoVNetID& id ){
+}
+
+void PingPong::onOverlayDestroy( const SpoVNetID& id ){
+}
+
+bool PingPong::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){
+	return true;
+}
+
+void PingPong::onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid ){
+
+	if( !startping ){
+
+		logging_info( "establishing link to node " << nodeid.toString() );
+		const LinkID link = overlay->establishLink( nodeid, PingPong::PINGPONG_ID );
+
+		logging_info( "adding node to registered nodes in pingpong: " << nodeid.toString() );
+		remoteNodes.insert( make_pair(nodeid,link) );
+
+		Timer::setInterval( 2000 );
+		Timer::start();
+	}
+}
+
+void PingPong::onNodeLeave( const NodeID& id, const SpoVNetID& spovnetid ){
+	RemoteNodes::iterator i = remoteNodes.find( id );
+	if( i != remoteNodes.end() ) remoteNodes.erase( i );
+}
+
+void PingPong::onJoinFail( const SpoVNetID& spovnetid ){
+}
+
+void PingPong::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){
+}
+
+void PingPong::onLinkDown( const LinkID& link, const NodeID& local, const NodeID& remote ){
+}
+
+void PingPong::onLinkChanged( const LinkID& link, const NodeID& local, const NodeID& remote ){
+}
+
+void PingPong::onLinkFail(const LinkID& id, const NodeID& local, const NodeID& remote){
+}
+
+void PingPong::onLinkQoSChanged(const LinkID& id, const NodeID& local, const NodeID& remote , const QoSParameterSet& qos){
+}
+
+}}} // namespace ariba, appplication, pingpong
Index: trash/pingpong/PingPong.h
===================================================================
--- trash/pingpong/PingPong.h	(revision 2409)
+++ trash/pingpong/PingPong.h	(revision 2409)
@@ -0,0 +1,100 @@
+#ifndef __PINGPONG_H_
+#define __PINGPONG_H_
+
+#include <map>
+#include <iostream>
+#include <vector>
+#include "ariba/utility/types.h"
+#include "ariba/utility/system/Timer.h"
+#include "ariba/utility/misc/Helper.h"
+#include "ariba/utility/messages.h"
+#include "ariba/utility/measurement/PathloadMeasurement.h"
+#include "ariba/utility/configuration/Configuration.h"
+#include "ariba/utility/logging/Logging.h"
+#include "ariba/utility/measurement/PathloadMeasurement.h"
+#include "ariba/utility/system/StartupInterface.h"
+#include "ariba/interface/UnderlayAbstraction.h"
+#include "ariba/interface/AribaContext.h"
+#include "ariba/interface/ServiceInterface.h"
+#include "PingPongMessage.h"
+
+using std::vector;
+using std::map;
+using std::cout;
+using ariba::application::pingpong::PingPongMessage;
+using ariba::interface::ServiceInterface;
+using ariba::interface::UnderlayAbstraction;
+using ariba::interface::AribaContext;
+using ariba::utility::NodeID;
+using ariba::utility::LinkID;
+using ariba::utility::StartupInterface;
+using ariba::utility::Timer;
+using ariba::utility::Configuration;
+using ariba::utility::NodeID;
+using ariba::utility::Identifier;
+using ariba::utility::ServiceID;
+using ariba::utility::PathloadMeasurement;
+using ariba::utility::PathloadMeasurementListener;
+
+namespace ariba {
+namespace appplication {
+namespace pingpong {
+
+/**
+/* The PingPong main class
+/* This class implements an example service for demonstration purposes
+/* The pingpong class sends and receives messages between two SpoVNet
+/* instances
+**/
+class PingPong :
+	public ServiceInterface,
+	public StartupInterface,
+	public Timer,
+	public PathloadMeasurementListener {
+
+	use_logging_h(PingPong);
+
+public:
+	PingPong();
+	virtual ~PingPong();
+	void setMode( bool startingNode );
+
+
+	virtual void onOverlayCreate( const SpoVNetID& id );
+	virtual void onOverlayDestroy( const SpoVNetID& id );
+	virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
+	virtual void onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid );
+	virtual void onNodeLeave( const NodeID& id, const SpoVNetID& spovnetid );
+	virtual void onJoinSuccess( const SpoVNetID& spovnetid );
+	virtual void onJoinFail( const SpoVNetID& spovnetid );
+	virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
+	virtual void onLinkDown( const LinkID& link, const NodeID& local, const NodeID& remote );
+	virtual void onLinkChanged( const LinkID& link, const NodeID& local, const NodeID& remote );
+	virtual void onLinkFail(const LinkID& id, const NodeID& local, const NodeID& remote);
+	virtual void onLinkQoSChanged(const LinkID& id, const NodeID& local, const NodeID& remote , const QoSParameterSet& qos);
+
+	virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& node );
+
+protected:
+	virtual void startup();
+	virtual void shutdown();
+
+	virtual void eventFunction(); // timer event function
+	virtual void onMeasurement(NodeID node, double mbps); // measurement event function
+
+private:
+	bool startping;
+	UnderlayAbstraction* abstraction;
+	AribaContext* context;
+	BaseOverlay* overlay;
+	static ServiceID PINGPONG_ID;
+	unsigned long pingid;
+	typedef map<NodeID, LinkID> RemoteNodes;
+	RemoteNodes remoteNodes;
+};
+
+ARIBA_SIMULATION_SERVICE(PingPong);
+
+}}} // namespace ariba, appplication, pingpong
+
+#endif // __PINGPONG_H_
Index: trash/pingpong/PingPongMessage.cpp
===================================================================
--- trash/pingpong/PingPongMessage.cpp	(revision 2409)
+++ trash/pingpong/PingPongMessage.cpp	(revision 2409)
@@ -0,0 +1,26 @@
+#include "PingPongMessage.h"
+
+namespace ariba {
+namespace application {
+namespace pingpong {
+
+vsznDefault(PingPongMessage);
+
+PingPongMessage::PingPongMessage() : id(0) {
+}
+
+PingPongMessage::PingPongMessage(uint8_t _id) : id(_id) {
+}
+
+PingPongMessage::~PingPongMessage(){
+}
+
+string PingPongMessage::info(){
+	return "ping pong message id " + ariba::utility::Helper::ultos(id);
+}
+
+uint8_t PingPongMessage::getid(){
+	return id;
+}
+
+}}} // namespace ariba, appplication, pingpong
Index: trash/pingpong/PingPongMessage.h
===================================================================
--- trash/pingpong/PingPongMessage.h	(revision 2409)
+++ trash/pingpong/PingPongMessage.h	(revision 2409)
@@ -0,0 +1,38 @@
+#ifndef PINGPONGMESSAGES_H_
+#define PINGPONGMESSAGES_H_
+
+#include <string>
+#include "ariba/utility/messages.h"
+#include "ariba/utility/serialization.h"
+#include "ariba/utility/misc/Helper.h"
+
+using std::string;
+using ariba::utility::Message;
+
+namespace ariba {
+namespace application {
+namespace pingpong {
+
+using_serialization;
+
+class PingPongMessage : public Message {
+	VSERIALIZEABLE;
+public:
+	PingPongMessage();
+	PingPongMessage(uint8_t _id);
+	virtual ~PingPongMessage();
+	
+	string info();
+	uint8_t getid();
+
+private:
+	uint8_t id;
+};
+
+}}} // namespace ariba, appplication , pingpong
+
+sznBeginDefault( ariba::application ::pingpong::PingPongMessage, X ) {
+	X && id;
+} sznEnd();
+
+#endif /* PINGPONGMESSAGES_H_ */
Index: trash/pingpong/main.cpp
===================================================================
--- trash/pingpong/main.cpp	(revision 2409)
+++ trash/pingpong/main.cpp	(revision 2409)
@@ -0,0 +1,25 @@
+#include <string>
+#include "ariba/utility/system/StartupWrapper.h"
+#include "PingPong.h"
+
+using std::string;
+using ariba::utility::StartupWrapper;
+using ariba::appplication::pingpong::PingPong;
+
+int main( int argc, char** argv ) {
+
+	string config = "../etc/settings.cnf";
+	if (argc >= 2) config = argv[1];
+
+	StartupWrapper::initConfig( config );
+	StartupWrapper::initSystem();
+
+	// this will do the main functionality and block
+	PingPong ping;
+	StartupWrapper::startup(&ping, true);
+
+	// this will run blocking until <enter> is hit
+
+	StartupWrapper::shutdown();
+	return 0;
+}
