TCP/IP

From Pulsed Media Wiki
Revision as of 13:19, 6 May 2025 by Gallogeta (talk | contribs) (Network)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Internet Protocol Suite (often referred to as TCP/IP) is the fundamental set of network protocols that underpin the Internet and most other computer networks. It defines how data should be packaged, addressed, transmitted, routed, and received, enabling diverse computer systems and networks to communicate with each other.

The suite is named after two of its most important protocols: the Transmission Control Protocol (TCP) and the Internet Protocol (IP). While it includes many other protocols, TCP and IP are central to its operation.

Overview

The TCP/IP suite is organized into layers, where each layer handles a specific aspect of network communication and interacts with the layers above and below it. This layered model simplifies the design and development of networking hardware and software. The most commonly referenced layers are:

  • **Application Layer:** Protocols that interact directly with applications (e.g., HTTP, FTP, SSH, DNS).
  • **Transport Layer:** Provides communication services to the application layer, managing data transfer between applications (e.g., TCP, UDP).
  • **Internet Layer:** Handles addressing and routing packets across networks (e.g., IP).
  • **Link Layer:** Protocols for the physical network interface and transmission medium (e.g., Ethernet, Wi-Fi).

Data passes down through the layers on the sending computer (adding headers at each step) and up through the layers on the receiving computer (removing headers and processing data).

Key Protocols: TCP and UDP

Within the TCP/IP suite, two major protocols operate at the Transport Layer, providing different services to applications:

Transmission Control Protocol (TCP)
A connection-oriented protocol that provides reliable, ordered, and error-checked delivery of a stream of packets between applications. It establishes a connection (the "three-way handshake") before sending data, ensures data arrives in the correct sequence, requests retransmission of lost packets, and manages flow control. TCP is slower due to this overhead but guarantees data integrity and reliable delivery.
User Datagram Protocol (UDP)
A connectionless protocol that provides a simpler, faster, but less reliable data transfer service. UDP sends data packets (datagrams) without establishing a connection or guaranteeing delivery order. It has lower overhead than TCP but does not retransmit lost packets or manage sequencing. It's suitable for applications where speed is more important than guaranteed delivery, or where error correction is handled by the application itself.

TCP vs. UDP Comparison

Comparison of TCP and UDP
Feature TCP UDP
Protocol Type Connection-oriented (requires handshake) Connectionless (sends datagrams directly)
Reliability / Delivery Guarantee Reliable (guarantees data arrives, retransmits lost packets) Unreliable (no guarantee of delivery or retransmission)
Order of Delivery Guaranteed (packets delivered in the order sent) Not Guaranteed (packets may arrive out of order or not at all)
Speed / Overhead Slower (higher overhead for connection management, error checking, etc.) Faster (lower overhead)
Use Cases (General) Applications requiring reliable, ordered data: Web Browse (HTTP/S), Email (SMTP, POP3, IMAP), File Transfer (FTP, SFTP), Secure Shell (SSH). Applications requiring speed over reliability: Streaming (video/audio), Online gaming, DNS, Voice over IP (VoIP).
Uses on Personal Computers Most internet traffic (Browse, email, downloading, secure remote access). Streaming services, voice/video calls, some games, background system services (like DNS lookups).
Uses on Seedbox/Servers Hosting websites (HTTP/S), Email servers (SMTP, IMAP, POP3), File transfer servers (FTP, SFTP), SSH access, Most torrent client peer connections. DNS servers, some monitoring services, certain peer-to-peer protocols like uTP (used by some torrent clients) or DHT, some game servers.

What TCP is Used For

TCP is used by applications whenever reliable and ordered delivery of a stream of data is essential. If a single packet is lost or arrives out of order, TCP handles the detection and correction, ensuring the application receives the data exactly as it was sent. This makes it suitable for:

  • Loading web pages (browsers need HTML, CSS, images to arrive completely and correctly).
  • Sending and receiving emails.
  • Transferring files accurately.
  • Establishing secure, interactive sessions via SSH.
  • Database connections.

How Pulsed Media Uses TCP/IP

