Computer Networks Basics: Understanding How the Internet Works

Learn computer networking fundamentals for beginners. Explore network types, topologies, TCP/IP, OSI model, protocols, and devices with practical examples

📅 Published: April 5, 2025 ✏️ Updated: April 28, 2025 By Ojaswi Athghara
#networking #tcp-ip #osi-model #beginners #tutorial #protocols

Computer Networks Basics: Understanding How the Internet Works

How Did My Message Reach Across the World in Milliseconds?

I was video calling my friend who was studying abroad in Germany—from my dorm room in California. We were talking in real-time, sharing screens, laughing at memes. Then I paused and thought:

"How is this even possible?"

My voice traveled from my laptop, through my university's Wi-Fi, across the Pacific Ocean, through multiple countries, reached his computer in Berlin—and he heard it instantly. No delays, no errors. Just... magic?

That's when I decided to take a computer networks course. What I discovered was more fascinating than magic—it was brilliant engineering. Layers upon layers of protocols working together, routing algorithms finding optimal paths, error correction happening invisibly.

In this guide, I'll share what I learned about computer networks from a beginner's perspective. If you've ever wondered how the internet actually works, why your Wi-Fi is slow sometimes, or what "TCP/IP" means, keep reading!

What Is a Computer Network?

A computer network is a collection of interconnected devices (computers, phones, servers) that can communicate and share resources with each other.

Simple Analogy

Think of a postal system:

  • Sender = Your computer
  • Recipient = Website server
  • Post offices = Routers (that forward your data)
  • Postal trucks = Network cables/wireless signals
  • Addresses = IP addresses
  • Delivery rules = Networking protocols

Just as the postal system has sorting centers, delivery trucks, and addressing rules to get a letter from you to your friend, computer networks have routers, cables, and protocols to get data from your computer to any device on the planet!

Why Do We Need Computer Networks?

Before I understood networks, I thought about what life was like without them:

Without networks:

  • Want to share a file? Use a USB drive
  • Want to print? Plug directly into the printer
  • Want information? Go to a library
  • Want to communicate? Write a letter or make a phone call

With networks:

  • Share files instantly across the world
  • Print to any printer on the network
  • Access any information in seconds (Google it!)
  • Video call someone on another continent

Networks enable resource sharing, communication, and collaboration on a global scale!

Types of Computer Networks

I was confused about LAN, WAN, and MAN until I understood it's just about geographical size.

1. Personal Area Network (PAN)

Range: Around you (typically 10 meters)

Examples:

  • Bluetooth connection between phone and headphones
  • Your laptop connected to wireless mouse/keyboard
  • Smartwatch syncing with your phone

My experience: I use PAN every day when my AirPods connect to my phone!

2. Local Area Network (LAN)

Range: One building or campus (up to a few kilometers)

Examples:

  • University campus network
  • Office network
  • Home Wi-Fi

What I learned: My entire dorm building is one LAN. We all share the same internet connection and can access shared printers.

Technology: Ethernet cables, Wi-Fi routers

Speed: 100 Mbps to 10 Gbps

# Check devices on your local network (Linux/Mac)
arp -a

# Example output:
? (192.168.1.1) at aa:bb:cc:dd:ee:ff [ether] on wlan0    # Router
? (192.168.1.5) at 11:22:33:44:55:66 [ether] on wlan0    # Another device

3. Metropolitan Area Network (MAN)

Range: A city or large campus (up to 50km)

Examples:

  • City-wide cable TV network
  • Network connecting multiple university campuses
  • Municipal Wi-Fi in smart cities

Real-world example: My university has three campuses across the city, all connected via MAN. I can access the same resources from any campus!

4. Wide Area Network (WAN)

Range: Countries, continents, the entire world

Examples:

  • The Internet (the largest WAN!)
  • Corporate networks connecting offices worldwide
  • Banking networks connecting branches globally

What amazed me: When I access a website hosted in Japan from California, I'm using WAN. The data travels through multiple countries in milliseconds!

Technology: Fiber optic cables (including undersea cables!), satellite links

Comparison Table

TypeCoverageSpeedExamples
PAN10m1-3 MbpsBluetooth devices
LAN1 building100 Mbps - 10 GbpsHome/office Wi-Fi
MANCity10-100 MbpsCity-wide network
WANGlobalVariesThe Internet

