node2:/root/test#python test8080.py
1461
The big message was sent! Your network supports really big packets!
发送长度为1461的数据:
node2:/root/test#cat test8080.py
import socket
import IN
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
hostName = '192.168.137.2'
Port = 8080
s.connect((hostName, Port))
s.setsockopt(socket.IPPROTO_IP, IN.IP_MTU_DISCOVER, IN.IP_PMTUDISC_DO)
try:
aa='#' * 1461
print len(aa)
s.send(aa)
except socket.error:
print 'The message did not make it'
option = getattr(IN, 'IP_MTU', 14)
print 'MTU:', s.getsockopt(socket.IPPROTO_IP, option)
else:
print 'The big message was sent! Your network supports really big packets!'