Wednesday 29 November 2023

Python code packet window is shown as full by Wireshark

I have a python code with such a structure:

server_info = (server_address, listen_port)
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
socket.setsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF, 100000)
socket.bind(server_info)
socket.listen(100)

while True:
    try:
        client_conn, client_address = socket.accept()

        more_to_read = True
        while more_to_read:
            client_conn.settimeout(3.0)
            data_part = client_conn.recv(10240)
            if data_part:
                print('Data part received ...')
                # record {data_part} somewhere
            else:
                more_to_read = False
                # finalize the message
        client_conn.close()
    except socket.error as e:
        print('Communication error:', str(e))
        continue

socket.close()

I know the outer loop does not exit!

In Wireshark I see this black record:

Wireshark failed packet

My first surprise is that I set the recv buffer size to 10240 but why does it show window size is 14656 and the second surprise is that why the window is marked as full while the data length is only 146 bytes?

Expert Info (Warning/Sequence): TCP window specified by the receiver is now completely full

The error message is:

Expert Info (Warning/Sequence): TCP window specified by the receiver is now completely full

How to fix the code?

PS.

1- Listen port is 7010

2- In the wireshark filter, tcp.port == 7010 the 1 after it is a typo that does not impact the filter.



from Python code packet window is shown as full by Wireshark

No comments:

Post a Comment