mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
added feedback from rsgenexchange into Global router to add routing information
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7628 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b593a918a0
commit
c17de671bb
6 changed files with 79 additions and 27 deletions
|
@ -35,10 +35,13 @@ class RsGRouterGenericDataItem ;
|
|||
|
||||
static const uint32_t GROUTER_CLIENT_ID_MESSAGES = 0x1001 ;
|
||||
|
||||
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 5;
|
||||
static const uint32_t RS_GROUTER_MATRIX_MAX_HIT_ENTRIES = 10; // max number of clues to store
|
||||
static const uint32_t RS_GROUTER_MATRIX_MIN_TIME_BETWEEN_HITS = 60; // can be set to up to half the publish time interval. Prevents flooding routes.
|
||||
static const uint32_t RS_GROUTER_MIN_CONFIG_SAVE_PERIOD = 5; // at most save config every 5 seconds
|
||||
|
||||
static const float RS_GROUTER_BASE_WEIGHT_ROUTED_MSG = 1.0f ; // base contribution of routed message clue to routing matrix
|
||||
static const float RS_GROUTER_BASE_WEIGHT_GXS_PACKET = 0.1f ; // base contribution of GXS message to routing matrix
|
||||
|
||||
static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything
|
||||
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation.
|
||||
static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 1 *10 ; // Check for key advertising every 10 minutes
|
||||
|
|
|
@ -760,7 +760,7 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item)
|
|||
//
|
||||
// The time should also be set so that the routing clue has less importance.
|
||||
//
|
||||
float base = (item->state == RS_GROUTER_ACK_STATE_RCVD)?1.0f : 0.5 ;
|
||||
float base = ((item->state == RS_GROUTER_ACK_STATE_RCVD)?1.0f : 0.5) * RS_GROUTER_BASE_WEIGHT_ROUTED_MSG ;
|
||||
uint32_t time_shift = now - (*it2).time_stamp ;
|
||||
float probability = (*it2).probability;
|
||||
|
||||
|
@ -832,6 +832,15 @@ void p3GRouter::handleRecvACKItem(RsGRouterACKItem *item)
|
|||
}
|
||||
}
|
||||
|
||||
void p3GRouter::addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id)
|
||||
{
|
||||
RsStackMutex mtx(grMtx) ;
|
||||
#ifdef GROUTER_DEBUG
|
||||
grouter_debug() << "Received new routing clue for key " << id << " from peer " << peer_id << std::endl;
|
||||
#endif
|
||||
_routing_matrix.addRoutingClue(id,peer_id,RS_GROUTER_BASE_WEIGHT_GXS_PACKET) ;
|
||||
}
|
||||
|
||||
void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item)
|
||||
{
|
||||
RsStackMutex mtx(grMtx) ;
|
||||
|
|
|
@ -57,12 +57,12 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||
// Router clients business //
|
||||
//===================================================//
|
||||
|
||||
// This method allows to associate client ids (that are saved to disk) to client objects deriving
|
||||
// This method allows to associate client ids (that are saved to disk) to client objects deriving
|
||||
// from GRouterClientService. The various services are responsible for regstering themselves to the
|
||||
// global router, with consistent ids. The services are stored in a map, and arriving objects are
|
||||
// passed on the correct service depending on the client id of the key they are reaching.
|
||||
//
|
||||
bool registerClientService(const GRouterServiceId& id,GRouterClientService *service) ;
|
||||
virtual bool registerClientService(const GRouterServiceId& id,GRouterClientService *service) ;
|
||||
|
||||
// Use this method to register/unregister a key that the global router will
|
||||
// forward in the network, so that is can be a possible destination for
|
||||
|
@ -77,10 +77,16 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||
// Unregistering a key might not have an instantaneous effect, so the client is responsible for
|
||||
// discarding traffic that might later come for this key.
|
||||
//
|
||||
bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
||||
bool unregisterKey(const GRouterKeyId& key) ;
|
||||
virtual bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
||||
virtual bool unregisterKey(const GRouterKeyId& key) ;
|
||||
|
||||
//===================================================//
|
||||
//===================================================//
|
||||
// Routing clue collection methods //
|
||||
//===================================================//
|
||||
|
||||
virtual void addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id) ;
|
||||
|
||||
//===================================================//
|
||||
// Client/server request services //
|
||||
//===================================================//
|
||||
|
||||
|
@ -89,12 +95,12 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||
// remembered by the client, so that he knows when the data has been received.
|
||||
// The client id is supplied so that the client can be notified when the data has been received.
|
||||
//
|
||||
void sendData(const GRouterKeyId& destination,const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) ;
|
||||
virtual void sendData(const GRouterKeyId& destination,const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) ;
|
||||
|
||||
// Sends an ACK to the origin of the msg. This is used to notify for
|
||||
// unfound route, or message correctly received, depending on the particular situation.
|
||||
//
|
||||
void sendACK(const RsPeerId& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
||||
virtual void sendACK(const RsPeerId& peer,GRouterMsgPropagationId mid, uint32_t flags) ;
|
||||
|
||||
//===================================================//
|
||||
// Interface with RsGRouter //
|
||||
|
@ -131,7 +137,7 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||
SERVICE_INFO_MIN_MINOR_VERSION) ;
|
||||
}
|
||||
|
||||
void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
||||
virtual void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
||||
protected:
|
||||
//===================================================//
|
||||
// Routing method handling //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue