2

I know that it is possible to read and set the MTU during runtime e.g. with:

adb shell ip -d -s l l dev rmnet0
adb shell ifconfig rmnet0 mtu <MTU>

This has the problem that the MTU set this way does not hold after restarting the phone.

So how to configure the default MTU for an interface when building your own build with Android Open Source Project sources?

There seems to be no mention about this anywhere and grepping code does not seem to help. Also the default Linux kernel configuration files where this is done do not seem to exist in Android.

There sure must be a way to do this, right?

Kung Foo
  • 151
  • 2
  • 11
  • ...why do you need to do this? – Matti Virkkunen Dec 31 '12 at 12:46
  • 1
    Some operator networks do not work right with the default Android MTU of 1500. Thus it needs to be lowered (e.g. to 1400) to get mobile data to work properly. – Kung Foo Dec 31 '12 at 12:48
  • Since [kitkat](https://github.com/aosp-mirror/platform_frameworks_base/search?q=mtu+filename%3Aconfig.xml+path%3Acore%2Fres%2Fres) most networks have their right value provisioned in the system. – mirh Nov 06 '19 at 14:04

1 Answers1

2

Apparently PMTUD is a better solution to this (RFC 4821). It can be enabled in AOSP builds in init.rc (e.g. system/core/rootdir/init.rc) by adding following lines at the end of section "on boot":

on boot
# Other configurations here...

# Set TCP MTU Probing to automatic:
    write /proc/sys/net/ipv4/tcp_mtu_probing 1
Kung Foo
  • 151
  • 2
  • 11
  • How you setting mtu? I have a rooted phone and when i run a command to set mtu like: adb shell ifconfig rmnet0 mtu 1440 it give me error: SIOCSIFMTU (Operation not permitted) – user565 Nov 16 '17 at 11:55
  • Sounds like your phone is not rooted enough. Or perhaps just add that little "su": su ifconfig rmnet0 mtu 1440 – Kung Foo Nov 16 '17 at 18:20
  • You are right, I was trying to run this on adb shell with out su.it is working now :) – user565 Nov 17 '17 at 14:57
  • I have a question how you setting this MTU permanently, as you mentioned that need to write a value in tcp_mtu_probing how you are doing this using adb shell ? – user565 Nov 17 '17 at 14:58
  • Init.d is what you would usually employ for boot scripts, if you can't be bothered to touch the ramdisk. – mirh Nov 06 '19 at 13:48