Index: source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- source/ariba/overlay/BaseOverlay.cpp	(revision 6797)
+++ source/ariba/overlay/BaseOverlay.cpp	(revision 6822)
@@ -56,12 +56,18 @@
 
 #include "ariba/utility/visual/OvlVis.h"
+#include "ariba/utility/visual/DddVis.h"
+#include "ariba/utility/visual/ServerVis.h"
 
 namespace ariba {
 namespace overlay {
+
+#define visual 				ariba::utility::DddVis::instance()
+#define visualIdOverlay 	ariba::utility::ServerVis::NETWORK_ID_BASE_OVERLAY
+#define visualIdBase		ariba::utility::ServerVis::NETWORK_ID_BASE_COMMUNICATION
 
 class ValueEntry {
 public:
 	ValueEntry( const Data& value ) : ttl(0), last_update(time(NULL)),
-		last_change(time(NULL)), value(value.clone()) {
+	last_change(time(NULL)), value(value.clone()) {
 	}
 
@@ -122,5 +128,5 @@
 		vector<Data> vect;
 		BOOST_FOREACH( ValueEntry& e, values )
-			vect.push_back( e.get_value() );
+		vect.push_back( e.get_value() );
 		return vect;
 	}
@@ -163,5 +169,5 @@
 						if (verbose)
 							std::cout << "DHT: Republished value. Refreshing value timestamp."
-							<< std::endl;
+								<< std::endl;
 						return;
 					}
@@ -171,5 +177,5 @@
 				if (verbose)
 					std::cout << "DHT: Added value to "
-					<< " key=" << key << " with value=" << value << std::endl;
+						<< " key=" << key << " with value=" << value << std::endl;
 				entry.values.push_back( ValueEntry( value ) );
 				entry.values.back().set_ttl(ttl);
@@ -181,5 +187,5 @@
 		if (verbose)
 			std::cout << "DHT: New key value pair "
-			<< " key=" << key << " with value=" << value << std::endl;
+				<< " key=" << key << " with value=" << value << std::endl;
 
 		// add new entry
@@ -274,6 +280,6 @@
 LinkDescriptor* BaseOverlay::getDescriptor( const LinkID& link, bool communication ) {
 	BOOST_FOREACH( LinkDescriptor* lp, links )
-		if ((communication ? lp->communicationId : lp->overlayId) == link)
-			return lp;
+				if ((communication ? lp->communicationId : lp->overlayId) == link)
+					return lp;
 	return NULL;
 }
@@ -281,6 +287,6 @@
 const LinkDescriptor* BaseOverlay::getDescriptor( const LinkID& link, bool communication ) const {
 	BOOST_FOREACH( const LinkDescriptor* lp, links )
-		if ((communication ? lp->communicationId : lp->overlayId) == link)
-			return lp;
+				if ((communication ? lp->communicationId : lp->overlayId) == link)
+					return lp;
 	return NULL;
 }
@@ -313,10 +319,10 @@
 	// search for a descriptor that is already up
 	BOOST_FOREACH( LinkDescriptor* lp, links )
-		if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->up && lp->keepAliveMissed == 0)
-			return lp;
+				if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->up && lp->keepAliveMissed == 0)
+					return lp;
 	// if not found, search for one that is about to come up...
 	BOOST_FOREACH( LinkDescriptor* lp, links )
-		if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->keepAliveMissed == 0 )
-			return lp;
+	if (lp->autolink && lp->remoteNode == node && lp->service == service && lp->keepAliveMissed == 0 )
+		return lp;
 	return NULL;
 }
@@ -328,5 +334,5 @@
 		if (!ld->up) continue;
 		OverlayMsg msg( OverlayMsg::typeLinkAlive,
-			OverlayInterface::OVERLAY_SERVICE_ID, nodeId, ld->remoteNode );
+				OverlayInterface::OVERLAY_SERVICE_ID, nodeId, ld->remoteNode );
 		if (ld->relayed) msg.setRouteRecord(true);
 		send_link( &msg, ld->overlayId );
@@ -416,10 +422,10 @@
 			bool found = false;
 			BOOST_FOREACH(NodeID& id, nodes)
