node2:/root/test#cat t22.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='#' * 14730
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!'
4:发送长度为 1460 的数据,这个数据包设置了不允许分片Don't fragment: Set
class IN:
IP_MTU = 14
IP_PMTUDISC_DONT = 0
IP_PMTUDISC_DO = 2
IP_MTU_DISCOVER=10