Skip to content
Computer Networks Explained — Beginner's Guide

Computer Networks Explained — Beginner's Guide

DodaTech Updated Jun 6, 2026 9 min read

Computer networking is how computers communicate — from your phone loading a webpage to servers exchanging data across continents. The internet is the world’s largest network.

What You’ll Learn

In this tutorial, you’ll learn the OSI and TCP/IP models, how HTTP and DNS work, and what happens when you type a URL into your browser.

Why It Matters

Every application you build will communicate over a network. Understanding how data travels helps you debug issues, build faster apps, and secure your systems.

Real-World Use

When you type “google.com” into your browser, your computer sends packets through multiple routers, DNS servers convert the name to an IP address, and Google’s server sends back HTML — all in under a second.

    flowchart LR
  A[Your Browser] --> B[Your Router]
  B --> C[ISP Router]
  C --> D[DNS Server]
  D --> C
  C --> E[Google Server]
  E --> C
  C --> B
  B --> A
  B -- "DNS Query: what is google.com?" --> D
  D -- "Response: 142.250.80.46" --> B
  C -- "HTTP Request" --> E
  E -- "HTTP Response (HTML)" --> C
  

The OSI Model

The OSI (Open Systems Interconnection) model is a conceptual framework that divides network communication into 7 layers. Each layer has a specific job.

The Layers (From Bottom to Top)

LayerNameWhat It DoesExample
7ApplicationUser-facing appsHTTP, FTP, SMTP
6PresentationData format, encryptionSSL/TLS, JPEG
5SessionConnection managementNetBIOS, RPC
4TransportReliable deliveryTCP, UDP
3NetworkRouting & addressingIP, ICMP
2Data LinkPhysical addressingEthernet, Wi-Fi
1PhysicalRaw bit transmissionCables, radio waves

How Data Flows Through the Layers

Think of it like sending a package:

  • Application — you write a letter (HTTP request)
  • Presentation — you translate it (encryption)
  • Session — you decide to send it now
  • Transport — you break it into boxes and label each (TCP segments)
  • Network — you address each box (IP packets)
  • Data Link — you put each box in a mail truck (frames)
  • Physical — the truck drives to the destination (bits on wire)

On the receiving end, the process reverses — each layer unwraps its part until the application gets the original data.

# Simulating the OSI model layers
import json

def application_layer(message):
    """Layer 7: Create the HTTP request"""
    http_request = f"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n{message}"
    print(f"L7 Application: Created HTTP request ({len(http_request)} bytes)")
    return http_request

def transport_layer(data, use_tcp=True):
    """Layer 4: Add TCP header (source/dest ports, sequence number)"""
    segment = {
        "source_port": 54321,
        "dest_port": 80,
        "seq_num": 1001,
        "data": data,
        "checksum": sum(data.encode()) % 65535
    }
    print(f"L4 Transport: Created TCP segment to port {segment['dest_port']}")
    return segment

def network_layer(segment):
    """Layer 3: Add IP header (source/dest IPs)"""
    packet = {
        "source_ip": "192.168.1.5",
        "dest_ip": "93.184.216.34",
        "ttl": 64,
        "protocol": "TCP",
        "segment": segment
    }
    print(f"L3 Network: Routing to {packet['dest_ip']}")
    return packet

def link_layer(packet):
    """Layer 2: Add MAC address and frame"""
    frame = {
        "source_mac": "00:1A:2B:3C:4D:5E",
        "dest_mac": "AB:CD:EF:01:23:45",
        "packet": packet,
        "fcs": "0xDEADBEEF"  # Error detection
    }
    print(f"L2 Data Link: Sending frame to {frame['dest_mac']}")
    return frame

# Simulate sending a message
message = "Hello, server!"
print("=== Sending Data ===")
data = application_layer(message)
segment = transport_layer(data)
packet = network_layer(segment)
frame = link_layer(packet)

print("\n=== Frame Size ===")
print(f"Original message: {len(message)} bytes")
print(f"Frame size: {len(json.dumps(frame))} bytes")
print(f"Overhead: {len(json.dumps(frame)) - len(message)} bytes")

Expected output:

=== Sending Data ===
L7 Application: Created HTTP request (55 bytes)
L4 Transport: Created TCP segment to port 80
L3 Network: Routing to 93.184.216.34
L2 Data Link: Sending frame to AB:CD:EF:01:23:45

