歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux上更改TCP窗口大小

使用route命令。像ifconfig, route, ip等這些工具參數非常多,有問題時應該看看這些工具的參數。窗口大小的變動對FTP等程序性能影響很明顯。

[[email protected] ipv4]# route del -net 10.60.56.0/24
[[email protected] ipv4]# route add -net 10.60.56.0/24 window 4096 dev eth0
[[email protected] ipv4]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.60.56.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         10.60.56.254    0.0.0.0         UG    0      0        0 eth0
[[email protected] ipv4]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.60.56.0      *               255.255.255.0   U         0 4096       0 eth0
169.254.0.0     *               255.255.0.0     U         0 0          0 eth0
default         10.60.56.254    0.0.0.0         UG        0 0          0 eth0

[[email protected] ipv4]# route del default gw 10.60.56.254
[[email protected] ipv4]# route add default gw 10.60.56.254 window 4096 dev eth0
[[email protected] ipv4]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.60.56.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         10.60.56.254    0.0.0.0         UG    0      0        0 eth0
[[email protected] ipv4]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.60.56.0      *               255.255.255.0   U         0 4096       0 eth0
169.254.0.0     *               255.255.0.0     U         0 0          0 eth0
default         10.60.56.254    0.0.0.0         UG        0 4096       0 eth0

還需要關掉scalable,即:
[[email protected] ipv4]# echo 0 > /proc/sys/net/ipv4/tcp_window_scaling

如果希望這個更改在重啟後也生效,可以將下面這一行添加到/etc/sysctl.conf文件中:
net.ipv4.tcp_window_scaling=0

Copyright © Linux教程網 All Rights Reserved