Network Topologies: How Networks Are Arranged

Topology = The physical or logical arrangement of devices in a network

Think of it like how students can sit in a classroom—in rows, in a circle, or in groups. Each arrangement has pros and cons!

1. Bus Topology

Structure: All devices connected to a single backbone cable

Device1 ---|
Device2 ---|--- [Main Cable] ---|--- Server
Device3 ---|

Pros:

  • Simple and cheap
  • Easy to add devices

Cons:

  • If the main cable fails, entire network fails
  • Performance degrades with more devices
  • Difficult to troubleshoot

Real-world use: Old Ethernet networks (rarely used now)

2. Star Topology

Structure: All devices connect to a central hub/switch

        Device1
           |
Device2 - [Hub] - Device3
           |
        Server

Pros:

  • Easy to manage
  • If one device fails, others aren't affected
  • Easy to troubleshoot
  • Can add/remove devices without disrupting network

Cons:

  • If central hub fails, entire network fails
  • More cable required than bus

Real-world use: This is what most modern networks use! Your home Wi-Fi router is the central hub.

3. Ring Topology

Structure: Each device connects to exactly two others, forming a circle

Device1 -- Device2
  |            |
Device4 -- Device3

How it works: Data travels in one direction around the ring

Pros:

  • Equal access for all devices
  • No collisions

Cons:

  • If any device fails, the entire ring breaks
  • Difficult to troubleshoot

Real-world use: Token Ring networks (mostly obsolete now)

4. Mesh Topology

Structure: Every device connects to every other device

Device1 ====== Device2
  ||  \\    //  ||
  ||   \\  //   ||
  ||    \\//    ||
Device3 ====== Device4

Pros:

  • Extremely reliable (multiple paths)
  • No traffic congestion
  • If one connection fails, data finds another route

Cons:

  • Very expensive (lots of cables!)
  • Complex to set up and manage

Real-world use:

  • Military networks
  • The Internet backbone (partial mesh)
  • Critical infrastructure

5. Hybrid Topology

Structure: Combination of two or more topologies

Example: Your university network might use:

  • Star topology within each building
  • Ring or mesh topology to connect buildings

Real-world use: Most large networks use hybrid topology

The OSI Model: How Network Communication Works in Layers

This was the most confusing concept until my professor explained it with an analogy:

The Letter-Sending Analogy

Imagine sending a physical letter:

  1. You write the message (content)
  2. You put it in an envelope (addressing)
  3. You take it to a mailbox (local delivery)
  4. Postal service sorts it (routing)
  5. Trucks/planes transport it (physical transport)
  6. Postal service at destination sorts it
  7. Mail carrier delivers to address
  8. Recipient opens envelope and reads

Networks work the same way—but with 7 layers!

The 7 Layers of OSI Model

Layer 7: Application    <- You interact here (web browser, email)
Layer 6: Presentation   <- Data formatting (encryption, compression)
Layer 5: Session        <- Establishes connections
Layer 4: Transport      <- Reliable delivery (TCP/UDP)
Layer 3: Network        <- Routing (IP addresses)
Layer 2: Data Link      <- Direct device-to-device (MAC addresses)
Layer 1: Physical       <- Actual cables and signals

Mnemonic I learned: "All People Seem To Need Data Processing"

Let me explain each layer with examples:

Layer 1: Physical Layer

What it does: Transmits raw bits (0s and 1s) over physical medium

Examples:

  • Ethernet cables
  • Fiber optic cables
  • Wi-Fi radio waves
  • Bluetooth signals

Analogy: The roads and highways for postal trucks

Real-world: When I plug an Ethernet cable into my laptop, that's Layer 1!

What it does: Packages bits into frames and handles device-to-device communication

Key concepts:

  • MAC addresses: Unique hardware identifier (like AA:BB:CC:DD:EE:FF)
  • Error detection: Checks if data arrived correctly
  • Flow control: Prevents fast sender from overwhelming slow receiver

Devices: Switches, network interface cards (NICs)

Example: Your laptop's Wi-Fi card has a unique MAC address

# Find your MAC address (Linux/Mac)
ifconfig | grep ether

