Browse Source

Tweak metric and clean out attic a bit.

Adam Ierymenko 9 years ago
parent
commit
0e26917c72
4 changed files with 1 additions and 218 deletions
  1. 0 153
      attic/BandwidthAccount.hpp
  2. 0 32
      attic/decrypt
  3. 0 32
      attic/encrypt
  4. 1 1
      service/OneService.cpp

+ 0 - 153
attic/BandwidthAccount.hpp

@@ -1,153 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015  ZeroTier, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * ZeroTier may be used and distributed under the terms of the GPLv3, which
- * are available at: http://www.gnu.org/licenses/gpl-3.0.html
- *
- * If you would like to embed ZeroTier into a commercial application or
- * redistribute it in a modified binary form, please contact ZeroTier Networks
- * LLC. Start here: http://www.zerotier.com/
- */
-
-#ifndef ZT_BWACCOUNT_HPP
-#define ZT_BWACCOUNT_HPP
-
-#include "Constants.hpp"
-
-#include <algorithm>
-
-#include <stdint.h>
-#include <math.h>
-
-#include "Utils.hpp"
-
-#ifdef __WINDOWS__
-#define	round(x) ((x-floor(x))>0.5 ? ceil(x) : floor(x))
-#endif
-
-namespace ZeroTier {
-
-/**
- * Bandwidth account used for rate limiting multicast groups
- *
- * This is used to apply a bank account model to multicast groups. Each
- * multicast packet counts against a balance, which accrues at a given
- * rate in bytes per second. Debt is possible. These parameters are
- * configurable.
- *
- * A bank account model permits bursting behavior, which correctly models
- * how OSes and apps typically use multicast. It's common for things to
- * spew lots of multicast messages at once, wait a while, then do it
- * again. A consistent bandwidth limit model doesn't fit.
- */
-class BandwidthAccount
-{
-public:
-	/**
-	 * Create an uninitialized account
-	 *
-	 * init() must be called before this is used.
-	 */
-	BandwidthAccount() throw() {}
-
-	/**
-	 * Create and initialize
-	 *
-	 * @param preload Initial balance to place in account
-	 * @param maxb Maximum allowed balance (> 0)
-	 * @param acc Rate of accrual in bytes per second
-	 * @param now Current time
-	 */
-	BandwidthAccount(uint32_t preload,uint32_t maxb,uint32_t acc,uint64_t now)
-		throw()
-	{
-		init(preload,maxb,acc,now);
-	}
-
-	/**
-	 * Initialize or re-initialize account
-	 *
-	 * @param preload Initial balance to place in account
-	 * @param maxb Maximum allowed balance (> 0)
-	 * @param acc Rate of accrual in bytes per second
-	 * @param now Current time
-	 */
-	inline void init(uint32_t preload,uint32_t maxb,uint32_t acc,uint64_t now)
-		throw()
-	{
-		_lastTime = ((double)now / 1000.0);
-		_balance = preload;
-		_maxBalance = maxb;
-		_accrual = acc;
-	}
-
-	/**
-	 * Update and retrieve balance of this account
-	 *
-	 * @param now Current time
-	 * @return New balance updated from current clock
-	 */
-	inline uint32_t update(uint64_t now)
-		throw()
-	{
-		double lt = _lastTime;
-		double nowf = ((double)now / 1000.0);
-		_lastTime = nowf;
-		return (_balance = std::min(_maxBalance,(uint32_t)round((double)_balance + ((double)_accrual * (nowf - lt)))));
-	}
-
-	/**
-	 * Update balance and conditionally deduct
-	 *
-	 * If the deduction amount fits, it is deducted after update. Otherwise
-	 * balance is updated and false is returned.
-	 *
-	 * @param amt Amount to deduct
-	 * @param now Current time
-	 * @return True if amount fit within balance and was deducted
-	 */
-	inline bool deduct(uint32_t amt,uint64_t now)
-		throw()
-	{
-		if (update(now) >= amt) {
-			_balance -= amt;
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * @return Most recent balance without update
-	 */
-	inline uint32_t balance() const
-		throw()
-	{
-		return _balance;
-	}
-
-private:
-	double _lastTime;
-	uint32_t _balance;
-	uint32_t _maxBalance;
-	uint32_t _accrual;
-};
-
-} // namespace ZeroTier
-
-#endif

+ 0 - 32
attic/decrypt

@@ -1,32 +0,0 @@
-#!/bin/bash
-
-export PATH=/bin:/usr/bin
-
-if [ ! -e /usr/bin/openssl ]; then
-	echo $0: requires /usr/bin/openssl, please install openssl tools
-	exit 1
-fi
-
-if [ "$#" -lt 1 ]; then
-	echo $0: Usage: $0 '<input>' '[output]'
-	exit 1
-fi
-
-if [ ! -r "$1" ]; then
-	echo $0: $1 does not exist or is not readable.
-	exit 1
-fi
-
-outpath=`echo "$1" | sed 's/[.]aes$//'`
-if [ "$#" -ge 2 ]; then
-	outpath="$2"
-fi
-
-if [ -f "$outpath" ]; then
-	echo $0: $outpath already exists, delete or rename first.
-	exit 1
-fi
-
-openssl aes-256-cbc -d -salt -in "$1" -out "$outpath"
-
-echo $0: wrote "$outpath"

+ 0 - 32
attic/encrypt

@@ -1,32 +0,0 @@
-#!/bin/bash
-
-export PATH=/bin:/usr/bin
-
-if [ ! -e /usr/bin/openssl ]; then
-	echo $0: requires /usr/bin/openssl, please install openssl tools
-	exit 1
-fi
-
-if [ "$#" -lt 1 ]; then
-	echo $0: Usage: $0 '<input>' '[output]'
-	exit 1
-fi
-
-if [ ! -r "$1" ]; then
-	echo $0: $1 does not exist or is not readable.
-	exit 1
-fi
-
-outpath="$1.aes"
-if [ "$#" -ge 2 ]; then
-	outpath="$2"
-fi
-
-if [ -f "$outpath" ]; then
-	echo $0: $outpath already exists, delete or rename first.
-	exit 1
-fi
-
-openssl aes-256-cbc -salt -in "$1" -out "$outpath"
-
-echo $0: wrote "$outpath"

+ 1 - 1
service/OneService.cpp

@@ -115,7 +115,7 @@ namespace ZeroTier { typedef BSDEthernetTap EthernetTap; }
 #define ZT_MAX_HTTP_CONNECTIONS 64
 #define ZT_MAX_HTTP_CONNECTIONS 64
 
 
 // Interface metric for ZeroTier taps
 // Interface metric for ZeroTier taps
-#define ZT_IF_METRIC 32768
+#define ZT_IF_METRIC 5000
 
 
 // How often to check for new multicast subscriptions on a tap device
 // How often to check for new multicast subscriptions on a tap device
 #define ZT_TAP_CHECK_MULTICAST_INTERVAL 5000
 #define ZT_TAP_CHECK_MULTICAST_INTERVAL 5000