summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/Constants.hpp11
-rw-r--r--node/Path.hpp16
-rw-r--r--node/Peer.cpp24
3 files changed, 38 insertions, 13 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 80083abe..ee2ff0a6 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -293,7 +293,7 @@
/**
* Number of samples to consider when computing path statistics
*/
-#define ZT_PATH_QUALITY_METRIC_WIN_SZ 128
+#define ZT_PATH_QUALITY_METRIC_WIN_SZ 64
/**
* How often important path metrics are sampled (in ms). These metrics are later used
@@ -311,7 +311,7 @@
* since we will record a 0 bit/s measurement if no valid latency measurement was made within this
* window of time.
*/
-#define ZT_PATH_LATENCY_SAMPLE_INTERVAL ZT_PING_CHECK_INVERVAL * 2
+#define ZT_PATH_LATENCY_SAMPLE_INTERVAL ZT_MULTIPATH_PEER_PING_PERIOD * 2
/**
* Interval used for rate-limiting the computation of path quality estimates. Set at 0
@@ -375,6 +375,13 @@
#define ZT_PEER_PING_PERIOD 60000
/**
+ * Delay between full-fledge pings of directly connected peers.
+ * With multipath bonding enabled ping peers more often to measure
+ * packet loss and latency.
+ */
+#define ZT_MULTIPATH_PEER_PING_PERIOD 5000
+
+/**
* Paths are considered expired if they have not sent us a real packet in this long
*/
#define ZT_PEER_PATH_EXPIRATION ((ZT_PEER_PING_PERIOD * 4) + 3000)
diff --git a/node/Path.hpp b/node/Path.hpp
index 7ce6e0f1..e6bcecf0 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -433,6 +433,22 @@ public:
}
/**
+ * @param buf Buffer to store resultant string
+ * @return Description of path, in ASCII string format
+ */
+ inline char *toString(char *buf) {
+ sprintf(buf,"%6s, q=%8.3f, %5.3f Mb/s, j=%8.2f, ml=%8.2f, meanAge=%8.2f, addr=%45s",
+ getName(),
+ lastComputedQuality(),
+ (float)meanThroughput() / (float)1000000,
+ jitter(),
+ meanLatency(),
+ meanAge(),
+ getAddressString());
+ return buf;
+ }
+
+ /**
* Record whether a packet is considered invalid by MAC/compression/cipher checks. This
* could be an indication of a bit error. This function will keep a running counter of
* up to a given window size and with each counter overflow it will compute a mean error rate
diff --git a/node/Peer.cpp b/node/Peer.cpp
index bbc6d6d2..c46ed751 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -100,14 +100,17 @@ void Peer::received(
path->trustedPacketReceived(now);
}
- if (RR->node->getMultipathMode() != ZT_MULTIPATH_NONE) {
- if ((now - _lastPathPrune) > ZT_CLOSED_PATH_PRUNING_INTERVAL) {
- _lastPathPrune = now;
- prunePaths();
- }
- for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
- if (_paths[i].p) {
- _paths[i].p->measureLink(now);
+ {
+ Mutex::Lock _l(_paths_m);
+ if (RR->node->getMultipathMode() != ZT_MULTIPATH_NONE) {
+ if ((now - _lastPathPrune) > ZT_CLOSED_PATH_PRUNING_INTERVAL) {
+ _lastPathPrune = now;
+ prunePaths();
+ }
+ for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
+ if (_paths[i].p) {
+ _paths[i].p->measureLink(now);
+ }
}
}
}
@@ -386,9 +389,9 @@ SharedPtr<Path> Peer::getAppropriatePath(int64_t now, bool includeExpired)
if (bestPath == ZT_MAX_PEER_NETWORK_PATHS || (numAlivePaths == 0 && numStalePaths == 0)) {
return SharedPtr<Path>();
} if (numAlivePaths == 1) {
- return _paths[bestPath].p;
+ //return _paths[bestPath].p;
} if (numStalePaths == 1) {
- return _paths[bestPath].p;
+ //return _paths[bestPath].p;
}
// Relative quality
@@ -725,7 +728,6 @@ unsigned int Peer::doPingAndKeepalive(void *tPtr,int64_t now)
unsigned int Peer::prunePaths()
{
- Mutex::Lock _l(_paths_m);
unsigned int pruned = 0;
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
if (_paths[i].p) {