summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-13 15:14:03 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-13 15:14:03 -0400
commitfc18334dbbd4445a208ed1dcbe4070feaa385ce3 (patch)
treeecfc33f77db407ec6f83b1679dd6f36c65be8098
parent4ce88d7f725626a42a217412788905aa00c7ce6a (diff)
downloadinfinitytier-fc18334dbbd4445a208ed1dcbe4070feaa385ce3.tar.gz
infinitytier-fc18334dbbd4445a208ed1dcbe4070feaa385ce3.zip
Version 0.4.3 (the real one): fix Gentoo ip config failures and crashes
This version fixes problems with locating the 'ip' command on Gentoo and possibly other Linux systems, and a problem that could cause a crash if EthernetTap was unable to locate one of the commands it invokes to configure IP information on tap devices. The code also now builds on Windows. It doesn't run yet, but it's a step. Windows port is in full swing. Finally, the multicast rate limit defaults were raised a little. More testing is needed here, and real world measurments.
-rw-r--r--node/Constants.hpp8
-rw-r--r--node/RateLimiter.hpp9
-rw-r--r--selftest.cpp29
3 files changed, 42 insertions, 4 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 20ec0a6b..f92540d6 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -284,22 +284,22 @@ error_no_ZT_ARCH_defined;
/**
* Default bytes per second limit for multicasts per peer on a network
*/
-#define ZT_MULTICAST_DEFAULT_BYTES_PER_SECOND 50.0
+#define ZT_MULTICAST_DEFAULT_BYTES_PER_SECOND 100.0
/**
* Default balance preload for multicast rate limiters on a network
*/
-#define ZT_MULTICAST_DEFAULT_RATE_PRELOAD 20000.0
+#define ZT_MULTICAST_DEFAULT_RATE_PRELOAD 25000.0
/**
* Default maximum balance for multicast rate limiters
*/
-#define ZT_MULTICAST_DEFAULT_RATE_MAX_BALANCE 20000.0
+#define ZT_MULTICAST_DEFAULT_RATE_MAX_BALANCE 25000.0
/**
* Default minimum balance for multicast rate limiters (max debt)
*/
-#define ZT_MULTICAST_DEFAULT_RATE_MIN_BALANCE -10000.0
+#define ZT_MULTICAST_DEFAULT_RATE_MIN_BALANCE -5000.0
/**
* Delay between scans of the topology active peer DB for peers that need ping
diff --git a/node/RateLimiter.hpp b/node/RateLimiter.hpp
index 69d47d0a..e5403717 100644
--- a/node/RateLimiter.hpp
+++ b/node/RateLimiter.hpp
@@ -135,6 +135,15 @@ public:
return allow;
}
+ /**
+ * @return Current balance
+ */
+ inline double balance() const
+ throw()
+ {
+ return _balance;
+ }
+
private:
double _lastTime;
double _balance;
diff --git a/selftest.cpp b/selftest.cpp
index cf4635b7..0792c1ee 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -33,6 +33,7 @@
#include <string>
#include <vector>
+#include "node/Constants.hpp"
#include "node/InetAddress.hpp"
#include "node/EllipticCurveKey.hpp"
#include "node/EllipticCurveKeyPair.hpp"
@@ -46,6 +47,7 @@
#include "node/Condition.hpp"
#include "node/NodeConfig.hpp"
#include "node/Dictionary.hpp"
+#include "node/RateLimiter.hpp"
#include <openssl/rand.h>
@@ -366,6 +368,32 @@ static int testOther()
return 0;
}
+static int testRateLimiter()
+{
+ RateLimiter limiter;
+ RateLimiter::Limit limit;
+
+ std::cout << "[ratelimiter] preload: 10000.0, rate: 1000.0/sec, max: 15000.0, min: -7500.0" << std::endl;
+ limit.bytesPerSecond = 1000.0;
+ limit.maxBalance = 15000.0;
+ limit.minBalance = -7500.0;
+ limiter.init(10000.0);
+ for(int i=0;i<25;++i) {
+ Thread::sleep(100);
+ std::cout << "[ratelimiter] delayed 0.1s, gate(1000.0): " << (limiter.gate(limit,1000.0) ? "OK" : "BLOCK");
+ std::cout << " (new balance afterwords: " << limiter.balance() << ")" << std::endl;
+ }
+ std::cout << "[ratelimiter] delaying 15s..." << std::endl;
+ Thread::sleep(15000);
+ for(int i=0;i<20;++i) {
+ Thread::sleep(1000);
+ std::cout << "[ratelimiter] delayed 1s, gate(2000.0): " << (limiter.gate(limit,2000.0) ? "OK" : "BLOCK");
+ std::cout << " (new balance afterwords: " << limiter.balance() << ")" << std::endl;
+ }
+
+ return 0;
+}
+
int main(int argc,char **argv)
{
int r = 0;
@@ -377,6 +405,7 @@ int main(int argc,char **argv)
r |= testPacket();
r |= testOther();
r |= testIdentity();
+ r |= testRateLimiter();
if (r)
std::cout << std::endl << "SOMETHING FAILED!" << std::endl;