用PMTU报文寻找运营商最大MTU值

首先把ADSL连接的MTU设为较大的一个值

ifconfig ppp0 mtu 2000

下面开始ping

hetao@ubuntu:~$ ping -s 1472 -c 2 -M do g.cn
PING g.cn (203.208.39.104) 1472(1500) bytes of data.

--- g.cn ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1010ms

 

因为IP和ICMP报头占了28字节,所以1472是ICMP负载大小,加起来就是PPPOE的负载1500字节

由高到低依次往下试

hetao@ubuntu:~$ ping -s 1464 -c 2 -M do g.cn
PING g.cn (203.208.39.99) 1464(1492) bytes of data.
1472 bytes from bi-in-f99.1e100.net (203.208.39.99): icmp_seq=1 ttl=239 time=43.7 ms
1472 bytes from bi-in-f99.1e100.net (203.208.39.99): icmp_seq=2 ttl=239 time=43.7 ms

--- g.cn ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 43.707/43.723/43.739/0.016 ms
可以看出我的MTU值是1492,这也是理论上的最大值了MAC帧的MTU是1500,减去PPPOE8个字节的报头正是1492

然后运行 pppoeconf或修改/etc/ppp/peers目录下的ADSL连接配置文件,把MTU设为1492

你可能感兴趣的:(C++,c,.net,ubuntu,C#)