如何知道Android智能手机的MTU大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11364170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:10:59  来源:igfitidea点击:

How to know the MTU size of Android Smartphone

androidmtu

提问by user1507022

Any command to know the MTU size of Android?

有什么命令可以知道 Android 的 MTU 大小吗?

回答by nEx.Software

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

您应该使用NetworkInterface类来查询和获取网络接口,然后调用getMTU().

回答by patedit

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)

今天看netcfg的代码看到接口的配置在/sys/class/net..然后就想到你了!(我昨天看了你的问题)

If you have root access, open a terminal and run

如果您有 root 访问权限,请打开终端并运行

cat /sys/class/net/<interface>/mtu

回答by Spawnrider

Without ROOTINGyour 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.

无需ROOTING您的手机,您可以使用来自Windows/Mac/Unix系统的ping命令。但是,ping-options的语法对于不同的操作系统是非常不同的。

For Windows

对于 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).

/l <Size>— 指定发送的回显请求消息中数据字段的长度(以字节为单位)。默认值为 32。

/f— 指定发送回声请求消息时,IP 标头中的 Do not Fragment 标志设置为 1(仅适用于 IPv4)。

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

使用-l命令行选项调整有效负载。当您达到上限时,您将看到此消息并找到 MTU 大小:

> 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

更多详情:https: //kb.netgear.com/19863/Ping-Test-to-determine-Optimal-MTU-Size-on-Router

回答by eapo

Methods to know the MTU size of Android:

了解Android MTU大小的方法:

  1. from terminal: ifconfig $DEVICE | egrep addr\|MTU
  2. through Android Debug Bridge (adb):
    • adb shell netcfg | grep UPto find the desired address and
    • adb shell ip addr show rmnet0in case of rmnet0or
    • adb shell cat /sys/class/net/rmnet0/mtuin case of rmnet0(as described by @patedit)
  1. 终端ifconfig $DEVICE | egrep addr\|MTU
  2. 通过Android 调试桥(adb)
    • adb shell netcfg | grep UP找到所需的地址和
    • adb shell ip addr show rmnet0rmnet0或的情况下
    • adb shell cat /sys/class/net/rmnet0/mtu如果rmnet0(如@patedit所述)

回答by HaloWebMaster

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

1480,我相信,但您可以通过使用ifconfig $DEVICE有根设备进行检查,并检查那里的 MTU。

回答by user4252070

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

对于大多数网络访问,MTU 可以通过 MTU 发现解决。您可以使用具有不同有效载荷大小的 Ping 命令,并且不要分段查找克莱斯勒值。祝你好运

回答by maxkoryukov

Without ROOTINGyour 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.

无需ROOTING您的手机,您可以使用来自Windows/Mac/Unix系统的ping命令。但是,ping-options的语法对于不同的操作系统是非常不同的。

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

来自大多数 Unix/Linux/Mac 系统(无需ROOTING 手机)

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

您可以从手机共享互联网连接,然后从任何连接到您的 android-phone 的 PC 上运行ping命令:

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

man pingsays:

-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 DFflag).

man ping说:

-s <packetsize>— 指定要发送的数据字节数。默认值为 56,当与 8 个字节的 ICMP 标头数据组合时,它转换为 64 个 ICMP 数据字节。

-M <pmtudisc_opt>— 选择路径 MTU 发现策略。<pmtudisc_option>可能是do(禁止分片,甚至是本地分片),want(做 PMTU 发现,当数据包大小很大时在本地分片),或dont(不设置DF标志)。

Adjust the payload using the -scommand-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 :

使用-s命令行选项调整负载(例如:1200, 1300, 1400, 1500, 1450, 1425, 1440, ...)。当您达到上限时,您会看到这样的消息,您会发现 MTU 大小:

> 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

我的回答是基于 Windows 的这个回答回答 #25165641