9

Any command to know the MTU size of Android?

user1507022
  • 91
  • 1
  • 1
  • 2
  • See this answer: http://stackoverflow.com/a/7847980/1006863 – Paulo Fidalgo May 27 '13 at 17:46
  • possible duplicate of [Is there a way to change android phone's mtu size?](http://stackoverflow.com/questions/5264344/is-there-a-way-to-change-android-phones-mtu-size) – Alfredo Cavalcanti Nov 04 '13 at 17:55
  • 2
    Not a duplicate of "is there a way to change android phone's mtu size" - this is just how to get the value, not change it. They are related however – Nick May 17 '16 at 18:38

7 Answers7

6

You should use the NetworkInterface class to query and obtain the network interfaces, then call getMTU().

nEx.Software
  • 6,782
  • 1
  • 26
  • 34
6

Today, looking into the code of netcfg I saw that the configuration of the interfaces is located into /sys/class/net.. and then I thought of you! (I read your question yesterday)

If you have root access, open a terminal and run

cat /sys/class/net/<interface>/mtu
patedit
  • 61
  • 1
5

Methods to know the MTU size of Android:

  1. from terminal: ifconfig $DEVICE | egrep addr\|MTU
  2. through Android Debug Bridge (adb):
    • adb shell netcfg | grep UP to find the desired address and
    • adb shell ip addr show rmnet0 in case of rmnet0 or
    • adb shell cat /sys/class/net/rmnet0/mtu in case of rmnet0 (as described by @patedit)
eapo
  • 1,053
  • 1
  • 19
  • 40
4

Without ROOTING your phone, you may use a ping command from a Windows/Mac/Unix system. Though, the syntax of ping-options is very different for different OS.

For Windows

try this:

ping /l 1473 /f 10.68.34.75

/l <Size> — Specifies the length, in bytes, of the Data field in the echo Request messages sent. The default is 32.

/f — Specifies that echo Request messages are sent with the Do not Fragment flag in the IP header set to 1 (available on IPv4 only).

Adjust the payload using the -l command-line option. When you reach the higher limit, you will see this message and you will find the MTU size :

> The packet needs to be fragmented but DF set.

More details: https://kb.netgear.com/19863/Ping-Test-to-determine-Optimal-MTU-Size-on-Router

maxkoryukov
  • 4,205
  • 5
  • 33
  • 54
Spawnrider
  • 1,727
  • 1
  • 19
  • 32
  • You will find others tips on http://delog.wordpress.com/2013/09/07/using-ping-to-determine-mtu-size/ – Spawnrider Aug 06 '14 at 16:39
  • after 6 years the link became broken. here is the new one: https://kb.netgear.com/19863/Ping-Test-to-determine-Optimal-MTU-Size-on-Router – maxkoryukov Apr 13 '20 at 01:34
1

1480, I believe, but you can check by using ifconfig $DEVICE with a rooted device, and checking the MTU there.

HaloWebMaster
  • 905
  • 6
  • 16
  • I believe, that there is a precise technical answer (even several answers). _1480, I believe_ =) bro, it is a technical question, not about beliefs. – maxkoryukov Apr 13 '20 at 01:47
1

For most network access, MTU could be resolved by MTU Discovery. You can use Ping command with different payload size and don't fragment to find aChrysler value. Good luck

0

Without ROOTING your phone, you may use a ping command from a Windows/Mac/Unix system. Though, the syntax of ping-options is very different for different OS.

From most Unix/Linux/Mac systems (Without ROOTING the phone)

You might share the internet connection from your phone, and then from any PC connected to your android-phone run ping commands:

ping www.yahoo.com -s 1413 -M do

man ping says:

-s <packetsize> — Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

-M <pmtudisc_opt> — Select Path MTU Discovery strategy. <pmtudisc_option> may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).

Adjust the payload using the -s command-line option (for example: 1200, 1300, 1400, 1500, 1450, 1425, 1440, ...). When you reach the higher limit, you will see a message like this and you will find the MTU size :

> From 192.168.1.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
ping: local error: Message too long, mtu=1500

My answer is based on this one for windows: answer #25165641

maxkoryukov
  • 4,205
  • 5
  • 33
  • 54