4

Assume we have two browsers (Chrome and Firefox) running simultaneously, and both are requesting a web page. Lets assume Chrome is requesting www.facebook.com, and Firefox is requesting www.youtube.com.

Let's also assume that the default port for HTTP is TCP 80.

Which of the following case is true?

Case 1: Both the browsers are making HTTP requests using TCP port number 80 (but one at a time), and this request goes to the corresponding web server, and then web server sends back the response via TCP port number 80. Thus, both the request and response use TCP port 80.

Case 2: Both the browsers are using different TCP ports for making HTTP requests, and then the web server responds using TCP port number 80 by default.

PS: I am confused whether the HTTP default TCP port 80 is used by the client for making request, or by the web server for sending response, or by both.

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Apr 1 '18 at 22:37
11

User applications use random ephemeral ports for outgoing connections. TCP port 80 is only the server side's default port for WWW.

A TCP socket connection consists of source IP, source port, destination IP, destination port. Only if all of these are identical it's the same socket.

  • I'll add, to those wondering about it : firewalls between you and the web server allow port 80 or port 443 toward "the internet". They see a connection opening "from your_ip:ephemeralport1 -to- webserverip:80-or-443" and allow it. they also allow replies "from webserverip:ephemeralport2 -to- your_ip : ephemeralport1" (now called a session) so you are allowed to receive the requested http informations from the remote server. (Ie no need to open all ephemeral ports : they open just with the session) – Olivier Dulac Mar 23 '18 at 17:39
  • Absolutely - for a stateful firewall that is. A stateless firewall would need to allow TCP packets from any outside IP:port 80 to any inside IP:any ephemeral port - which obviously isn't a good idea and we use stateful firewalls instead. – Zac67 Mar 23 '18 at 17:44
7

Every TCP packet has two port fields; one is the Source Port, and the other is the Destination Port.

The youtube.com server is listening on Port 80. This means that any packet travelling to youtube.com from your computer has Dest Port = 80, Source Port = (ephemeral). Any packet travelling from youtube.com to your computer has Source Port = 80, Dest Port = (ephemeral).

(ephemeral) is any number from 1025 to 65535. This number is fixed to some value in this range when the connection starts, and remains unchanged as long as the TCP session is in force. This is why you can start two youtube sessions simultaneously on your computer, and both will work without interfering with the other: the (ephemeral) number is different for the two sessions.

  • 1
    In fact, system or "well-known" port numbers are 0-1023, the user or "registered" (with IANA) ports are 1024-49151, and dynamic or "ephemeral" or "private" are 49152-65535, per RFC 6335. – jonathanjo Mar 10 '18 at 19:17
0

The other piece to this is that generally with a client/server application, the server side process will listen on the port (socket) in question (in this instance port 80), and then when a request comes in it will create a new unique process to handle that specific connection. The main process would listen on the server with source port = * (any) / source IP = * and destination port 80 / destination IP = server IP the process is bound to.

the NEW process would be specific to the connection from each browser:

Firefox: src port = 4000, srcIP = 1.1.1.1; dst port =80, dstIP=3.3.3.3
Chrome:  src port = 4001, srcIP = 1.1.1.1; dst port =80, dstIP=3.3.3.3

This allows the server and the client to uniquely identify and handle each connection individually. When the connections close, the unique processes are torn down.

  • Multi-process servers have fallen significantly in popularity since the standardization of POSIX threads. – Ben Voigt Mar 10 '18 at 22:52
0

when user access a web page(http), a unique socket will be opened for that TCP connection with source port assigned by OS, destination port 80 ( widely used for http), source IP and destination IP. In TCP/IP, a unique sessions with 5-tuple (protocol, sourceIP, sourcePort, destinationIP, destinationPort) will be handling each communication. Because of source port is assigned by OS,even-if you are accessing same website from different browser, your processes will be unique.

  • Just a little comment on terminology as given in the TCP RFC 793: a "socket" is the concatenation of the address and port number; a "connection" as being identified by two sockets. – jonathanjo Mar 10 '18 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.