Unit 2 - Notes

CSE357 7 min read

Unit 2: Computer Networking Basics

1. Foundations of Computer Networks

1.1 Definition and Goals

A Computer Network is a set of computers connected together for the purpose of sharing resources. The connection between computers can be done via cabling, usually the Ethernet cable, or wirelessly through radio waves.

  • Key Goals:
    • Resource Sharing: Sharing printers, storage devices, and files.
    • High Reliability: Replication of files on multiple machines ensures data availability even if one fails.
    • Scalability: Ability to increase system performance gradually by adding more processors.
    • Communication Medium: Facilitating email, chat, and video conferencing.

1.2 Classification by Geographical Scope

  1. PAN (Personal Area Network): Smallest scope (e.g., Bluetooth connecting a phone to headphones). Range: ~10 meters.
  2. LAN (Local Area Network): Covers a small geographic area like a home, office, or building. High data transfer rates. Ethernet/Wi-Fi are standard.
  3. MAN (Metropolitan Area Network): Connects LANs across a city (e.g., Cable TV network).
  4. WAN (Wide Area Network): Spans large physical distances (countries/continents). The Internet is the largest WAN.
  5. SAN (Storage Area Network): A specialized, high-speed network that provides block-level network access to storage.

1.3 Data Switching Techniques

How data moves from source to destination.

  • Circuit Switching: A dedicated physical path is established before data transfer (e.g., old telephone networks).
    • Pros: Constant bandwidth, no delay once established.
    • Cons: Inefficient use of resources during silence/idling.
  • Packet Switching: Data is broken into small chunks called "packets." Each packet travels independently, potentially taking different routes.
    • Pros: Efficient line usage, robust against line failure.
    • Cons: Variable delay (jitter), requires reassembly at destination.

2. Network Topologies and Transmission Medium

2.1 Network Topologies

The geometric arrangement of devices (nodes) and links in a network.

Topology Description Advantages Disadvantages
Bus All nodes connect to a single central cable (backbone). Cheap, easy to install, requires less cable. Single point of failure (cable break), heavy traffic slows performance.
Star All nodes connect to a central device (Hub/Switch). Easy to troubleshoot, failure of one node doesn't affect others. Dependent on central hub; more cabling than Bus.
Ring Nodes connect in a closed loop; data travels in one direction. No collisions (token passing), equal access for all. Failure of one node breaks the ring; difficult to troubleshoot.
Mesh Full Mesh: Every node connects to every other node. Partial Mesh: Some redundancy. Highest reliability and fault tolerance; best security. Very expensive; complex cabling and installation.
Tree Hierarchical structure; "Star of Stars." Scalable, easy to manage parent-child hierarchy. If the root node fails, the sub-branches disconnect.

2.2 Transmission Media

The physical path between transmitter and receiver.

A. Guided Media (Wired)

  1. Twisted Pair Cable:
    • UTP (Unshielded Twisted Pair): Common in LANs (Cat5e, Cat6). Cheap, flexible, prone to EMI (Electromagnetic Interference).
    • STP (Shielded Twisted Pair): Has metal shielding. Better protection against interference, more expensive.
  2. Coaxial Cable: Central copper conductor surrounded by insulation and a metal shield. Used in Cable TV and early Ethernet. High bandwidth, resistant to noise.
  3. Fiber Optic Cable: Transmits data as light pulses using glass/plastic strands.
    • Single-Mode: Long distance, laser light source, small core.
    • Multi-Mode: Shorter distance, LED source, larger core.
    • Note: Immune to electromagnetic interference, highest speed, expensive.

B. Unguided Media (Wireless)

  1. Radio Waves: Omnidirectional; can penetrate walls. Used for AM/FM radio.
  2. Microwaves: Unidirectional (line-of-sight required). Used for cellular phones, satellite communications, and Wi-Fi.
  3. Infrared: Short-range communication (TV remotes). Cannot penetrate walls.

3. Understanding OSI and TCP/IP Models

3.1 The OSI Model (Open Systems Interconnection)

A conceptual 7-layer model developed by ISO to standardize network communication.

Mnemonic: Please Do Not Throw Sausage Pizza Away (Physical to Application).

Layer # Layer Name PDU (Unit) Key Function Devices/Protocols
7 Application Data End-user interface; network services for applications. HTTP, FTP, SMTP
6 Presentation Data Translation (ASCII/EBCDIC), Encryption, Compression. SSL/TLS, JPEG
5 Session Data Session establishment, maintenance, and termination. NetBIOS, RPC
4 Transport Segment End-to-end delivery, flow control, error correction. TCP, UDP
3 Network Packet Logical addressing (IP), Routing (path selection). Routers, IPv4/IPv6
2 Data Link Frame Physical addressing (MAC), Error detection (CRC). Switches, Bridges
1 Physical Bit Transmission of raw bits over physical medium. Hubs, Cables

3.2 The TCP/IP Model

