How to check whether or not your OS supports TCP Window scaling.
# cat /proc/sys/net/ipv4/tcp_window_scaling
1
|
1 : enable window scale
0 : disable window scale
[ when disabling TCP window scale ]
Client ( CentOS 6.2 ) ------ web sites
OS informs Window scaling factor when sending syn packet.
# echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
|
capture and then access to an web site.
# tshark -i eth0 port 80 -w ws_disable.pcap
|
# wget http://www.google.com
|
Here’s a syn packet sent from the client
Client -> google
the client does not add window scale option in TCP options.
Flags: 0x02 (SYN)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...0 .... = Acknowledgement: Not set
.... 0... = Push: Not set
.... .0.. = Reset: Not set
.... ..1. = Syn: Set
Options: (16 bytes)
Maximum segment size: 1460 bytes
SACK permitted
|
[ when enabling Window scale ]
enable window scale
# echo 1 > /proc/sys/net/ipv4/tcp_window_scaling
|
# tshark -i eth0 port 80 -w ws_enable.pcap
# wget http://www.google.com
|
syn packet
The client adds window scaling factor in TCP options.
Flags: 0x02 (SYN)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...0 .... = Acknowledgement: Not set
.... 0... = Push: Not set
.... .0.. = Reset: Not set
.... ..1. = Syn: Set
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 807482, TSecr 0
NOP
Window scale: 6 (multiply by 64) <- 2**6 =64
|
In this case , Window size will be 1460 * 2**6 = 93440
[ how to change window scaling factor ]
You may change scaling factor by editing the following three files. ( receive buffer )
/proc/sys/net/ipv4/tcp_rmem
/proc/sys/net/core/rmem_default
/proc/sys/net/core/rmem_max
The scaling factor range is from 0 to 14.
- scaling factor : 0
# echo "4096 65535 65535" > /proc/sys/net/ipv4/tcp_rmem
# echo 65535 > /proc/sys/net/core/rmem_default
# echo 65535 > /proc/sys/net/core/rmem_max
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 1516864, TSecr 0
NOP
Window scale: 0 (multiply by 1)
|
window size : 1460 * 2**0 = 1460
- scaling factor : 1
# echo 131070 > /proc/sys/net/core/rmem_max
# echo 131070 > /proc/sys/net/core/rmem_default
# echo "4096 131070 131070" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 1665986, TSecr 0
NOP
Window scale: 1 (multiply by 2)
|
window size : 1460 * 2**1 = 2920
- scaling factor : 2
# echo "4096 196605 196605" > /proc/sys/net/ipv4/tcp_rmem
# echo 196605 > /proc/sys/net/core/rmem_default
# echo 196605 > /proc/sys/net/core/rmem_max
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 1892175, TSecr 0
NOP
Window scale: 2 (multiply by 4)
|
- scaling factor : 3
# echo "4096 300000 300000" > /proc/sys/net/core/rmem_default
# echo 300000 > /proc/sys/net/core/rmem_max
# echo 300000 > /proc/sys/net/core/rmem_default
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 3386446, TSecr 0
NOP
Window scale: 3 (multiply by 8)
|
- scaling factor : 4
# echo 1048560 > /proc/sys/net/core/rmem_default
# echo 1048560 > /proc/sys/net/core/rmem_max
# echo "4096 1048560 1048560" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 3644467, TSecr 0
NOP
Window scale: 4 (multiply by 16)
|
- scaling factor : 5
>>> 65535*2**5
2097120
scaling factor becomes 5 ???
# echo 2097120 > /proc/sys/net/core/rmem_default
# echo 2097120 > /proc/sys/net/core/rmem_max
# echo "4096 2097120 2097120" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 3817108, TSecr 0
NOP
Window scale: 5 (multiply by 32)
|
- scaling factor : 6
>>> 65535*2**6
4194240
# echo 4194240 > /proc/sys/net/core/rmem_default
# echo 4194240 > /proc/sys/net/core/rmem_max
# echo "4096 4194240 4194240" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 4000584, TSecr 0
NOP
Window scale: 6 (multiply by 64)
|
- scaling factor : 7
>>> 65535*2**7
8388480
# echo 8388480 > /proc/sys/net/core/rmem_default
# echo 8388480 > /proc/sys/net/core/rmem_max
# echo "4096 8388480 8388480" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 4338817, TSecr 0
NOP
Window scale: 7 (multiply by 128)
|
- scaling factor : 8
>>> 65535*2**8
16776960
# echo "4096 16776960 16776960" > /proc/sys/net/ipv4/tcp_rmem
# echo 16776960 > /proc/sys/net/core/rmem_default
# echo 16776960 > /proc/sys/net/core/rmem_max
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 4465434, TSecr 0
NOP
Window scale: 8 (multiply by 256)
|
- scaling factor : 9
>>> 65535*2**9
33553920
# echo 33553920 > /proc/sys/net/core/rmem_default
# echo 33553920 > /proc/sys/net/core/rmem_max
# echo "4096 33553920 33553920" > /proc/sys/net/ipv4/tcp_rmem
|
Options: (20 bytes)
Maximum segment size: 1460 bytes
SACK permitted
Timestamps: TSval 4596689, TSecr 0
NOP
Window scale: 9 (multiply by 512)
|
scale factor 10 – 14 ….. I’m tired of checking … :(
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.