Tweak some timings and stuff.

This commit is contained in:
Adam Ierymenko 2014-04-03 16:19:41 -07:00
parent c96d3ebf8c
commit 158002d2d1
4 changed files with 22 additions and 18 deletions

View file

@ -267,13 +267,13 @@ error_no_byte_order_defined;
*/ */
#define ZT_PEER_DIRECT_PING_DELAY 120000 #define ZT_PEER_DIRECT_PING_DELAY 120000
/** /**
* Delay in ms between firewall opener packets to direct links * Delay in ms between firewall opener packets to direct links
* *
* This should be lower than the UDP conversation entry timeout in most * This should be lower than the UDP conversation entry timeout in most
* stateful firewalls. * stateful firewalls.
*/ */
#define ZT_FIREWALL_OPENER_DELAY 50000 #define ZT_FIREWALL_OPENER_DELAY 30000
/** /**
* Delay between requests for updated network autoconf information * Delay between requests for updated network autoconf information
@ -290,7 +290,7 @@ error_no_byte_order_defined;
* *
* This is the shortest of the check delays/periods. * This is the shortest of the check delays/periods.
*/ */
#define ZT_MIN_SERVICE_LOOP_INTERVAL ZT_NETWORK_FINGERPRINT_CHECK_DELAY #define ZT_MIN_SERVICE_LOOP_INTERVAL 5000
/** /**
* Activity timeout for links * Activity timeout for links

View file

@ -598,12 +598,12 @@ Node::ReasonForTermination Node::run()
} }
if (resynchronize) { if (resynchronize) {
/* If resynchronizing, forget P2P links to all peers and then send /* Send NOP to all peers on resynchronize, directly to supernodes and
* something to formerly active ones. This will relay via a supernode * indirectly to regular nodes (to trigger RENDEZVOUS). Also clear
* which will trigger a new RENDEZVOUS and a new hole punch. This * learned paths since they're likely no longer valid, and close
* functor excludes supernodes, which are pinged separately above. */ * TCP sockets since they're also likely invalid. */
_r->topology->eachPeer(Topology::ResetActivePeers(_r,now));
_r->sm->closeTcpSockets(); _r->sm->closeTcpSockets();
_r->topology->eachPeer(Topology::ResetActivePeers(_r,now));
} else { } else {
/* Periodically check for changes in our local multicast subscriptions /* Periodically check for changes in our local multicast subscriptions
* and broadcast those changes to directly connected peers. */ * and broadcast those changes to directly connected peers. */

View file

@ -133,10 +133,10 @@ public:
Utils::snprintf(tmp,sizeof(tmp),"%s;%s;%lld;%lld;%lld;%lld;%s", Utils::snprintf(tmp,sizeof(tmp),"%s;%s;%lld;%lld;%lld;%lld;%s",
t, t,
_addr.toString().c_str(), _addr.toString().c_str(),
(long long)((_lastSend != 0) ? (now - _lastSend) : -1), (long long)((_lastSend != 0) ? ((now - _lastSend) / 1000LL) : -1),
(long long)((_lastReceived != 0) ? (now - _lastReceived) : -1), (long long)((_lastReceived != 0) ? ((now - _lastReceived) / 1000LL) : -1),
(long long)((_lastFirewallOpener != 0) ? (now - _lastFirewallOpener) : -1), (long long)((_lastFirewallOpener != 0) ? ((now - _lastFirewallOpener) / 1000LL) : -1),
(long long)((_lastPing != 0) ? (now - _lastPing) : -1), (long long)((_lastPing != 0) ? ((now - _lastPing) / 1000LL) : -1),
((_fixed) ? "fixed" : (active(now) ? "active" : "inactive")) ((_fixed) ? "fixed" : (active(now) ? "active" : "inactive"))
); );
return std::string(tmp); return std::string(tmp);

View file

@ -272,8 +272,6 @@ public:
/** /**
* Function object to forget direct links to active peers and then ping them indirectly * Function object to forget direct links to active peers and then ping them indirectly
*
* Note that this excludes supernodes.
*/ */
class ResetActivePeers class ResetActivePeers
{ {
@ -286,12 +284,18 @@ public:
inline void operator()(Topology &t,const SharedPtr<Peer> &p) inline void operator()(Topology &t,const SharedPtr<Peer> &p)
{ {
if (!_supernodeAddresses.count(p->address())) { p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes
p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes
Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP);
outp.armor(p->key(),false); // no need to encrypt a NOP
if (_supernodeAddresses.count(p->address())) {
// Send NOP directly to supernodes
p->send(_r,outp.data(),outp.size(),_now);
} else {
// Send NOP indirectly to regular peers if still active, triggering a new RENDEZVOUS
if (((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT)&&(_supernode)) { if (((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT)&&(_supernode)) {
TRACE("sending reset NOP to %s",p->address().toString().c_str()); TRACE("sending reset NOP to %s",p->address().toString().c_str());
Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP);
outp.armor(p->key(),false); // no need to encrypt a NOP
_supernode->send(_r,outp.data(),outp.size(),_now); _supernode->send(_r,outp.data(),outp.size(),_now);
} }
} }