Changeset 5902 for source/ariba/overlay
- Timestamp:
- Aug 13, 2009, 2:51:52 AM (15 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r5901 r5902 132 132 OverlayMsg msg( OverlayMsg::typeLinkAlive, 133 133 OverlayInterface::OVERLAY_SERVICE_ID, nodeId, ld->remoteNode ); 134 msg.setRelayed(true);135 134 if (ld->relayed) msg.setRouteRecord(true); 136 135 send_link( &msg, ld->overlayId ); … … 235 234 // exceeded time-to-live? yes-> drop message 236 235 if (message->getNumHops() > message->getTimeToLive()) { 237 logging_warn("Message exceeded TTL -> drop message!"); 236 logging_warn("Message exceeded TTL. Dropping message and relay routes" 237 "for recovery."); 238 relay_routes.clear(); 238 239 return; 240 } 239 241 240 242 // no-> forward message 241 }else {243 else { 242 244 // destinastion myself? yes-> handle message 243 245 if (message->getDestinationNode() == nodeId) { … … 269 271 } 270 272 271 // relay path known? yes-> send over relay link 272 next_link = getRelayLinkTo( destination ); 273 if (next_link != NULL) { 274 if (message->isRelayed()) next_link->setRelaying(); 275 return send(message, next_link); 276 } 277 278 // no-> relay path! route over overlay path 279 LinkID next_id = overlayInterface->getNextLinkId( destination ); 280 if (next_id.isUnspecified()) { 281 logging_error("Could not send message. No next hop found to " << destination ); 282 return -1; 283 } 284 285 // get link descriptor, up and running? yes-> send message 286 next_link = getDescriptor(next_id); 287 if (next_link != NULL && next_link->up) 288 return send(message, next_link); 289 290 // no-> error, dropping message 273 // use relay path? 274 if (message->isRelayed()) { 275 next_link = getRelayLinkTo( destination ); 276 if (next_link != NULL) { 277 next_link->setRelaying(); 278 return bc->sendMessage(next_link->communicationId, message); 279 } else { 280 logging_error("Could not send message. No relay hop found to " 281 << destination) 282 return -1; 283 } 284 } 285 286 // routed message 291 287 else { 292 logging_error("Could not send message. Link not known or up"); 293 return -1; 288 // no-> relay path! route over overlay path 289 LinkID next_id = overlayInterface->getNextLinkId( destination ); 290 if (next_id.isUnspecified()) { 291 logging_error("Could not send message. No next hop found to " << 292 destination ); 293 return -1; 294 } 295 296 // get link descriptor, up and running? yes-> send message 297 next_link = getDescriptor(next_id); 298 if (next_link != NULL && next_link->up) { 299 // send message over relayed link 300 return send(message, next_link); 301 } 302 303 // no-> error, dropping message 304 else { 305 logging_error("Could not send message. Link not known or up"); 306 return -1; 307 } 294 308 } 295 309 … … 317 331 logging_debug("Resolving direct link for relayed link to " 318 332 << ldr->remoteNode); 319 message->setRelayed(); 320 return send(message, ldr->remoteNode); 333 ld = getRelayLinkTo( ldr->remoteNode ); 334 ld->setRelaying(); 335 message->setRelayed(true); 321 336 } else 322 337 ld = ldr; … … 355 370 356 371 message->setService(ld->service); 372 message->setRelayed(ld->relayed); 357 373 return send( message, ld, ignore_down ); 358 374 } … … 401 417 if (ld == NULL 402 418 || ld->relayed 403 || !message->isRelayed()404 // || !(message->getService() == OverlayInterface::OVERLAY_SERVICE_ID)405 419 || message->getSourceNode()==nodeId ) return; 406 420 407 // check wheter this node is already part of the routing table 408 LinkID next_link = overlayInterface->getNextLinkId(message->getSourceNode()); 409 if (next_link == ld->overlayId) return; 410 ld->setRelaying(); 411 412 // try to find source node 413 BOOST_FOREACH( relay_route& route, relay_routes ) { 414 415 // relay route found? yes-> 416 if ( route.node == message->getSourceNode() ) { 417 418 // refresh timer 419 route.used = time(NULL); 420 421 // route has a shorter hop count? yes-> replace 422 if (route.hops > message->getNumHops() ) { 423 logging_info("Updating relay information to node " 424 << route.node.toString() 425 << " reducing to " << message->getNumHops() << " hops."); 426 route.hops = message->getNumHops(); 427 route.link = ld->overlayId; 421 // update usage information 422 if (message->isRelayed()) { 423 // try to find source node 424 BOOST_FOREACH( relay_route& route, relay_routes ) { 425 // relay route found? yes-> 426 if ( route.node == message->getDestinationNode() ) { 427 ld->setRelaying(); 428 route.used = time(NULL); 428 429 } 429 return; 430 } 431 } 432 433 // not found-> add new entry 434 relay_route route; 435 route.hops = message->getNumHops(); 436 route.link = ld->overlayId; 437 route.node = message->getSourceNode(); 438 route.used = time(NULL); 439 logging_info("Remembering relay information to node " << route.node.toString()); 440 relay_routes.push_back(route); 430 } 431 432 } 433 434 // register relay path 435 if (message->isRegisterRelay()) { 436 // set relaying 437 ld->setRelaying(); 438 439 // try to find source node 440 BOOST_FOREACH( relay_route& route, relay_routes ) { 441 442 // relay route found? yes-> 443 if ( route.node == message->getSourceNode() ) { 444 445 // refresh timer 446 route.used = time(NULL); 447 448 // route has a shorter hop count? yes-> replace 449 if (route.hops > message->getNumHops() ) { 450 logging_info("Updating relay information to node " 451 << route.node.toString() 452 << " reducing to " << message->getNumHops() << " hops."); 453 route.hops = message->getNumHops(); 454 route.link = ld->overlayId; 455 } 456 return; 457 } 458 } 459 460 // not found-> add new entry 461 relay_route route; 462 route.hops = message->getNumHops(); 463 route.link = ld->overlayId; 464 route.node = message->getSourceNode(); 465 route.used = time(NULL); 466 logging_info("Remembering relay information to node " 467 << route.node.toString()); 468 relay_routes.push_back(route); 469 } 441 470 } 442 471 … … 447 476 if (route.node == remote ) { 448 477 LinkDescriptor* ld = getDescriptor( route.link ); 449 if (ld==NULL || !ld->up ) return NULL; else {478 if (ld==NULL || !ld->up || !ld->communicationUp) return NULL; else { 450 479 route.used = time(NULL); 451 480 return ld; -
source/ariba/overlay/messages/OverlayMsg.h
r5889 r5902 147 147 } 148 148 149 bool isRegisterRelay() const { 150 return (flags & 0x02)!=0; 151 } 152 153 void setRegisterRelay( bool relayed = true ) { 154 if (relayed) flags |= 0x02; else flags &= ~0x02; 155 } 156 149 157 bool isRouteRecord() const { 150 return (flags & 0x0 2)!=0;158 return (flags & 0x04)!=0; 151 159 } 152 160 153 161 void setRouteRecord( bool route_record = true ) { 154 if (route_record) flags |= 0x0 2; else flags &= ~0x02;162 if (route_record) flags |= 0x04; else flags &= ~0x04; 155 163 } 156 164 -
source/ariba/overlay/modules/chord/Chord.cpp
r5887 r5902 104 104 seqnum_t Chord::send( OverlayMsg* msg, const LinkID& link ) { 105 105 if (link.isUnspecified()) return 0; 106 msg->setRelayed(true);107 106 return baseoverlay.send_link( msg, link ); 108 107 } … … 116 115 117 116 OverlayMsg msg( typeDiscovery ); 118 msg.setRe layed(true);117 msg.setRegisterRelay(true); 119 118 Discovery dmsg( Discovery::normal, (uint8_t)ttl, baseoverlay.getEndpointDescriptor() ); 120 119 msg.encapsulate(&dmsg); … … 129 128 // send predecessor discovery 130 129 OverlayMsg msg( typeDiscovery ); 131 msg.setRe layed(true);130 msg.setRegisterRelay(true); 132 131 Discovery dmsg( Discovery::predecessor, ttl, 133 132 baseoverlay.getEndpointDescriptor() ); … … 139 138 OverlayMsg msg( typeDiscovery ); 140 139 msg.setSourceEndpoint( baseoverlay.getEndpointDescriptor() ); 141 msg.setRe layed(true);140 msg.setRegisterRelay(true); 142 141 Discovery dmsg( Discovery::successor, ttl, 143 142 baseoverlay.getEndpointDescriptor() ); … … 354 353 omsg.encapsulate(dmsg); 355 354 omsg.setService(OverlayInterface::OVERLAY_SERVICE_ID); 356 omsg.setRelayed(true);357 355 baseoverlay.send(&omsg, omsg.getDestinationNode()); 358 356 break; … … 382 380 omsg.setDestinationNode(item->id); 383 381 omsg.setService(OverlayInterface::OVERLAY_SERVICE_ID); 384 omsg.setRelayed(true);385 382 baseoverlay.send(&omsg, omsg.getDestinationNode()); 386 383 break; -
source/ariba/overlay/modules/chord/detail/chord_routing_table.hpp
r5735 r5902 267 267 } 268 268 } 269 if (best_item != NULL && distance(value, id)<distance(value, best_item->id)) 270 return NULL; 269 271 return best_item; 270 272 }
Note:
See TracChangeset
for help on using the changeset viewer.