-				if (id  == ld->remoteNode) found = true;
+			if (id  == ld->remoteNode) found = true;
 			if (found) continue;
 			i++;
 			nodes.push_back(ld->remoteNode);
 			if ((i%1) == 1) s << "<tr style=\"background-color=#f0f0f0;\">";
-				else s << "<tr>";
+			else s << "<tr>";
 			s << "<td>" << ld->overlayId.toString().substr(0,4) << "..</td>";
 			s << "<td>" << ld->remoteNode.toString().substr(0,4) << "..</td>";
@@ -455,6 +461,6 @@
 	LinkDescriptor* rhsld = getDescriptor(rhs);
 	if (lhsld==NULL || rhsld==NULL
-		|| !lhsld->up || !rhsld->up
-		|| lhsld->remoteNode != rhsld->remoteNode) return -1;
+			|| !lhsld->up || !rhsld->up
+			|| lhsld->remoteNode != rhsld->remoteNode) return -1;
 
 	if ((lhsld->remoteLink^lhsld->overlayId)<(rhsld->remoteLink^lhsld->overlayId)  )
@@ -503,5 +509,5 @@
 	if (destination == nodeId) {
 		logging_warn("Sent message to myself. Handling message.")
-		Message msg;
+				Message msg;
 		msg.encapsulate(message);
 		handleMessage( &msg, NULL );
@@ -518,5 +524,5 @@
 			logging_warn("Could not send message. No relay hop found to "
 					<< destination)
-			return -1;
+					return -1;
 		}
 	}
@@ -528,5 +534,5 @@
 		if (next_id.isUnspecified()) {
 			logging_warn("Could not send message. No next hop found to " <<
-				destination );
+					destination );
 			return -1;
 		}
@@ -568,5 +574,5 @@
 	if (ldr->relayed) {
 		logging_debug("Resolving direct link for relayed link to "
-			<< ldr->remoteNode);
+				<< ldr->remoteNode);
 		ld = getRelayLinkTo( ldr->remoteNode );
 		if (ld==NULL) {
@@ -592,5 +598,5 @@
 
 seqnum_t BaseOverlay::send_node( OverlayMsg* message, const NodeID& remote,
-	const ServiceID& service) {
+		const ServiceID& service) {
 	message->setSourceNode(nodeId);
 	message->setDestinationNode(remote);
@@ -627,6 +633,6 @@
 		// relay link still used and alive?
 		if (ld==NULL
-			|| !ld->isDirectVital()
-			|| difftime(route.used, time(NULL)) > 8) {
+				|| !ld->isDirectVital()
+				|| difftime(route.used, time(NULL)) > 8) {
 			logging_info("Forgetting relay information to node "
 					<< route.node.toString() );
@@ -658,6 +664,6 @@
 	// handle relayed messages from real links only
 	if (ld == NULL
-		|| ld->relayed
-		|| message->getSourceNode()==nodeId ) return;
+			|| ld->relayed
+			|| message->getSourceNode()==nodeId ) return;
 
 	// update usage information
@@ -691,9 +697,9 @@
 				// route has a shorter hop count or old link is dead? yes-> replace
 				if (route.hops > message->getNumHops()
-					|| rld == NULL
-					|| !rld->isDirectVital()) {
+						|| rld == NULL
+						|| !rld->isDirectVital()) {
 					logging_info("Updating relay information to node "
-						<< route.node.toString()
-						<< " reducing to " << message->getNumHops() << " hops.");
+							<< route.node.toString()
+							<< " reducing to " << message->getNumHops() << " hops.");
 					route.hops = message->getNumHops();
 					route.link = ld->overlayId;
@@ -710,5 +716,5 @@
 		route.used = time(NULL);
 		logging_info("Remembering relay information to node "
-			<< route.node.toString());
+				<< route.node.toString());
 		relay_routes.push_back(route);
 	}
@@ -739,7 +745,7 @@
 
 BaseOverlay::BaseOverlay() :
