mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
* Moved Relay Packet Debug to a seperate #define.
* Improved Relay Status Output & print when checkRelay() is called. * initialise timer variable (mMinuteTS) - was causing checkRelay to never be called. * switched to 10 second calling of checkRelay(). * Increased RELAY lifetimes (x2). now GENERAL = 1 hr, so they can at least transfer 1 meg (minimum block size) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4777 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f20ac8630e
commit
ec05a7cc7d
@ -96,6 +96,8 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
||||
std::string dhtVersion = "RS51"; // should come from elsewhere!
|
||||
mOwnRsId = id;
|
||||
|
||||
mMinuteTS = 0;
|
||||
|
||||
#ifdef DEBUG_BITDHT
|
||||
std::cerr << "p3BitDht::p3BitDht()" << std::endl;
|
||||
std::cerr << "Using Id: " << id;
|
||||
|
@ -1089,6 +1089,7 @@ int p3BitDht::tick()
|
||||
}
|
||||
|
||||
#define MINUTE_IN_SECS 60
|
||||
#define TEN_IN_SECS 10
|
||||
|
||||
int p3BitDht::minuteTick()
|
||||
{
|
||||
@ -1100,7 +1101,8 @@ int p3BitDht::minuteTick()
|
||||
deltaT = now-mMinuteTS;
|
||||
}
|
||||
|
||||
if (deltaT > MINUTE_IN_SECS)
|
||||
//if (deltaT > MINUTE_IN_SECS)
|
||||
if (deltaT > TEN_IN_SECS)
|
||||
{
|
||||
mRelay->checkRelays();
|
||||
|
||||
|
@ -27,7 +27,8 @@
|
||||
#include <iostream>
|
||||
|
||||
/*
|
||||
* #define DEBUG_UDP_RELAY 1
|
||||
* #define DEBUG_UDP_RELAY 1
|
||||
* #define DEBUG_UDP_RELAY_PKTS 1
|
||||
*/
|
||||
|
||||
#define DEBUG_UDP_RELAY 1
|
||||
@ -211,6 +212,12 @@ int UdpRelayReceiver::getRelayProxies(std::list<UdpRelayProxy> &relayProxies)
|
||||
|
||||
int UdpRelayReceiver::checkRelays()
|
||||
{
|
||||
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
// As this locks - must be out of the Mutex.
|
||||
status(std::cerr);
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(relayMtx); /********** LOCK MUTEX *********/
|
||||
|
||||
/* iterate through the Relays */
|
||||
@ -318,6 +325,7 @@ int UdpRelayReceiver::checkRelays()
|
||||
{
|
||||
removeUdpRelay_relayLocked(&(*it));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -599,6 +607,16 @@ int UdpRelayReceiver::RelayStatus(std::ostream &out)
|
||||
out << "\tDataSize: " << rit->second.mDataSize;
|
||||
out << "\tLastBandwidthTS: " << rit->second.mLastBandwidthTS;
|
||||
}
|
||||
|
||||
out << "ClassLimits:" << std::endl;
|
||||
for(int i = 0; i < UDP_RELAY_NUM_CLASS; i++)
|
||||
{
|
||||
out << "ClassLimit[" << i << "] = " << mClassLimit[i] << std::endl;
|
||||
out << "ClassCount[" << i << "] = " << mClassCount[i] << std::endl;
|
||||
out << "ClassBandwidth[" << i << "] = " << mClassBandwidth[i] << std::endl;
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -610,20 +628,45 @@ int UdpRelayReceiver::status(std::ostream &out)
|
||||
|
||||
RelayStatus(out);
|
||||
|
||||
RsStackMutex stack(relayMtx); /********** LOCK MUTEX *********/
|
||||
|
||||
out << "UdpRelayReceiver::Connections:" << std::endl;
|
||||
|
||||
std::map<struct sockaddr_in, UdpRelayEnd>::iterator pit;
|
||||
for(pit = mStreams.begin(); pit != mStreams.end(); pit++)
|
||||
{
|
||||
out << "\t" << pit->first << " : " << pit->second;
|
||||
out << std::endl;
|
||||
RsStackMutex stack(relayMtx); /********** LOCK MUTEX *********/
|
||||
|
||||
out << "UdpRelayReceiver::Connections:" << std::endl;
|
||||
|
||||
std::map<struct sockaddr_in, UdpRelayEnd>::iterator pit;
|
||||
for(pit = mStreams.begin(); pit != mStreams.end(); pit++)
|
||||
{
|
||||
out << "\t" << pit->first << " : " << pit->second;
|
||||
out << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
UdpPeersStatus(out);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int UdpRelayReceiver::UdpPeersStatus(std::ostream &out)
|
||||
{
|
||||
RsStackMutex stack(udppeerMtx); /********** LOCK MUTEX *********/
|
||||
|
||||
/* iterate through the Relays */
|
||||
out << "UdpRelayReceiver::UdpPeersStatus()";
|
||||
out << std::endl;
|
||||
|
||||
std::map<struct sockaddr_in, UdpPeer *>::iterator pit;
|
||||
for(pit = mPeers.begin(); pit != mPeers.end(); pit++)
|
||||
{
|
||||
out << "UdpPeer for: " << pit->first;
|
||||
out << " is: " << pit->second;
|
||||
out << std::endl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define UDP_RELAY_HEADER_SIZE 16
|
||||
|
||||
/* higher level interface */
|
||||
@ -633,7 +676,7 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
(void) from;
|
||||
|
||||
/* print packet information */
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
||||
std::cerr << "UdpRelayReceiver::recvPkt(" << size << ") from: " << from;
|
||||
std::cerr << std::endl;
|
||||
displayUdpRelayPacketHeader(data, size);
|
||||
@ -642,7 +685,7 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
|
||||
if (!isUdpRelayPacket(data, size))
|
||||
{
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
||||
std::cerr << "UdpRelayReceiver::recvPkt() is Not RELAY Pkt";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -665,11 +708,11 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
if (rit != mRelays.end())
|
||||
{
|
||||
/* we are the relay */
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
||||
std::cerr << "UdpRelayReceiver::recvPkt() We are the Relay. Passing onto: ";
|
||||
std::cerr << rit->first.mDestAddr;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
/* do accounting */
|
||||
rit->second.mLastTS = time(NULL);
|
||||
rit->second.mDataSize += size;
|
||||
@ -690,11 +733,11 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
if (pit != mPeers.end())
|
||||
{
|
||||
/* we are the end-point */
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
||||
std::cerr << "UdpRelayReceiver::recvPkt() Sending to UdpPeer: ";
|
||||
std::cerr << pit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
/* remove the header */
|
||||
void *pktdata = (void *) (((uint8_t *) data) + UDP_RELAY_HEADER_SIZE);
|
||||
int pktsize = size - UDP_RELAY_HEADER_SIZE;
|
||||
@ -705,10 +748,10 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
else
|
||||
{
|
||||
/* packet undersized */
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
//#ifdef DEBUG_UDP_RELAY
|
||||
std::cerr << "UdpRelayReceiver::recvPkt() ERROR Packet Undersized";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -716,10 +759,10 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
}
|
||||
|
||||
/* unknown */
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
//#ifdef DEBUG_UDP_RELAY
|
||||
std::cerr << "UdpRelayReceiver::recvPkt() Peer Unknown!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -743,7 +786,7 @@ int UdpRelayReceiver::sendPkt(const void *data, int size, const struct sockaddr_
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
||||
std::cerr << "UdpRelayReceiver::sendPkt() to Relay: " << it->second;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
@ -110,9 +110,9 @@ std::ostream &operator<<(std::ostream &out, const UdpRelayEnd &ure);
|
||||
//#define UDP_RELAY_LIFETIME_FOF 360 // 6 minutes.
|
||||
//#define UDP_RELAY_LIFETIME_FRIENDS 720 // 12 minutes.
|
||||
|
||||
#define UDP_RELAY_LIFETIME_GENERAL 1800 // 30 minutes
|
||||
#define UDP_RELAY_LIFETIME_FOF 3600 // 1 Hour.
|
||||
#define UDP_RELAY_LIFETIME_FRIENDS 7200 // 2 Hour.
|
||||
#define UDP_RELAY_LIFETIME_GENERAL 3600 // 1 hour (chosen so we at least transfer 1 or 2 meg at lowest speed)
|
||||
#define UDP_RELAY_LIFETIME_FOF 7200 // 2 Hours.
|
||||
#define UDP_RELAY_LIFETIME_FRIENDS 14400 // 4 Hours.
|
||||
|
||||
#define STD_RELAY_TTL 64
|
||||
|
||||
@ -157,6 +157,7 @@ virtual int recvPkt(void *data, int size, struct sockaddr_in &from);
|
||||
virtual int sendPkt(const void *data, int size, const struct sockaddr_in &to, int ttl);
|
||||
|
||||
int status(std::ostream &out);
|
||||
int UdpPeersStatus(std::ostream &out);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user