Fundamentals 30 min read

How Computers Talk: From Cables to TCP/IP – A Step‑by‑Step Guide

This article walks through the fundamentals of computer networking, explaining how two PCs connect with a cable, how hubs and switches forward frames using MAC addresses, how IP addressing, subnets, ARP and routing tables enable multi‑network communication, and how TCP ensures reliable, ordered delivery with flow‑ and congestion‑control mechanisms.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How Computers Talk: From Cables to TCP/IP – A Step‑by‑Step Guide

Imagine a computer named A that initially has no network connection. One day it plugs a network cable into a second computer B and they can exchange data. The article uses this story to illustrate the three core networking layers.

Layer 1 – Physical Connection and Hub

Connecting two PCs directly with a cable works, but the communication is limited to those two devices. A hub (also called a concentrator ) is introduced as a simple device that forwards every incoming Ethernet frame to all ports (broadcast). The hub operates at the physical layer and does not examine MAC addresses, so it has no intelligence.

Hub diagram
Hub diagram

Layer 2 – Switch and MAC Address Table

To avoid broadcasting to every device, a switch is used. The switch learns the MAC address of each device on each port and builds a MAC address table . When a frame arrives, the switch looks up the destination MAC; if it finds a matching port, it forwards the frame only there, otherwise it floods the frame.

Example MAC‑address table (port mapping):

bb‑bb‑bb‑bb‑bb‑bb → port 1

cc‑cc‑cc‑cc‑cc‑cc → port 3

aa‑aa‑aa‑aa‑aa‑aa → port 4

dd‑dd‑dd‑dd‑dd‑dd → port 5

Switch forwarding
Switch forwarding

Layer 3 – Router, IP Addresses, Subnets and ARP

When the network grows beyond a single LAN, a router (operating at the network layer ) is needed. Each router interface has its own MAC address and its own IP subnet. Devices use IP addresses (e.g., 192.168.0.1) for logical addressing, while MAC addresses are used for actual frame delivery.

IP addresses are 32‑bit numbers usually written in dotted decimal. They are divided into network and host portions using a subnet mask (e.g., 255.255.255.0). Two hosts are in the same subnet if IP & subnet_mask yields the same network identifier.

To send a packet to a host in a different subnet, a device forwards the packet to its default gateway (the router’s IP). The router consults its routing table to decide the outgoing interface.

Because a device only knows the destination IP, it must discover the corresponding MAC address. This is done with the ARP (Address Resolution Protocol) : the sender broadcasts an ARP request, the owner of the IP replies with its MAC, and both sides cache the mapping in an ARP cache .

ARP exchange
ARP exchange

Routing Table Example

Destination: 192.168.0.0/24 → port 0

Destination: 192.168.1.0/24 → port 1

Destination: 192.168.2.0/24 → next hop 192.168.100.5 → port 2

Transport Layer – TCP Reliability

TCP provides a connection‑oriented, reliable, byte‑stream service on top of IP. The connection is established with a three‑way handshake (SYN, SYN‑ACK, ACK). After the handshake, data is transferred in segments that carry sequence numbers and acknowledgments.

Key TCP mechanisms covered:

Stop‑and‑wait (simple but inefficient) – each segment must be ACKed before the next is sent.

Sliding window – the sender can transmit multiple segments up to the window size without waiting for individual ACKs, improving throughput.

Selective acknowledgment (cumulative ACK) – an ACK number indicates that all bytes up to that number have been received.

Flow control – the receiver advertises a window (rwnd) indicating how much data it can buffer.

Congestion control – the sender limits its sending rate based on network conditions (cwnd). The effective window is min(cwnd, rwnd).

Connection termination – a four‑step FIN/ACK exchange gracefully closes the TCP session.

TCP sliding window
TCP sliding window

Example TCP Handshake and Data Transfer

The article shows a captured trace of a TCP session where A sends a large payload that exceeds the MSS, causing the data to be split into multiple segments, followed by the three‑way handshake, data exchange, and four‑step termination.

Summary of Core Tables

MAC address table (switch) – learned from traffic, maps MAC → port.

Routing table (router) – maps destination network (or prefix) → next hop / output port.

ARP cache (host & router) – maps IP → MAC for recent neighbors.

Understanding how these tables are built and used explains how a packet travels from source to destination across multiple devices.

With these concepts, readers can design, simulate, and troubleshoot network topologies using tools such as Cisco Packet Tracer.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

routingTCP/IPARPOSI modelSwitchesSubnets
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.