#!/bin/bash do { #//////////////////////////////////// # DietPi # #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com #//////////////////////////////////// # # Info: # - Obtains the optimal MTU size. # # Usage: # - dietpi-optimal_mtu | Tests using google.com # - dietpi-optimal_mtu URL/IP address | Tests using the provided URL/IP #//////////////////////////////////// #Grab Input setvar URL = ''www.google.com'' if test $1 != "" { setvar URL = "$1" } #Import DietPi-Globals --------------------------------------------------------------- source /DietPi/dietpi/func/dietpi-globals export G_PROGRAM_NAME='DietPi-Optimal_mtu' #Import DietPi-Globals --------------------------------------------------------------- setvar MTU_SIZE = '1500' setvar TEST_MTU_SIZE = '0' setvar SUCCESS = '0' #----------------------------------------------------------------------------------- echo -e "DietPi - MTU optimal size tool\n - Finding optimal MTU size, please wait..." while (($SUCCESS == 0)) { #remove ipv4 icmp headers from total size setvar TEST_MTU_SIZE = $(( $MTU_SIZE - 28 )) echo -e "Testing MTU: $MTU_SIZE" if (( $(ping -c 1 -s $TEST_MTU_SIZE -M do $URL | grep -ci -m1 '+1 error') == 0 )){ setvar SUCCESS = '1' echo -e "\nCompleted:\n - MTU optimal size = $MTU_SIZE\n" } elif (( $MTU_SIZE <= 0 )) { echo -e "\nERROR:\n - Failed to find MTU size\n" } else { ((MTU_SIZE--)) } } #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- }