Tcp – Is UDP used in every TCP/IP connection

layer4ositcptransport-protocoludp

I am confused on whether UDP and TCP work together, or are they completely separate protocols.

So, UDP is used to allow multiplexing of different services on the same machine. So, essentially, for example, when I make a request to YouTube.com (from Chrome application, let's say running on port 10). First, my packet will be created with IP address (and different headers), and a TCP connection would be make to the YouTube server.

Then, when the server responds back, it will send the data to the source machine (that made the request) at the port (10). Is this when the UDP protocol is used? So, if I have another application like Netflix streaming on my computer (running on port 11), then UDP knows that there is a stream on port 10 and port 11 and it will multiplex this data coming in from the Internet to the specific ports of the application that is running on my machine?

I am having a hard time understanding whether UDP is used in every TCP/IP connection since every application essentially runs on the port on the computer. So, would the UDP protocol know of all of these applications running at whichever port on the specific machine and multiplex data at this port?

Best Answer

UDP and TCP are completely separate Transport Layer (Layer 4 in the OSI model) protocols. There are also other layer-4 protocols, but TCP and UDP are the most commonly used. UDP was first, and it is a connectionless, unreliable, fire-and-forget protocol. TCP was added later to provide connections and reliability to layer 4.

Layer-4 protocols have their own addresses, called ports. UDP port 10 is not the same thing as TCP port 10. Applications register with TCP or UDP to use their ports. Only one application can use a per-protocol port at any given time, but if you have two different applications, one could use UDP port 10 at the same time as another uses TCP port 10.

UDP is only used by applications which want to use UDP, and TCP is only used by applications which want to use TCP. Some applications will use both protocols, and some applications use neither. Neither protocol is required by IPv4 or IPv6.