Search for HTTP on List of TCP and UDP port numbers for some of them. ![]() Many other ports are used to host web servers.The remote ports are usually 80 (HTTP), 443 (HTTPS) or 8080 (HTTP Alternate). You can see that the local ports are all different. Here is an example, showing my current Firefox connections (I have 9 open tabs) on Windows 7: If you can ensure that each new connection from your client uses a higher ISN value than the last, you should be able to connect without issue.Do browsers use different ports to connect to different websites? If you are confident that TIME-WAIT is always ending up on the server side and you are unable to connect when your ephemeral ports get reused, then the ISN used by your client must not be increasing for each new connection (perhaps it is being chosen randomly or always uses the same value?). In Linux, the ISN of a new connection should be constantly increasing - it is somewhat tied to the system clock. You can test this on a Linux machine by setting your ephemeral port range to a single port echo 32769 32769 > /proc/sys/net/ipv4/ip_local_port_range and then making several consecutive requests to a website with the Connection: Close HTTP header set wget -no-http-keep-alive Even though the 5 tuple of all your connections is the same, the server will accept the new connections whilst in TIME-WAIT because the ISN of each new connection should be higher than the sequence number last seen on the socket. (2) returns to TIME-WAIT state if the SYN turns out to be Number it used on the previous connection incarnation, (1) assigns its initial sequence number for the newĬonnection to be larger than the largest sequence However, it MAYĪccept a new SYN from the remote TCP to reopen the connection directly State for a time 2xMSL (Maximum Segment Lifetime). When a connection is closed actively, it MUST linger in TIME-WAIT Is there a way to change ephemeral port selection strategy on a client (Linux) to avoid such collisions?Ī socket in TIME-WAIT will gladly accept a new connection from a device using the same 5 tuple (protocol, source IP, source port, destination IP, destination port) providing that the Initial Sequence Number (ISN) of the new connection is higher than the last sequence number seen on the previous connection. Increasing ephemeral port range would only slightly decrease probability of collision. It is also difficult to change client app in order to pick source port manually as I am using a 3rd party library to make HTTP requests. I have no control on the server so reducing TIME_WAIT delay or changing behavior is not an option. Exact scenario is also described in RFC6056 section 2.3 With 32k ephemeral port range and 150 sockets in TIME_WAIT there's >10% chance of this happening. Occasionally new connection from client chooses a recently used ephemeral source port that is in TIME_WAIT state on the server and connection fails. As client application makes repeated requests the number of TIME_WAIT connections on server grows and settles on ~150 sockets being in TIME_WAIT constantly. Connection lasts for the duration of one request and then server closes the connection so socket on the server ends up in TIME_WAIT state for few minutes. ![]() There's a single client application that makes frequent TCP (HTTP) connections to the server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |