Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking Performance Optimisations #115

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
46a44e8
create network optimisation sysctl
raja-grewal Jul 25, 2022
d0d4ecd
increase the size of the receive queue
raja-grewal Jul 25, 2022
b8eefc8
increase the maximum number of connections
raja-grewal Jul 25, 2022
32e8b82
increase memory dedicated to the network interfaces
raja-grewal Jul 25, 2022
cc9f973
increase the default UDP limits
raja-grewal Jul 25, 2022
9fd84f0
enable TCP Fast Open
raja-grewal Jul 25, 2022
9577c6e
raise maximum queue length of pending connections
raja-grewal Jul 25, 2022
1e1cafa
raise maximum number of sockets in TIME_WAIT state
raja-grewal Jul 25, 2022
e2198e0
let TCP reuse an existing connection in the TIME-WAIT state
raja-grewal Jul 25, 2022
7070470
reduce reconds to wait for a final FIN packet
raja-grewal Jul 25, 2022
446d5e3
disable TCP slow start
raja-grewal Jul 25, 2022
031abae
reduce the TCP keepalive period
raja-grewal Jul 25, 2022
0a52793
enable MTU probing when a ICMP black hole detected
raja-grewal Jul 25, 2022
4c42c9b
Update README.md
raja-grewal Jul 25, 2022
141dee5
Merge branch 'Kicksecure:master' into network
raja-grewal Jul 28, 2022
2c9048d
Merge branch 'Kicksecure:master' into network
raja-grewal Aug 15, 2022
d24ed18
Merge branch 'Kicksecure:master' into network
raja-grewal Sep 14, 2022
ef2fbde
Revert enabling MTU probing when a ICMP black hole is detected
raja-grewal Oct 4, 2022
bc13505
Merge branch 'Kicksecure:master' into network
raja-grewal Dec 13, 2022
fa75555
Merge branch 'Kicksecure:master' into network
raja-grewal Dec 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -200,6 +200,22 @@ dropping RST packets for sockets in the time-wait state.
* Reverse path filtering is enabled to prevent IP spoofing and mitigate
vulnerabilities such as CVE-2019-14899.

## Network optimisation

* Increases the size of the receive queue and the number of maximum connections.

* Increases memory dedicated to the network interfaces.

* Raises the default UDP limits.

* Enable TCP Fast Open to reduce network latency.

* Raise the number of pending connections in order to be more resistant to simple DoS attack.

* Disables TCP slow start after idle.

* Reduces the TCP keepalive time.

## Entropy collection improvements

* The `jitterentropy_rng` kernel module is loaded as early as possible
Expand Down
56 changes: 56 additions & 0 deletions etc/sysctl.d/30_network-opt.conf
@@ -0,0 +1,56 @@
## Copyright (C) 2019 - 2022 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## Improvements in networking performance largely based on Arch's recommendations
## https://wiki.archlinux.org/title/sysctl#Improving_performance

## Increasing the size of the receive queue
net.core.netdev_max_backlog=16384

## Increase the maximum number of connections
net.core.somaxconn=8192

## Increase memory dedicated to the network interfaces
## Set max cache size (in bytes) to 16MB
## These settings are for extremely fast connections and likely allocate excessive memory for typical networks
## https://blog.cloudflare.com/the-story-of-one-latency-spike/
## https://github.com/redhat-performance/tuned/blob/master/profiles/network-throughput/tuned.conf#L10
## https://nateware.com/2013/04/06/linux-network-tuning-for-2013/
net.core.rmem_default=1048576
net.core.rmem_max=16777216
net.core.wmem_default=1048576
net.core.wmem_max=16777216
net.core.optmem_max=65536
net.ipv4.tcp_rmem=4096 1048576 2097152
net.ipv4.tcp_wmem=4096 65536 16777216

## Increase the default UDP limits
net.ipv4.udp_rmem_min=8192
net.ipv4.udp_wmem_min=8192

## Enable TCP Fast Open for both incoming and outgoing connections
## https://www.keycdn.com/support/tcp-fast-open
net.ipv4.tcp_fastopen=3

## Raise maximum queue length of pending connections
net.ipv4.tcp_max_syn_backlog=8192

## Raise maximum number of sockets in TIME_WAIT state
net.ipv4.tcp_max_tw_buckets=2000000

## Let TCP reuse an existing connection in the TIME-WAIT state
net.ipv4.tcp_tw_reuse=1

## Seconds to wait for a final FIN packet before the socket is forcibly closed
net.ipv4.tcp_fin_timeout=10

## Disable TCP slow start
## https://en.wikipedia.org/wiki/TCP_congestion_control#Slow_start
net.ipv4.tcp_slow_start_after_idle=0

## Change TCP keepalive parameters
## Reduces the TCP keepalive period from 2 hours to 2 minutes
## https://en.wikipedia.org/wiki/Keepalive#TCP_keepalive
net.ipv4.tcp_keepalive_time=60
net.ipv4.tcp_keepalive_intvl=10
net.ipv4.tcp_keepalive_probes=6