=== Frame Size ===
Original message: 14 bytes
Frame size: ~380 bytes
Overhead: ~366 bytes

TCP/IP Model

The TCP/IP model is the practical implementation that powers the internet. It has 4 layers (condensed from OSI’s 7):

TCP/IP LayerEquivalent OSI LayersProtocols
Application7, 6, 5 (Application, Presentation, Session)HTTP, DNS, FTP, SMTP
Transport4 (Transport)TCP, UDP
Internet3 (Network)IP, ICMP
Network Access2, 1 (Data Link, Physical)Ethernet, Wi-Fi

TCP vs UDP

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryBest effort (may lose packets)
OrderingOrdered deliveryNo ordering
SpeedSlower (due to overhead)Faster
Use casesWeb, email, file transferVideo streaming, gaming, DNS

How HTTP Works

HTTP is the protocol your browser uses to communicate with web servers.

import socket

# Simulating an HTTP request at a low level
def http_get(hostname, path="/"):
    """Simulate sending an HTTP GET request"""
    print(f"Connecting to {hostname}...")

    # DNS resolution (simplified)
    ip_address = f"resolved_ip_for_{hostname}"
    print(f"DNS resolved {hostname} -> {ip_address}")

    # Build HTTP request
    request = (
        f"GET {path} HTTP/1.1\r\n"
        f"Host: {hostname}\r\n"
        f"User-Agent: DodaTech Browser/1.0\r\n"
        f"Accept: text/html\r\n"
        f"Connection: close\r\n"
        f"\r\n"
    )

    print(f"\n--- HTTP Request ({len(request)} bytes) ---")
    print(request)
    print("--- End Request ---")

    # Simulated response
    response = (
        "HTTP/1.1 200 OK\r\n"
        "Content-Type: text/html\r\n"
        "Content-Length: 45\r\n"
        "Server: nginx/1.24.0\r\n"
        "\r\n"
        "<html><body><h1>Hello, World!</h1></body></html>"
    )

    print(f"\n--- HTTP Response ---")
    print(response[:200] + "...")
    print("--- End Response ---")

    return response

http_get("example.com", "/")

Expected output:

Connecting to example.com...
DNS resolved example.com -> resolved_ip_for_example.com

--- HTTP Request (98 bytes) ---
GET / HTTP/1.1
Host: example.com
User-Agent: DodaTech Browser/1.0
Accept: text/html
Connection: close

--- End Request ---

--- HTTP Response ---
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 45
Server: nginx/1.24.0

<html><body><h1>Hello, World!</h1></body></html>
...
--- End Response ---

How DNS Works

DNS converts human-readable domain names (google.com) into computer-readable IP addresses (142.250.80.46).

DNS Resolution Steps

def dns_lookup(domain):
    """Simulate a DNS lookup"""
    cache = {
        "google.com": "142.250.80.46",
        "youtube.com": "142.250.80.110",
        "facebook.com": "157.240.1.35",
        "dodatech.com": "192.0.2.1",
    }

    steps = []
    steps.append(f"1. Check browser cache for {domain}")

    if domain in cache:
        steps.append(f"2. CACHE HIT! Found in browser cache")
        return cache[domain], steps

    steps.append(f"2. Cache miss. Asking OS resolver")
    steps.append(f"3. OS checks its cache - miss")
    steps.append(f"4. Querying recursive DNS resolver (ISP)")
    steps.append(f"5. Resolver checks root DNS servers")

    if domain.endswith(".com"):
        steps.append(f"6. Root server points to .com TLD servers")
        steps.append(f"7. TLD server has record for {domain}")

    ip = cache.get(domain, "UNKNOWN")
    steps.append(f"8. Found: {domain} -> {ip}")
    return ip, steps

ip, steps = dns_lookup("google.com")
print("DNS Resolution Steps:")
for step in steps:
    print(f"  {step}")
print(f"\nResult: google.com resolves to {ip}")

Expected output:

DNS Resolution Steps:
  1. Check browser cache for google.com
  2. CACHE HIT! Found in browser cache
Result: google.com resolves to 142.250.80.46

What Happens When You Type a URL

Let’s trace the complete journey:

  1. Browser checks cache — has it visited this site before?
  2. DNS lookup — resolve the domain to an IP address
  3. TCP handshake — establish a connection (SYN, SYN-ACK, ACK)
  4. TLS handshake — if HTTPS, negotiate encryption
  5. HTTP request — send the GET request
  6. Server processes — server handles the request
  7. HTTP response — server sends back HTML
  8. Browser renders — browser parses HTML, fetches CSS/JS, renders the page

