Search code examples
tcpscapyflow-control

Scapy set tcp flow window bigger then 65535


When using scapy, how can I set a tcp packet with flow control window bigger than 65535? I know that writing in scapy:

packet1[TCP].window=65535

will set the window to 65535; But if there is a need to set windows size bigger then 65535, it should be set in a different way because at the tcp header the window field is just two bytes so it can't be greather than 65535 so it should be done in another way. I know it should be possible.

Thanks.


Solution

  • Sort answer is: you cannot set the field TCP.window to a bigger value than 65535, since it is coded on two bytes:

    >>> ls(TCP)
    [...]
    window     : ShortField                          = (8192)
    [...]
    

    But TCP window can be higher than 65535, using the "Window Scale" option. The window value is the value of the window field multiplied by 2 raised to the power of the window scale value.

    In Scapy:

    >>> IP()/TCP(window=65535, options=[('WScale', 10)])
    

    The value is 65535 * 2 ** 10, 67107840.