-	bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
-	spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid),
-	sideport(&SideportListener::DEFAULT), started(false), counter(0) {
+			bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
+			spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid),
+			sideport(&SideportListener::DEFAULT), started(false), counter(0) {
 	dht = new DHT();
 	localDHT = new DHT();
@@ -818,5 +824,5 @@
 		state = BaseOverlayStateCompleted;
 		BOOST_FOREACH( NodeListener* i, nodeListeners )
-			i->onJoinCompleted( spovnetId );
+		i->onJoinCompleted( spovnetId );
 
 		//ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA );
@@ -853,10 +859,10 @@
 	BOOST_FOREACH( LinkDescriptor* ld, links ) {
 		if( ld->service != OverlayInterface::OVERLAY_SERVICE_ID )
-		servicelinks.push_back( ld->overlayId );
+			servicelinks.push_back( ld->overlayId );
 	}
 
 	// drop all service links
 	BOOST_FOREACH( LinkID lnk, servicelinks )
-		dropLink( lnk );
+	dropLink( lnk );
 
 	// let the node leave the spovnet overlay interface
@@ -867,9 +873,12 @@
 	// drop still open bootstrap links
 	BOOST_FOREACH( LinkID lnk, bootstrapLinks )
-		bc->dropLink( lnk );
+	bc->dropLink( lnk );
 
 	// change to inalid state
 	state = BaseOverlayStateInvalid;
 	//ovl.visShutdown( ovlId, nodeId, string("") );
+
+	visual.visShutdown(visualIdOverlay, nodeId, "");
+	visual.visShutdown(visualIdBase, nodeId, "");
 
 	// inform all registered services of the event
@@ -898,8 +907,13 @@
 
 		BOOST_FOREACH( NodeListener* i, nodeListeners )
-			i->onJoinFailed( spovnetId );
+		i->onJoinFailed( spovnetId );
 
 		return;
 	}
+
+	visual.configure("127.0.0.1", 50005);
+	//visual.configure("141.3.161.8", 50005);
+	visual.visCreate(visualIdBase, nodeId, "", "");
+	visual.visCreate(visualIdOverlay, nodeId, "", "");
 }
 
@@ -907,5 +921,5 @@
 
 const LinkID BaseOverlay::establishLink( const EndpointDescriptor& remoteEp,
-	const NodeID& remoteId, const ServiceID& service ) {
+		const NodeID& remoteId, const ServiceID& service ) {
 
 	// establish link via overlay
@@ -914,7 +928,7 @@
 	else
 
-	// establish link directly if only ep is known
-	if (remoteId.isUnspecified())
-		return establishDirectLink(remoteEp, service );
+		// establish link directly if only ep is known
+		if (remoteId.isUnspecified())
+			return establishDirectLink(remoteEp, service );
 
 }
@@ -922,5 +936,5 @@
 /// call base communication's establish link and add link mapping
 const LinkID BaseOverlay::establishDirectLink( const EndpointDescriptor& ep,
-	const ServiceID& service ) {
+		const ServiceID& service ) {
 
 	/// find a service listener
@@ -941,5 +955,5 @@
 	/// establish link and add mapping
 	logging_info("Establishing direct link " << ld->communicationId.toString()
-		<< " using " << ep.toString());
+			<< " using " << ep.toString());
 
 	return ld->communicationId;
@@ -948,5 +962,5 @@
 /// establishes a link between two arbitrary nodes
 const LinkID BaseOverlay::establishLink( const NodeID& remote,
-	const ServiceID& service ) {
+		const ServiceID& service ) {
 
 	// do not establish a link to myself!
@@ -967,8 +981,8 @@
 	// debug message
 	logging_info(
-		"Sending link request with"
-		<< " link=" << ld->overlayId.toString()
-		<< " node=" << ld->remoteNode.toString()
-		<< " serv=" << ld->service.toString()
+			"Sending link request with"
+			<< " link=" << ld->overlayId.toString()
+			<< " node=" << ld->remoteNode.toString()
+			<< " serv=" << ld->service.toString()
 	);
 
@@ -1023,5 +1037,5 @@
 	if( ld == NULL ) {
 		logging_error("Could not send message. "
-			<< "Link not found id=" << link.toString());
+				<< "Link not found id=" << link.toString());
 		return -1;
 	}
