TCP/IP Networking Notes


1. Connection Establishment

  • This is the three-way handshake process.
  • Client and server synchronize sequence numbers and confirm readiness.
  • Ensures both sides know the connection state before sending real data.

2. Data Transmission

  • Once the connection is established, actual data can be sent.

  • TCP provides:

    • Reliable delivery (ACKs + retransmissions)
    • Ordered delivery (sequence numbers)
    • Flow & congestion control (sliding window, buffer management)
  • This phase continues until all data has been successfully exchanged.


3. Connection Termination

  • Uses the four-way handshake.
  • Ensures all pending data is delivered before shutting down.
  • Either client or server can initiate termination.
  • Supports half-close (one side stops sending but can still receive).

Application Layers

Communication between the transport and application layers.

  • Contains high-level protocols covering many applications.

Sockets

Definition

endpoint of communication between two devices on a network

  • Interface between transport and application layer.
  • Between the operating system and transport layer.
  • Accesses services provided by the TCP/IP suite.
  • Uses IP address + port number.

Types of Sockets

  • Stream Socket (TCP)

    • Connection-oriented
    • Reliable
    • Ordered
    • Error-checked delivery
  • Datagram Socket (UDP)

    • Fast
    • Unreliable
    • Connectionless

Client–Server Architecture

Definition

Model where multiple client devices communicates and request services from central server.

Server

Computer or program that provides services or resources to clients over a network.

  • Runs indefinitely (infinite program).
  • Waits for client requests and responds accordingly.

Client

A computer or program that initiates a request for services / resources from a server over a network.

  • Finite program (runs when triggered by user or application, ends after service).
  • Opens communication channel using server’s IP.
  • Uses well-known server ports to locate the server program.
    • Sends requests and receives responses until the process ends

Advantages

  • centralized resource management:
    • server holds and manages resources
    • central control of data security backups and user access
  • scalability:
    • new clients can be added without changes
    • system hardware can be upgraded to service more clients
  • security:
    • enforce security policies from server
    • eg: user authentication, file permissions and monitoring network traffic
  • ease maintenance:
    • software updates backups and system only have to apply to server
    • no need to reconfigure client devices every time
  • reliability and consistency:
    • data stored is consistent and all clients access should be up to date
  • remote access support:
    • should be accessible from anywhere over the internet(remote desktop protocol…ect)

Disadvantages

  • Single point of failure - all clients lose access to services due to server failure
  • High setup & maintenance cost - expensive startup/ hardware / administrative
  • Risk of network congestion/overload
  • Heavy network dependence - needs stable connection

Peer-to-Peer (P2P)

Definition

a decentralized model where computer acts as both the client and server

Characteristics

  • Equal roles for peers - can both receive and send requests
  • No central authority - resources managed by peers
  • Resource sharing (files, processing power, bandwidth)
  • Autonomy (peers may join/leave anytime, peers manage their own resources)

Advantages

  • Low cost(does not needserver infrastructure n hardware)
  • Scalability - new peers can join the network to contribute
  • No single point of failure - continue operation even after failure of a peer
  • Efficient resource sharing - stated above of same point

Disadvantages

  • lack centralized control - no central authority: unable to manage resources and security, enforcement of rules and monitoring activity
  • security risks - peer is responsible for their own saftey
    • malicious peers can spread harmful files
  • data consistency issues - shared files may not be up to date
  • performance - low performance if only few peers or low bandwidth

DHCP (Dynamic Host Configuration Protocol)

Automatically assigns IP addresses and configuration parameters to devices on a network:

  • IP address
  • Subnet mask
  • Default gateway
  • DNS server
  • Lease duration
    automation for a otherwise error prone inefficient process

DORA Process

  1. Discover – client broadcasts to find available DHCP servers.
  2. Offer – DHCP server replies with an IP and config.
  3. Request – client requests to use the IP offered.
  4. Acknowledge – server confirms and leases the IP.

Uses UDP (lightweight, connection-less, no handshake).

  • client doesn’t have a IP destination address to use the TCP
  • also basically faster and easier to setup

Types of IP Allocation

  • dynamic IP address:
    • leases a reusable IP to the client for a period of time
    • goes by the DORA process
  • Static IP address:
    • Device manually configured with IP address, sub-net mask gateway and DNS
    • DHCP reservation:
      • use of the MAC address of specific device to get the same IP address from the DHCP pool
      • same IP assigned using device’s MAC.