Network Security

Firewalls — Network firewalls block unauthorized traffic at the network/transport layers. They decide which packets are allowed based on source/dest IP and port.

HTTPS — HTTP over TLS encrypts all communication between browser and server. Without it, anyone on the same Wi-Fi network can read your data.

DNS Security — DNSSEC prevents DNS spoofing. DoH (DNS over HTTPS) encrypts DNS queries so your ISP can’t see what sites you visit.

DDoS protection — Distributed Denial of Service attacks flood servers with traffic. CDNs like Cloudflare absorb these attacks by distributing traffic across many servers.

Common Mistakes Beginners Make

1. Confusing TCP and UDP

TCP is reliable but slow. UDP is fast but unreliable. Choose based on your needs — file transfer needs TCP, video streaming can use UDP.

2. Thinking “localhost” is the same as “127.0.0.1”

They’re the same thing — both refer to your own computer. localhost resolves to 127.0.0.1.

3. Not understanding ports

Ports are like apartment numbers in a building (IP address). Port 80 = HTTP, 443 = HTTPS, 22 = SSH.

4. Ignoring network latency

Your packets don’t travel instantly. Light in fiber takes ~70ms round-trip across the Atlantic. Distance matters.

5. Forgetting about NAT

Your router uses NAT (Network Address Translation) to let multiple devices share one public IP. This is why your computer’s IP is usually 192.168.x.x.

Practice Questions

  1. What are the 7 layers of the OSI model? Physical, Data Link, Network, Transport, Session, Presentation, Application. Mnemonic: “Please Do Not Throw Sausage Pizza Away.”

  2. What’s the difference between TCP and UDP? TCP is connection-oriented with guaranteed delivery. UDP is connectionless with no delivery guarantee but lower latency.

  3. What does DNS do? Converts human-readable domain names (google.com) into machine-readable IP addresses (142.250.80.46).

  4. What happens in the TCP three-way handshake? SYN (client) → SYN-ACK (server) → ACK (client). This establishes a reliable connection.

  5. Why is HTTPS more secure than HTTP? HTTPS encrypts all data between browser and server using TLS. HTTP sends data in plaintext.

Challenge

Use curl -v http://example.com to see the full HTTP request/response including headers. Then try curl -v https://example.com and compare the TLS handshake in the output.

Real-World Task

Open your browser’s developer tools (F12) → Network tab. Reload this page. Look at the first request — examine the HTTP method, status code, headers, and timing.

FAQ

What is an IP address?
A unique numerical identifier for each device on a network. IPv4 (e.g., 192.168.1.1) and IPv6 (e.g., 2001:db8::1) are the two versions.
What is a subnet mask?
It defines which part of an IP address identifies the network and which part identifies the device. 255.255.255.0 means the first three numbers are the network.
What’s the difference between a hub, switch, and router?
Hub: broadcasts to all ports (dumb). Switch: sends only to the correct port (smart). Router: connects different networks and routes between them.
Can the internet run out of IP addresses?
IPv4 has ~4.3 billion addresses and is exhausted. IPv6 has 340 undecillion addresses — enough for every atom on Earth to have its own IP.
What is a VPN?
A Virtual Private Network encrypts all your traffic and routes it through another server, hiding your IP address from websites and your ISP.

Try It Yourself

▶ Try It Yourself Edit the code and click Run

Mini Project: Packet Sniffer Simulator

Build a Python script that:

  1. Captures network packets from a pcap file (or simulates them)
  2. Parses Ethernet, IP, and TCP headers
  3. Displays protocol information in a readable format

Security angle: Network monitoring tools like Wireshark use this same packet analysis to detect suspicious traffic. Antivirus and security tools analyze network patterns to identify command-and-control (C2) communication from malware.

What’s Next

Before moving on, you should understand:

  • The 7 OSI layers and the 4 TCP/IP layers
  • How DNS resolves domain names to IPs
  • The TCP three-way handshake
  • How HTTP requests and responses work

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

What’s Next

Congratulations on completing this Computer Networks tutorial! Here’s where to go from here:

  • Practice daily — Consistency is more important than long study sessions
  • Build a project — Apply what you learned by building something real
  • Explore related topics — Check out other tutorials in the same category
  • Join the community — Discuss with other learners and share your progress

Remember: every expert was once a beginner. Keep coding!

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro