Merge pull request #103 from greatest-ape/work-2022-11-01

improve udp bandwidth statistics, improve changelog
This commit is contained in:
Joakim Frostegård 2022-11-01 18:42:56 +01:00 committed by GitHub
commit e45a20cb30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 30 deletions

View file

@ -4,42 +4,78 @@
### Added
#### General
* Add cli flag for printing parsed config
* Add `aquatic_http_private`, an experiment for integrating with private trackers
* _aquatic_udp_: implement optional response resend buffer
* _aquatic_udp_: add optional extended statistics
* _aquatic_udp_: add Dockerfile to make it easier to get started
* _aquatic_ws_: add HTTP health check route when running without TLS
#### aquatic_udp
* Add optional response resend buffer for use on on operating systems that
don't buffer outgoing UDP traffic
* Add optional extended statistics
* Add Dockerfile to make it easier to get started
#### aquatic_ws
* Add HTTP health check route when running without TLS
### Changed
#### General
* Rename request workers to swarm workers
* Switch to thin LTO for faster compile times
* Use proper workspace path declarations and remove workspace patch section
* Use proper workspace path declarations instead of workspace patch section
* Use [Rust 1.64 workspace inheritance](https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html)
* Reduce space taken by ValidUntil struct from 128 to 32 bits, reducing memory
consumtion for each stored peer by same amount
* Use regular (non-amortized) IndexMap for peer and pending scrape response maps (but not for torrent maps)
consumption for each stored peer by same amount
* Use regular (non-amortized) IndexMap for peer and pending scrape response
maps (but not for torrent maps)
* Improve privilege dropping
* Quit whole program if any thread panics
* Update dependencies
* _aquatic_udp_: replace ConnectionMap with BLAKE3-based connection validator,
greatly decreasing memory consumtion
* _aquatic_udp_: don't return any response peers if announce event is stopped
* _aquatic_udp_: ignore requests with source port value of zero
* _aquatic_http_: don't return any response peers if announce event is stopped
* _aquatic_ws_: reduce size of various structs
* _aquatic_ws_: make TLS optional
* _aquatic_ws_: support reverse proxies
#### aquatic_udp
* Replace ConnectionMap with BLAKE3-based connection validator, greatly
decreasing memory consumtion
* Don't return any response peers if announce event is stopped
* Ignore requests with source port value of zero
#### aquatic_http
* Don't return any response peers if announce event is stopped
#### aquatic_ws
* Make TLS optional
* Support reverse proxies
* Reduce size of various structs
### Fixed
#### General
* Forbid unrecognized keys when parsing config files
* Fix warnings from invalid avx512 key included in `./scripts/env-native-cpu-without-avx-512`
* _aquatic_http_protocol_: explicity check for /scrape path
* _aquatic_http_protocol_: return NeedMoreData until headers are fully parsed
* _aquatic_http_protocol_: fix issues with ScrapeRequest::write and AnnounceRequest::write
* _aquatic_http_protocol_: expose write and parse methods for subtypes
* _aquatic_http_load_test_: exclusively use TLS 1.3
* _aquatic_ws_: remove peer from swarms immediately when connection is closed
* _aquatic_ws_: allow peers to use multiple peer IDs, as long as they only use one per info hash
* Stop including invalid avx512 key in `./scripts/env-native-cpu-without-avx-512`
#### aquatic_udp
* When calculating bandwidth statistics, include size of protocol headers
#### aquatic_http_protocol
* Explicity check for /scrape path
* Return NeedMoreData until headers are fully parsed
* Fix issues with ScrapeRequest::write and AnnounceRequest::write
* Expose write and parse methods for subtypes
#### aquatic_http_load_test
* Exclusively use TLS 1.3
#### aquatic_ws
* Remove peer from swarms immediately when connection is closed
* Allow peers to use multiple peer IDs, as long as they only use one per info hash

View file

@ -25,6 +25,24 @@ use crate::config::Config;
use storage::PendingScrapeResponseSlab;
use validator::ConnectionValidator;
/// Bytes of data transmitted when sending an IPv4 UDP packet, in addition to payload size
///
/// Consists of:
/// - 8 bit ethernet frame
/// - 14 + 4 bit MAC header and checksum
/// - 20 bit IPv4 header
/// - 8 bit udp header
const EXTRA_PACKET_SIZE_IPV4: usize = 8 + 18 + 20 + 8;
/// Bytes of data transmitted when sending an IPv4 UDP packet, in addition to payload size
///
/// Consists of:
/// - 8 bit ethernet frame
/// - 14 + 4 bit MAC header and checksum
/// - 40 bit IPv6 header
/// - 8 bit udp header
const EXTRA_PACKET_SIZE_IPV6: usize = 8 + 18 + 40 + 8;
pub struct SocketWorker {
config: Config,
shared_state: State,
@ -241,12 +259,12 @@ impl SocketWorker {
if request_parsable {
requests_received_ipv4 += 1;
}
bytes_received_ipv4 += bytes_read;
bytes_received_ipv4 += bytes_read + EXTRA_PACKET_SIZE_IPV4;
} else {
if request_parsable {
requests_received_ipv6 += 1;
}
bytes_received_ipv6 += bytes_read;
bytes_received_ipv6 += bytes_read + EXTRA_PACKET_SIZE_IPV6;
}
}
Err(err) if err.kind() == ErrorKind::WouldBlock => {
@ -379,12 +397,22 @@ impl SocketWorker {
match socket.send_to(&cursor.get_ref()[..bytes_written], addr) {
Ok(amt) if config.statistics.active() => {
let stats = if canonical_addr.is_ipv4() {
&shared_state.statistics_ipv4
} else {
&shared_state.statistics_ipv6
};
let stats = &shared_state.statistics_ipv4;
stats.bytes_sent.fetch_add(amt, Ordering::Relaxed);
stats
.bytes_sent
.fetch_add(amt + EXTRA_PACKET_SIZE_IPV4, Ordering::Relaxed);
stats
} else {
let stats = &shared_state.statistics_ipv6;
stats
.bytes_sent
.fetch_add(amt + EXTRA_PACKET_SIZE_IPV6, Ordering::Relaxed);
stats
};
match response {
Response::Connect(_) => {