DNS (Domain Name System)

Translates domain names → IP addresses.

Mapping of host name to IP

  1. host name is passed to the file transfer client
  2. FTC passes the host name to the DNS client
  3. DNS queries DNS server regarding FT server name, responds with the IP address of the DNS server
  4. DNS server responds with IP of FT server
  5. DNS client passes IP address to the FT server
  6. FT uses it to access the FT server

Resolution Process

  1. Check local cache.
  2. Query Local DNS (Internet Service Provider’s DNS resolver)
    • client sends a query to the DNS server specifies in the IP configuration(i use 1.1.1.1 which is Cloud-flare)
    • the server checks its own cache
  3. If not cached, resolver queries global DNS hierarchy:
    • Recursive: ISP DNS performs the lookup:
      • each layer directs the server to the next
        1. root DNS server directs the TOP level domain servers (.com .org .sg)
        2. TLD server directs to the authoritative DNS server for the domain
        3. The authoritative DNS servers returns the actual IP address
    • Iterative: client follows step by step with the same process as above (root → TLD → authoritative).
  4. IP is returned to client.

Caching(informational)

  • Stores results to speed up future queries.
  • Uses TTL (time-to-live) (basically expiry period).
  • Risk: outdated mappings.

informational

caching - reduction of search time by DNS
• When a server asked for a mapping from another server and receives the mapping, it stores this mapping in its cache memory before sending it to the client.
• When a client asks for the same mapping, the server checks its cache memory and resolve it. To inform the client that the mapping is from the cache and not from an authoritative source, the server marks the mapping as unauthoritative.
• Problem with caching – mapping might be outdated.
• Time-to-live (TTL) – time in seconds that the server can cache
• TTL is added to each mapping.
• Mapping with expired TTL will be purged periodically

Transport

  • Primarily UDP (fast, lightweight, stateless).
    • good for when users expect fast responses
    • DNS queries fit into UDP data-gram
    • easier and faster to set up
  • Uses TCP when:
    • Responses too large (e.g., IPv6).
    • DNS Server synchronization.

HTTP (HyperText Transfer Protocol)

Definition

HTTP is a stateless protocol - server does not keep infor about the client. the client inits the transaction by sending a request, and the server replies with the response

Request Format

GET /test.html HTTP/1.1

  • Method
  • Path to document
  • HTTP version
  • Optional: headers, message body (e.g., POST data submission).

Response Format

  • Status line (version + status code)
    • 200 OK
    • 404 Not Found
    • 500 Internal Server Error
  • Headers: additional info
  • Message body (e.g., HTML document, content format dictated by content type header)

Email Protocols

SMTP (Simple Mail Transfer Protocol)

Definition

protocol used to send/relay emails across the internet

  • not for accessing emails tho
  • Used for sending/relaying emails.
  • Ports 25 / 587 (secure).
  • Message structure:
    • Envelope (MAIL FROM, RCPT TO, DATA)
    • Headers - sender, receiver content type
    • Body - behind message content

POP3 (Post Office Protocol v3)

Definition

used to download emails from the server to the client, and delete messages from the mailbox on the server

  • Used for downloading emails.
  • Ports 110 / 995 (secure).
  • Messages usually deleted from server after download.
  • process
    • mail starts with the client
    • client opens a connection to server via tcp on port 110
    • sends username and password to access mailbox
    • list and retrieve messages one by one

IMAP4 (Internet Message Access Protocol v4)

  • Allows viewing & managing emails directly on server(kind of similar to POP3), from multiple locations
  • Ports 143 / 993 (secure).
  • Supports synchronization across devices.
  • Can fetch headers or partial messages.
    • better for slow speed connections
    • MS outlook, apple mail, mozilla thunderbird(technically the browser)

FTP (File Transfer Protocol)

Protocol for copying files between hosts.

Features

  • Handles naming conventions, data formats, and directory structures.
  • Uses two connections:
    • Port 21: control channel (client commands / server responses).
    • Port 20: data transfer (file upload/download, directory listing).
  • Control channel remains open, data channel opens/closes as needed.


✧ ✧ ✧