4008063323.net

Understanding TCP: The Backbone of Internet Communication

Written on

Chapter 1: Introduction to TCP

When discussing TCP, or Transmission Control Protocol, what does it really mean?

Understanding TCP Protocol

Upon clicking the publish button, Medium will make this article live and notify my email subscribers with a link. Since web browsers and email clients operate using different applications, they rely on distinct Application Protocols—HTTP for web pages and SMTP for emails.

Beneath the Application Layer, the Transport Layer plays a crucial role in segmenting data into packets for transmission across the Internet. This article delves into TCP and the reasoning behind its design.

Let's revisit the earlier scenario. Imagine you're using Gmail for your Medium subscription. Here, we have two entities at play: the Gmail server and the Medium email server. Each server may handle various processes, such as web services, caching, or file transfers. If the Medium server simply sends data to the Gmail server, the latter won’t know which specific process should manage the incoming data. To clarify which process data is sent from and received by, TCP utilizes Source Port and Destination Port fields to pinpoint the respective processes involved.

Before any data packets can be exchanged between machines, they must first establish a connection—a process referred to as the Three-Way Handshake.

TCP Three-Way Handshake Illustration

After this connection is set up, Machine A can communicate with Machine B by sending and receiving data packets.

Data Packet Transmission

However, networks can be unreliable; data packets may be lost during transmission, often without either Machine A or B being aware of it. (By the way, do you know which existing protocol might lead to this issue?—The answer will be revealed at the conclusion.)

Potential Data Loss in Transmission

To tackle this challenge, two questions must be addressed: How does Machine A know when a data packet is lost?—Machine B will inform Machine A. What happens to the lost data packet?—It needs to be retransmitted.

TCP employs a strategy where Machine A must receive an acknowledgment (ACK) from Machine B for each packet sent before proceeding with the next. If the ACK is not received within a certain timeout period, Machine A will retransmit the data, thus ensuring reliable communication.

Acknowledgment Process in TCP

However, this introduces a new issue—inefficiency. Machine A must wait for an ACK for every single data packet it sends, which can lead to excessive waiting times if multiple packets are involved. To enhance efficiency, TCP adopted batch processing instead of waiting for individual acknowledgments.

Batch Processing in TCP

The network's complexity means that different packets from Machine A may take varied routes to reach Machine B. This can create an inconsistency in the order of packets—what Machine B receives might not match the order in which Machine A sent them.

Out-of-Order Data Packets

So, what’s the solution? If each packet sent by Machine A includes an identifier for its order, Machine B can then correctly arrange the data upon receipt. Thus, Machine A includes a sequence number (SEQ), and Machine B responds with a confirmation number in the ACK message, addressing the ordering issue.

Sequence and Acknowledgment Numbers in TCP

It's important to note that in actual protocol operation, the acknowledgment from Machine B should indicate (last sequence number received + 1)—this informs Machine A of the next packet to send. The above illustration is simplified for clarity.

Sometimes, due to varying machine performances, Machine B may struggle to process numerous incoming messages from Machine A. If Machine A sends too many packets simultaneously, it can overwhelm Machine B, leading to a breakdown. How do the two machines communicate their capacity to receive data?

During data exchange, both machines transmit a value known as WIN (Window Size), which signifies how many packets can be accepted. This allows either Machine A or B to adjust the number of packets sent based on the WIN value.

TCP Window Size Indicator

At this point, we have outlined a TCP header with essential components: source port, destination port, sequence number, acknowledgment number, window size, and various flags (e.g., ACK, SYN).

Components of TCP Header

Finally, before concluding communication, a Four-Way Termination process must be executed to safely close the connection.

TCP Four-Way Termination Process

I hope this article has been informative. If you share my passion for learning Java and exploring backend engineering, feel free to follow my channel for updates inspired by my daily experiences.

Read More:

  • A Case About Java Static Keyword During My Job
  • How Can You Solve This Java Multithreading Interview Problem?

Get Connected:

  • My LinkedIn

The answer to the earlier question is: UDP.

Image Credits: Shanke

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Understanding Trauma Processing Through EMDR Techniques

Explore how EMDR therapy aids in processing trauma and alleviating emotional pain.

Is Your Smartphone Really Listening? Unraveling Targeted Advertising

Explore the truth behind targeted ads and discover how your data is used without your phone actually eavesdropping.

# Rethinking

Explore the balance between acceptance and action, and learn why

Harnessing Ketosis: Transforming Emotions and Mental Health

Discover how ketosis from fasting can enhance emotional stability and mental well-being through its transformative effects.

Unveiling the Ancient Mysteries of the Bosnian Pyramids

Explore the enigmatic Bosnian Pyramids, their origins, and the technological wonders attributed to them.

Simplifying Self-Help: Why Less is More for Personal Growth

Discover why consuming less self-help content can lead to meaningful change and the importance of execution over mere learning.

# Insights for Gemini Entrepreneurs This Week: Predictions and Guidance

Explore key predictions for Gemini entrepreneurs this week, focusing on business challenges, opportunities, and personal growth.

Mastering Debugging Techniques in IntelliJ IDEA

Explore essential debugging methods in IntelliJ IDEA, perfect for backend developers looking to enhance their skills.