# Output:
ether aa:bb:cc:dd:ee:ff

Layer 3: Network Layer

What it does: Routes packets across different networks using IP addresses

Key concepts:

  • IP addresses: Logical addresses (like 192.168.1.5 or 2001:db8::1)
  • Routing: Finding the best path to destination
  • Packet forwarding: Sending packets to the next hop

Devices: Routers

Protocols: IP (Internet Protocol), ICMP (ping uses this!)

Example: When I ping Google, routers use Layer 3 to find the path:

# Trace route to google.com
traceroute google.com

# Output shows each router (hop) along the path:
1  192.168.1.1 (my router)           2ms
2  10.0.0.1 (ISP router)              15ms
3  72.14.238.232 (regional router)    25ms
...
12 142.250.185.46 (Google server)     35ms

Layer 4: Transport Layer

What it does: Ensures reliable, ordered delivery of data

Key protocols:

TCP (Transmission Control Protocol):

  • Reliable delivery (guarantees data arrives)
  • Ordered (packets arrive in correct order)
  • Connection-oriented (handshake before data transfer)
  • Use case: Web pages, email, file transfers

UDP (User Datagram Protocol):

  • Unreliable delivery (fire and forget)
  • No ordering guarantee
  • Connectionless (no handshake)
  • Use case: Video streaming, gaming, DNS lookups

Example: When I watch YouTube, the video uses UDP (some packet loss is OK). But when I download a file, it uses TCP (need every byte!).

# Python TCP socket example
import socket

# Create TCP socket
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.connect(('example.com', 80))

# Create UDP socket
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_socket.sendto(b'Hello', ('example.com', 53))

Layer 5: Session Layer

What it does: Manages sessions (connections) between applications

Key functions:

  • Establishes sessions
  • Maintains sessions
  • Terminates sessions
  • Synchronization checkpoints

Example: When I log into a website, the session layer keeps track of my logged-in state across multiple page requests.

Layer 6: Presentation Layer

What it does: Translates data between application and network format

Key functions:

  • Encryption/Decryption: HTTPS uses this layer
  • Compression: Reducing data size
  • Data format conversion: ASCII to EBCDIC, JPEG encoding

Example: When I visit an HTTPS website, Layer 6 encrypts my data before sending!

Layer 7: Application Layer

What it does: Provides network services directly to user applications

Protocols you use every day:

  • HTTP/HTTPS: Web browsing
  • FTP: File transfer
  • SMTP: Sending email
  • POP3/IMAP: Receiving email
  • DNS: Domain name resolution
  • SSH: Secure remote access

Example: When I type google.com in my browser, I'm interacting with Layer 7!

TCP/IP Model: What Actually Powers the Internet

While studying, I learned that the OSI model is theoretical, but the TCP/IP model is what the Internet actually uses!

TCP/IP Layers (4 layers instead of 7)

Application Layer     <- HTTP, FTP, DNS, SSH (OSI Layers 5-7 combined)
Transport Layer       <- TCP, UDP (OSI Layer 4)
Internet Layer        <- IP, ICMP (OSI Layer 3)
Network Access Layer  <- Ethernet, Wi-Fi (OSI Layers 1-2 combined)

TCP/IP in Action: Loading a Web Page

Let me break down what happens when I type www.example.com in my browser:

Step 1: Application Layer (HTTP)

Browser: "I need to GET the page at www.example.com"

Step 2: Transport Layer (TCP)

TCP: "I'll break this request into packets and number them"
TCP: "I'll establish a connection first (3-way handshake)"

SYN ->
    <- SYN-ACK
ACK ->

TCP: "Connection established! Now sending data..."

Step 3: Internet Layer (IP)

IP: "I need to find the IP address of www.example.com"
DNS Lookup: www.example.com -> 93.184.216.34
IP: "I'll add the destination IP address to each packet"
IP: "I'll find the best route to 93.184.216.34"

Step 4: Network Access Layer (Ethernet/Wi-Fi)

Ethernet: "I'll add the MAC address of the next hop (my router)"
Wi-Fi: "I'll convert this to radio signals and transmit"

Then the process reverses at the destination!

IP Addresses Explained

IPv4 Addresses

