Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Tuesday, December 13, 2011

Find Maximum MTU

Source
Thanks!
A script to find the maximum MTU (the value before the packet is fragmented). I was not particularly satisfied with dlsreports guide. The command given for us linux might not work most of the time (doesn’t prohibit fragmentation at time) as well as it is not an automatic operation but relies on trial and error.
=================================================================================
#!/bin/bash

PKT_SIZE=1472
HOSTNAME="www.dslreports.com"

count=`ping -M do -c 1 -s $PKT_SIZE $HOSTNAME | grep -c "Frag needed"`

while [ $count -eq 1 ]; do
 ((PKT_SIZE--))
 count=$((`ping -M do -c 1 -s $PKT_SIZE $HOSTNAME | grep -c "Frag needed"`))
done

printf "Your Maximum MTU is [ $((PKT_SIZE + 28)) ] \n"
=============================================================================================
This script will neatly print out the maximum MTU at the end of the operation after finding the optimal value of the packet size.
Explaination:
-M do : Select Path MTU Discovery strategy do (pro‐hibit  fragmentation,  even local one)
-c : to stop ping when you are done sending information.

No comments: