Path.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2025-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_PATH_HPP
  14. #define ZT_PATH_HPP
  15. #include <stdint.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18. #include <stdexcept>
  19. #include <algorithm>
  20. #include "Constants.hpp"
  21. #include "InetAddress.hpp"
  22. #include "SharedPtr.hpp"
  23. #include "AtomicCounter.hpp"
  24. #include "Utils.hpp"
  25. #include "Packet.hpp"
  26. #include "RingBuffer.hpp"
  27. #include "../osdep/Link.hpp"
  28. /**
  29. * Maximum return value of preferenceRank()
  30. */
  31. #define ZT_PATH_MAX_PREFERENCE_RANK ((ZT_INETADDRESS_MAX_SCOPE << 1) | 1)
  32. namespace ZeroTier {
  33. class RuntimeEnvironment;
  34. /**
  35. * A path across the physical network
  36. */
  37. class Path
  38. {
  39. friend class SharedPtr<Path>;
  40. friend class Bond;
  41. public:
  42. /**
  43. * Efficient unique key for paths in a Hashtable
  44. */
  45. class HashKey
  46. {
  47. public:
  48. HashKey() {}
  49. HashKey(const int64_t l,const InetAddress &r)
  50. {
  51. if (r.ss_family == AF_INET) {
  52. _k[0] = (uint64_t)reinterpret_cast<const struct sockaddr_in *>(&r)->sin_addr.s_addr;
  53. _k[1] = (uint64_t)reinterpret_cast<const struct sockaddr_in *>(&r)->sin_port;
  54. _k[2] = (uint64_t)l;
  55. } else if (r.ss_family == AF_INET6) {
  56. memcpy(_k,reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,16);
  57. _k[2] = ((uint64_t)reinterpret_cast<const struct sockaddr_in6 *>(&r)->sin6_port << 32) ^ (uint64_t)l;
  58. } else {
  59. memcpy(_k,&r,std::min(sizeof(_k),sizeof(InetAddress)));
  60. _k[2] += (uint64_t)l;
  61. }
  62. }
  63. inline unsigned long hashCode() const { return (unsigned long)(_k[0] + _k[1] + _k[2]); }
  64. inline bool operator==(const HashKey &k) const { return ( (_k[0] == k._k[0]) && (_k[1] == k._k[1]) && (_k[2] == k._k[2]) ); }
  65. inline bool operator!=(const HashKey &k) const { return (!(*this == k)); }
  66. private:
  67. uint64_t _k[3];
  68. };
  69. Path() :
  70. _lastOut(0),
  71. _lastIn(0),
  72. _lastTrustEstablishedPacketReceived(0),
  73. _localSocket(-1),
  74. _latency(0xffff),
  75. _addr(),
  76. _ipScope(InetAddress::IP_SCOPE_NONE),
  77. _lastAckReceived(0),
  78. _lastAckSent(0),
  79. _lastQoSMeasurement(0),
  80. _lastThroughputEstimation(0),
  81. _lastRefractoryUpdate(0),
  82. _lastAliveToggle(0),
  83. _lastEligibilityState(false),
  84. _lastTrialBegin(0),
  85. _refractoryPeriod(0),
  86. _monitorInterval(0),
  87. _upDelay(0),
  88. _downDelay(0),
  89. _ipvPref(0),
  90. _mode(0),
  91. _onlyPathOnLink(false),
  92. _enabled(false),
  93. _bonded(false),
  94. _negotiated(false),
  95. _deprecated(false),
  96. _shouldReallocateFlows(false),
  97. _assignedFlowCount(0),
  98. _latencyMean(0),
  99. _latencyVariance(0),
  100. _packetLossRatio(0),
  101. _packetErrorRatio(0),
  102. _throughputMean(0),
  103. _throughputMax(0),
  104. _throughputVariance(0),
  105. _allocation(0),
  106. _byteLoad(0),
  107. _relativeByteLoad(0),
  108. _affinity(0),
  109. _failoverScore(0),
  110. _unackedBytes(0),
  111. _packetsReceivedSinceLastAck(0),
  112. _packetsReceivedSinceLastQoS(0),
  113. _bytesAckedSinceLastThroughputEstimation(0),
  114. _packetsIn(0),
  115. _packetsOut(0)
  116. {}
  117. Path(const int64_t localSocket,const InetAddress &addr) :
  118. _lastOut(0),
  119. _lastIn(0),
  120. _lastTrustEstablishedPacketReceived(0),
  121. _localSocket(localSocket),
  122. _latency(0xffff),
  123. _addr(addr),
  124. _ipScope(addr.ipScope()),
  125. _lastAckReceived(0),
  126. _lastAckSent(0),
  127. _lastQoSMeasurement(0),
  128. _lastThroughputEstimation(0),
  129. _lastRefractoryUpdate(0),
  130. _lastAliveToggle(0),
  131. _lastEligibilityState(false),
  132. _lastTrialBegin(0),
  133. _refractoryPeriod(0),
  134. _monitorInterval(0),
  135. _upDelay(0),
  136. _downDelay(0),
  137. _ipvPref(0),
  138. _mode(0),
  139. _onlyPathOnLink(false),
  140. _enabled(false),
  141. _bonded(false),
  142. _negotiated(false),
  143. _deprecated(false),
  144. _shouldReallocateFlows(false),
  145. _assignedFlowCount(0),
  146. _latencyMean(0),
  147. _latencyVariance(0),
  148. _packetLossRatio(0),
  149. _packetErrorRatio(0),
  150. _throughputMean(0),
  151. _throughputMax(0),
  152. _throughputVariance(0),
  153. _allocation(0),
  154. _byteLoad(0),
  155. _relativeByteLoad(0),
  156. _affinity(0),
  157. _failoverScore(0),
  158. _unackedBytes(0),
  159. _packetsReceivedSinceLastAck(0),
  160. _packetsReceivedSinceLastQoS(0),
  161. _bytesAckedSinceLastThroughputEstimation(0),
  162. _packetsIn(0),
  163. _packetsOut(0)
  164. {}
  165. /**
  166. * Called when a packet is received from this remote path, regardless of content
  167. *
  168. * @param t Time of receive
  169. */
  170. inline void received(const uint64_t t) {
  171. if (!alive(t,_bonded)) {
  172. _lastAliveToggle = _lastIn;
  173. }
  174. _lastIn = t;
  175. }
  176. /**
  177. * Set time last trusted packet was received (done in Peer::received())
  178. */
  179. inline void trustedPacketReceived(const uint64_t t) { _lastTrustEstablishedPacketReceived = t; }
  180. /**
  181. * Send a packet via this path (last out time is also updated)
  182. *
  183. * @param RR Runtime environment
  184. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  185. * @param data Packet data
  186. * @param len Packet length
  187. * @param now Current time
  188. * @return True if transport reported success
  189. */
  190. bool send(const RuntimeEnvironment *RR,void *tPtr,const void *data,unsigned int len,int64_t now);
  191. /**
  192. * Manually update last sent time
  193. *
  194. * @param t Time of send
  195. */
  196. inline void sent(const int64_t t) { _lastOut = t; }
  197. /**
  198. * Update path latency with a new measurement
  199. *
  200. * @param l Measured latency
  201. */
  202. inline void updateLatency(const unsigned int l, int64_t now)
  203. {
  204. unsigned int pl = _latency;
  205. if (pl < 0xffff) {
  206. _latency = (pl + l) / 2;
  207. }
  208. else {
  209. _latency = l;
  210. }
  211. }
  212. /**
  213. * @return Local socket as specified by external code
  214. */
  215. inline int64_t localSocket() const { return _localSocket; }
  216. /**
  217. * @return Physical address
  218. */
  219. inline const InetAddress &address() const { return _addr; }
  220. /**
  221. * @return IP scope -- faster shortcut for address().ipScope()
  222. */
  223. inline InetAddress::IpScope ipScope() const { return _ipScope; }
  224. /**
  225. * @return True if path has received a trust established packet (e.g. common network membership) in the past ZT_TRUST_EXPIRATION ms
  226. */
  227. inline bool trustEstablished(const int64_t now) const { return ((now - _lastTrustEstablishedPacketReceived) < ZT_TRUST_EXPIRATION); }
  228. /**
  229. * @return Preference rank, higher == better
  230. */
  231. inline unsigned int preferenceRank() const
  232. {
  233. // This causes us to rank paths in order of IP scope rank (see InetAdddress.hpp) but
  234. // within each IP scope class to prefer IPv6 over IPv4.
  235. return ( ((unsigned int)_ipScope << 1) | (unsigned int)(_addr.ss_family == AF_INET6) );
  236. }
  237. /**
  238. * Check whether this address is valid for a ZeroTier path
  239. *
  240. * This checks the address type and scope against address types and scopes
  241. * that we currently support for ZeroTier communication.
  242. *
  243. * @param a Address to check
  244. * @return True if address is good for ZeroTier path use
  245. */
  246. static inline bool isAddressValidForPath(const InetAddress &a)
  247. {
  248. if ((a.ss_family == AF_INET)||(a.ss_family == AF_INET6)) {
  249. switch(a.ipScope()) {
  250. /* Note: we don't do link-local at the moment. Unfortunately these
  251. * cause several issues. The first is that they usually require a
  252. * device qualifier, which we don't handle yet and can't portably
  253. * push in PUSH_DIRECT_PATHS. The second is that some OSes assign
  254. * these very ephemerally or otherwise strangely. So we'll use
  255. * private, pseudo-private, shared (e.g. carrier grade NAT), or
  256. * global IP addresses. */
  257. case InetAddress::IP_SCOPE_PRIVATE:
  258. case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
  259. case InetAddress::IP_SCOPE_SHARED:
  260. case InetAddress::IP_SCOPE_GLOBAL:
  261. if (a.ss_family == AF_INET6) {
  262. // TEMPORARY HACK: for now, we are going to blacklist he.net IPv6
  263. // tunnels due to very spotty performance and low MTU issues over
  264. // these IPv6 tunnel links.
  265. const uint8_t *ipd = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(&a)->sin6_addr.s6_addr);
  266. if ((ipd[0] == 0x20)&&(ipd[1] == 0x01)&&(ipd[2] == 0x04)&&(ipd[3] == 0x70))
  267. return false;
  268. }
  269. return true;
  270. default:
  271. return false;
  272. }
  273. }
  274. return false;
  275. }
  276. /**
  277. * @return Latency or 0xffff if unknown
  278. */
  279. inline unsigned int latency() const { return _latency; }
  280. /**
  281. * @return Path quality -- lower is better
  282. */
  283. inline long quality(const int64_t now) const
  284. {
  285. const long l = (long)_latency;
  286. const long age = (long)std::min((now - _lastIn),(int64_t)(ZT_PATH_HEARTBEAT_PERIOD * 10)); // set an upper sanity limit to avoid overflow
  287. return (
  288. (
  289. (age < (long)(ZT_PATH_HEARTBEAT_PERIOD + 5000)) ? l : (l + 0xffff + age)
  290. ) * (
  291. ((long)ZT_INETADDRESS_MAX_SCOPE - (long)_ipScope) + (_addr.isV6() ? (long)1 : (long)3)
  292. )
  293. );
  294. }
  295. /**
  296. * @param bonded Whether this path is part of a bond.
  297. */
  298. inline void setBonded(bool bonded) { _bonded = bonded; }
  299. /**
  300. * @return True if this path is currently part of a bond.
  301. */
  302. inline bool bonded() { return _bonded; }
  303. /**
  304. * @return True if this path is alive (receiving heartbeats)
  305. */
  306. inline bool alive(const int64_t now, bool bondingEnabled = false) const {
  307. return (bondingEnabled && _monitorInterval) ? ((now - _lastIn) < (_monitorInterval * 3)) : ((now - _lastIn) < (ZT_PATH_HEARTBEAT_PERIOD + 5000));
  308. }
  309. /**
  310. * @return True if this path needs a heartbeat
  311. */
  312. inline bool needsHeartbeat(const int64_t now) const { return ((now - _lastOut) >= ZT_PATH_HEARTBEAT_PERIOD); }
  313. /**
  314. * @return True if this path needs a heartbeat in accordance to the user-specified path monitor frequency
  315. */
  316. inline bool needsGratuitousHeartbeat(const int64_t now) { return allowed() && (_monitorInterval > 0) && ((now - _lastOut) >= _monitorInterval); }
  317. /**
  318. * @return Last time we sent something
  319. */
  320. inline int64_t lastOut() const { return _lastOut; }
  321. /**
  322. * @return Last time we received anything
  323. */
  324. inline int64_t lastIn() const { return _lastIn; }
  325. /**
  326. * @return the age of the path in terms of receiving packets
  327. */
  328. inline int64_t age(int64_t now) { return (now - _lastIn); }
  329. /**
  330. * @return Time last trust-established packet was received
  331. */
  332. inline int64_t lastTrustEstablishedPacketReceived() const { return _lastTrustEstablishedPacketReceived; }
  333. /**
  334. * @return Time since last VERB_ACK was received
  335. */
  336. inline int64_t ackAge(int64_t now) { return _lastAckReceived ? now - _lastAckReceived : 0; }
  337. /**
  338. * Set or update a refractory period for the path.
  339. *
  340. * @param punishment How much a path should be punished
  341. * @param pathFailure Whether this call is the result of a recent path failure
  342. */
  343. inline void adjustRefractoryPeriod(int64_t now, uint32_t punishment, bool pathFailure) {
  344. if (pathFailure) {
  345. unsigned int suggestedRefractoryPeriod = _refractoryPeriod ? punishment + (_refractoryPeriod * 2) : punishment;
  346. _refractoryPeriod = std::min(suggestedRefractoryPeriod, (unsigned int)ZT_MULTIPATH_MAX_REFRACTORY_PERIOD);
  347. _lastRefractoryUpdate = 0;
  348. } else {
  349. uint32_t drainRefractory = 0;
  350. if (_lastRefractoryUpdate) {
  351. drainRefractory = (now - _lastRefractoryUpdate);
  352. } else {
  353. drainRefractory = (now - _lastAliveToggle);
  354. }
  355. _lastRefractoryUpdate = now;
  356. if (_refractoryPeriod > drainRefractory) {
  357. _refractoryPeriod -= drainRefractory;
  358. } else {
  359. _refractoryPeriod = 0;
  360. _lastRefractoryUpdate = 0;
  361. }
  362. }
  363. }
  364. /**
  365. * Determine the current state of eligibility of the path.
  366. *
  367. * @param includeRefractoryPeriod Whether current punishment should be taken into consideration
  368. * @return True if this path can be used in a bond at the current time
  369. */
  370. inline bool eligible(uint64_t now, int ackSendInterval, bool includeRefractoryPeriod = false) {
  371. if (includeRefractoryPeriod && _refractoryPeriod) {
  372. return false;
  373. }
  374. bool acceptableAge = age(now) < ((_monitorInterval * 4) + _downDelay); // Simple RX age (driven by packets of any type and gratuitous VERB_HELLOs)
  375. bool acceptableAckAge = ackAge(now) < (ackSendInterval); // Whether the remote peer is actually responding to our outgoing traffic or simply sending stuff to us
  376. bool notTooEarly = (now - _lastAliveToggle) >= _upDelay; // Whether we've waited long enough since the link last came online
  377. bool inTrial = (now - _lastTrialBegin) < _upDelay; // Whether this path is still in its trial period
  378. bool currEligibility = allowed() && (((acceptableAge || acceptableAckAge) && notTooEarly) || inTrial);
  379. return currEligibility;
  380. }
  381. /**
  382. * Record when this path first entered the bond. Each path is given a trial period where it is admitted
  383. * to the bond without requiring observations to prove its performance or reliability.
  384. */
  385. inline void startTrial(uint64_t now) { _lastTrialBegin = now; }
  386. /**
  387. * @return True if a path is permitted to be used in a bond (according to user pref.)
  388. */
  389. inline bool allowed() {
  390. return _enabled
  391. && (!_ipvPref
  392. || ((_addr.isV4() && (_ipvPref == 4 || _ipvPref == 46 || _ipvPref == 64))
  393. || ((_addr.isV6() && (_ipvPref == 6 || _ipvPref == 46 || _ipvPref == 64)))));
  394. }
  395. /**
  396. * @return True if a path is preferred over another on the same physical link (according to user pref.)
  397. */
  398. inline bool preferred() {
  399. return _onlyPathOnLink
  400. || (_addr.isV4() && (_ipvPref == 4 || _ipvPref == 46))
  401. || (_addr.isV6() && (_ipvPref == 6 || _ipvPref == 64));
  402. }
  403. /**
  404. * @param now Current time
  405. * @return Whether an ACK (VERB_ACK) packet needs to be emitted at this time
  406. */
  407. inline bool needsToSendAck(int64_t now, int ackSendInterval) {
  408. return ((now - _lastAckSent) >= ackSendInterval ||
  409. (_packetsReceivedSinceLastAck == ZT_QOS_TABLE_SIZE)) && _packetsReceivedSinceLastAck;
  410. }
  411. /**
  412. * @param now Current time
  413. * @return Whether a QoS (VERB_QOS_MEASUREMENT) packet needs to be emitted at this time
  414. */
  415. inline bool needsToSendQoS(int64_t now, int qosSendInterval) {
  416. return ((_packetsReceivedSinceLastQoS >= ZT_QOS_TABLE_SIZE) ||
  417. ((now - _lastQoSMeasurement) > qosSendInterval)) && _packetsReceivedSinceLastQoS;
  418. }
  419. /**
  420. * Reset packet counters
  421. */
  422. inline void resetPacketCounts()
  423. {
  424. _packetsIn = 0;
  425. _packetsOut = 0;
  426. }
  427. private:
  428. volatile int64_t _lastOut;
  429. volatile int64_t _lastIn;
  430. volatile int64_t _lastTrustEstablishedPacketReceived;
  431. int64_t _localSocket;
  432. volatile unsigned int _latency;
  433. InetAddress _addr;
  434. InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often
  435. AtomicCounter __refCount;
  436. std::map<uint64_t,uint64_t> qosStatsOut; // id:egress_time
  437. std::map<uint64_t,uint64_t> qosStatsIn; // id:now
  438. std::map<uint64_t,uint16_t> ackStatsIn; // id:len
  439. RingBuffer<int,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> qosRecordSize;
  440. RingBuffer<float,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> qosRecordLossSamples;
  441. RingBuffer<uint64_t,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> throughputSamples;
  442. RingBuffer<bool,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> packetValiditySamples;
  443. RingBuffer<float,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> _throughputVarianceSamples;
  444. RingBuffer<uint16_t,ZT_QOS_SHORTTERM_SAMPLE_WIN_SIZE> latencySamples;
  445. /**
  446. * Last time that a VERB_ACK was received on this path.
  447. */
  448. uint64_t _lastAckReceived;
  449. /**
  450. * Last time that a VERB_ACK was sent out on this path.
  451. */
  452. uint64_t _lastAckSent;
  453. /**
  454. * Last time that a VERB_QOS_MEASUREMENT was sent out on this path.
  455. */
  456. uint64_t _lastQoSMeasurement;
  457. /**
  458. * Last time that the path's throughput was estimated.
  459. */
  460. uint64_t _lastThroughputEstimation;
  461. /**
  462. * The last time that the refractory period was updated.
  463. */
  464. uint64_t _lastRefractoryUpdate;
  465. /**
  466. * The last time that the path was marked as "alive".
  467. */
  468. uint64_t _lastAliveToggle;
  469. /**
  470. * State of eligibility at last check. Used for determining state changes.
  471. */
  472. bool _lastEligibilityState;
  473. /**
  474. * Timestamp indicating when this path's trial period began.
  475. */
  476. uint64_t _lastTrialBegin;
  477. /**
  478. * Amount of time that this path will be prevented from becoming a member of a bond.
  479. */
  480. uint32_t _refractoryPeriod;
  481. /**
  482. * Monitor interval specific to this path or that was inherited from the bond controller.
  483. */
  484. int32_t _monitorInterval;
  485. /**
  486. * Up delay interval specific to this path or that was inherited from the bond controller.
  487. */
  488. uint32_t _upDelay;
  489. /**
  490. * Down delay interval specific to this path or that was inherited from the bond controller.
  491. */
  492. uint32_t _downDelay;
  493. /**
  494. * IP version preference inherited from the physical link.
  495. */
  496. uint8_t _ipvPref;
  497. /**
  498. * Mode inherited from the physical link.
  499. */
  500. uint8_t _mode;
  501. /**
  502. * IP version preference inherited from the physical link.
  503. */
  504. bool _onlyPathOnLink;
  505. /**
  506. * Enabled state inherited from the physical link.
  507. */
  508. bool _enabled;
  509. /**
  510. * Whether this path is currently part of a bond.
  511. */
  512. bool _bonded;
  513. /**
  514. * Whether this path was intentionally negotiated by either peer.
  515. */
  516. bool _negotiated;
  517. /**
  518. * Whether this path has been deprecated due to performance issues. Current traffic flows
  519. * will be re-allocated to other paths in the most non-disruptive manner (if possible),
  520. * and new traffic will not be allocated to this path.
  521. */
  522. bool _deprecated;
  523. /**
  524. * Whether flows should be moved from this path. Current traffic flows will be re-allocated
  525. * immediately.
  526. */
  527. bool _shouldReallocateFlows;
  528. /**
  529. * The number of flows currently assigned to this path.
  530. */
  531. uint16_t _assignedFlowCount;
  532. /**
  533. * The mean latency (computed from a sliding window.)
  534. */
  535. float _latencyMean;
  536. /**
  537. * Packet delay variance (computed from a sliding window.)
  538. */
  539. float _latencyVariance;
  540. /**
  541. * The ratio of lost packets to received packets.
  542. */
  543. float _packetLossRatio;
  544. /**
  545. * The ratio of packets that failed their MAC/CRC checks to those that did not.
  546. */
  547. float _packetErrorRatio;
  548. /**
  549. * The estimated mean throughput of this path.
  550. */
  551. uint64_t _throughputMean;
  552. /**
  553. * The maximum observed throughput of this path.
  554. */
  555. uint64_t _throughputMax;
  556. /**
  557. * The variance in the estimated throughput of this path.
  558. */
  559. float _throughputVariance;
  560. /**
  561. * The relative quality of this path to all others in the bond, [0-255].
  562. */
  563. uint8_t _allocation;
  564. /**
  565. * How much load this path is under.
  566. */
  567. uint64_t _byteLoad;
  568. /**
  569. * How much load this path is under (relative to other paths in the bond.)
  570. */
  571. uint8_t _relativeByteLoad;
  572. /**
  573. * Relative value expressing how "deserving" this path is of new traffic.
  574. */
  575. uint8_t _affinity;
  576. /**
  577. * Score that indicates to what degree this path is preferred over others that
  578. * are available to the bonding policy. (specifically for active-backup)
  579. */
  580. uint32_t _failoverScore;
  581. /**
  582. * Number of bytes thus far sent that have not been acknowledged by the remote peer.
  583. */
  584. int64_t _unackedBytes;
  585. /**
  586. * Number of packets received since the last VERB_ACK was sent to the remote peer.
  587. */
  588. int32_t _packetsReceivedSinceLastAck;
  589. /**
  590. * Number of packets received since the last VERB_QOS_MEASUREMENT was sent to the remote peer.
  591. */
  592. int32_t _packetsReceivedSinceLastQoS;
  593. /**
  594. * Bytes acknowledged via incoming VERB_ACK since the last estimation of throughput.
  595. */
  596. uint64_t _bytesAckedSinceLastThroughputEstimation;
  597. /**
  598. * Counters used for tracking path load.
  599. */
  600. int _packetsIn;
  601. int _packetsOut;
  602. };
  603. } // namespace ZeroTier
  604. #endif