mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added global router to network simulator
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7248 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e93cd21a2e
commit
cc8b1e8cb0
@ -8,6 +8,8 @@ INCLUDEPATH *= ../../.. ..
|
|||||||
TARGET = NetworkSim
|
TARGET = NetworkSim
|
||||||
DESTDIR = bin
|
DESTDIR = bin
|
||||||
|
|
||||||
|
PRE_TARGETDEPS = ../nscore/nscore.pro
|
||||||
|
|
||||||
SOURCES = main.cpp NetworkViewer.cpp NetworkSimulatorGUI.cpp \
|
SOURCES = main.cpp NetworkViewer.cpp NetworkSimulatorGUI.cpp \
|
||||||
TurtleRouterStatistics.cpp RsAutoUpdatePage.cpp
|
TurtleRouterStatistics.cpp RsAutoUpdatePage.cpp
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class FakePublisher: public pqiPublisher
|
|||||||
virtual bool sendItem(RsRawItem *item)
|
virtual bool sendItem(RsRawItem *item)
|
||||||
{
|
{
|
||||||
_item_queue.push_back(item) ;
|
_item_queue.push_back(item) ;
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsRawItem *outgoing()
|
RsRawItem *outgoing()
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
#include "MonitoredGRouterClient.h"
|
||||||
|
|
||||||
|
const uint32_t MonitoredGRouterClient::GROUTER_CLIENT_SERVICE_ID_00 = 0x0111 ;
|
||||||
|
|
||||||
|
void MonitoredGRouterClient::receiveGRouterData(const GRouterKeyId& destination_key,const RsGRouterGenericDataItem *item)
|
||||||
|
{
|
||||||
|
std::cerr << "received one global grouter item for key " << destination_key << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MonitoredGRouterClient::provideKey(const GRouterKeyId& key_id)
|
||||||
|
{
|
||||||
|
_grouter->registerKey(key_id,GROUTER_CLIENT_SERVICE_ID_00,"test grouter address") ;
|
||||||
|
|
||||||
|
std::cerr << "Registered new key " << key_id << " for service " << std::hex << GROUTER_CLIENT_SERVICE_ID_00 << std::dec << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MonitoredGRouterClient::sendMessage(const GRouterKeyId& destination_key_id) const
|
||||||
|
{
|
||||||
|
RsGRouterGenericDataItem *item = new RsGRouterGenericDataItem ;
|
||||||
|
item->data_size = 1000 + (RSRandom::random_u32()%1000) ;
|
||||||
|
item->data_bytes = (unsigned char *)malloc(item->data_size) ;
|
||||||
|
|
||||||
|
_grouter->sendData(destination_key_id,item) ;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <grouter/grouterclientservice.h>
|
||||||
|
|
||||||
|
class MonitoredGRouterClient: public GRouterClientService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const uint32_t GROUTER_CLIENT_SERVICE_ID_00 ;
|
||||||
|
|
||||||
|
// Derived from grouterclientservice.h
|
||||||
|
//
|
||||||
|
virtual void connectToGlobalRouter(p3GRouter *p) { _grouter = p ; p->registerClientService(GROUTER_CLIENT_SERVICE_ID_00,this) ; }
|
||||||
|
virtual void receiveGRouterData(const GRouterKeyId& destination_key,const RsGRouterGenericDataItem *item);
|
||||||
|
|
||||||
|
// Own functionality
|
||||||
|
//
|
||||||
|
void sendMessage(const GRouterKeyId& destination_key) const ;
|
||||||
|
void provideKey(const GRouterKeyId& key) ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
p3GRouter *_grouter ;
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "MonitoredTurtle.h"
|
#include "MonitoredTurtleClient.h"
|
||||||
|
|
||||||
bool MonitoredTurtleClient::handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id)
|
bool MonitoredTurtleClient::handleTunnelRequest(const TurtleFileHash& hash,const RsPeerId& peer_id)
|
||||||
{
|
{
|
@ -15,7 +15,7 @@
|
|||||||
#include <ft/ftcontroller.h>
|
#include <ft/ftcontroller.h>
|
||||||
#include <services/p3service.h>
|
#include <services/p3service.h>
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "MonitoredTurtle.h"
|
#include "MonitoredTurtleClient.h"
|
||||||
#include "FakeComponents.h"
|
#include "FakeComponents.h"
|
||||||
|
|
||||||
bool Network::initRandom(uint32_t nb_nodes,float connexion_probability)
|
bool Network::initRandom(uint32_t nb_nodes,float connexion_probability)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "PeerNode.h"
|
#include "PeerNode.h"
|
||||||
#include "FakeComponents.h"
|
#include "FakeComponents.h"
|
||||||
#include "MonitoredTurtle.h"
|
#include "MonitoredTurtleClient.h"
|
||||||
|
#include "MonitoredGRouterClient.h"
|
||||||
|
|
||||||
PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
|
PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
|
||||||
: _id(id)
|
: _id(id)
|
||||||
@ -15,20 +16,24 @@ PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends)
|
|||||||
|
|
||||||
_service_server = new p3ServiceServer(_publisher,ctrl);
|
_service_server = new p3ServiceServer(_publisher,ctrl);
|
||||||
|
|
||||||
ftServer *ft_server = new ftServer(peer_mgr,ctrl) ;
|
|
||||||
|
|
||||||
_service_server->addService(_turtle = new p3turtle(ctrl,link_mgr),true) ;
|
|
||||||
|
|
||||||
_ftserver = new MonitoredTurtleClient ;
|
|
||||||
_ftserver->connectToTurtleRouter(_turtle) ;
|
|
||||||
|
|
||||||
RsServicePermissions perms;
|
RsServicePermissions perms;
|
||||||
perms.mDefaultAllowed = true ;
|
perms.mDefaultAllowed = true ;
|
||||||
perms.mServiceId = RS_SERVICE_TYPE_TURTLE ;
|
perms.mServiceId = RS_SERVICE_TYPE_TURTLE ;
|
||||||
|
|
||||||
ctrl->updateServicePermissions(RS_SERVICE_TYPE_TURTLE,perms) ;
|
ctrl->updateServicePermissions(RS_SERVICE_TYPE_TURTLE,perms) ;
|
||||||
// add a turtle router.
|
|
||||||
|
// Turtle business
|
||||||
|
|
||||||
|
_service_server->addService(_turtle = new p3turtle(ctrl,link_mgr),true) ;
|
||||||
|
_turtle_client = new MonitoredTurtleClient ;
|
||||||
|
_turtle_client->connectToTurtleRouter(_turtle) ;
|
||||||
|
|
||||||
|
// global router business.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
_service_server->addService(_grouter = new p3GRouter(ctrl,link_mgr),true) ;
|
||||||
|
_grouter_client = new MonitoredGRouterClient ;
|
||||||
|
_grouter_client->connectToGlobalRouter(_grouter) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerNode::~PeerNode()
|
PeerNode::~PeerNode()
|
||||||
@ -54,13 +59,13 @@ RsRawItem *PeerNode::outgoing()
|
|||||||
void PeerNode::provideFileHash(const RsFileHash& hash)
|
void PeerNode::provideFileHash(const RsFileHash& hash)
|
||||||
{
|
{
|
||||||
_provided_hashes.insert(hash) ;
|
_provided_hashes.insert(hash) ;
|
||||||
_ftserver->provideFileHash(hash) ;
|
_turtle_client->provideFileHash(hash) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerNode::manageFileHash(const RsFileHash& hash)
|
void PeerNode::manageFileHash(const RsFileHash& hash)
|
||||||
{
|
{
|
||||||
_managed_hashes.insert(hash) ;
|
_managed_hashes.insert(hash) ;
|
||||||
_turtle->monitorTunnels(hash,_ftserver) ;
|
_turtle->monitorTunnels(hash,_turtle_client) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerNode::getTrafficInfo(NodeTrafficInfo& info)
|
void PeerNode::getTrafficInfo(NodeTrafficInfo& info)
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
#include <retroshare/rstypes.h>
|
#include <retroshare/rstypes.h>
|
||||||
#include <turtle/p3turtle.h>
|
#include <turtle/p3turtle.h>
|
||||||
|
|
||||||
class MonitoredTurtleRouter ;
|
|
||||||
class MonitoredTurtleClient ;
|
class MonitoredTurtleClient ;
|
||||||
|
class MonitoredGRouterClient ;
|
||||||
class RsTurtle ;
|
class RsTurtle ;
|
||||||
class p3turtle ;
|
class p3turtle ;
|
||||||
|
class p3GRouter ;
|
||||||
class pqiPublisher ;
|
class pqiPublisher ;
|
||||||
class RsRawItem ;
|
class RsRawItem ;
|
||||||
class p3ServiceServer ;
|
class p3ServiceServer ;
|
||||||
@ -30,10 +31,10 @@ class PeerNode
|
|||||||
|
|
||||||
void tick() ;
|
void tick() ;
|
||||||
|
|
||||||
const RsTurtle *turtle_service() const { return _turtle ; }
|
|
||||||
|
|
||||||
// Turtle-related methods
|
// Turtle-related methods
|
||||||
//
|
//
|
||||||
|
const RsTurtle *turtle_service() const { return _turtle ; }
|
||||||
|
|
||||||
void manageFileHash(const RsFileHash& hash) ;
|
void manageFileHash(const RsFileHash& hash) ;
|
||||||
void provideFileHash(const RsFileHash& hash) ;
|
void provideFileHash(const RsFileHash& hash) ;
|
||||||
|
|
||||||
@ -42,13 +43,23 @@ class PeerNode
|
|||||||
|
|
||||||
void getTrafficInfo(NodeTrafficInfo& trinfo) ; //
|
void getTrafficInfo(NodeTrafficInfo& trinfo) ; //
|
||||||
|
|
||||||
|
// GRouter-related methods
|
||||||
|
//
|
||||||
private:
|
private:
|
||||||
p3ServiceServer *_service_server ;
|
p3ServiceServer *_service_server ;
|
||||||
p3turtle *_turtle ;
|
|
||||||
MonitoredTurtleClient *_ftserver ;
|
|
||||||
pqiPublisher *_publisher ;
|
pqiPublisher *_publisher ;
|
||||||
RsPeerId _id ;
|
RsPeerId _id ;
|
||||||
|
|
||||||
|
// turtle stuff
|
||||||
|
//
|
||||||
|
p3turtle *_turtle ;
|
||||||
|
MonitoredTurtleClient *_turtle_client ;
|
||||||
|
|
||||||
|
// grouter stuff
|
||||||
|
//
|
||||||
|
p3GRouter *_grouter ;
|
||||||
|
MonitoredGRouterClient *_grouter_client ;
|
||||||
|
|
||||||
std::set<RsFileHash> _provided_hashes ;
|
std::set<RsFileHash> _provided_hashes ;
|
||||||
std::set<RsFileHash> _managed_hashes ;
|
std::set<RsFileHash> _managed_hashes ;
|
||||||
};
|
};
|
||||||
|
@ -8,11 +8,13 @@ TARGET = nscore
|
|||||||
SOURCES = Network.cpp \
|
SOURCES = Network.cpp \
|
||||||
PeerNode.cpp \
|
PeerNode.cpp \
|
||||||
MonitoredRsPeers.cpp \
|
MonitoredRsPeers.cpp \
|
||||||
MonitoredTurtle.cpp
|
MonitoredTurtleClient.cpp \
|
||||||
|
MonitoredGRouterClient.cpp
|
||||||
|
|
||||||
HEADERS = Network.h \
|
HEADERS = Network.h \
|
||||||
PeerNode.h \
|
PeerNode.h \
|
||||||
MonitoredTurtle.h \
|
MonitoredRsPeers.h \
|
||||||
MonitoredRsPeers.h
|
MonitoredTurtleClient.h \
|
||||||
|
MonitoredGRouterClient.h
|
||||||
|
|
||||||
DESTDIR = ../lib
|
DESTDIR = ../lib
|
Loading…
Reference in New Issue
Block a user