@@ -55,6 +55,7 @@ function _install_raspap() {
5555 _install_lighttpd_configs
5656 _default_configuration
5757 _configure_networking
58+ _prompt_configure_tcp_bbr
5859 _prompt_install_features
5960 _install_extra_features
6061 _patch_system_files
@@ -788,6 +789,67 @@ function _configure_networking() {
788789 _install_status 0
789790 }
790791
792+ # Prompt to configure TCP BBR option
793+ function _prompt_configure_tcp_bbr() {
794+ _install_log " Configure TCP BBR congestion control"
795+ echo " Network performance can be improved by changing TCP congestion control to BBR (Bottleneck Bandwidth and RTT)"
796+ echo -n " Enable TCP BBR congestion control algorithm (Recommended)? [Y/n]: "
797+ if [ " $assume_yes " == 0 ]; then
798+ read answer < /dev/tty
799+ if [ " $answer " != " ${answer# [Nn]} " ]; then
800+ _install_status 0 " (Skipped)"
801+ else
802+ _configure_tcp_bbr
803+ fi
804+ elif [ " ${bbr_option} " == 1 ]; then
805+ _configure_tcp_bbr
806+ else
807+ echo " (Skipped)"
808+ fi
809+ }
810+
811+ function _configure_tcp_bbr() {
812+ echo " Checking kernel support for the TCP BBR algorithm..."
813+ _check_tcp_bbr_available
814+ if [ $? -eq 0 ]; then
815+ echo " TCP BBR option found. Enabling configuration"
816+ # Load the BBR module
817+ echo " Loading BBR kernel module"
818+ sudo modprobe tcp_bbr || _install_status 1 " Unable to execute modprobe tcp_bbr"
819+ # Add BBR configuration to sysctl.conf if not present
820+ echo " Adding BBR configuration to /etc/sysctl.conf if not present"
821+ if ! grep -q " net.core.default_qdisc=fq" /etc/sysctl.conf; then
822+ echo " net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf || _install_status 1 " Unable to modify /etc/sysctl.conf"
823+ fi
824+ if ! grep -q " net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then
825+ echo " net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf || _install_status 1 " Unable to modify /etc/sysctl.conf"
826+ fi
827+ # Apply the sysctl changes
828+ echo " Applying changes"
829+ sudo sysctl -p || _install_status 1 " Unable to execute sysctl"
830+
831+ # Verify if BBR is enabled
832+ cc=$( sysctl net.ipv4.tcp_congestion_control | awk ' {print $3}' )
833+ if [ " $cc " == " bbr" ]; then
834+ echo " TCP BBR successfully enabled"
835+ else
836+ _install_status 1 " Failed to enable TCP BBR"
837+ fi
838+ else
839+ _install_status 2 " TCP BBR option is not available (Skipped)"
840+ fi
841+ _install_status 0
842+ }
843+
844+ function _check_tcp_bbr_available() {
845+ config_file=" /boot/config-$( uname -r) "
846+ if grep -q ' CONFIG_TCP_CONG_BBR' " $config_file " && grep -q ' CONFIG_NET_SCH_FQ' " $config_file " ; then
847+ return 0
848+ else
849+ return 1
850+ fi
851+ }
852+
791853# Add sudoers file to /etc/sudoers.d/ and set file permissions
792854function _patch_system_files() {
793855
0 commit comments