@@ -1050,5 +1064,5 @@
 
 seqnum_t BaseOverlay::sendMessage(const Message* message,
-	const NodeID& node, const ServiceID& service) {
+		const NodeID& node, const ServiceID& service) {
 
 	// find link for node and service
@@ -1060,6 +1074,6 @@
 		// debug output
 		logging_info( "No link to send message to node "
-			<< node.toString() << " found for service "
-			<< service.toString() << ". Creating auto link ..."
+				<< node.toString() << " found for service "
+				<< service.toString() << ". Creating auto link ..."
 		);
 
@@ -1183,5 +1197,5 @@
 	// already bound? yes-> warning
 	NodeListenerVector::iterator i =
-		find( nodeListeners.begin(), nodeListeners.end(), listener );
+			find( nodeListeners.begin(), nodeListeners.end(), listener );
 	if( i != nodeListeners.end() ) {
 		logging_warn("Node listener " << listener << " is already bound!" );
@@ -1212,5 +1226,5 @@
 
 void BaseOverlay::onLinkUp(const LinkID& id,
-	const address_v* local, const address_v* remote) {
+		const address_v* local, const address_v* remote) {
 	logging_debug( "Link up with base communication link id=" << id );
 
@@ -1221,11 +1235,11 @@
 	if( std::find(bootstrapLinks.begin(), bootstrapLinks.end(), id) != bootstrapLinks.end() ){
 		logging_info(
-			"Join has been initiated by me and the link is now up. " <<
-			"Sending out join request for SpoVNet " << spovnetId.toString()
+				"Join has been initiated by me and the link is now up. " <<
+				"Sending out join request for SpoVNet " << spovnetId.toString()
 		);
 
 		// send join request message
 		OverlayMsg overlayMsg( OverlayMsg::typeJoinRequest,
-			OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
+				OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
 		JoinRequest joinRequest( spovnetId, nodeId );
 		overlayMsg.encapsulate( &joinRequest );
@@ -1249,5 +1263,5 @@
 		// -> wait for update message!
 
-	// link mapping found? -> send update message with node-id and service id
+		// link mapping found? -> send update message with node-id and service id
 	} else {
 		logging_info( "onLinkUp descriptor (initiated locally):" << ld );
@@ -1271,7 +1285,7 @@
 			// note: necessary to validate the link on the remote side!
 			logging_info( "Sending out update" <<
-				" for service " << ld->service.toString() <<
-				" with local node id " << nodeId.toString() <<
-				" on link " << ld->overlayId.toString() );
+					" for service " << ld->service.toString() <<
+					" with local node id " << nodeId.toString() <<
+					" on link " << ld->overlayId.toString() );
 
 			// compile and send update message
@@ -1285,5 +1299,5 @@
 
 void BaseOverlay::onLinkDown(const LinkID& id,
-	const address_v* local, const address_v* remote) {
+		const address_v* local, const address_v* remote) {
 
 	// erase bootstrap links
@@ -1318,6 +1332,6 @@
 
 void BaseOverlay::onLinkChanged(const LinkID& id,
-	const address_v* oldlocal, const address_v* newlocal,
-	const address_v* oldremote, const address_v* newremote) {
+		const address_v* oldlocal, const address_v* newlocal,
+		const address_v* oldremote, const address_v* newremote) {
 
 	// get descriptor for link
@@ -1335,5 +1349,5 @@
 
 void BaseOverlay::onLinkFail(const LinkID& id,
-	const address_v* local, const address_v* remote) {
+		const address_v* local, const address_v* remote) {
 	logging_debug( "Link fail with base communication link id=" << id );
 
@@ -1353,5 +1367,5 @@
 
 void BaseOverlay::onLinkQoSChanged(const LinkID& id, const address_v* local,
-	const address_v* remote, const QoSParameterSet& qos) {
+		const address_v* remote, const QoSParameterSet& qos) {
 	logging_debug( "Link quality changed with base communication link id=" << id );
 
@@ -1363,5 +1377,5 @@
 
 bool BaseOverlay::onLinkRequest( const LinkID& id, const address_v* local,
-	const address_v* remote ) {
+		const address_v* remote ) {
 	logging_debug("Accepting link request from " << remote->to_string() );
 	return true;
@@ -1389,6 +1403,6 @@
 	if( joinReq->getSpoVNetID() != spovnetId ) {
 		logging_error(
-			"Received join request for spovnet we don't handle " <<
-			joinReq->getSpoVNetID().toString() );
+				"Received join request for spovnet we don't handle " <<
+				joinReq->getSpoVNetID().toString() );
 		return false;
 	}
@@ -1405,8 +1419,8 @@
 	assert( overlayInterface != NULL );
 	logging_debug( "Using bootstrap end-point "
-		<< getEndpointDescriptor().toString() )
+			<< getEndpointDescriptor().toString() )
 	OverlayParameterSet parameters = overlayInterface->getParameters();
 	OverlayMsg retmsg( OverlayMsg::typeJoinReply,
-		OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
+			OverlayInterface::OVERLAY_SERVICE_ID, nodeId );
 	JoinReply replyMsg( spovnetId, parameters,
 			allow, getEndpointDescriptor() );
@@ -1448,5 +1462,5 @@
 		// inform all registered services of the event
 		BOOST_FOREACH( NodeListener* i, nodeListeners )
-			i->onJoinFailed( spovnetId );
+		i->onJoinFailed( spovnetId );
 
 		delete replyMsg;
@@ -1459,5 +1473,5 @@
 
 	logging_debug( "Using bootstrap end-point "
-		<< replyMsg->getBootstrapEndpoint().toString() );
+			<< replyMsg->getBootstrapEndpoint().toString() );
 
 	// create overlay structure from spovnet parameter set
@@ -1468,5 +1482,5 @@
 
 		overlayInterface = OverlayFactory::create(
-			*this, replyMsg->getParam(), nodeId, this );
+				*this, replyMsg->getParam(), nodeId, this );
 
 		// overlay structure supported? no-> fail!
@@ -1503,5 +1517,5 @@
 		// inform all registered services of the event
 		BOOST_FOREACH( NodeListener* i, nodeListeners )
-			i->onJoinCompleted( spovnetId );
+		i->onJoinCompleted( spovnetId );
 
 		delete replyMsg;
@@ -1526,11 +1540,11 @@
 	const ServiceID& service = overlayMsg->getService();
 	logging_debug( "Received data for service " << service.toString()
-		<< " on link " << overlayMsg->getDestinationLink().toString() );
+			<< " on link " << overlayMsg->getDestinationLink().toString() );
 
 	// delegate data message
 	getListener(service)->onMessage(
-		overlayMsg,
-		overlayMsg->getSourceNode(),
-		overlayMsg->getDestinationLink()
+			overlayMsg,
+			overlayMsg->getSourceNode(),
+			overlayMsg->getDestinationLink()
 	);
 
@@ -1550,6 +1564,6 @@
 	// update our link mapping information for this link
 	bool changed =
-		( ld->remoteNode != overlayMsg->getSourceNode() )
-		|| ( ld->service != overlayMsg->getService() );
+			( ld->remoteNode != overlayMsg->getSourceNode() )
+			|| ( ld->service != overlayMsg->getService() );
 
 	// set parameters
@@ -1591,5 +1605,5 @@
 
 		logging_debug("Link id=" << ld->overlayId.toString() <<
-			" has been denied by service " << ld->service.toString() << ", dropping link");
+				" has been denied by service " << ld->service.toString() << ", dropping link");
 
 		// prevent onLinkDown calls to the service
@@ -1668,5 +1682,5 @@
 	if (ldn == NULL) {
 		logging_error( "No link request pending for "
-			<< overlayMsg->getDestinationLink().toString() );
+				<< overlayMsg->getDestinationLink().toString() );
 		return false;
 	}
@@ -1681,8 +1695,8 @@
 	// debug message
 	logging_debug( "Link request reply received. Establishing link"
-		<< " for service " << overlayMsg->getService().toString()
-		<< " with local id=" << overlayMsg->getDestinationLink()
-		<< " and remote link id=" << overlayMsg->getSourceLink()
-		<< " to " << overlayMsg->getSourceEndpoint().toString()
+			<< " for service " << overlayMsg->getService().toString()
+			<< " with local id=" << overlayMsg->getDestinationLink()
+			<< " and remote link id=" << overlayMsg->getSourceLink()
+			<< " to " << overlayMsg->getSourceEndpoint().toString()
 	);
 
@@ -1702,5 +1716,5 @@
 	if( ldn->messageQueue.size() > 0 ) {
 		logging_info( "Sending out queued messages on link " <<
-			ldn->overlayId.toString() );
+				ldn->overlayId.toString() );
 		BOOST_FOREACH( Message* msg, ldn->messageQueue ) {
 			sendMessage( msg, ldn->overlayId );
@@ -1715,5 +1729,5 @@
 	// try to replace relay link with direct link
 	ldn->communicationId =
-		bc->establishLink( overlayMsg->getSourceEndpoint() );
+			bc->establishLink( overlayMsg->getSourceEndpoint() );
 
 	return true;
@@ -1725,5 +1739,5 @@
 	if ( rld != NULL ) {
 		logging_debug("Keep-Alive for " <<
-			overlayMsg->getDestinationLink() );
+				overlayMsg->getDestinationLink() );
 		if (overlayMsg->isRouteRecord())
 			rld->routeRecord = overlayMsg->getRouteRecord();
@@ -1765,10 +1779,10 @@
 /// handles an incoming message
 bool BaseOverlay::handleMessage( const Message* message, LinkDescriptor* ld,
-	const LinkID bcLink ) {
+		const LinkID bcLink ) {
 	logging_debug( "Handling message: " << message->toString());
 
 	// decapsulate overlay message
 	OverlayMsg* overlayMsg =
-		const_cast<Message*>(message)->decapsulate<OverlayMsg>();
+			const_cast<Message*>(message)->decapsulate<OverlayMsg>();
 	if( overlayMsg == NULL ) return false;
 
@@ -1788,5 +1802,5 @@
 	// handle signaling messages (do not route!)
 	if (overlayMsg->getType()>=OverlayMsg::typeSignalingStart &&
-		overlayMsg->getType()<=OverlayMsg::typeSignalingEnd ) {
+			overlayMsg->getType()<=OverlayMsg::typeSignalingEnd ) {
 		overlayInterface->onMessage(overlayMsg, NodeID::UNSPECIFIED, LinkID::UNSPECIFIED);
 		delete overlayMsg;
@@ -1796,8 +1810,8 @@
 	// message for reached destination? no-> route message
 	if (!overlayMsg->getDestinationNode().isUnspecified() &&
- 		 overlayMsg->getDestinationNode() != nodeId ) {
+			overlayMsg->getDestinationNode() != nodeId ) {
 		logging_debug("Routing message "
-			<< " from " << overlayMsg->getSourceNode()
-			<< " to " << overlayMsg->getDestinationNode()
+				<< " from " << overlayMsg->getSourceNode()
+				<< " to " << overlayMsg->getDestinationNode()
 		);
 		route( overlayMsg );
@@ -1818,33 +1832,33 @@
 	switch ( overlayMsg->getType() ) {
 
-		// data transport messages
-		case OverlayMsg::typeData:
-			ret = handleData(overlayMsg, ld); 			break;
+	// data transport messages
+	case OverlayMsg::typeData:
+		ret = handleData(overlayMsg, ld); 			break;
 
 		// overlay setup messages
-		case OverlayMsg::typeJoinRequest:
-			ret = handleJoinRequest(overlayMsg, bcLink ); 	break;
-		case OverlayMsg::typeJoinReply:
-			ret = handleJoinReply(overlayMsg, bcLink ); 	break;
+	case OverlayMsg::typeJoinRequest:
+		ret = handleJoinRequest(overlayMsg, bcLink ); 	break;
+	case OverlayMsg::typeJoinReply:
+		ret = handleJoinReply(overlayMsg, bcLink ); 	break;
 
 		// link specific messages
-		case OverlayMsg::typeLinkRequest:
-			ret = handleLinkRequest(overlayMsg, ld ); 	break;
-		case OverlayMsg::typeLinkReply:
-			ret = handleLinkReply(overlayMsg, ld ); 	break;
-		case OverlayMsg::typeLinkUpdate:
-			ret = handleLinkUpdate(overlayMsg, ld );  	break;
-		case OverlayMsg::typeLinkAlive:
-			ret = handleLinkAlive(overlayMsg, ld );   	break;
-		case OverlayMsg::typeLinkDirect:
-			ret = handleLinkDirect(overlayMsg, ld );  	break;
+	case OverlayMsg::typeLinkRequest:
+		ret = handleLinkRequest(overlayMsg, ld ); 	break;
+	case OverlayMsg::typeLinkReply:
+		ret = handleLinkReply(overlayMsg, ld ); 	break;
+	case OverlayMsg::typeLinkUpdate:
+		ret = handleLinkUpdate(overlayMsg, ld );  	break;
+	case OverlayMsg::typeLinkAlive:
+		ret = handleLinkAlive(overlayMsg, ld );   	break;
+	case OverlayMsg::typeLinkDirect:
+		ret = handleLinkDirect(overlayMsg, ld );  	break;
 
 		// handle unknown message type
-		default: {
-			logging_error( "received message in invalid state! don't know " <<
+	default: {
+		logging_error( "received message in invalid state! don't know " <<
 				"what to do with this message of type " << overlayMsg->getType() );
-			ret = false;
-			break;
-		}
+		ret = false;
+		break;
+	}
 	}
 
@@ -1910,6 +1924,134 @@
 	stabilizeLinks();
 	stabilizeDHT();
-}
-
+	updateVisual();
+}
+
+void BaseOverlay::updateVisual(){
+
+	//
+	// update base overlay structure
+	//
+
+	static NodeID pre = NodeID::UNSPECIFIED;
+	static NodeID suc = NodeID::UNSPECIFIED;
+
+	vector<NodeID> nodes = this->getOverlayNeighbors(false);
+
+	if(nodes.size() == 0){
+
+		if(pre != NodeID::UNSPECIFIED){
+			visual.visDisconnect(visualIdOverlay, this->nodeId, pre, "");
+			pre = NodeID::UNSPECIFIED;
+		}
+		if(suc != NodeID::UNSPECIFIED){
+			visual.visDisconnect(visualIdOverlay, this->nodeId, suc, "");
+			suc = NodeID::UNSPECIFIED;
+		}
+
+	} // if(nodes.size() == 0)
+
+	if(nodes.size() == 1){
+		// only one node, make this pre and succ
+		// and then go into the node.size()==2 case
+		//nodes.push_back(nodes.at(0));
+
+		if(pre != nodes.at(0)){
+			pre = nodes.at(0);
+			if(pre != NodeID::UNSPECIFIED)
+				visual.visConnect(visualIdOverlay, this->nodeId, pre, "");
+		}
+	}
+
+	if(nodes.size() == 2){
+
+		// old finger
+		if(nodes.at(0) != pre){
+			if(pre != NodeID::UNSPECIFIED)
+				visual.visDisconnect(visualIdOverlay, this->nodeId, pre, "");
+			pre = NodeID::UNSPECIFIED;
+		}
+		if(nodes.at(1) != suc){
+			if(suc != NodeID::UNSPECIFIED)
+				visual.visDisconnect(visualIdOverlay, this->nodeId, suc, "");
+			suc = NodeID::UNSPECIFIED;
+		}
+
+		// connect with fingers
+		if(pre == NodeID::UNSPECIFIED){
+			pre = nodes.at(0);
+			if(pre != NodeID::UNSPECIFIED)
+				visual.visConnect(visualIdOverlay, this->nodeId, pre, "");
+		}
+		if(suc == NodeID::UNSPECIFIED){
+			suc = nodes.at(1);
+			if(suc != NodeID::UNSPECIFIED)
+				visual.visConnect(visualIdOverlay, this->nodeId, suc, "");
+		}
+
+	} //if(nodes.size() == 2)
+
+//	{
+//		logging_error("================================");
+//		logging_error("my nodeid " << nodeId.get(MAX_KEYLENGTH-16, 16));
+//		logging_error("================================");
+//		if(nodes.size()>= 1){
+//			logging_error("real pre " << nodes.at(0).toString());
+//			logging_error("real pre " << nodes.at(0).get(MAX_KEYLENGTH-16, 16));
+//		}
+//		if(nodes.size()>= 2){
+//			logging_error("real suc " << nodes.at(1).toString());
+//			logging_error("real suc " << nodes.at(1).get(MAX_KEYLENGTH-16, 16));
+//		}
+//		logging_error("================================");
+//		if(pre == NodeID::UNSPECIFIED){
+//			logging_error("pre: unspecified");
+//		}else{
+//			unsigned int prei = pre.get(MAX_KEYLENGTH-16, 16);
+//			logging_error("pre: " << prei);
+//		}
+//		if(suc == NodeID::UNSPECIFIED){
+//			logging_error("suc: unspecified");
+//		}else{
+//			unsigned int suci = suc.get(MAX_KEYLENGTH-16, 16);
+//			logging_error("suc: " << suci);
+//		}
+//		logging_error("================================");
+//	}
+
+	//
+	// update base communication links
+	//
+
+	static set<NodeID> linkset;
+	set<NodeID> remotenodes;
+	BOOST_FOREACH( LinkDescriptor* ld, links ) {
+		if (!ld->isVital() || ld->service != OverlayInterface::OVERLAY_SERVICE_ID)
+			continue;
+
+		if (ld->routeRecord.size()>1 && ld->relayed) {
+			for (size_t i=1; i<ld->routeRecord.size(); i++)
+				remotenodes.insert( ld->routeRecord[ld->routeRecord.size()-i-1] );
+		} else {
+			remotenodes.insert(ld->remoteNode);
+		}
+	}
+
+	// which links are old and need deletion?
+	BOOST_FOREACH(NodeID n, linkset){
+		if(remotenodes.find(n) == remotenodes.end()){
+			visual.visDisconnect(visualIdBase, this->nodeId, n, "");
+			linkset.erase(n);
+		}
+	}
+
+	// which links are new and need creation?
+	BOOST_FOREACH(NodeID n, remotenodes){
+		if(linkset.find(n) == linkset.end()){
+			visual.visConnect(visualIdBase, this->nodeId, n, "");
+			linkset.insert(n);
+		}
+	}
+
+}
 
 // ----------------------------------------------------------------------------
@@ -1954,6 +2096,6 @@
 	if (!overlayInterface->isClosestNodeTo(msg->getDestinationNode())) {
 		logging_debug("Routing DHT message to closest node "
-			<< " from " << msg->getSourceNode()
-			<< " to " << msg->getDestinationNode()
+				<< " from " << msg->getSourceNode()
+				<< " to " << msg->getDestinationNode()
 		);
 		route( msg );
@@ -1966,5 +2108,5 @@
 	case OverlayMsg::typeDHTPut: {
 		BOOST_FOREACH( Data value, dhtMsg->getValues() )
-			dht->put(dhtMsg->getKey(), value, dhtMsg->getTTL() );
+					dht->put(dhtMsg->getKey(), value, dhtMsg->getTTL() );
 		break;
 	}
@@ -1987,5 +2129,5 @@
 		if (dhtMsg->hasValues()) {
 			BOOST_FOREACH( Data value, dhtMsg->getValues() )
-					dht->remove(dhtMsg->getKey(), value );
+							dht->remove(dhtMsg->getKey(), value );
 		} else
 			dht->remove( dhtMsg->getKey() );
Index: source/ariba/overlay/BaseOverlay.h
===================================================================
--- source/ariba/overlay/BaseOverlay.h	(revision 6797)
+++ source/ariba/overlay/BaseOverlay.h	(revision 6822)
@@ -70,7 +70,4 @@
   class CommunicationListener;
   class SideportListener;
-  namespace utility {
-    class OvlVis;
-  }
 }
 
@@ -110,8 +107,4 @@
 using ariba::utility::seqnum_t;
 using ariba::utility::Timer;
-using ariba::utility::OvlVis;
-
-//#define ovl OvlVis::instance()
-//#define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY
 
 namespace ariba {
@@ -519,4 +512,6 @@
 	typedef vector<NodeID> JoiningNodes;
 	JoiningNodes joiningNodes;
+
+	void updateVisual();
 };
 
