如何知道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
How to know the MTU size of Android Smartphone
提问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 -l
command-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大小的方法:
- from terminal:
ifconfig $DEVICE | egrep addr\|MTU
- through Android Debug Bridge (adb):
adb shell netcfg | grep UP
to find the desired address andadb shell ip addr show rmnet0
in case ofrmnet0
oradb shell cat /sys/class/net/rmnet0/mtu
in case ofrmnet0
(as described by @patedit)
- 从终端:
ifconfig $DEVICE | egrep addr\|MTU
- 通过Android 调试桥(adb):
adb shell netcfg | grep UP
找到所需的地址和adb shell ip addr show rmnet0
在rmnet0
或的情况下adb shell cat /sys/class/net/rmnet0/mtu
如果rmnet0
(如@patedit所述)
回答by HaloWebMaster
1480, I believe, but you can check by using ifconfig $DEVICE
with 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 ping
commands:
您可以从手机共享互联网连接,然后从任何连接到您的 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 eitherdo
(prohibit fragmentation, even local one),want
(do PMTU discovery, fragment locally when packet size is large), ordont
(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 -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 :
使用-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