Index: sample/CMakeLists.txt
===================================================================
--- sample/CMakeLists.txt	(revision 12775)
+++ 	(revision )
@@ -1,43 +1,0 @@
-# [License]
-# The Ariba-Underlay Copyright
-#
-# Copyright (c) 2008-2012, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
-#
-# Institute of Telematics
-# UniversitÃ€t Karlsruhe (TH)
-# Zirkel 2, 76128 Karlsruhe
-# Germany
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and documentation
-# are those of the authors and should not be interpreted as representing
-# official policies, either expressed or implied, of the Institute of
-# Telematics.
-# [License]
-
-add_subdirectory(pingpong)
-
-## NOTE: "AribaTunnel" is not part of the ariba build process. 
-#        It has to be compiled separately!
-
Index: sample/Makefile.am
===================================================================
--- sample/Makefile.am	(revision 2378)
+++ sample/Makefile.am	(revision 2378)
@@ -0,0 +1,2 @@
+#SUBDIRS = pingpong
+SUBDIRS = tidy_pingpong
Index: sample/pingpong/CMakeLists.txt
===================================================================
--- sample/pingpong/CMakeLists.txt	(revision 12775)
+++ 	(revision )
@@ -1,78 +1,0 @@
-# [License]
-# The Ariba-Underlay Copyright
-#
-# Copyright (c) 2008-2012, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
-#
-# Institute of Telematics
-# UniversitÃ€t Karlsruhe (TH)
-# Zirkel 2, 76128 Karlsruhe
-# Germany
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and documentation
-# are those of the authors and should not be interpreted as representing
-# official policies, either expressed or implied, of the Institute of
-# Telematics.
-# [License]
-
-# Find Boost
-find_package(BoostAdditionalVersions QUIET)
-if(NOT DEFINED BoostAdditionalVersions_FOUND)
-    message(WARNING "Could not find FindBoostAdditionalVersions.cmake. "
-        "This might cause the Boost detection to fail")
-endif()
-find_package(Boost 1.42.0 REQUIRED COMPONENTS system)
-mark_as_advanced(Boost_DIR)
-
-include_directories(${Boost_INCLUDE_DIRS})
-
-
-# Include ariba header files
-include_directories("${ariba_SOURCE_DIR}/source/" "${ariba_BINARY_DIR}/source/")
-add_executable(pingpong
-    PingPongMessage.cpp
-    PingPongMessage.h
-    PingPong.cpp
-    PingPong.h
-    main.cpp
-    )
-
-if(${BUILD_STATIC_BINS})
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
-    string(REPLACE "-rdynamic" "" 
-        CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS
-        "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}"
-        )
-    # Compile system libraries statically
-    set_target_properties(pingpong PROPERTIES
-            LINK_SEARCH_END_STATIC ON)
-endif(${BUILD_STATIC_BINS})
-
-target_link_libraries(pingpong ariba ${Boost_LIBRARIES})
-
-# Installation stuff
-install(TARGETS pingpong
-    DESTINATION lib/ariba
-    COMPONENT Documentation
-    )
Index: sample/pingpong/Makefile.am
===================================================================
--- sample/pingpong/Makefile.am	(revision 2378)
+++ sample/pingpong/Makefile.am	(revision 2378)
@@ -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: sample/pingpong/PingPong.cpp
===================================================================
--- sample/pingpong/PingPong.cpp	(revision 12775)
+++ sample/pingpong/PingPong.cpp	(revision 2378)
@@ -1,221 +1,173 @@
 #include "PingPong.h"
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/json_parser.hpp>
 
