#!/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 setglobal URL = ''www.google.com'' if test $1 != "" { setglobal URL = $1 } #Import DietPi-Globals --------------------------------------------------------------- source /DietPi/dietpi/func/dietpi-globals export G_PROGRAM_NAME='DietPi-Optimal_mtu' #Import DietPi-Globals --------------------------------------------------------------- setglobal MTU_SIZE = '1500' setglobal TEST_MTU_SIZE = '0' setglobal 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 setglobal TEST_MTU_SIZE = $shExpr(' $MTU_SIZE - 28 ') echo -e "Testing MTU: $MTU_SIZE" if sh-expr ' $(ping -c 1 -s $TEST_MTU_SIZE -M do $URL | grep -ci -m1 '+1 error') == 0 '{ setglobal SUCCESS = '1' echo -e "\nCompleted:\n - MTU optimal size = $MTU_SIZE\n" } elif sh-expr ' $MTU_SIZE <= 0 ' { echo -e "\nERROR:\n - Failed to find MTU size\n" } else { sh-expr 'MTU_SIZE--' } } #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- }