A practical model on which the Internet is built. It condenses the OSI layers.

  1. Application Layer: Combines OSI Application, Presentation, and Session layers.
  2. Transport Layer: Maps to OSI Transport (TCP/UDP).
  3. Internet Layer: Maps to OSI Network (IP, ICMP, ARP).
  4. Network Access (Link) Layer: Combines OSI Data Link and Physical layers.

4. Subnetting and Routing

4.1 IP Addressing (IPv4)

An IPv4 address is a 32-bit number divided into 4 octets (e.g., 192.168.1.1).

  • Classes of IP Addresses:
    • Class A: 1.0.0.0 to 126.0.0.0 (Large networks, First octet is Net ID).
    • Class B: 128.0.0.0 to 191.255.0.0 (Medium networks).
    • Class C: 192.0.0.0 to 223.255.255.0 (Small networks/LANs).
    • Class D: Multicasting.
    • Class E: Experimental/Research.

4.2 Subnetting

The process of dividing a single large network into smaller, manageable sub-networks (subnets).

  • Subnet Mask: Differentiates the Network ID from the Host ID.
    • Default Class C Mask: 255.255.255.0 (or /24 in CIDR notation).
  • CIDR (Classless Inter-Domain Routing): Replaced classful addressing. Uses a suffix (e.g., /26) to indicate the number of bits used for the network portion.

Example Calculation (/26 network):

  • Base: 192.168.1.0/24.
  • Goal: Create 4 subnets. We need to borrow 2 bits ().
  • New Mask: /26.
  • Binary Mask: 11111111.11111111.11111111.11000000
  • Decimal Mask: 255.255.255.192.
  • Block Size (Increment): 64 ().
  • Subnet 1: 192.168.1.0 to 192.168.1.63
  • Subnet 2: 192.168.1.64 to 192.168.1.127

4.3 Routing

The process of selecting a path for traffic in a network.

  • Static Routing: Routes are manually configured by an administrator. Secure but not scalable.
  • Dynamic Routing: Routers exchange information to update routing tables automatically.
    • Distance Vector Protocols (e.g., RIP): Determine best path based on hop count. Vulnerable to routing loops.
    • Link State Protocols (e.g., OSPF): Build a full map (topology) of the network. Dijkstra’s algorithm determines the shortest path. Fast convergence.

5. Key Protocols

5.1 HTTP (HyperText Transfer Protocol) & HTTPS

  • Function: Foundation of data communication for the World Wide Web. Fetches resources (HTML docs).
  • Layer: Application.
  • Ports: HTTP (80), HTTPS (443).
  • Mechanism: Request-Response model.
    • Methods: GET (retrieve data), POST (submit data), PUT (update), DELETE.
    • Stateless: The server does not retain information about previous client requests (unless Cookies are used).
    • HTTPS: Uses SSL/TLS to encrypt the payload.

5.2 SMTP (Simple Mail Transfer Protocol)

  • Function: Used for sending emails from a client to a server, or between servers.
  • Layer: Application.
  • Ports: 25 (legacy), 587 (modern secure submission).
  • Mechanism: "Push" protocol. It pushes mail outward. It cannot "pull" mail from a server to a client.

5.3 Mail Access Protocols: POP vs. IMAP

Used by email clients (Outlook, Thunderbird) to retrieve emails from a server.

Feature POP3 (Post Office Protocol v3) IMAP (Internet Message Access Protocol)
Primary Function Download and delete. Synchronization.
Storage Emails stored locally on the device. Emails stored on the server.
Multi-device Poor (email exists on one device). Excellent (view same email on phone/laptop).
Ports 110 (Unsecure), 995 (SSL). 143 (Unsecure), 993 (SSL).

5.4 FTP (File Transfer Protocol)

  • Function: Transferring files between a client and server.
  • Ports:
    • Port 21: Command/Control connection (authentication, commands).
    • Port 20: Data connection (actual file transfer).
  • Modes: Active and Passive (PASV is friendlier to firewalls).
  • Security Note: FTP sends credentials in plain text. SFTP (SSH File Transfer Protocol) is the secure alternative.

5.5 DNS (Domain Name System)

  • Function: Translates human-readable domain names (www.google.com) into IP addresses (142.250.190.46). The "Phonebook of the Internet."
  • Port: 53 (UDP for queries, TCP for zone transfers).
  • Hierarchy:
    1. Root Servers (.)
    2. TLD Servers (.com, .org, .edu)
    3. Authoritative Name Servers (google.com)
  • Resolution Process:
    1. Client checks local cache.
    2. Asks Recursive Resolver (ISP).
    3. Resolver traverses the hierarchy (Root -> TLD -> Authoritative) to find the IP.

5.6 DHCP (Dynamic Host Configuration Protocol)

  • Function: Automatically assigns IP addresses and network configuration (Subnet mask, Gateway, DNS) to devices.
  • Ports: UDP 67 (Server), UDP 68 (Client).
  • The DORA Process:
    1. Discover: Client broadcasts "Is there a DHCP server?"
    2. Offer: Server replies "Yes, here is an IP I can offer."
    3. Request: Client says "I accept this IP."
    4. Acknowledge: Server confirms "The IP is yours for X amount of time (Lease)."