Format: Four numbers (0-255) separated by dots

Example: 192.168.1.100

My laptop's IP address:

# Linux/Mac
ifconfig
# or
ip addr show

# Output:
inet 192.168.1.100  netmask 255.255.255.0

Classes of IP addresses:

Class A: 1.0.0.0 to 126.255.255.255 (for very large networks) Class B: 128.0.0.0 to 191.255.255.255 (for medium networks) Class C: 192.0.0.0 to 223.255.255.255 (for small networks)

Private IP ranges (not routable on Internet):

  • 10.0.0.0 to 10.255.255.255
  • 172.16.0.0 to 172.31.255.255
  • 192.168.0.0 to 192.168.255.255

Public IP address: What the outside world sees

# Find your public IP
curl ifconfig.me
# or
curl ipinfo.io/ip

IPv6 Addresses

Why we need it: We're running out of IPv4 addresses! (only 4.3 billion possible)

Format: Eight groups of hexadecimal digits

Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Shortened: 2001:db8:85a3::8a2e:370:7334 (consecutive zeros can be compressed)

Subnet Mask

What it does: Divides IP address into network and host portions

Example:

  • IP: 192.168.1.100
  • Subnet mask: 255.255.255.0
  • Network portion: 192.168.1 (first 24 bits)
  • Host portion: 100 (last 8 bits)

CIDR notation: 192.168.1.100/24 (the /24 means first 24 bits are network)

Network Protocols You Use Every Day

1. HTTP/HTTPS (Web Browsing)

HTTP: HyperText Transfer Protocol HTTPS: HTTP Secure (encrypted)

What I learned: Every website you visit uses HTTP(S)

# HTTP request
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0

# HTTP response
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1234

<html>...</html>

2. DNS (Domain Name System)

What it does: Translates domain names to IP addresses

# Look up IP address of a domain
nslookup google.com

# Output:
Server:  8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name:    google.com
Address: 142.250.185.46

Why we need it: Would you rather remember google.com or 142.250.185.46?

3. DHCP (Dynamic Host Configuration Protocol)

What it does: Automatically assigns IP addresses to devices on a network

What happens when you connect to Wi-Fi:

  1. Your device: "I need an IP address!"
  2. DHCP server: "Here's 192.168.1.105, use subnet mask 255.255.255.0, and use 192.168.1.1 as your gateway"
  3. Your device: "Thanks!" (now you can access the internet)

4. SSH (Secure Shell)

What it does: Secure remote access to computers

# Connect to remote server
ssh alice@server.example.com

# Now I can run commands on the remote server!

5. FTP (File Transfer Protocol)

What it does: Transfer files between computers

# Connect to FTP server
ftp ftp.example.com

# Commands:
ls          # List files
get file.txt  # Download
put file.txt  # Upload

Network Devices Explained

1. Router

What it does: Connects different networks and routes packets

Example: Your home router connects your home network (LAN) to the Internet (WAN)

My home router:

  • Assigns IP addresses via DHCP
  • Provides Wi-Fi access point
  • Acts as firewall
  • Does NAT (Network Address Translation)

2. Switch

What it does: Connects devices within the same network

How it's different from router: Switch works at Layer 2 (MAC addresses), router works at Layer 3 (IP addresses)

Example: Office building with 50 computers—all connected through switches, which connect to one router for Internet access

3. Hub (Obsolete)

What it does: Connects devices but broadcasts to all ports

Why it's obsolete: Inefficient! If Device A sends to Device B, the hub also sends to Devices C, D, E... (wasteful)

Replaced by: Switches (which only send to the intended recipient)

4. Access Point

What it does: Provides Wi-Fi connectivity

Example: The Wi-Fi access points around my university campus

5. Modem

What it does: Modulates/demodulates signals for Internet connection

Example: Cable modem converts cable TV signals to Ethernet

Common confusion: Router vs Modem

  • Modem: Connects you to Internet service provider
  • Router: Connects multiple devices and manages traffic

Most home devices are modem-router combos!

TCP vs UDP: When to Use Each

TCP (Transmission Control Protocol)

Characteristics:

  • Reliable delivery
  • Ordered packets
  • Error checking
  • Flow control
  • Connection-oriented (handshake)

