test_mtu.sh 844 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Run script with sudo!
  3. # NOTE: Rebuild IAP with DUMMY_PROG option enabled to skip any read/write ioperations during the test.
  4. ETH=enp5s0
  5. IP=$1
  6. MTU_MIN=400
  7. MTU_MAX=1500
  8. total=()
  9. failed=()
  10. success=()
  11. echo "Test MTUs: $MTU_MIN - $MTU_MAX"
  12. for (( size=$MTU_MIN; size<=$MTU_MAX; size++ ))
  13. do
  14. ifconfig enp5s0 mtu $size
  15. MTU=$(ifconfig $ETH | grep MTU | awk '{print $5}' | awk -F ":" '{print $2}')
  16. total+=($MTU)
  17. ./tools/upload.sh $IP > /dev/null 2>&1
  18. if [ $? -eq 0 ]
  19. then
  20. echo "MTU $MTU - OK"
  21. success+=($MTU)
  22. else
  23. echo "MTU $MTU - Error"
  24. failed+=($MTU)
  25. # IAP will reboot automaticaly by timeout
  26. echo "Waiting IAP reboot timeout..."
  27. sleep 25
  28. fi
  29. sleep 5
  30. done
  31. echo "Success: ${#success[@]}/${#total[@]}"
  32. if [ ${#failed[@]} -ne 0 ]
  33. then
  34. echo "Failed: ${#failed[@]}/${#total[@]}"
  35. echo "Failed MTUs: ${failed[@]}"
  36. fi