Introduction-to-TCP-and-UDP

Introduction to TCP and UDP

Introduction to TCP and UDP in the OSI transport layer (Layer 4) defines several functions, the most important of which are error recovery and flow control. Likewise, the TCP/IP transport layer protocols also implement these same sorts of features. Note that both the OSI model and the TCP/IP model call this layer the transport layer. But as was common , when pertaining to the TCP/IP model, the layer name and number are supported OSI, so any TCP/IP transport layer protocols are considered

Layer 4 protocols. The key difference between TCP and UDP is that TCP provides a good sort of services to applications, whereas UDP doesn’t . for instance , routers discard packets for several reasons, including bit errors, congestion, and instances during which no correct routes are known. As you’ve got read already, most data-link protocols notice errors (a process called error detection) but then discard frames that have errors. TCP provides retransmission (error recovery ) and helps to avoid congestion (flow control), whereas UDP doesn’t . As a result, many application protocols prefer to use TCP. However, don’t let UDP’s lack of services make you think that UDP is worse than TCP. By providing fewer services, UDP needs fewer bytes in its header compared to TCP, resulting in fewer bytes of overhead within the network. UDP software doesn’t slow down data transfer in cases where TCP can purposefully slow down. Also, some applications, notably today voice over IP (VoIP) and video over IP, don’t need error recovery, so they use UDP. So, UDP also has an important place in TCP/IP networks today.

Also Read : Overview of TCP/IP Applications

Table 5-2 lists the most features supported by TCP/UDP. Note that only the primary item listed within the table is supported by UDP, whereas all items within the table are supported by TCP.

Next, this section describes the features of TCP, followed by a quick comparison to UDP.

Transmission Control Protocol

Each TCP/IP application typically chooses to use either TCP or UDP based on the application’s requirements. for instance , TCP provides error recovery, but to do so, it consumes more bandwidth and uses more processing cycles. UDP doesn’t perform error recovery, but it takes less bandwidth and uses fewer processing cycles. no matter which of those two TCP/IP transport layer protocols the application chooses to use, you ought to understand the basics of how each of those transport layer protocols works.

TCP, as defined in Request For Comments (RFC) 793, accomplishes the functions listed in Table 5-2 through mechanisms at the endpoint computers. TCP relies on IP for end-to-end delivery of the data, including routing issues. In other words, TCP performs only a part of the functions necessary to deliver the data between applications. Also, the role that it plays is directed toward providing services for the applications that sit at the endpoint computers.

Regardless of whether two computers are on the same Ethernet, or are separated by the whole Internet, TCP performs its functions the same way. Figure 5-1 shows the fields within the TCP header. Although you don’t got to memorize the names of the fields or their locations, the rest of this section refers to many of the fields, therefore the entire header is included here for reference.

The message created by TCP that begins with the TCP header, followed by any application data, is named a TCP segment. Alternatively, the more generic term Layer 4 PDU, or L4PDU, also can be used.

Multiplexing Using TCP Port Numbers

TCP and UDP both use an idea called multiplexing. Therefore, this section begins with an explanation of multiplexing with TCP and UDP. Afterward, the unique features of TCP are explored. Multiplexing by TCP and UDP involves the method of how a computer thinks when receiving data. the pc could be running many applications, like a web browser, an email package, or an internet VoIP application (for example, Skype). TCP and UDP multiplexing tells the receiving computer to which application to offer the received data. Some examples will help make the need for multiplexing obvious. The sample network consists of two PCs, labeled Hannah and Jessie. Hannah uses an application that she wrote to send advertisements that appear on Jessie’s screen. the application sends a new ad to Jessie every 10 seconds. Hannah uses a second application, a wire-transfer application, to send Jessie some money. Finally, Hannah uses a web browser to access the web server that runs on Jessie’s PC. The ad application and wire-transfer application are imaginary, only for this instance . the web application works a bit like it might in real world .

Figure 5-2 shows the sample network, with Jessie running three applications:

  • A UDP-based advertisement application
  • A TCP-based wire-transfer application
  • A TCP web server application

Jessie must know which application to offer the data to, but all three packets are from the same Ethernet and IP address. you would possibly think that Jessie could check out whether the packet contains a UDP or TCP header, but as you see within the figure, two applications (wire transfer and web) are using TCP.

TCP and UDP solve this problem by using a port number field within the TCP or UDP header, respectively. Each of Hannah’s TCP and UDP segments uses a special destination port number so that Jessie knows which application to give the data to. Figure 5-3 shows an example.

Multiplexing relies on an idea called a socket. A socket consists of three things:

  • An IP address
  • A transport protocol
  • A port number

So, for a web server application on Jessie, the socket would be (10.1.1.2, TCP, port 80) because, by default, web servers use the well-known port 80. When Hannah’s web browserconnects to the web server, Hannah uses a socket as well—possibly one like this: (10.1.1.1, TCP, 1030). Why 1030? Well, Hannah just needs a port number that’s unique on Hannah, so Hannah sees that port 1030 is available and uses it. In fact, hosts typically allocate dynamic port numbers starting at 1024 because the ports below 1024 are reserved for well known applications.

In Figure 5-3, Hannah and Jessie use three applications at the same time—hence, three socket connections are open. Because a socket on one computer should be unique, a connection between two sockets should identify a singular connection between two computers. This uniqueness means you’ll use multiple applications at the same time, lecture applications running on the same or different computers. Multiplexing, supported sockets, ensures that the data is delivered to the right applications. Figure 5-4 shows the three socket connections between Hannah and Jessie.

Port numbers are a vital a part of the socket concept. Well-known port numbers are used by servers; other port numbers are used by clients. Applications that provide a service, like FTP, Telnet, and web servers, open a socket using a well-known port and listen for connection requests. Because these connection requests from clients are required to incorporate both the source and destination port numbers, the port numbers used by the servers must be well-known. Therefore, each service uses a specific well-known port number.On client machines, where the requests originate, any locally unused port number are often allocated. The result’s that every client on the same host uses a unique port number, but a server uses an equivalent port number for all connections. for instance , 100 web browsers on the same host computer could each connect to an internet server, but the web server with 100 clients connected thereto would have just one socket and, therefore, just one port number

(port 80, during this case). The server can tell which packets are sent from which of the 100 clients by watching the source port of received TCP segments. The server can send data to the right web client (browser) by sending data thereto same port number listed as a destination port. the mixture of source and destination sockets allows all participating hosts to differentiate between the data’s source and destination. Although the instance explains the concept using 100 TCP connections, the same port-numbering concept applies to UDP sessions within the same way.

Questions related to this topic
  1. What is TCP and UDP socket?
  2. Does UDP use sockets?
  3. What is TCP IP socket?
  4. Can you use UDP and TCP at the same time?

This Blog Article is posted by

Infosavvy, 2nd Floor, Sai Niketan, Chandavalkar Road Opp. Gora Gandhi Hotel, Above Jumbo King, beside Speakwell Institute, Borivali West, Mumbai, Maharashtra 400092

Contact us – www.info-savvy.com

https://g.co/kgs/ttqPpZ

Leave a Comment