The backbone of internet communication: TCP/IP & UDP

devfish·2023년 3월 6일
0

Network

목록 보기
1/4

UDP vs. IP

So, what's the point of using UDP over IP? Well, for the following two reasons!

  • Error detection (through the checksum technique, detailed below)
    When you want to ensure that the data sent is indeed the data that was received
  • Specifying the destination (where to send the payload), as in which application on the computer

A UDP packet specifies two destination identifiers, the IP address which identifies the computer, and the port number which identifies the application on said computer.

So what is this checksum method for checking data integrity during transfers used by UDP?

Checksums vs. hash algorithms

Checksums are often used to detect errors in data transmission, as a small change in the input data will result in a different checksum value. However, checksums are not designed to be secure against deliberate tampering, as it is easy to generate a new input with the same checksum value.

  • Hash algorithms produce a fixed-size, unique representation of the input, while checksums produce a small value that can be used to detect errors in the data.
  • Hash algorithms are designed to be secure against deliberate tampering, while checksums are not.
  • Hash algorithms are typically more complex and computationally expensive than checksums.

Checksums is just one of many other error detection techniques, but what makes it special is its simplicity and efficiency. It is used often in various applications including computer networks, storage systems, and file transfer protocols.

UDP vs. TCP: Speed vs. Accuracy

The above meme is a classic among a gazillion others on UDP. You get the idea. TCP is more a handshake that needs both sides to be in agreement about the exchange. UDP, on the other hand, is a connectionless protocol that sends without asking. The sender has no idea if all the data made it to the other side, or if the data made it there at all, or if the other side is there to receive it.

Basically you would more often choose UDP over TCP when speed is of paramount importance. TCP you'd use for slower but reliable transfers, typically for email and web browsing. UDP you'd want to be using for fast, but non-guaranteed transfers ("best effort"), typically for real-time services like music streaming and VoIP (Voice over IP) which is primarily concerned with keeping the stream going, as fast as possible.

TCP/IP

TCP and IP are two separate computer network protocols. IP is the part that obtains the address to which data is sent. TCP handles data delivery once that IP address has been found. The two terms are sandwiched together and referred to as one unified framework ("TCP/IP model") since they're generally used in tandem.

Think of it this way: The IP address is like the phone number assigned to your smartphone. TCP is all the technology that makes the phone ring, and that enables you to talk to someone on another phone. They are different from one another, but they are also meaningless without one another.

The purpose of a TCP/IP socket is to identify the computer or network server's unique IP address, along with its port number.

TCP/IP vs. UDP

For a detailed comparison click here.

  • Connection Versus Connectionless
  • Stream Versus Packet
  • TCP/IP Is a Reliable Protocol, While UDP Is Unreliable

How TCP & IP work together

Or at least how our favorite study buddy describes it:

  • TCP (Transmission Control Protocol) and IP (Internet Protocol) are two separate protocols that work together to enable communication over the internet. TCP provides reliable, ordered, and error-checked delivery of a stream of packets from one program on one computer to another program on another computer. IP is responsible for routing the packets between different networks.

    Let's say you want to send an email from your computer to a friend's computer. Here is how TCP and IP work together to accomplish this task:

    • Your email client (such as Gmail or Outlook) breaks down the email message into smaller packets of data, each with a header that contains information such as the source and destination addresses, sequence number, and checksum.

    • The packets are then handed over to TCP, which divides the data into segments and assigns a sequence number to each segment. TCP also ensures that the segments are delivered in the correct order and retransmits any lost or corrupted packets.

    • TCP then hands over the segments to IP, which adds its own header with information such as the source and destination IP addresses, time-to-live (TTL) value, and protocol number (which in this case is TCP).

    • IP then determines the best route for the packets to take to reach the destination computer. This is done by consulting a routing table that contains information about the various networks and their connections.

    • Once the packets arrive at the destination computer, IP removes its header and hands over the data to TCP.

    • TCP then reassembles the segments in the correct order, checks for any missing packets or errors, and delivers the complete message to the email client on the destination computer.

    • The destination email client then sends an acknowledgment back to the source email client using the same process, but in reverse.

  • Overall, TCP and IP work together to ensure that data is transmitted reliably and efficiently over the internet. TCP provides reliable data transfer by dividing data into segments, assigning sequence numbers, and retransmitting any lost or corrupted packets. IP provides routing of packets by adding its own header and consulting a routing table to determine the best path for the packets to take. Together, TCP and IP form the backbone of internet communication, allowing us to send and receive data across the globe.

References

What is TCP/IP?
TCP vs. UDP
TCP/IP and UDP Comparison
TCP vs. UDP in VoIP

profile
la, di, lah

0개의 댓글