TCP port numbers reused and TCP Retransmission

networkingsquidtcp

Facing issues due to TCP Port Reuse and Retransmission for HTTP traffic.

My deployment is as follows:

enter image description here

I have a squid proxy installed on a unix machine which is sending handling http requests coming from an trusted source. Squid then forwards to a URL Filter which has a list of whitelists and blacklists. This URL filtering engine which will allow/block URL according to the rule.

From client I have run a script which does 500 wget to www.naukri.com in a loop continuously. This URL I have blocked on URL filtering engine.

After some requests ~120 wget got hanged in between for exactly 1 min. During this hanged state, I took tcpdump on server and found that it is showing "TCP port numbers reused" and start sending sync packet with same port which was used earlier and showing "TCP Retransmisson". Also FIN, ACK and RST received for the earlier request.

Attaching tcp dump screenshot for reference:

enter image description here

Can you please let me know why it is using same port for the new request and re-transmitting the packet again? Is there a way to avoid port reuse?

Best Answer

why it is using same port for the new request and re-transmitting the packet again?

It reuses the same port because it's more efficient to do that.

There's a good exaplanation here: https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t

re-transmit? What re-transmit? There may be packet re-transmissions but these should be completely seperate from the port re-use issue.