-using namespace ariba;
+#include "ariba/interface/UnderlayAbstraction.h"
 
 namespace ariba {
-namespace application {
+namespace appplication {
 namespace pingpong {
 
-// logging
-use_logging_cpp( PingPong );
+use_logging_cpp(PingPong);
+ServiceID PingPong::PINGPONG_ID = ServiceID(111);
 
-// the service that the pingpong wants to use
-ServiceID PingPong::PINGPONG_SERVICEID = ServiceID( 111 );
-
-// construction
-PingPong::PingPong( string config)  :
-        node(),
-        counter( 0 ),
-        pingId( 0 ),
-        config_file(config)
-{
-	Timer::setInterval( 5000 );
+PingPong::PingPong() : pingid( 0 ) {
 }
 
-// destruction
-PingPong::~PingPong() {
+PingPong::~PingPong(){
 }
 
-// implementation of the startup interface
-void PingPong::startup()
-{
-    using boost::property_tree::ptree;
-    using boost::property_tree::json_parser::read_json;
-    
-	// set up logging
-	logging_rootlevel_debug();
-	logging_classlevel_debug(PingPong);
-
-	logging_info( "[PINGPONG]\t starting up PingPong service ... " );
-
-    // read config
-    ptree config;
-    try
-    {
-        read_json(config_file, config);
-    }
-    catch ( exception& e )
-    {
-        logging_warn("ERROR: Failed to read config file Â»" << config_file << "Â«: ");
-        logging_warn(e.what());
-        logging_warn("---> Using fallback config.");
-        
-        config.put("ariba.spovnet_name", "pingpong");
-    }
-    
-    // use node name also in the application
-    name = config.get("ariba.node_name", "NO_NAME");
-    
-	// bind communication and node listener
-	node.bind( this );                              /*NodeListener*/
-	node.bind( this, PingPong::PINGPONG_SERVICEID); /*CommunicationListener*/
-
-    // connecting
-    logging_debug( "connecting ... " );
-
-	node.connect(config.get_child("ariba"));
-
-	// ping pong started up...
-	logging_info( "[PINGPONG]\t pingpong starting up with"
-			<< " [spovnetid " << node.getSpoVNetId().toString() << "]"
-			<< " and [nodeid " << node.getNodeId().toString() << "]" );
+void PingPong::setMode(bool startingNode){
+	startping = startingNode;
 }
 
-// implementation of the startup interface
-void PingPong::shutdown() {
+void PingPong::startup(){
+	abstraction = new UnderlayAbstraction();
 
-	logging_info( "[PINGPONG]\t pingpong service starting shutdown sequence ..." );
+	logging_info( "starting up PingPong service ... " );
 
-	// stop timer
+	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();
 
-	// leave spovnet
-	node.leave();
+	if( !startping ) abstraction->destroySpoVNet( context );
+	else             abstraction->leaveSpoVNet( context );
 
-	// unbind communication and node listener
-	node.unbind( this );                               /*NodeListener*/
-	node.unbind( this, PingPong::PINGPONG_SERVICEID ); /*CommunicationListener*/
+	delete abstraction;
 
-	// now we are completely shut down
-	logging_info( "pingpong service shut down" );
+	logging_info( "PingPong service shut down" );
 }
 
-// timer event
-void PingPong::eventFunction()
-{
-	// We ping all nodes that are known in the overlay structure
-	// this can be all nodes (OneHop) overlay or just some neighbors
-	// in case of a Chord or Kademlia structure
-	// NOTE: Currently ariba only supports the Chord overlay.
+bool PingPong::receiveMessage(const Message* message, const LinkID& link, const NodeID& node){
 
-	// In this sample we use auto-links: we just send out our message
-	// to the node and the link is established automatically. for more
-	// control we would use the node->establishLink function to create
-	// a link and start using the link in the CommunicationListener::onLinkUp
-	// function that is implemented further down in PingPong::onLinkUp
-	
-	// NOTE: This example still uses the old deprecated ariba::message messages 
-	//   with the ariba built-in serialization. 
-	// For future applications please use the new reboost::message_t messages. 
-	//   Data is stored in high efficient zero-copy buffers of type 
-	//   reboost::shared_buffer_t. These buffers hold plain data, so you have to 
-	//   serialize the data "on your own".
-	// We recommend third-party serialization libraries like:
-	//   - Protocol Buffers (http://en.wikipedia.org/wiki/Protocol_Buffers)
-	//   - MessagePack      (http://en.wikipedia.org/wiki/MessagePack)
+	PingPongMessage* incoming = ((Message*)message)->decapsulate<PingPongMessage>();
 
-	
-	// don't do anything if we have no neighbors
-	if ( node.getNeighborNodes().size() == 0)
-    {
-        logging_info( "[PINGPONG]\t +++ no neighbors +++" );
-        return;
-    }
-    
-    
-	pingId++;
-    logging_info( "\n|||||||||| >>>>>>>>>>\n"
-	        << "[PINGPONG]\t PINGING overlay neighbors with ping id " << pingId );
-	PingPongMessage pingmsg( pingId, name );
-	
-	//-----------------------------------------------------------------------
-	// Option 1: get all neighboring nodes and send the message to each
-	//-----------------------------------------------------------------------
-	counter++;
-	if (counter<0 || counter>4) {
-		counter = 0;
-		string s;
-		for (int i=0; i<names.size();i++) {
-			if (i!=0) s+= ", ";
-			s = s+names[i];
-		}
-		logging_info("[PINGPONG]\t ----> I am " << name << " and I know " << s);
-		names.clear();
-	}
+	logging_info( "received ping message on link " << link.toString() <<
+				 " from node with id " << (int)incoming->getid());
 
-	vector<NodeID> nodes = node.getNeighborNodes();
-	BOOST_FOREACH( NodeID nid, nodes ){
-		logging_info( "[PINGPONG]\t sending ping message to " << nid.toString() );
-		node.sendMessage( pingmsg, nid, PingPong::PINGPONG_SERVICEID );
-	}
-
-	//-----------------------------------------------------------------------
-	// Option 2: send a "broadcast message" that actually does the same thing
-	//           internally, gets all neighboring nodes and sends the message
-	//-----------------------------------------------------------------------
-	// node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_SERVICEID );
+// 	if( ((int)incoming->getid() % 5) == 0 )
+// 		PathloadMeasurement::instance().measure( node, this );
 }
 
-void PingPong::onJoinCompleted( const SpoVNetID& vid ) {
-	logging_info( "pingpong node join completed, spovnetid=" << vid.toString() );
+void PingPong::eventFunction(){
 
-	// start the timer to ping every second
-	Timer::start();
+	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::onJoinFailed( const SpoVNetID& vid ) {
-	logging_error("pingpong node join failed, spovnetid=" << vid.toString() );
+void PingPong::onMeasurement(NodeID node, double mbps){
+	logging_info( "pingpong received measurement for node " << node.toString() << " with result " << mbps );
 }
 
-void PingPong::onLeaveCompleted( const SpoVNetID& vid ){
-	logging_info("pingpong node leave completed, spovnetid=" << vid.toString() );
+void PingPong::onJoinSuccess( const SpoVNetID& spovnetid ){
 }
 
-void PingPong::onLeaveFailed( const SpoVNetID& vid ){
-	logging_error("pingpong node leave failed, spovnetid=" << vid.toString() );
+void PingPong::onOverlayCreate( const SpoVNetID& id ){
 }
 
-void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) {
-	PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> ();
-	bool found=false;
-	for (int i=0;i<names.size(); i++) if (names[i]==pingmsg->getName()) found=true;
-	if (!found) names.push_back(pingmsg->getName());
-	logging_info( "\n<<<<<<<<<< ||||||||||\n"
-	        << "[PINGPONG]\t RECEIVED ping message on link "
-	        << lnk.toString()
-	        << " " << (node.isLinkDirect(lnk) ? "[DIRECT-LINK]" : "[INDIRECT-LINK]")
-	        << " HopCount: " << node.getHopCount(lnk)
-			<< " from node " << remote.toString()
-			<< " (" << pingmsg->getName() << ")"
-			<< ": " << pingmsg->info() );
-	delete pingmsg;
+void PingPong::onOverlayDestroy( const SpoVNetID& id ){
 }
 
-void PingPong::onLinkUp(const LinkID& lnk, const NodeID& remote){
-	logging_info( "received link-up event for link " << lnk.toString()
-			<< " and node " << remote.toString() );
-}
-
-void PingPong::onLinkDown(const LinkID& lnk, const NodeID& remote){
-	logging_info( "received link-down event for link " << lnk.toString()
-			<< " and node " << remote.toString() );
-}
-
-void PingPong::onLinkChanged(const LinkID& lnk, const NodeID& remote){
-	logging_info( "link-changed event for link " << lnk.toString()
-			<< " and node " << remote.toString() );
-}
-
-bool PingPong::onLinkRequest(const NodeID& remote) {
-	logging_info( "node " << remote.toString() << " wants to build up a link with us ... allowing" );
+bool PingPong::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){
 	return true;
 }
 
-void PingPong::onLinkFail(const LinkID& lnk, const NodeID& remote){
-	logging_info( "received link-failed event for link " << lnk.toString()
-			<< " and node " << remote.toString() );
+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();
+	}
 }
 
-}}} // namespace ariba, application, pingpong
+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: sample/pingpong/PingPong.h
===================================================================
--- sample/pingpong/PingPong.h	(revision 12775)
+++ sample/pingpong/PingPong.h	(revision 2378)
@@ -2,77 +2,99 @@
 #define __PINGPONG_H_
 
-#include "ariba/ariba.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"
-#include "ariba/utility/system/StartupInterface.h"
-#include "ariba/utility/system/Timer.h"
 
-#include <vector>
-
-using namespace ariba;
+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 application {
+namespace appplication {
 namespace pingpong {
 
-using namespace std;
-
 /**
- * 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 NodeListener,
-	public CommunicationListener,
+/* 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 Timer,
+	public PathloadMeasurementListener {
 
 	use_logging_h(PingPong);
 
 public:
-	PingPong( string config );
+	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:
-	// communication listener interface
-	virtual bool onLinkRequest(const NodeID& remote);
-	virtual void onMessage(const DataMessage& msg, const NodeID& remote,
-		const LinkID& lnk = LinkID::UNSPECIFIED);
-	virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
-	virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
-	virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
-	virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
-
-	// node listener interface
-	virtual void onJoinCompleted(const SpoVNetID& vid);
-	virtual void onJoinFailed(const SpoVNetID& vid);
-	virtual void onLeaveCompleted(const SpoVNetID& vid);
-	virtual void onLeaveFailed(const SpoVNetID& vid);
-
-	// startup wrapper interface
 	virtual void startup();
 	virtual void shutdown();
 
-	// timer events
-	virtual void eventFunction();
+	virtual void eventFunction(); // timer event function
+	virtual void onMeasurement(NodeID node, double mbps); // measurement event function
 
 private:
-	Node node;
-	string name;
-	int counter;
-	vector<string> names;
-
-	// the ping pong service id
-	static ServiceID PINGPONG_SERVICEID;
-
-	// the current ping id
-	unsigned long pingId;
-
-	string config_file;
+	bool startping;
+	UnderlayAbstraction* abstraction;
+	AribaContext* context;
+	BaseOverlay* overlay;
+	static ServiceID PINGPONG_ID;
+	unsigned long pingid;
+	typedef map<NodeID, LinkID> RemoteNodes;
+	RemoteNodes remoteNodes;
 };
 
-}}} // namespace ariba, application, pingpong
+ARIBA_SIMULATION_SERVICE(PingPong);
+
+}}} // namespace ariba, appplication, pingpong
 
 #endif // __PINGPONG_H_
Index: sample/pingpong/PingPongMessage.cpp
===================================================================
--- sample/pingpong/PingPongMessage.cpp	(revision 12775)
+++ sample/pingpong/PingPongMessage.cpp	(revision 2378)
@@ -1,4 +1,3 @@
 #include "PingPongMessage.h"
-#include <sstream>
 
 namespace ariba {
@@ -11,5 +10,5 @@
 }
 
-PingPongMessage::PingPongMessage(uint8_t _id, string name) : id(_id),name(name) {
+PingPongMessage::PingPongMessage(uint8_t _id) : id(_id) {
 }
 
@@ -17,9 +16,6 @@
 }
 
-string PingPongMessage::info()
-{
-    ostringstream out;
-    out << "ping pong message id " << (int) id;
-	return out.str();
+string PingPongMessage::info(){
+	return "ping pong message id " + ariba::utility::Helper::ultos(id);
 }
 
Index: sample/pingpong/PingPongMessage.h
===================================================================
--- sample/pingpong/PingPongMessage.h	(revision 12775)
+++ sample/pingpong/PingPongMessage.h	(revision 2378)
@@ -3,8 +3,10 @@
 
 #include <string>
-#include "ariba/ariba.h"
+#include "ariba/utility/messages.h"
+#include "ariba/utility/serialization.h"
+#include "ariba/utility/misc/Helper.h"
 
-using namespace ariba;
 using std::string;
+using ariba::utility::Message;
 
 namespace ariba {
@@ -18,22 +20,18 @@
 public:
 	PingPongMessage();
-	PingPongMessage( uint8_t _id, string name = string("<ping>") );
+	PingPongMessage(uint8_t _id);
 	virtual ~PingPongMessage();
-
+	
 	string info();
 	uint8_t getid();
 
-	inline string getName() const {
-		return name;
-	}
 private:
 	uint8_t id;
-	string name;
 };
 
 }}} // namespace ariba, appplication , pingpong
 
-sznBeginDefault( ariba::application::pingpong::PingPongMessage, X ) {
-	X && id && T(name);
+sznBeginDefault( ariba::application ::pingpong::PingPongMessage, X ) {
+	X && id;
 } sznEnd();
 
Index: sample/pingpong/main.cpp
===================================================================
--- sample/pingpong/main.cpp	(revision 12775)
+++ sample/pingpong/main.cpp	(revision 2378)
@@ -5,23 +5,21 @@
 using std::string;
 using ariba::utility::StartupWrapper;
-using ariba::application::pingpong::PingPong;
+using ariba::appplication::pingpong::PingPong;
 
 int main( int argc, char** argv ) {
 
-	// get config file
-	string config;
+	string config = "../etc/settings.cnf";
 	if (argc >= 2) config = argv[1];
 
-	StartupWrapper::startSystem();
+	StartupWrapper::initConfig( config );
+	StartupWrapper::initSystem();
 
 	// this will do the main functionality and block
-	PingPong ping(config);
-	StartupWrapper::startup(&ping);
+	PingPong ping;
+	StartupWrapper::startup(&ping, true);
 
-	// --> we will run blocking until <enter> is hit
+	// this will run blocking until <enter> is hit
 
-	StartupWrapper::shutdown(&ping);
-	StartupWrapper::stopSystem();
-
+	StartupWrapper::shutdown();
 	return 0;
 }
Index: sample/tidy_pingpong/Makefile.am
===================================================================
--- sample/tidy_pingpong/Makefile.am	(revision 2378)
+++ sample/tidy_pingpong/Makefile.am	(revision 2378)
@@ -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 = \
+  TidyPingPong.cpp \
+  TidyPingPong.h \
+  TidyPingPongMessage.cpp \
+  TidyPingPongMessage.h
+
+else
+
+#needed to fix autotools bug
+pingpong_CPPFLAGS = $(AM_CPPFLAGS)
+
+pingpong_SOURCES = \
+  TidyPingPongMessage.cpp \
+  TidyPingPongMessage.h \
+  TidyPingPong.cpp \
+  TidyPingPong.h \
+  main.cpp
+
+endif
Index: sample/tidy_pingpong/TidyPingPong.cpp
===================================================================
--- sample/tidy_pingpong/TidyPingPong.cpp	(revision 2378)
+++ sample/tidy_pingpong/TidyPingPong.cpp	(revision 2378)
@@ -0,0 +1,138 @@
+
+#include "TidyPingPong.h"
+#include "ariba/utility/configuration/Configuration.h"
+
+using ariba::utility::Configuration;
+using namespace ariba;
+
+namespace ariba {
+namespace application {
+namespace pingpong {
+
+// logging
+use_logging_cpp( PingPong);
+
+// the service id of the ping pong service
+ServiceID PingPong::PINGPONG_ID = ServiceID(111);
+
+// construction
+PingPong::PingPong() : pingId( 0 ) {
+}
+
+// destruction
+PingPong::~PingPong() {
+}
+
+// implementation of the startup interface
+void PingPong::startup() {
+
+	// create ariba module
+	logging_info("Creating ariba underlay module ... ");
+	ariba = new AribaModule();
+
+	logging_info("Starting up PingPong service ... ");
+
+	// --- get config ---
+	Configuration& config = Configuration::instance();
+
+	// generate spovnet name
+	Name spovnetName("pingpong");
+
+	// get initiator flag
+	this->isInitiator = Configuration::instance().read<bool> ("node.initiator");
+
+	// get node name
+	Name nodeName = Name::UNSPECIFIED;
+	if (config.exists("node.name")) nodeName
+			= config.read<string> ("node.name");
+
+	// configure ariba module
+	if (config.exists("ariba.ip.addr")) ariba->setProperty("ip.addr",
+			config.read<string> ("ariba.ip.addr"));
+	if (config.exists("ariba.tcp.port")) ariba->setProperty("tcp.port",
+			config.read<string> ("ariba.tcp.port"));
+	if (config.exists("ariba.udp.port")) ariba->setProperty("udp.port",
+			config.read<string> ("ariba.udp.port"));
+	if (config.exists("ariba.bootstrap.hints")) ariba->setProperty("bootstrap.hints",
+			config.read<string> ("ariba.bootstrap.hints"));
+
+	// start ariba module
+	ariba->start();
+
+	// create node and join
+	node = new Node(*ariba, nodeName);
+
+	// start node module
+	node->start();
+
+	if (!isInitiator) {
+		node->join(spovnetName);
+	} else {
+		node->initiate(spovnetName);
+	}
+
+	// bind communication and node listener
+	node->bind(this);
+	node->bind(this, PingPong::PINGPONG_ID);
+
+	// ping pong started up...
+	logging_info("PingPong started up");
+}
+
+// implementation of the startup interface
+void PingPong::shutdown() {
+	logging_info("PingPong service starting shutdown sequence ...");
+
+	// stop timer
+	Timer::stop();
+
+	// leave spovnet
+	node->leave();
+
+	// unbind listeners
+	node->unbind( this );
+	node->unbind( this, PingPong::PINGPONG_ID );
+
+	logging_info("PingPong service shut down!");
+}
+
+// node listener interface
+void PingPong::onJoinCompleted( const SpoVNetID& vid ) {
+	logging_info("PingPong node join completed, spovnetid=" << vid.toString() );
+}
+
+void PingPong::onJoinFailed( const SpoVNetID& vid ) {
+	logging_info("PingPong node join failed, spovnetid=" << vid.toString() );
+}
+
+// communication listener
+bool PingPong::onLinkRequest(const NodeID& remote, Message* msg) {
+	return false;
+}
+
+void PingPong::onMessage(Message* msg, const NodeID& remote, const LinkID& lnk =
+		LinkID::UNSPECIFIED) {
+	PingPongMessage* incoming = msg->decapsulate<PingPongMessage> ();
+
+	logging_info("received ping message on link " << lnk.toString()
+			<< " from node with id " << (int) incoming->getid());
+}
+
+// timer event
+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);
+// 	}
+}
+
+}}} // namespace ariba, application, pingpong
Index: sample/tidy_pingpong/TidyPingPong.h
===================================================================
--- sample/tidy_pingpong/TidyPingPong.h	(revision 2378)
+++ sample/tidy_pingpong/TidyPingPong.h	(revision 2378)
@@ -0,0 +1,75 @@
+#ifndef __PINGPONG_H_
+#define __PINGPONG_H_
+
+#include "ariba/tidy/ariba.h"
+#include "TidyPingPongMessage.h"
+
+using namespace ariba;
+
+#include "ariba/utility/system/StartupInterface.h"
+#include "ariba/utility/system/Timer.h"
+using ariba::utility::StartupInterface;
+using ariba::utility::Timer;
+
+namespace ariba {
+namespace application {
+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 NodeListener,
+	public CommunicationListener,
+	public StartupInterface,
+	public Timer {
+
+	use_logging_h(PingPong);
+
+public:
+	PingPong();
+	virtual ~PingPong();
+
+protected:
+	// communication listener interface
+	virtual bool onLinkRequest(const NodeID& remote, Message* msg);
+	virtual void onMessage(Message* msg, const NodeID& remote, const LinkID& lnk);
+
+	// node listener interface
+	virtual void onJoinCompleted( const SpoVNetID& vid );
+	virtual void onJoinFailed( const SpoVNetID& vid );
+
+	// startup wrapper interface
+	virtual void startup();
+	virtual void shutdown();
+
+	// timer events
+ 	virtual void eventFunction();
+
+private:
+	// the ariba module and a node
+	AribaModule* ariba;
+	Node* node;
+
+	// flag, wheter this node is the initiator of this spovnet
+	bool isInitiator;
+
+ 	// the ping pong service id
+ 	static ServiceID PINGPONG_ID;
+
+ 	// the current ping id
+ 	unsigned long pingId;
+
+// 	// the known remote nodes
+// 	typedef map<NodeID, LinkID> RemoteNodes;
+// 	RemoteNodes remoteNodes;
+};
+
+//ARIBA_SIMULATION_SERVICE(PingPong);
+
+}}} // namespace ariba, application, pingpong
+
+#endif // __PINGPONG_H_
Index: sample/tidy_pingpong/TidyPingPongMessage.cpp
===================================================================
--- sample/tidy_pingpong/TidyPingPongMessage.cpp	(revision 2378)
+++ sample/tidy_pingpong/TidyPingPongMessage.cpp	(revision 2378)
@@ -0,0 +1,26 @@
+#include "TidyPingPongMessage.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: sample/tidy_pingpong/TidyPingPongMessage.h
===================================================================
--- sample/tidy_pingpong/TidyPingPongMessage.h	(revision 2378)
+++ sample/tidy_pingpong/TidyPingPongMessage.h	(revision 2378)
@@ -0,0 +1,40 @@
+#ifndef PINGPONGMESSAGES_H_
+#define PINGPONGMESSAGES_H_
+
+// #include "ariba/utility/messages.h"
+// #include "ariba/utility/serialization.h"
+// #include "ariba/utility/misc/Helper.h"
+// using ariba::utility::Message;
+
+#include <string>
+#include "ariba/tidy/ariba.h"
+
+using namespace ariba;
+using std::string;
+
+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: sample/tidy_pingpong/main.cpp
===================================================================
--- sample/tidy_pingpong/main.cpp	(revision 2378)
+++ sample/tidy_pingpong/main.cpp	(revision 2378)
@@ -0,0 +1,25 @@
+#include <string>
+#include "ariba/utility/system/StartupWrapper.h"
+#include "TidyPingPong.h"
+
+using std::string;
+using ariba::utility::StartupWrapper;
+using ariba::application::pingpong::PingPong;
+
+int main( int argc, char** argv ) {
+
+	// get config file
+	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;
+}