Like virtually all services provided over the modern internet, Pulsed Media's services—including seedboxes, Virtual Private Servers (VPS), and Dedicated Servers—**fundamentally rely on the TCP/IP suite for all network communication**. TCP/IP is the essential language of the internet that allows clients to connect to servers and servers to communicate with each other.

Specific ways Pulsed Media services use TCP/IP protocols include:

  • **Client Access:** When you connect to your seedbox or server using tools like SSH, SFTP, FTP (though FTP has security risks and should be avoided in favor of SFTP/FTPS), or access a web-based GUI, you are using applications that operate over TCP/IP (e.g., SSH and SFTP run over TCP, FTP over TCP, Web GUIs over HTTP/HTTPS which run over TCP).
  • **Torrenting:** While the BitTorrent protocol itself has layers, the primary data transfer connections between peers for sending and receiving file blocks typically occur over **TCP**. The initial connections to trackers also often use TCP. Some parts of BitTorrent, like DHT (Distributed Hash Table) or uTP (Micro Transport Protocol), use UDP, particularly on personal computers, but high-performance seedboxes often optimize core peer-to-peer data transfers over robust TCP connections or use dedicated UDP ports.
  • **Hosting Services (VPS/Dedicated Servers):** If you use a VPS or dedicated server for web hosting, email hosting, or other services, these services use TCP/IP protocols extensively (e.g., Apache or Nginx for HTTP/S over TCP, Postfix/Dovecot for SMTP/IMAP/POP3 over TCP, etc.).

In essence, every bit of data transferred into or out of a Pulsed Media seedbox or server over the internet relies on the TCP/IP stack functioning correctly.

Tutorial: Opening TCP Ports on Linux (Debian) Server

To allow external network traffic to reach a specific service running on a TCP port on your Linux server, you need to configure the server's firewall to permit incoming connections to that port. This tutorial uses `ufw` (Uncomplicated Firewall), a user-friendly front-end for `nftables` or `iptables`, common on Debian-based systems like Ubuntu.

Prerequisites:

Steps:

  1. Check ufw status (optional):

Verify that the firewall is active. If it's inactive, you'll need to enable it later.

     sudo ufw status verbose  


  1. Allow a specific TCP port:'

Use the `ufw allow` command followed by the port number and `/tcp`. Replace `port_number` with the actual port the service listens on.

     sudo ufw allow 80/tcp  # Example: Allow HTTP traffic
     sudo ufw allow 443/tcp # Example: Allow HTTPS traffic
     sudo ufw allow 22/tcp  # Example: Allow SSH traffic (essential if connecting remotely)
     sudo ufw allow 8080/tcp # Example: Allow traffic on a custom port


  1. Allow a service by name (if defined in ufw):

`ufw` has predefined rules for some common services (listed in `/etc/services`). You can use the service name instead of the port number.

     sudo ufw allow http  
     sudo ufw allow https  
     sudo ufw allow ssh  


  1. Allow a port/service from a specific IP address or network range (more secure):

To restrict access to a port to only specific source IPs.

     sudo ufw allow from 203.0.113.100 to any port 22 proto tcp # Allow SSH only from 203.0.113.100
     sudo ufw allow from 192.168.1.0/24 to any port 8080 proto tcp # Allow port 8080 from local network 192.168.1.0/24


  1. Reload ufw to apply changes (if it was already active):

If `ufw status verbose` showed `Status: active`, reload to apply your new rules.

     sudo ufw reload  


  1. Enable ufw (if it was inactive):

If `ufw status verbose` showed `Status: inactive`, enable it. **WARNING:** Ensure you have allowed SSH (port 22) *before* enabling if connecting remotely via SSH, otherwise you will be locked out.

     sudo ufw enable  

Confirm the action when prompted.

  1. Verify the new rules:

Check the status again to see your newly added rules.

     sudo ufw status verbose  


Remember to only open the ports necessary for the services you intend to run and make accessible from the network.

Note on NAT/Port Forwarding: If your server is behind a router performing NAT and you want to access a service from the public internet, you will also need to configure Port forwarding on the router to direct incoming traffic from a public IP and port to your server's private IP and the service's TCP port.

See also


External links