TCP streams/connections

layer4protocol-theorytcptransport-protocol

I want to ask how TCP creates streams (and what exactly is a stream). In Wireshark for example, I see multiple streams to one server and I can not understand how/when TCP creates this streams from the same connection.
I also read that HTTP/1.1 uses multiple connections to get more objects from the web server at the same time, so are these connections same with streams in Wireshark?

Thank you in advance.

Best Answer

In brief, a given TCP connection is specified by four things:

  • Host A IP address
  • Host A port number
  • Host B IP address
  • Host B port number

This is what uniquely defines a given connection.

When a host opens a TCP connection to another (perhaps a web fetch), it chooses an unused port, typically a "random high port number", and makes the connection to the well-known port number of the server, perhaps 80. If it opens another connection to the same server, it will have a different local port.

Captured in real life during a web refresh of a page, my computer had many connections of which these are two:

192.168.0.28:34628      69.30.95.247:80
192.168.0.28:34626      69.30.95.247:80

As a given host has a maximum of 2^16 ports (in IPv4), it can have at most 65,536 simultaneous connections to a given web server on the normal web port (minus some ports which have special meanings). That's not a problem for an individual's computer, but might be for a large web proxy. (And a given operating system might well have other much smaller limits: the limit I'm speaking of is inherent in the protocol limit.)

Hope that helps clarify somewhat.