Changeset 5316
- Timestamp:
- Jul 24, 2009, 8:53:41 PM (15 years ago)
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
/
- Property svn:mergeinfo changed (with no actual effect on merging)
-
sample/pingpong/PingPong.cpp
r5284 r5316 33 33 ariba = new AribaModule(); 34 34 35 // get the configuration object36 Configuration& config = Configuration::instance();37 38 // generate spovnet name39 35 Name spovnetName("pingpong"); 40 41 // get initiator flag 42 this->isInitiator = Configuration::instance().read<bool>("node.initiator"); 43 36 Name nodeName = Name::UNSPECIFIED; 44 37 this->name = string("<ping>"); 45 38 46 // get node name 47 Name nodeName = Name::UNSPECIFIED; 48 if (config.exists("node.name")) nodeName = config.read<string> ("node.name"); 49 50 // configure ariba module 51 if (config.exists("ariba.endpoints")) 52 ariba->setProperty("endpoints", config.read<string>("ariba.endpoints")); 53 if (config.exists("ariba.bootstrap.hints")) 54 ariba->setProperty("bootstrap.hints", config.read<string>("ariba.bootstrap.hints")); 55 if (config.exists("pingpong.name")) 56 name = config.read<string>("pingpong.name"); 39 // get settings from configuration object 40 if( Configuration::haveConfig() ){ 41 Configuration& config = Configuration::instance(); 42 43 // get node name 44 if (config.exists("node.name")) 45 nodeName = config.read<string> ("node.name"); 46 47 // configure ariba module 48 if (config.exists("ariba.endpoints")) 49 ariba->setProperty("endpoints", config.read<string>("ariba.endpoints")); 50 if (config.exists("ariba.bootstrap.hints")) 51 ariba->setProperty("bootstrap.hints", config.read<string>("ariba.bootstrap.hints")); 52 if (config.exists("pingpong.name")) 53 name = config.read<string>("pingpong.name"); 54 55 } // if( Configuration::haveConfig() ) 57 56 58 57 // start ariba module … … 73 72 //params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop 74 73 75 // initiate or join the spovnet 76 if (!isInitiator) node->join(spovnetName); 77 else node->initiate(spovnetName, params); 74 // initiate the spovnet 75 logging_info("initiating spovnet"); 76 node->initiate(spovnetName, params); 77 78 // join the spovnet 79 logging_info("joining spovnet"); 80 node->join(spovnetName); 78 81 79 82 // ping pong started up... … … 122 125 // function that is implemented further down in PingPong::onLinkUp 123 126 124 // logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 125 127 logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 126 128 PingPongMessage pingmsg( pingId, name ); 127 129 … … 140 142 names.clear(); 141 143 } 144 142 145 vector<NodeID> nodes = node->getNeighborNodes(); 143 146 BOOST_FOREACH( NodeID nid, nodes ){ 147 logging_info( "sending ping message to " << nid.toString() ); 144 148 node->sendMessage( pingmsg, nid, PingPong::PINGPONG_SERVICEID ); 145 149 } … … 176 180 for (int i=0;i<names.size(); i++) if (names[i]==pingmsg->getName()) found=true; 177 181 if (!found) names.push_back(pingmsg->getName()); 178 //logging_info( "received ping message on link " << lnk.toString()179 //<< " from node " << remote.toString()180 //<< ": " << pingmsg->info() );182 logging_info( "received ping message on link " << lnk.toString() 183 << " from node " << remote.toString() 184 << ": " << pingmsg->info() ); 181 185 } 182 186 -
sample/pingpong/PingPong.h
r5151 r5316 68 68 vector<string> names; 69 69 70 // flag, whether this node initiates or just joins the spovnet71 bool isInitiator;72 73 70 // the ping pong service id 74 71 static ServiceID PINGPONG_SERVICEID; -
source/ariba/AribaModule.cpp
r5284 r5316 61 61 AribaModule::AribaModule() 62 62 : base_comm(NULL), sideport_sniffer(NULL), started(false) { 63 64 endpoints = "tcp{41322}"; 65 66 //srand( time(NULL) ); 67 //uint16_t tcpport = (rand() + 1024) % 50000; 68 //uint16_t udpport = (rand() + 1024) % 50000; 63 69 } 64 70 -
source/ariba/AribaModule.h
r5284 r5316 42 42 #include <string> 43 43 #include <vector> 44 #include <ctime> 45 #include <cstdlib> 44 46 #include "ariba/utility/logging/Logging.h" 45 46 47 47 48 using std::vector; -
source/ariba/Node.cpp
r5284 r5316 63 63 const communication::EndpointDescriptor* ep = 64 64 ariba_mod.getBootstrapNode(vnetname); 65 if( ep == NULL ) { 66 std::cout << "no bootstrap node defined" << std::endl; 67 return; 68 } 69 ariba_mod.base_comm->start(); 70 base_overlay->start( *ariba_mod.base_comm, nodeId ); 71 base_overlay->joinSpoVNet( spovnetId, *ep); 65 66 // start base comm if not started 67 if( !ariba_mod.base_comm->isStarted() ) 68 ariba_mod.base_comm->start(); 69 70 // start base overlay if not started 71 // join against ourselfs 72 if( !base_overlay->isStarted() ) 73 base_overlay->start( *ariba_mod.base_comm, nodeId ); 74 base_overlay->joinSpoVNet( spovnetId ); 75 76 // join against further nodes 77 if( ep != NULL && *ep != EndpointDescriptor::UNSPECIFIED ) 78 base_overlay->joinSpoVNet( spovnetId, *ep); 72 79 } 73 80 … … 82 89 nodeId = generateNodeId(name); 83 90 84 ariba_mod.base_comm->start(); 85 86 base_overlay->start( *ariba_mod.base_comm, nodeId ); 91 // start base comm if not started 92 if( !ariba_mod.base_comm->isStarted() ) 93 ariba_mod.base_comm->start(); 94 95 // start base overlay if not started 96 if( !base_overlay->isStarted() ) 97 base_overlay->start( *ariba_mod.base_comm, nodeId ); 98 87 99 base_overlay->createSpoVNet( spovnetId, ovrpset ); 88 89 ariba_mod.addBootstrapNode(vnetname,90 new EndpointDescriptor(ariba_mod.base_comm->getEndpointDescriptor()));91 100 } 92 101 -
source/ariba/SideportListener.cpp
r5151 r5316 74 74 } 75 75 76 vector<NodeID> SideportListener::getOverlayNeighbors(bool deep){ 77 vector<NodeID> nodes; 78 if( overlay == NULL ) return nodes; 79 80 overlay->getOverlayNeighbors(deep); 81 } 82 76 83 bool SideportListener::isRelayedNode(const NodeID& node){ 77 84 -
source/ariba/SideportListener.h
r5151 r5316 135 135 136 136 /** 137 * Get the neighbots in the overlay structure 138 * @return A vector of NodeIDs of the neighbors 139 */ 140 vector<NodeID> getOverlayNeighbors(bool deep = true); 141 142 /** 137 143 * Is this node acting as a relay for us 138 144 * -
source/ariba/SpoVNetProperties.h
r3718 r5316 70 70 CHORD_OVERLAY = 1, 71 71 }; 72 73 72 74 73 /** -
source/ariba/overlay/BaseOverlay.cpp
r5284 r5316 245 245 BaseOverlay::BaseOverlay() : 246 246 bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED), 247 spovnetId(SpoVNetID::UNSPECIFIED), initiatorLink(LinkID::UNSPECIFIED),248 s tate(BaseOverlayStateInvalid), sideport(&SideportListener::DEFAULT) {247 spovnetId(SpoVNetID::UNSPECIFIED), state(BaseOverlayStateInvalid), 248 sideport(&SideportListener::DEFAULT), started(false) { 249 249 } 250 250 … … 268 268 Timer::setInterval( 500 ); 269 269 Timer::start(); 270 271 started = true; 272 state = BaseOverlayStateInvalid; 270 273 } 271 274 … … 285 288 bc->unregisterMessageReceiver( this ); 286 289 bc->unregisterEventListener( this ); 290 291 started = false; 292 state = BaseOverlayStateInvalid; 293 } 294 295 bool BaseOverlay::isStarted(){ 296 return started; 287 297 } 288 298 … … 292 302 const EndpointDescriptor& bootstrapEp) { 293 303 294 ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." ); 304 if(id != spovnetId){ 305 logging_error("attempt to join against invalid spovnet, call initiate first"); 306 return; 307 } 308 309 310 //ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." ); 295 311 logging_info( "Starting to join spovnet " << id.toString() << 296 312 " with nodeid " << nodeId.toString()); 297 313 298 // contact the spovnet initiator and request to join. if the join is granted we will 299 // receive further information on the structure of the overlay that is used in the spovnet 300 // but first, we have to establish a link to the initiator... 301 spovnetId = id; 302 state = BaseOverlayStateJoinInitiated; 303 304 initiatorLink = bc->establishLink( bootstrapEp ); 305 logging_info("join process initiated for " << id.toString() << "..."); 314 if(bootstrapEp == EndpointDescriptor::UNSPECIFIED && state == BaseOverlayStateInvalid){ 315 316 // bootstrap against ourselfs 317 logging_debug("joining spovnet locally"); 318 319 overlayInterface->joinOverlay(); 320 state = BaseOverlayStateCompleted; 321 BOOST_FOREACH( NodeListener* i, nodeListeners ) 322 i->onJoinCompleted( spovnetId ); 323 324 //ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA ); 325 //ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN ); 326 327 logging_debug("starting overlay bootstrap module"); 328 overlayBootstrap.start(this, spovnetId, nodeId); 329 overlayBootstrap.publish(bc->getEndpointDescriptor()); 330 331 } else { 332 333 // bootstrap against another node 334 logging_debug("joining spovnet remotely against " << bootstrapEp.toString()); 335 336 const LinkID& lnk = bc->establishLink( bootstrapEp ); 337 bootstrapLinks.push_back(lnk); 338 logging_info("join process initiated for " << id.toString() << "..."); 339 } 306 340 } 307 341 … … 310 344 logging_info( "Leaving spovnet " << spovnetId ); 311 345 bool ret = ( state != this->BaseOverlayStateInvalid ); 346 347 logging_debug("stopping overlay bootstrap module"); 348 overlayBootstrap.stop(); 349 overlayBootstrap.revoke(); 312 350 313 351 logging_debug( "Dropping all auto-links" ); … … 329 367 overlayInterface->leaveOverlay(); 330 368 331 // leave spovnet 332 if( state != BaseOverlayStateInitiator ) { 333 // then, leave the spovnet baseoverlay 334 OverlayMsg overMsg( OverlayMsg::typeBye, nodeId ); 335 bc->sendMessage( initiatorLink, &overMsg ); 336 337 // drop the link and set to correct state 338 bc->dropLink( initiatorLink ); 339 initiatorLink = LinkID::UNSPECIFIED; 340 } 369 // drop still open bootstrap links 370 BOOST_FOREACH( LinkID lnk, bootstrapLinks ) 371 bc->dropLink( lnk ); 341 372 342 373 // change to inalid state 343 374 state = BaseOverlayStateInvalid; 344 ovl.visShutdown( ovlId, nodeId, string("") );375 //ovl.visShutdown( ovlId, nodeId, string("") ); 345 376 346 377 // inform all registered services of the event … … 362 393 363 394 spovnetId = id; 364 state = BaseOverlayStateInitiator;365 395 366 396 overlayInterface = OverlayFactory::create( *this, param, nodeId, this ); … … 368 398 logging_fatal( "overlay structure not supported" ); 369 399 state = BaseOverlayStateInvalid; 400 401 BOOST_FOREACH( NodeListener* i, nodeListeners ) 402 i->onJoinFailed( spovnetId ); 403 370 404 return; 371 405 } 372 373 // bootstrap against ourselfs374 overlayInterface->joinOverlay();375 BOOST_FOREACH( NodeListener* i, nodeListeners )376 i->onJoinCompleted( spovnetId );377 378 ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA );379 ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN );380 406 } 381 407 … … 695 721 LinkDescriptor* ld = getDescriptor(id, true); 696 722 697 // handle initiator link698 if( state == BaseOverlayStateJoinInitiated && id == initiatorLink){723 // handle bootstrap link we initiated 724 if( std::find(bootstrapLinks.begin(), bootstrapLinks.end(), id) != bootstrapLinks.end() ){ 699 725 logging_info( 700 726 "Join has been initiated by me and the link is now up. " << … … 759 785 const address_v* local, const address_v* remote) { 760 786 787 // erase bootstrap links 788 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), id ); 789 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 790 761 791 // get descriptor for link 762 792 LinkDescriptor* ld = getDescriptor(id, true); … … 800 830 const address_v* local, const address_v* remote) { 801 831 logging_debug( "Link fail with base communication link id=" << id ); 832 833 // erase bootstrap links 834 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), id ); 835 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 802 836 803 837 // get descriptor for link … … 927 961 logging_debug("received join reply message"); 928 962 JoinReply* replyMsg = overlayMsg->decapsulate<JoinReply>(); 929 assert(state == BaseOverlayStateJoinInitiated);930 963 931 964 // correct spovnet? … … 942 975 943 976 // drop initiator link 944 bc->dropLink( initiatorLink ); 945 initiatorLink = LinkID::UNSPECIFIED; 946 state = BaseOverlayStateInvalid; 977 978 if(bcLink != LinkID::UNSPECIFIED){ 979 bc->dropLink( bcLink ); 980 981 vector<LinkID>::iterator it = std::find( 982 bootstrapLinks.begin(), bootstrapLinks.end(), bcLink); 983 if( it != bootstrapLinks.end() ) 984 bootstrapLinks.erase(it); 985 } 947 986 948 987 // inform all registered services of the event 949 988 BOOST_FOREACH( NodeListener* i, nodeListeners ) 950 989 i->onJoinFailed( spovnetId ); 990 951 991 return true; 952 992 } … … 956 996 spovnetId.toString() ); 957 997 998 logging_debug( "Using bootstrap end-point " 999 << replyMsg->getBootstrapEndpoint().toString() ); 1000 1001 // 958 1002 // create overlay structure from spovnet parameter set 959 overlayInterface = OverlayFactory::create( 960 *this, replyMsg->getParam(), nodeId, this ); 961 962 // overlay structure supported? no-> fail! 963 if( overlayInterface == NULL ) { 964 logging_error( "overlay structure not supported" ); 965 966 bc->dropLink( initiatorLink ); 967 initiatorLink = LinkID::UNSPECIFIED; 968 state = BaseOverlayStateInvalid; 1003 // if we have not boostrapped yet against some other node 1004 // 1005 1006 if( overlayInterface == NULL ){ 1007 1008 logging_debug("first-time bootstrapping"); 1009 1010 overlayInterface = OverlayFactory::create( 1011 *this, replyMsg->getParam(), nodeId, this ); 1012 1013 // overlay structure supported? no-> fail! 1014 if( overlayInterface == NULL ) { 1015 logging_error( "overlay structure not supported" ); 1016 1017 if(bcLink != LinkID::UNSPECIFIED){ 1018 bc->dropLink( bcLink ); 1019 1020 vector<LinkID>::iterator it = std::find( 1021 bootstrapLinks.begin(), bootstrapLinks.end(), bcLink); 1022 if( it != bootstrapLinks.end() ) 1023 bootstrapLinks.erase(it); 1024 } 1025 1026 // inform all registered services of the event 1027 BOOST_FOREACH( NodeListener* i, nodeListeners ) 1028 i->onJoinFailed( spovnetId ); 1029 1030 return true; 1031 } 1032 1033 // everything ok-> join the overlay! 1034 state = BaseOverlayStateCompleted; 1035 overlayInterface->createOverlay(); 1036 1037 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 1038 1039 // update ovlvis 1040 //ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN); 969 1041 970 1042 // inform all registered services of the event 971 1043 BOOST_FOREACH( NodeListener* i, nodeListeners ) 972 i->onJoinFailed( spovnetId ); 973 974 return true; 975 } 976 977 // everything ok-> join the overlay! 978 state = BaseOverlayStateCompleted; 979 overlayInterface->createOverlay(); 980 logging_debug( "Using bootstrap end-point " 981 << replyMsg->getBootstrapEndpoint().toString() ); 982 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 983 984 // update ovlvis 985 ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN); 986 987 // inform all registered services of the event 988 BOOST_FOREACH( NodeListener* i, nodeListeners ) 989 i->onJoinCompleted( spovnetId ); 1044 i->onJoinCompleted( spovnetId ); 1045 1046 } else { 1047 1048 // this is not the first bootstrap, just join the additional node 1049 logging_debug("not first-time bootstrapping"); 1050 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 1051 1052 } // if( overlayInterface == NULL ) 990 1053 991 1054 return true; … … 1103 1166 1104 1167 // --------------------------------------------------------------------- 1105 // handle bye messages1106 // ---------------------------------------------------------------------1107 case OverlayMsg::typeBye: {1108 logging_debug( "received bye message from " <<1109 overlayMsg->getSourceNode().toString() );1110 1111 /* if we are the initiator and receive a bye from a node1112 * the node just left. if we are a node and receive a bye1113 * from the initiator, we have to close, too.1114 */1115 if( overlayMsg->getSourceNode() == spovnetInitiator ) {1116 1117 bc->dropLink( initiatorLink );1118 initiatorLink = LinkID::UNSPECIFIED;1119 state = BaseOverlayStateInvalid;1120 1121 logging_fatal( "initiator ended spovnet" );1122 1123 // inform all registered services of the event1124 BOOST_FOREACH( NodeListener* i, nodeListeners )1125 i->onLeaveFailed( spovnetId );1126 1127 } else {1128 // a node that said goodbye and we are the initiator don't have to1129 // do much here, as the node also will go out of the overlay1130 // structure1131 logging_info( "node left " << overlayMsg->getSourceNode() );1132 }1133 1134 return true;1135 1136 }1137 1138 // ---------------------------------------------------------------------1139 1168 // handle link request forwarded through the overlay 1140 1169 // --------------------------------------------------------------------- 1141 1170 case OverlayMsg::typeLinkRequest: { 1171 1172 logging_debug( "received link request on link" ); 1142 1173 1143 1174 // decapsulate message … … 1261 1292 case OverlayMsg::typeRelay: { 1262 1293 1294 logging_debug( "received relay request on link" ); 1295 1263 1296 // decapsulate message 1264 1297 RelayMessage* relayMsg = overlayMsg->decapsulate<RelayMessage>(); … … 1347 1380 // --------------------------------------------------------------------- 1348 1381 case OverlayMsg::typeKeepAlive: { 1382 1383 logging_debug( "received keep-alive on link" ); 1384 1349 1385 if ( ld != NULL ) { 1350 1386 //logging_force("Keep-Alive for "<< ld->overlayId); … … 1358 1394 // --------------------------------------------------------------------- 1359 1395 case OverlayMsg::typeDirectLink: { 1396 1397 logging_debug( "received direct link replacement request" ); 1398 1360 1399 LinkDescriptor* rld = getDescriptor( overlayMsg->getRelayLink() ); 1361 1400 logging_force( "Received direct link convert notification for " << rld ); … … 1380 1419 1381 1420 } /* switch */ 1421 1382 1422 return false; 1383 1423 } … … 1398 1438 } 1399 1439 1400 vector<NodeID> BaseOverlay::getOverlayNeighbors( ) const {1440 vector<NodeID> BaseOverlay::getOverlayNeighbors(bool deep) const { 1401 1441 // the known nodes _can_ also include our node, so we remove ourself 1402 vector<NodeID> nodes = overlayInterface->getKnownNodes( );1442 vector<NodeID> nodes = overlayInterface->getKnownNodes(deep); 1403 1443 vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId ); 1404 1444 if( i != nodes.end() ) nodes.erase( i ); … … 1499 1539 // drop links 1500 1540 BOOST_FOREACH( const LinkDescriptor* ld, oldlinks ) { 1501 if (!ld->communicationId.isUnspecified() && ld->communicationId == initiatorLink) { 1541 1542 vector<LinkID>::iterator it = std::find( 1543 bootstrapLinks.begin(), bootstrapLinks.end(), ld->communicationId); 1544 1545 if (!ld->communicationId.isUnspecified() && it != bootstrapLinks.end() ){ 1502 1546 logging_force( "Not dropping initiator link: " << ld ); 1503 1547 continue; -
source/ariba/overlay/BaseOverlay.h
r5284 r5316 112 112 using ariba::utility::OvlVis; 113 113 114 #define ovl OvlVis::instance()115 #define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY114 //#define ovl OvlVis::instance() 115 //#define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY 116 116 117 117 namespace ariba { … … 156 156 157 157 /** 158 * Is the BaseOverlay instance started up yet 159 */ 160 bool isStarted(); 161 162 /** 158 163 * Starts a link establishment procedure to the specfied node 159 164 * for the service with id service … … 211 216 * @return A list of overlay neighbors. 212 217 */ 213 vector<NodeID> getOverlayNeighbors( ) const;218 vector<NodeID> getOverlayNeighbors(bool deep = true) const; 214 219 215 220 /** … … 264 269 * @param boot A bootstrap node 265 270 */ 266 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot );271 void joinSpoVNet(const SpoVNetID& id, const EndpointDescriptor& boot = EndpointDescriptor::UNSPECIFIED); 267 272 268 273 /** … … 365 370 typedef enum _BaseOverlayState { 366 371 BaseOverlayStateInvalid = 0, 367 BaseOverlayStateInitiator = 1, 368 BaseOverlayStateJoinInitiated = 2, 369 BaseOverlayStateCompleted = 3, 372 BaseOverlayStateCompleted = 1, 370 373 } BaseOverlayState; 371 374 372 BaseOverlayState state; ///< Current Base-Overlay state373 BaseCommunication* bc; ///< reference to the base communication374 NodeID nodeId; ///< the node id of this node375 SpoVNetID spovnetId; ///< the spovnet id of the currently joined overlay376 LinkID initiatorLink; ///< the link id of the link to the initiator node377 NodeID spovnetInitiator; ///< The initiator node375 BaseOverlayState state; ///< Current Base-Overlay state 376 BaseCommunication* bc; ///< reference to the base communication 377 NodeID nodeId; ///< the node id of this node 378 SpoVNetID spovnetId; ///< the spovnet id of the currently joined overlay 379 vector<LinkID> bootstrapLinks; ///< the link id of the link to the initiator node 380 NodeID spovnetInitiator; ///< The initiator node 378 381 379 382 /// the service id communication listeners … … 440 443 */ 441 444 OverlayBootstrap overlayBootstrap; 445 446 /// is the base overlay started yet 447 bool started; 442 448 }; 443 449 -
source/ariba/overlay/OverlayBootstrap.cpp
r5002 r5316 61 61 nodeid = _nodeid; 62 62 63 logging_info("starting overlay bootstrap"); 64 63 65 manager.registerCallback( this ); 64 //manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 66 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 67 //manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 65 68 } 66 69 … … 70 73 nodeid = NodeID::UNSPECIFIED; 71 74 75 logging_info("stopping overlay bootstrap"); 76 72 77 manager.unregisterCallback( this ); 73 //manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 78 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 79 //manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 74 80 } 75 81 … … 83 89 // tell the base overlay to join using this endpoint 84 90 assert( overlay != NULL ); 85 // TODO:overlay->joinSpoVNet( spovnetid, data->endpoint );91 overlay->joinSpoVNet( spovnetid, data->endpoint ); 86 92 87 93 delete data; -
source/ariba/overlay/messages/OverlayMsg.h
r5151 r5316 70 70 typeJoinReply = 3, ///< join reply 71 71 typeUpdate = 4, ///< update message for link association 72 typeBye = 5, ///< leave (no encapsulated messages) 73 typeLinkRequest = 6, ///< link request (sent over the overlay) 74 typeRelay = 7, ///< relay message 75 typeKeepAlive = 8, ///< a keep-alive message 76 typeDirectLink = 9, 72 typeLinkRequest = 5, ///< link request (sent over the overlay) 73 typeRelay = 6, ///< relay message 74 typeKeepAlive = 7, ///< a keep-alive message 75 typeDirectLink = 8, 77 76 ///< a direct connection has been established 78 77 }; -
source/ariba/overlay/modules/OverlayInterface.h
r5151 r5316 149 149 * @return The list of all known nodes 150 150 */ 151 virtual NodeList getKnownNodes( ) const = 0;151 virtual NodeList getKnownNodes(bool deep = true) const = 0; 152 152 153 153 /** -
source/ariba/overlay/modules/chord/Chord.cpp
r5151 r5316 61 61 stabilize_counter = 0; 62 62 stabilize_finger = 0; 63 bootstrapLink = LinkID::UNSPECIFIED;64 63 } 65 64 … … 112 111 void Chord::joinOverlay(const EndpointDescriptor& boot) { 113 112 logging_info( "joining Chord overlay structure through end-point " << 114 (boot == EndpointDescriptor::UNSPECIFIED ? 115 "local" : boot.toString()) ); 113 (boot.isUnspecified() ? "local" : boot.toString()) ); 116 114 117 115 // initiator? no->setup first link 118 if (! (boot == EndpointDescriptor::UNSPECIFIED))119 bootstrapLink = setup(boot);116 if (!boot.isUnspecified()) 117 bootstrapLinks.push_back( setup(boot) ); 120 118 121 119 // timer for stabilization management … … 176 174 } 177 175 178 OverlayInterface::NodeList Chord::getKnownNodes( ) const {176 OverlayInterface::NodeList Chord::getKnownNodes(bool deep) const { 179 177 OverlayInterface::NodeList nodelist; 180 for (size_t i = 0; i < table->size(); i++) 181 if ((*table)[i]->ref_count != 0 182 && !(*table)[i]->info.isUnspecified()) 183 nodelist.push_back((*table)[i]->id); 178 179 if( deep ){ 180 // all nodes that I know, fingers, succ/pred 181 for (size_t i = 0; i < table->size(); i++){ 182 if ((*table)[i]->ref_count != 0 183 && !(*table)[i]->info.isUnspecified()) 184 nodelist.push_back((*table)[i]->id); 185 } 186 } else { 187 // only succ and pred 188 if( table->get_predesessor() != NULL ) 189 nodelist.push_back( *(table->get_predesessor()) ); 190 191 if( table->get_successor() != NULL ) 192 nodelist.push_back( *(table->get_successor()) ); 193 } 194 184 195 return nodelist; 185 196 } … … 208 219 } 209 220 210 if (!bootstrapLink.isUnspecified() && lnk == bootstrapLink) { 221 vector<LinkID>::iterator it = std::find(bootstrapLinks.begin(), bootstrapLinks.end(), lnk); 222 if( it != bootstrapLinks.end() ) { 211 223 send_discovery_to(nodeid); 212 bootstrapLink = LinkID::UNSPECIFIED;224 bootstrapLinks.erase( it ); 213 225 } 214 226 } -
source/ariba/overlay/modules/chord/Chord.h
r5151 r5316 76 76 int stabilize_counter; 77 77 int stabilize_finger; 78 LinkID bootstrapLink;78 vector<LinkID> bootstrapLinks; 79 79 vector<NodeID> pending; 80 80 … … 120 120 121 121 /// @see OverlayInterface.h 122 virtual NodeList getKnownNodes( ) const;122 virtual NodeList getKnownNodes(bool deep = true) const; 123 123 124 124 /// @see CommunicationListener.h or @see OverlayInterface.h -
source/ariba/overlay/modules/onehop/OneHop.cpp
r5151 r5316 52 52 OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param) 53 53 : OverlayInterface( _baseoverlay, _nodeid, _eventsReceiver, param ), 54 state ( OneHopStateInvalid ), 55 bootstrapLink ( LinkID::UNSPECIFIED ), 56 pendingLinks ( 0 ) { 54 state( OneHopStateInvalid ) { 57 55 58 56 // … … 88 86 logging_debug( "routing message to node " << destnode.toString() ); 89 87 88 // msg for ourselfs 89 if(destnode == nodeid) 90 baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid ); 91 92 // msg for other node 90 93 OverlayNodeMapping::const_iterator i = overlayNodes.find( destnode ); 91 94 if (i == overlayNodes.end()) { … … 116 119 // the create and join process is completed now. 117 120 logging_info( "creating onehop overlay structure" ); 118 state = OneHopStateCompleted;119 121 } 120 122 … … 123 125 logging_info( "deleting onehop overlay structure" ); 124 126 state = OneHopStateInvalid; 125 pendingLinks = 0; 126 } 127 128 OverlayInterface::NodeList OneHop::getKnownNodes() const { 127 } 128 129 OverlayInterface::NodeList OneHop::getKnownNodes(bool deep) const { 129 130 130 131 OverlayInterface::NodeList retlist; … … 142 143 143 144 logging_info( "joining onehop overlay structure through end-point " << 144 (bootstrapEp == EndpointDescriptor::UNSPECIFIED ? 145 "local" : bootstrapEp.toString()) ); 146 147 state = OneHopStateJoinInitiated; 148 pendingLinks = 0; 149 150 if( bootstrapEp == EndpointDescriptor::UNSPECIFIED ){ 145 (bootstrapEp.isUnspecified() ? "local" : bootstrapEp.toString()) ); 146 147 if( bootstrapEp.isUnspecified() ){ 151 148 152 149 // we are the initiator and we are to bootstrap against … … 156 153 state = OneHopStateCompleted; 157 154 } else { 158 bootstrapLink = baseoverlay.establishLink( bootstrapEp, 159 OverlayInterface::OVERLAY_SERVICE_ID ); 155 bootstrapLinks.push_back( 156 baseoverlay.establishLink( bootstrapEp, 157 OverlayInterface::OVERLAY_SERVICE_ID ) 158 ); 160 159 } 161 160 } … … 187 186 } 188 187 } 189 190 pendingLinks = 0;191 188 } 192 189 … … 210 207 } 211 208 } 209 210 vector<LinkID>::iterator it = std::find( bootstrapLinks.begin(), bootstrapLinks.end(), lnk ); 211 if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it ); 212 212 } 213 213 214 214 void OneHop::onLinkUp(const LinkID& lnk, const NodeID& remote){ 215 216 //217 // as soon as a link goes up, we always request the node listing.218 // and try to get connections to as much nodes as possible in a greedy way.219 //220 221 if( lnk != bootstrapLink ){222 if( pendingLinks > 0 ) pendingLinks--;223 if( pendingLinks == 0 ) state = OneHopStateCompleted;224 }225 215 226 216 logging_debug( "link is up, sending out node listing request" ); … … 230 220 onemsg.encapsulate( &requestmsg ); 231 221 232 state = OneHopStateJoinListingRequested;233 222 baseoverlay.sendMessage( &onemsg, lnk ); 234 223 } … … 309 298 const NodeListingReply::NodeEndpointList& endpoints = reply->getList(); 310 299 logging_debug( "received " << endpoints.size() << " nodes in listing" ); 311 pendingLinks = 0;312 300 313 301 NodeListingReply::NodeEndpointList::const_iterator i = endpoints.begin(); … … 330 318 331 319 overlayNodes.insert( make_pair(node, link) ); 332 pendingLinks++;333 320 334 321 } // for( ; i != iend; i++ ) … … 356 343 if( onemsg->isType( OneHopMessage::OneHopMessageTypeRoute) ){ 357 344 logging_debug( "Route message arrived at destination node -> delegate to BaseOverlay" ); 358 baseoverlay.incomingRouteMessage( onemsg 345 baseoverlay.incomingRouteMessage( onemsg, lnk, remote); 359 346 } // OneHopMessageTypeRoute 360 347 -
source/ariba/overlay/modules/onehop/OneHop.h
r5151 r5316 90 90 91 91 /// @see OverlayInterface.h 92 virtual NodeList getKnownNodes( ) const;92 virtual NodeList getKnownNodes(bool deep = true) const; 93 93 94 94 /// @see CommunicationListener.h or @see OverlayInterface.h … … 110 110 typedef enum _OneHopState { 111 111 OneHopStateInvalid = 0, 112 OneHopStateJoinInitiated = 1, 113 OneHopStateJoinListingRequested = 2, 114 OneHopStateCompleted = 3, 112 OneHopStateCompleted = 1, 115 113 } OneHopState; 116 114 117 115 OneHopState state; 118 uint16_t pendingLinks; 119 LinkID bootstrapLink; 116 vector<LinkID> bootstrapLinks; 120 117 }; 121 118 -
source/ariba/utility/bootstrap/modules/bluetoothsdp
- Property svn:mergeinfo changed (with no actual effect on merging)
-
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp
r4970 r5316 41 41 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 42 42 43 // Attribute descriptors for SDP44 // base was chosen randomly45 #define SDP_SPOVNET_BASE 0x400046 #define SDP_ATTR_SPOVNET_NAME 0x0000 + SDP_SPOVNET_BASE47 #define SDP_ATTR_SPOVNET_INFO1 0x0001 + SDP_SPOVNET_BASE48 #define SDP_ATTR_SPOVNET_INFO2 0x0002 + SDP_SPOVNET_BASE49 #define SDP_ATTR_SPOVNET_INFO3 0x0003 + SDP_SPOVNET_BASE50 51 // The SpoVNet unique identifier, this should be the same for all SpoVNet implementations52 const uint8_t svc_uuid_int[] = {0x59, 0x29, 0x24, 0x34, 0x69, 0x42, 0x11, 0xde, 0x94,53 0x3e, 0x00, 0x21, 0x5d, 0xb4, 0xd8, 0x54};54 55 const char *service_name = "SpoVNet";56 const char *svc_dsc = "Spontaneous Virtual Network";57 const char *service_prov = "ITM Uni Karlsruhe";43 // Attribute descriptors for SDP 44 // base was chosen randomly 45 #define SDP_SPOVNET_BASE 0x4000 46 #define SDP_ATTR_SPOVNET_NAME 0x0000 + SDP_SPOVNET_BASE 47 #define SDP_ATTR_SPOVNET_INFO1 0x0001 + SDP_SPOVNET_BASE 48 #define SDP_ATTR_SPOVNET_INFO2 0x0002 + SDP_SPOVNET_BASE 49 #define SDP_ATTR_SPOVNET_INFO3 0x0003 + SDP_SPOVNET_BASE 50 51 // The SpoVNet unique identifier, this should be the same for all SpoVNet implementations 52 const uint8_t svc_uuid_int[] = {0x59, 0x29, 0x24, 0x34, 0x69, 0x42, 0x11, 0xde, 0x94, 53 0x3e, 0x00, 0x21, 0x5d, 0xb4, 0xd8, 0x54}; 54 55 const char *service_name = "SpoVNet"; 56 const char *svc_dsc = "www.ariba-underlay.org"; 57 const char *service_prov = "ITM Uni Karlsruhe"; 58 58 59 59 #endif // HAVE_BLUETOOTH_BLUETOOTH_H … … 66 66 BluetoothSdp::BluetoothSdp(BootstrapInformationCallback* _callback) : 67 67 BootstrapModule(_callback), scan_timer_(io_service_) { 68 srand( time(NULL) ); 68 69 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 69 70 … … 88 89 bool BluetoothSdp::isFunctional() { 89 90 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 90 return true; // Not tested yet :)91 return true; 91 92 #else 92 93 return false; … … 118 119 t_.join(); 119 120 121 if(sdp_session_ != NULL) 122 sdp_close(sdp_session_); 123 120 124 #endif // HAVE_BLUETOOTH_BLUETOOTH_H 121 125 } … … 130 134 */ 131 135 132 logging_ info("Registering SDP service");136 logging_debug("registering SDP service"); 133 137 134 138 uint8_t rfcomm_channel = channel_; … … 142 146 sdp_session_ = 0; 143 147 144 bdaddr_t bdaddr_any = (bdaddr_t) { {0, 0, 0, 0, 0, 0}};145 bdaddr_t bdaddr_local = (bdaddr_t) { {0, 0, 0, 0xff, 0xff, 0xff}};146 147 148 // prepare the info attribute buffers 148 149 //string namebuf, info1buf, info2buf, info3buf; … … 155 156 156 157 if((namelen > 256) || (info1len > 256) || (info2len > 256) || (info3len > 256)) { 157 logging_error(" String Argument too long, max size is 256!");158 logging_error("string argument too long, max size is 256!"); 158 159 return; 159 160 } 160 161 // we need to save the string len for sdp; do we?162 /*163 namebuf = (char)namelen;164 namebuf.append(name);165 info1buf = (char)info1len;166 info1buf.append(info1);167 info2buf = (char)info2len;168 info2buf.append(info2);169 info3buf = (char)info3len;170 info3buf.append(info3);171 */172 161 173 162 // set the general service ID … … 222 211 info3.data()); 223 212 224 // connect to the local SDP server, register the service record, 225 // and disconnect 226 sdp_session_ = sdp_connect(&bdaddr_any, &bdaddr_local, SDP_RETRY_IF_BUSY); 227 228 if (sdp_session_ == 0) { 229 logging_error( "Something is wrong with your SDP server, nothing registered" ); 213 // connect to the local SDP server, register the service record 214 if( sdp_session_ == NULL ){ 215 sdp_session_ = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); 216 } 217 218 if (sdp_session_ == NULL) { 219 logging_error( "something is wrong with your SDP server, nothing registered" ); 230 220 } else { 231 sdp_record_register(sdp_session_, &record, 0); 221 int ret = sdp_record_register(sdp_session_, &record, 0); 222 223 if(ret < 0){ 224 logging_error("failed registering sdp record"); 225 }else{ 226 logging_debug("sdp record registered using session " << sdp_session_); 227 } 232 228 } 233 229 … … 247 243 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 248 244 249 logging_ info("Unregistering SDP service");245 logging_debug("unregistering SDP service"); 250 246 sdp_close(sdp_session_); 251 247 … … 256 252 257 253 void BluetoothSdp::bt_scan() { 258 259 260 254 /* 261 255 * Scans for other bluetooth devices and starts a SDP search on them. 262 * Repeats 20 seconds after the end of the scan. 263 */ 264 265 logging_info("Scanning for peers"); 256 */ 257 258 logging_debug("scanning for peers"); 266 259 267 260 inquiry_info *ii = NULL; … … 276 269 sock = hci_open_dev(dev_id); 277 270 if (dev_id < 0 || sock < 0) { 278 logging_error("opening socket ");279 exit(1);271 logging_error("opening socket for device " << dev_id << " failed. can not scan for peers"); 272 return; 280 273 } 281 274 … … 287 280 num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags); 288 281 if (num_rsp < 0) 289 logging_error("hci_inquiry ");282 logging_error("hci_inquiry failed with " << num_rsp); 290 283 291 284 for (i = 0; i < num_rsp; i++) { 292 /*293 ba2str(&(ii + i)->bdaddr, addr);294 memset(name, 0, sizeof(name));295 if (hci_read_remote_name(sock, &(ii + i)->bdaddr, sizeof(name),296 name, 0) < 0)297 strcpy(name, "[unknown]");298 printf("%s %s\n", addr, name);299 */300 285 301 286 address = (ii + i)->bdaddr; 302 303 logging_info("Found peer " << ba2string(&address) << ", querying SDP.") 287 logging_debug("found peer " << ba2string(&address) << ", querying SDP.") 304 288 305 289 // TODO: sdp_search can be very slow, fork it! … … 310 294 close(sock); 311 295 312 logging_info("Next scan in 20 seconds"); 313 314 scan_timer_.expires_from_now(boost::posix_time::seconds(20)); 296 int nextscan = (rand() % 40) + 5; 297 logging_debug("Next sdp scan in " << nextscan << " seconds"); 298 299 scan_timer_.expires_from_now(boost::posix_time::seconds(nextscan)); 315 300 scan_timer_.async_wait(boost::bind(&BluetoothSdp::bt_scan, this)); 316 301 } … … 326 311 uuid_t svc_uuid; 327 312 sdp_list_t *response_list, *search_list, *attrid_list; 328 sdp_session_t *session = 0;313 sdp_session_t *session = NULL; 329 314 uint32_t range = 0x0000ffff; 330 315 uint8_t port = 0; 331 bdaddr_t any_addr = (bdaddr_t) { {0, 0, 0, 0, 0, 0}};332 316 333 317 // prepare the buffers for the attributes … … 335 319 336 320 // connect to the SDP server running on the remote machine 337 session = sdp_connect(&any_addr, &target, 0); 338 339 if (session == 0) { 340 logging_error("Failed to connect to SDP server at " << ba2string(&target) <<"."); 321 logging_debug("querying services from bt device " << ba2string(&target)); 322 session = sdp_connect(BDADDR_ANY, &target, 0); 323 324 if (session == NULL) { 325 logging_error("failed to connect to SDP server at " << ba2string(&target) <<"."); 341 326 return; 342 327 } … … 356 341 357 342 // go through each of the service records 358 for ( ; r; r = r->next) {343 for ( ; r != NULL; r = r->next) { 359 344 sdp_record_t *rec = (sdp_record_t*) r->data; 360 345 … … 368 353 369 354 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_NAME, (char*)&name, 256); 370 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO1, (char*)& name, 256);371 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO2, (char*)& name, 256);372 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO3, (char*)& name, 256);355 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO1, (char*)&info1, 256); 356 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO2, (char*)&info2, 256); 357 sdp_get_string_attr(rec, SDP_ATTR_SPOVNET_INFO3, (char*)&info3, 256); 373 358 374 359 logging_info("Remote peer name is: " << name); … … 379 364 // Callback 380 365 callback->onBootstrapServiceFound(name, info1, info2, info3); 381 382 366 } 383 367 sdp_record_free(rec); 384 368 } 385 } 369 } else { 370 logging_error("sdp_service_search_attr_req failed with timeout"); 371 } 372 386 373 sdp_list_free(response_list, 0); 387 374 sdp_list_free(search_list, 0); 388 375 sdp_list_free(attrid_list, 0); 389 376 sdp_close(session); 390 391 377 } 392 378 … … 395 381 * Returns a string holding the bt adress in human readable form. 396 382 */ 397 char *str; 383 char addr[32] = { 0 }; 384 char str[32] = { 0 }; 398 385 ba2str(ba, str); 399 386 string result = str; -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h
r4970 r5316 44 44 #include <iostream> 45 45 #include <string> 46 #include <ctime> 46 47 #include <boost/bind.hpp> 47 48 #include <boost/asio.hpp> … … 94 95 boost::asio::deadline_timer scan_timer_; 95 96 boost::thread t_; 96 97 97 }; 98 98 -
source/ariba/utility/bootstrap/modules/periodicbroadcast
- Property svn:mergeinfo changed (with no actual effect on merging)
-
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp
r4934 r5316 66 66 : BootstrapModule(_callback), 67 67 server(io_service, &newRemoteServices, &newRemoteServicesMutex) { 68 69 68 } 70 69 -
source/ariba/utility/configuration/Configuration.cpp
r3690 r5316 51 51 void Configuration::setConfigFilename(string filename){ 52 52 CONFIG_FILE = filename; 53 instance().reload(); 53 if(haveConfig()) 54 instance().reload(); 54 55 } 55 56 56 57 Configuration::~Configuration(){ 57 58 delete config; 59 } 60 61 bool Configuration::haveConfig(){ 62 std::ifstream in( CONFIG_FILE.c_str() ); 63 if( !in ) return false; 64 65 in.close(); 66 return true; 58 67 } 59 68 … … 64 73 65 74 bool Configuration::exists(const string& name){ 75 if(config == NULL) return false; 66 76 return config->keyExists( name ); 67 77 } -
source/ariba/utility/configuration/Configuration.h
r3690 r5316 63 63 static Configuration& instance(); 64 64 static void setConfigFilename(string filename); 65 static bool haveConfig(); 65 66 66 67 /** -
source/ariba/utility/misc/OvlVis.cpp
r3690 r5316 50 50 OvlVis::OvlVis() : socket(io_service), socketOpened(false) { 51 51 52 if( ! Configuration::haveConfig() ) return; 52 53 if( ! Configuration::instance().exists("DEMO_OvlVisIP") ) return; 53 54 if( ! Configuration::instance().exists("DEMO_OvlVisPort") ) return; -
source/ariba/utility/system/StartupWrapper.cpp
r5289 r5316 98 98 { 99 99 log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger()); 100 logger->setLevel(log4cxx::Level::get Error());100 logger->setLevel(log4cxx::Level::getWarn()); 101 101 } 102 102 … … 107 107 } 108 108 { 109 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("BaseCommunication"));110 logger->setLevel(log4cxx::Level::getError());109 // log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("BaseCommunication")); 110 // logger->setLevel(log4cxx::Level::getError()); 111 111 } 112 112 113 113 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 114 // DON'T SVN COMMIT YOUR CHAN TED LOGGING! THE ABOVE CODE MUST REMAIN AS IS!114 // DON'T SVN COMMIT YOUR CHANGED LOGGING! THE ABOVE CODE MUST REMAIN AS IS! 115 115 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 116 116 } -
source/ariba/utility/system/SystemQueue.cpp
r4721 r5316 226 226 // call the queue and this will 227 227 // call the actual event handler 228 obj->queueMutex.unlock(); 228 229 obj->onNextQueueItem( ev ); 230 obj->queueMutex.lock(); 229 231 230 232 } // !obj->eventsQueue.empty() )
Note:
See TracChangeset
for help on using the changeset viewer.