mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -35,10 +35,13 @@ class RsGRouterGenericDataItem ;
|
|||||||
|
|
||||||
static const uint32_t GROUTER_CLIENT_ID_MESSAGES = 0x1001 ;
|
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_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 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_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_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
|
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.
|
// 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 ;
|
uint32_t time_shift = now - (*it2).time_stamp ;
|
||||||
float probability = (*it2).probability;
|
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)
|
void p3GRouter::handleRecvDataItem(RsGRouterGenericDataItem *item)
|
||||||
{
|
{
|
||||||
RsStackMutex mtx(grMtx) ;
|
RsStackMutex mtx(grMtx) ;
|
||||||
|
@ -62,7 +62,7 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||||||
// global router, with consistent ids. The services are stored in a map, and arriving objects are
|
// 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.
|
// 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
|
// 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
|
// forward in the network, so that is can be a possible destination for
|
||||||
@ -77,8 +77,14 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||||||
// Unregistering a key might not have an instantaneous effect, so the client is responsible for
|
// Unregistering a key might not have an instantaneous effect, so the client is responsible for
|
||||||
// discarding traffic that might later come for this key.
|
// discarding traffic that might later come for this key.
|
||||||
//
|
//
|
||||||
bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
virtual bool registerKey(const GRouterKeyId& key, const GRouterServiceId& client_id,const std::string& description_string) ;
|
||||||
bool unregisterKey(const GRouterKeyId& key) ;
|
virtual bool unregisterKey(const GRouterKeyId& key) ;
|
||||||
|
|
||||||
|
//===================================================//
|
||||||
|
// Routing clue collection methods //
|
||||||
|
//===================================================//
|
||||||
|
|
||||||
|
virtual void addRoutingClue(const GRouterKeyId& id,const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
//===================================================//
|
//===================================================//
|
||||||
// Client/server request services //
|
// 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.
|
// 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.
|
// 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
|
// 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.
|
// 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 //
|
// Interface with RsGRouter //
|
||||||
@ -131,7 +137,7 @@ class p3GRouter: public RsGRouter, public p3Service, public p3Config
|
|||||||
SERVICE_INFO_MIN_MINOR_VERSION) ;
|
SERVICE_INFO_MIN_MINOR_VERSION) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
virtual void setDebugEnabled(bool b) { _debug_enabled = b ; }
|
||||||
protected:
|
protected:
|
||||||
//===================================================//
|
//===================================================//
|
||||||
// Routing method handling //
|
// Routing method handling //
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "util/contentvalue.h"
|
#include "util/contentvalue.h"
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
#include "retroshare/rsgxscircles.h"
|
#include "retroshare/rsgxscircles.h"
|
||||||
|
#include "retroshare/rsgrouter.h"
|
||||||
#include "rsgixs.h"
|
#include "rsgixs.h"
|
||||||
#include "rsgxsutil.h"
|
#include "rsgxsutil.h"
|
||||||
|
|
||||||
@ -180,6 +181,8 @@ void RsGenExchange::tick()
|
|||||||
|
|
||||||
processRecvdData();
|
processRecvdData();
|
||||||
|
|
||||||
|
processRoutingClues() ;
|
||||||
|
|
||||||
if(!mNotifications.empty())
|
if(!mNotifications.empty())
|
||||||
{
|
{
|
||||||
notifyChanges(mNotifications);
|
notifyChanges(mNotifications);
|
||||||
@ -2040,6 +2043,16 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RsGenExchange::processRoutingClues()
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mGenMtx);
|
||||||
|
|
||||||
|
for(std::map<RsGxsId,std::set<RsPeerId> >::const_iterator it = mRoutingClues.begin();it!=mRoutingClues.end();++it)
|
||||||
|
for(std::set<RsPeerId>::const_iterator it2(it->second.begin());it2!=it->second.end();++it2)
|
||||||
|
rsGRouter->addRoutingClue(GRouterKeyId(it->first),(*it2)) ;
|
||||||
|
|
||||||
|
mRoutingClues.clear() ;
|
||||||
|
}
|
||||||
void RsGenExchange::processGroupDelete()
|
void RsGenExchange::processGroupDelete()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mGenMtx);
|
RsStackMutex stack(mGenMtx);
|
||||||
@ -2507,7 +2520,11 @@ void RsGenExchange::processRecvdMessages()
|
|||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
|
std::cerr << " new status flags: " << meta->mMsgStatus << std::endl;
|
||||||
std::cerr << " computed hash: " << meta->mHash << std::endl;
|
std::cerr << " computed hash: " << meta->mHash << std::endl;
|
||||||
|
std::cerr << "Message received. Identity=" << msg->metaData->mAuthorId << ", from peer " << msg->PeerId() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(!msg->metaData->mAuthorId.isNull())
|
||||||
|
mRoutingClues[msg->metaData->mAuthorId].insert(msg->PeerId()) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2626,6 +2643,15 @@ void RsGenExchange::processRecvdGroups()
|
|||||||
|
|
||||||
computeHash(grp->grp, meta->mHash);
|
computeHash(grp->grp, meta->mHash);
|
||||||
|
|
||||||
|
// group has been validated. Let's notify the global router for the clue
|
||||||
|
|
||||||
|
#ifdef GEN_EXCH_DEBUG
|
||||||
|
std::cerr << "Group routage info: Identity=" << meta->mAuthorId << " from " << grp->PeerId() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!meta->mAuthorId.isNull())
|
||||||
|
mRoutingClues[meta->mAuthorId].insert(grp->PeerId()) ;
|
||||||
|
|
||||||
// now check if group already existss
|
// now check if group already existss
|
||||||
if(std::find(existingGrpIds.begin(), existingGrpIds.end(), grp->grpId) == existingGrpIds.end())
|
if(std::find(existingGrpIds.begin(), existingGrpIds.end(), grp->grpId) == existingGrpIds.end())
|
||||||
{
|
{
|
||||||
|
@ -672,6 +672,7 @@ private:
|
|||||||
void processGroupUpdatePublish();
|
void processGroupUpdatePublish();
|
||||||
|
|
||||||
void processGroupDelete();
|
void processGroupDelete();
|
||||||
|
void processRoutingClues();
|
||||||
|
|
||||||
void publishMsgs();
|
void publishMsgs();
|
||||||
|
|
||||||
@ -884,9 +885,10 @@ private:
|
|||||||
std::vector<GroupUpdate> mGroupUpdates, mPeersGroupUpdate;
|
std::vector<GroupUpdate> mGroupUpdates, mPeersGroupUpdate;
|
||||||
|
|
||||||
std::vector<GroupUpdatePublish> mGroupUpdatePublish;
|
std::vector<GroupUpdatePublish> mGroupUpdatePublish;
|
||||||
|
|
||||||
std::vector<GroupDeletePublish> mGroupDeletePublish;
|
std::vector<GroupDeletePublish> mGroupDeletePublish;
|
||||||
|
|
||||||
|
std::map<RsGxsId,std::set<RsPeerId> > mRoutingClues ;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGENEXCHANGE_H
|
#endif // RSGENEXCHANGE_H
|
||||||
|
@ -87,6 +87,12 @@ class RsGRouter
|
|||||||
|
|
||||||
virtual void sendData(const GRouterKeyId& destination, const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) =0;
|
virtual void sendData(const GRouterKeyId& destination, const GRouterServiceId& client_id, RsGRouterGenericDataItem *item,GRouterMsgPropagationId& id) =0;
|
||||||
virtual bool registerKey(const GRouterKeyId& key,const GRouterServiceId& client_id,const std::string& description_string) =0;
|
virtual bool registerKey(const GRouterKeyId& key,const GRouterServiceId& client_id,const std::string& description_string) =0;
|
||||||
|
|
||||||
|
//===================================================//
|
||||||
|
// Routage feedback from other services //
|
||||||
|
//===================================================//
|
||||||
|
|
||||||
|
virtual void addRoutingClue(const GRouterKeyId& destination, const RsPeerId& source) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// To access the GRouter from anywhere
|
// To access the GRouter from anywhere
|
||||||
|
Loading…
Reference in New Issue
Block a user