Use cases:

  • Web browsing (HTTP/HTTPS)
  • Email (SMTP, IMAP)
  • File transfer (FTP, SFTP)
  • SSH connections

Example: Downloading a file—you need every byte!

UDP (User Datagram Protocol)

Characteristics:

  • Unreliable delivery (no guarantee)
  • No ordering
  • Minimal error checking
  • No flow control
  • Connectionless (no handshake)

Use cases:

  • Video streaming (YouTube, Netflix)
  • Online gaming
  • DNS lookups
  • VoIP calls

Example: Video call—if a frame is lost, just show the next one (no time to retransmit!)

Speed comparison:

  • UDP: Faster (less overhead)
  • TCP: Slower but reliable

Common Networking Commands

Here are the commands I use regularly:

Check Network Configuration

# Linux/Mac
ifconfig        # Show network interfaces
ip addr show    # Modern alternative to ifconfig

# Windows
ipconfig        # Show network configuration

Test Connectivity

# Ping (test if host is reachable)
ping google.com

# Traceroute (show path to host)
traceroute google.com    # Linux/Mac
tracert google.com       # Windows

# DNS lookup
nslookup google.com
dig google.com           # More detailed

Network Scanning

# See all devices on local network
arp -a

# Scan ports (Linux)
nmap -p 80,443,22 example.com

Check Open Connections

# See active network connections
netstat -an

# See which program uses which port (Linux)
sudo lsof -i -P -n

Network Security Basics

Common Threats I Learned About

1. Man-in-the-Middle Attack

  • Attacker intercepts communication between two parties
  • Protection: Use HTTPS (encrypted)

2. Packet Sniffing

  • Attacker captures data packets on the network
  • Protection: Use VPN, encrypted protocols

3. DDoS (Distributed Denial of Service)

  • Overwhelm server with traffic
  • Protection: Rate limiting, CDNs

Best Practices

✅ Always use HTTPS (look for the padlock in browser) ✅ Use strong Wi-Fi passwords (WPA3 encryption) ✅ Don't use public Wi-Fi for sensitive data (use VPN) ✅ Keep router firmware updated ✅ Use firewall

Conclusion: Networks Connect the World

After learning about computer networks, I have a newfound appreciation every time I:

  • Load a web page
  • Send a message
  • Watch a video
  • Make a video call

It's not magic—it's brilliant engineering! Layers of protocols working together, routers finding optimal paths in milliseconds, error correction happening invisibly.

Key takeaways from my networking journey:

  1. Networks enable global communication through interconnected devices
  2. Different network types serve different geographical needs (PAN, LAN, MAN, WAN)
  3. Network topologies define how devices are physically or logically arranged
  4. OSI and TCP/IP models break networking into manageable layers
  5. IP addresses and protocols enable devices to find and communicate with each other
  6. TCP provides reliability, UDP provides speed
  7. Understanding networks makes you better at web development, system administration, and troubleshooting

You don't need to be a network engineer to benefit from understanding these basics. Knowing how networks work:

  • Helps you troubleshoot connection issues
  • Makes you a better web developer
  • Opens career opportunities in networking and cybersecurity
  • Helps you appreciate the complexity behind simple actions like clicking a link

Start exploring! Use ping, traceroute, and network monitoring tools. Set up a home lab. The more you experiment, the more it makes sense.

Remember, the Internet that connects billions of people started with just a few connected computers. Understanding these fundamentals connects you to that incredible legacy!

Happy networking, and may your packets always find their destination! 🌐


Fascinated by computer networks? I'd love to discuss networking concepts and answer questions! Connect with me on Twitter or LinkedIn for more networking and computer science discussions.

Support My Work

If this guide helped you understand computer networks, how the Internet works, and networking fundamentals like TCP/IP and the OSI model, I'd really appreciate your support! Creating comprehensive, beginner-friendly tutorials with practical examples and commands takes significant time and effort. Your support helps me continue sharing knowledge and creating more helpful resources for computer science students.

☕ Buy me a coffee - Every contribution, big or small, means the world to me and keeps me motivated to create more content!


Cover image by Thomas Jensen on Unsplash

Related Blogs

Ojaswi Athghara

SDE, 4+ Years

Š ojaswiat.com 2025-2027