Computer Networking Notes for Competitive Exams | OSI, TCP/IP, Subnetting

Computer Networking Notes for Competitive Exams

This document provides an easy-to-understand overview of Computer Networking, based on the provided class materials, tailored for competitive exam preparation.


1. Introduction to Networking

A network is a collection of interconnected computing devices that can exchange data and share resources with each other.

  • First Network: ARPANET (Advanced Research Projects Agency Network) was created by the US Department of Defense in 1969.
  • First Email: Sent over ARPANET in 1971 by Ray Tomlinson.
  • Internet Founders: Bob Kahn and Vint Cerf are considered the founders of the internet.
  • Internet Birthday: January 1, 1983, marks the official adoption of TCP/IP protocols.
  • Internet in India: Publicly available service launched by VSNL on 15 August 1995.

Networking Models define guidelines and standards for data transmission and reception over a network. They are also known as networking architectures.

Two Primary Models:

  1. TCP/IP Model (1970-1983)
  2. OSI Model (1984)

2. Network Types and Classifications

Networks are classified based on their geographical area, ownership, and purpose.

  • LAN (Local Area Network):
    • Covers a small geographical area like an office or home.
    • Private network, high security.
    • Data transfer speed: 10 Mbps to 1 Gbps.
    • Uses devices like Hubs/Switches.
    • Cables: Twisted Pair, Coaxial Cable.
    • IEEE standards: 802.3 (Ethernet - Wired LAN), 802.11 (Wi-Fi - Wireless LAN).
  • WLAN (Wireless Local Area Network): A LAN that uses wireless communication (Wi-Fi).
  • MAN (Metropolitan Area Network):
    • Covers a city.
    • Created by interconnecting two or more LANs.
    • Uses Fiber Optic Cable. Example: Cable television network.
    • Devices: Hubs, Switches, Routers, Bridges. Less security than LAN.
    • IEEE standard: 802.6 .
  • WAN (Wide Area Network):
    • Telecommunication network covering large geographical areas like countries.
    • The Internet is the largest WAN.
    • Transmission medium: Satellite.
    • Devices: Routers. Less security than LAN, often requires Firewalls.
  • PAN (Personal Area Network):
    • Connects devices within a short range (e.g., 10 meters).
    • Examples: Bluetooth-enabled devices, Infrared devices, wireless keyboards/mice, hotspots, TV remotes.
    • IEEE standard: 802.15 (Wireless PANs), specifically 802.15.1 (Bluetooth) and 802.15.4 (Zigbee).
  • VPN (Virtual Private Network): A secure network connection over a public network.
  • SAN (Storage Area Network): Primarily used for cloud computing services like AWS, Microsoft Azure, Google Cloud Platform.
  • CAN (Campus Area Network):
    • Also known as a Corporate Area Network.
    • A group of interconnected LANs, typically covering 1 to 5 km.

Network Types (by Access):

  • Internet: A public network accessible by all.
  • Intranet: A private network for employees only.
  • Extranet: A private network shared between two companies.

3. Network Topologies

Topology refers to the physical or logical layout of a network.

  • Bus Topology:
    • Multipoint connection.
    • Common in LANs.
    • Fault tolerance is difficult.
    • Uses CSMA/CD (Carrier-sense multiple access with collision detection) and CSMA/CA (Carrier-sense multiple access with collision avoidance).
  • Star Topology:
    • All devices connect to a central device (e.g., a Hub).
    • Common in LANs.
  • Ring Topology:
    • Devices are connected in a circular fashion.
    • Uses tokens for data transmission.
    • FDDI (Fiber Distributed Data Interface) is an example.
  • Tree Topology: Hierarchical structure using multiple Hubs.
  • Mesh Topology:
    • Each device has a dedicated point-to-point link to every other device.
    • Highly reliable, offers high fault tolerance and scalability, but requires more cabling.
    • Used in home automation, often involves Routers.
    • To connect n devices in a fully connected mesh network, n(n-1)/2 links are required.
  • Hybrid Topology: A combination of two or more different topologies.

4. Transmission Media

Transmission media are the physical pathways over which data travels.

4.1. Guided/Bounded Media (Wired)

Data travels through a physical cable.

  • Twisted Pair Cable:
    • STP (Shielded Twisted Pair): Used in factories.
    • UTP (Unshielded Twisted Pair): Common for LAN connections.
    • Connector: RJ45 (Registered Jack-45).
  • Coaxial Cable:
    • Similar to TV cables.
    • Connector: BNC (Bayonet Neill–Concelman).
  • Optical Fiber Cable:
    • Fastest transmission medium.
    • Used for broadband connections and under-sea cables.
    • Connectors: SC , ST , LC , FC .

4.2. Unguided/Unbounded Media (Wireless)

Data travels through electromagnetic waves without a physical conductor.

  • Radio Waves: Used in wireless mice.
  • Microwaves: Used in remote sensing, radar, TV antennas.
  • Infrared Waves: Used in thermal imaging, TV remotes, and short-range communication between a PC and a peripheral device.

5. Communication Modes

Defines how data flows between two devices.

  • Simplex: Data transmission in only one direction.
    • Examples: TV, Radio, Keyboard to Monitor.
  • Half Duplex: Data can be transmitted in both directions, but only one direction at a time.
    • Examples: Walkie-talkie, Bluetooth.
  • Full Duplex: Data can be transmitted in both directions simultaneously.
    • Examples: Telephone, Video conferencing.

6. Network Models (OSI & TCP/IP)

These models provide a framework for understanding how data is transmitted across networks.

6.1. OSI Model (Open Systems Interconnection)

  • Developed by ISO (International Organization for Standardization) in 1984.
  • It is a Reference Model or Conceptual Model , not practically implemented as is.
  • Consists of 7 Layers , each with specific functions.
  • Layers follow a set of rules called Protocols .

6.2. TCP/IP Model (Transmission Control Protocol/Internet Protocol)

  • Developed by the US Department of Defense in the 1970s and standardized in 1983.
  • Developed by Vint Cerf and Bob Kahn.
  • It is the foundational protocol for the Internet.
  • Typically described with 4 or 5 Layers . The 5-layer model (Application, Transport, Internet, Data Link, Physical) is often used to better map to OSI.
  • Key difference from OSI: Session and Presentation layers are absent/combined into the Application layer.

6.3. OSI vs. TCP/IP Layer Mapping and PDU (Protocol Data Unit)

Each layer handles data in a specific format (PDU).

OSI Layer (7 Layers) TCP/IP Layer (5-Layer View) PDU (Data Unit) Main Functions Associated Devices Address Type
7. Application Layer Application Layer Data User interface, network services (e.g., email, web browsing). Protocols: HTTP , FTP , Telnet , DNS , SMTP , POP3 . Gateway (N/A)
6. Presentation Layer (Combined into Application) Data Data format translation, encryption, decryption, compression. Gateway (N/A)
5. Session Layer (Combined into Application) Data Establishes, maintains, and terminates connections (log on/off), synchronization, dialog control, token management. Gateway (N/A)
4. Transport Layer Transport Layer Segments End-to-end (host-to-host or process-to-process) reliable data delivery, segmentation/reassembly, flow control, acknowledgment. Heart of the OSI model. Protocols: TCP (connection-oriented), UDP (connectionless). Gateway Port Address
3. Network Layer Internet Layer Packets Logical addressing (IP), routing, forwarding packets across multiple network links, congestion control. Source-to-Destination delivery. Router IP Address (Logical Address)
2. Data Link Layer Data Link Layer Frames Node-to-node (hop-to-hop) error-free data transfer, MAC addressing, framing, flow/error control, CSMA/CA . Sub-layers: LLC (Logical Link Control) and MAC (Media Access Control). Switch, Bridge, Modem MAC Address (Physical Address)
1. Physical Layer Physical Layer Bits Physical connection maintenance, topology formation, bit synchronization, bit rate control, voltage, wire speed, cables. Closest to the transmission medium. Hub, Repeater, Modem, Cables (N/A)

7. Network Addressing

Different types of addresses are used to identify devices and processes on a network.

7.1. IP Address (Logical Address)

  • Identifies a device on the Internet.
  • IPv4: 32-bit address (4 bytes), written in decimal notation.
    • Classes:
      • Class A: 1.0.0.0 to 126.255.255.255 (First bit is 0)
      • Class B: 128.0.0.0 to 191.255.255.255 (First two bits are 10)
      • Class C: 192.0.0.0 to 223.255.255.255 (First three bits are 110)
      • Class D: 224.0.0.0 to 239.255.255.255 (Used for Multicast, first four bits are 1110)
      • Class E: 240.0.0.0 to 255.255.255.255 (Used for Research/Experimental, first four bits are 1111)
    • Default Subnet Masks:
      • Class A: 255.0.0.0
      • Class B: 255.255.0.0
      • Class C: 255.255.255.0
    • Private IP Address Ranges (Reserved by IANA):
      • 10.0.0.0 to 10.255.255.255 (Class A)
      • 172.16.0.0 to 172.31.255.255 (Class B)
      • 192.168.0.0 to 192.168.255.255 (Class C)
      • 100.64.0.0 to 100.127.255.255
    • Special IP Addresses:
      • Loopback Address: 127.0.0.1 (used for testing own system).
      • Broadcast IP Address: 255.255.255.255 (sends message to all devices on local network).
  • IPv6: 128-bit address (16 bytes), written in hexadecimal notation.
  • Changing IP Address: Can be done by switching networks, resetting modem, using VPN/proxy, or contacting ISP.
  • Developed by: IPv4 by DARPA , IPv6 by IETF .
  • Managed by: IANA (Internet Assigned Numbers Authority); in India, by APNIC .
  • Command to view IP: ipconfig .

7.2. MAC Address (Physical/Hardware/Ethernet/Burned-in Address)

  • Identifies a network device on a local network segment.
  • 48-bit address (6 bytes), written as a 12-digit hexadecimal number.
  • It is permanent and cannot be changed (burned into the NIC - Network Interface Card).
  • Developed by: Xerox PARC.
  • Command to view MAC: getmac .

7.3. Port Address

  • A 16-bit number (0-65535) used to identify specific applications or processes on a host.
  • Crucial for the Transport Layer to differentiate between multiple applications running on the same IP address.

Common Port Numbers:

  • FTP (File Transfer Protocol): 20 (Data Channel), 21 (Control Channel)
  • SFTP (SSH File Transfer Protocol): 22
  • Telnet : 23
  • SMTP (Simple Mail Transfer Protocol): 25
  • DNS (Domain Name System): 53
  • DHCP (Dynamic Host Configuration Protocol): 67 (Server), 68 (Client)
  • HTTP (Hypertext Transfer Protocol): 80
  • POP3 (Post Office Protocol v3): 110
  • IMAP (Internet Message Access Protocol): 143
  • IRC (Internet Relay Chat): 194
  • HTTPS (HTTP Secure): 443

8. Subnetting

Subnetting is the process of dividing a larger network into smaller, logical sub-networks (subnets).

  • Purpose/Uses:
    • To maintain security by isolating network segments.
    • Reduces network traffic and improves efficiency.
    • Divides broadcast domains, routing traffic more efficiently, enhancing network performance.
  • Classful Subnetting: All subnets are of the same size, have an equal number of hosts, and use the same subnet mask.
  • Classless Subnetting: Subnets are not necessarily of the same size, may not have an equal number of hosts, and can use different subnet masks ( CIDR - Classless Inter-Domain Routing).

8.1. Subnetting Calculations (Example for 192.168.10.0/30 )

Given an IP address 192.168.10.0/30 (a Class C network), let's find the subnet details.

The /30 indicates that 30 bits are used for the network portion of the IP address. For IPv4 (32 bits total):

  1. Subnet Mask:
    • The first 30 bits are '1's, and the remaining 2 bits are '0's.
    • 11111111.11111111.11111111.11111100
    • Converting to decimal: 255.255.255.252 .
  2. Total Number of Networks:
    • Class C default subnet mask is /24 ( 255.255.255.0 ). The "borrowed bits" for subnetting are 30 - 24 = 6 bits.
    • Number of networks = 2 n , where n is the number of borrowed bits.
    • 2 6 = 64 networks can be created.
  3. Total Number of Addresses per Network:
    • The "host bits" are the remaining bits after the network mask. For /30 , there are 32 - 30 = 2 host bits.
    • Number of addresses = 2 n , where n is the number of host bits.
    • 2 2 = 4 addresses per subnetwork.
  4. Total Number of Usable Hosts per Network:
    • From the total addresses, we subtract 2 (for the Network ID and Broadcast ID).
    • Usable hosts = 2 n - 2 , where n is the number of host bits.
    • 2 2 - 2 = 4 - 2 = 2 usable hosts per subnetwork.

Note: Network ID is the first address in a subnet, used to identify the subnet itself. Broadcast ID is the last address, used to send data to all hosts in that subnet. Neither can be assigned to individual hosts.


9. Key Networking Protocols

Protocols are rules that govern data communication.

  • TCP (Transmission Control Protocol):
    • Connection-oriented protocol.
    • Provides reliable, ordered, and error-checked delivery of a stream of bytes between applications.
    • Mechanisms for reliable delivery: Handshaking, Checksums, Sequence numbers, Acknowledgments.
    • Heart of the OSI Transport Layer.
  • UDP (User Datagram Protocol):
    • Connectionless protocol.
    • Offers faster transmission with lower overhead, but does not guarantee delivery, order, or error checking (unreliable).
    • Preferred for real-time applications like video streaming and online gaming where speed is more critical than guaranteed delivery.
  • IP (Internet Protocol):
    • Connectionless protocol.
    • Responsible for logical addressing and routing packets across networks.
  • HTTP (Hypertext Transfer Protocol): Used for web browsing (distributing, searching, and retrieving documents over the Internet).
  • HTTPS (HTTP Secure): Uses SSL/TLS encryption to protect data confidentiality and integrity.
  • FTP (File Transfer Protocol): Primary purpose is transferring files between a client and a server.
  • SFTP (SSH File Transfer Protocol): Secure version of FTP using SSH.
  • Telnet : Used for remote terminal connection service (remote login).
  • SMTP (Simple Mail Transfer Protocol): Used to send and distribute outgoing emails.
  • POP3 (Post Office Protocol v3): Allows users to download emails from the server to their local devices.
  • IMAP (Internet Message Access Protocol): Allows users to view and manipulate emails on the server without downloading them, enabling advanced email management and synchronization across devices.
  • DNS (Domain Name System): Translates human-readable domain names (e.g., google.com) into IP addresses.
  • DHCP (Dynamic Host Configuration Protocol): Automatically assigns IP addresses and network configuration settings to devices on a network.
  • ARP (Address Resolution Protocol): Translates IP addresses to MAC addresses.
  • RARP (Reverse Address Resolution Protocol): Translates MAC addresses to IP addresses (finds IP when only MAC is known).
  • ICMP (Internet Control Message Protocol): Used by network devices to send error messages and operational information. Also used for path MTU (Maximum Transmission Unit) discovery.
  • IRC (Internet Relay Chat): Used for real-time communication through text messaging.
  • RTP (Real-time Transport Protocol): Used for the transport of voice over IP (VoIP) communications.
  • SSL (Secure Socket Layer) / TLS (Transport Layer Security): Protocols providing secure communication over a computer network. SSL is generally considered deprecated, with TLS being its successor.
  • IEEE Standards:
    • 802.1 : LAN Protocol (Bridging)
    • 802.2 : Logical Link Control
    • 802.3 : Ethernet (Wired LAN)
    • 802.11 : WLAN (Wi-Fi)
    • 802.15 : Wireless PANs
    • 802.15.1 : Bluetooth
    • 802.15.4 : Zigbee (low energy consumption compared to Wi-Fi)
    • 802.16 : WiMAX (Wireless MAN)

10. Network Devices

Hardware components that connect computers and other devices in a network.

  • Hub:
    • A "dumb" device operating at the Physical Layer (Layer 1) .
    • Connects multiple devices and broadcasts incoming data to all connected devices.
  • Repeater:
    • Operates at the Physical Layer (Layer 1) .
    • Regenerates (boosts) signals to extend network reach. Can act as an "Active Hub".
  • Bridge:
    • Operates at the Data Link Layer (Layer 2) .
    • Connects network segments that use the same protocol .
    • Forwards data based on MAC addresses . A Layer-2 Switch is also called a Multiport Bridge.
  • Switch:
    • Operates at the Data Link Layer (Layer 2) .
    • Connects devices in a LAN and intelligently forwards data (frames) only to the intended destination MAC address .
  • Router:
    • An internetworking device operating at the Network Layer (Layer 3) .
    • Connects different networks and forwards data (packets) based on IP addresses .
    • Maintains a Routing Table.
    • Often includes features like Firewall, VPN, Traffic Monitor.
  • Gateway:
    • Operates across all seven layers of the OSI model (or multiple layers, including Transport and Application).
    • Connects two dissimilar networks that may work on different networking models or protocols, acting as a protocol converter.
  • Modem:
    • Operates at the Physical and Data Link Layers .
    • Modulator-Demodulator: Converts digital signals from a computer into analog signals for transmission over telephone lines (modulation), and converts analog signals back to digital (demodulation).
  • Firewall:
    • Can be hardware, software, or a combination.
    • Primary purpose is to filter and block unauthorized access to/from a network.
    • Traditionally operates at Network (Layer 3) and Transport (Layer 4) Layers .
    • Modern firewalls (e.g., Web Application Firewall, Next-Generation Firewall) can inspect traffic at the Application Layer .
    • Next-Generation Firewall (NGFW): Integrates multiple layers of security, deep packet inspection, and application awareness.
    • Proxy Firewall: Performs deep packet inspection to examine contents of traffic.
    • Stateful Inspection Firewall: Maintains a table of active connections and inspects traffic based on the connection's state.
    • Web Application Firewall (WAF): Primarily protects against application-layer vulnerabilities (e.g., SQL injection, Cross-Site Scripting (XSS), DDoS attacks targeting web applications).
    • Packet-Filtering Firewall Disadvantage: Cannot inspect the contents of packets, making it vulnerable to certain attacks.

11. Error & Flow Control (Data Link Layer)

Ensures reliable data transfer between nodes.

11.1. Error Detection

Techniques to identify errors introduced during data transmission.

  • Error Types: Single bit (one bit flipped), Burst bit (multiple consecutive bits flipped), Multibit.
  • Parity Check: An extra bit (parity bit) is added to a data unit to make the total number of '1's either even (even parity) or odd (odd parity). Only detects single-bit errors or an odd number of errors.
  • Cyclic Redundancy Check (CRC): A powerful error-detecting code based on binary division using a general polynomial. Detects accidental changes to raw data during transmission or storage.
  • Checksum: An error detection method used by upper-layer protocols. It calculates a sum of data units and includes it with the transmission. The receiver recalculates the checksum and compares it. Considered more reliable than LRC, VRC, CRC for upper layers.

11.2. Error Correction

Techniques to correct errors.

  • Backward Error Correction (Retransmission): When the receiver detects an error, it requests the sender to retransmit the data unit.
  • Forward Error Correction (FEC): The receiver executes error-correcting code (e.g., Hamming code) to auto-recover and correct some kinds of errors without retransmission.

11.3. Flow Control

Manages the rate of data transmission between sender and receiver to prevent overwhelming the receiver.

  • Stop and Wait: The sender transmits a data frame and stops, waiting for an acknowledgment ( ACK ) from the receiver before sending the next frame.
    • Challenges: If a message or ACK is lost, or if ACK is delayed, it can lead to retransmission or timeouts. Wastes resources.
  • Sliding Window: Allows the sender to transmit multiple data frames before waiting for an acknowledgment, improving efficiency. Both sender and receiver agree on a "window size" (number of frames).

11.4. Automatic Repeat Request (ARQ)

A combination of error detection, positive/negative acknowledgments, and retransmission for reliable data transfer.

  • Stop-and-Wait ARQ: Same as Stop and Wait flow control, but with error detection and retransmission if an error or loss is detected.
  • Go-Back-N ARQ: The sender can send multiple frames without waiting for an ACK. If an error is detected in a frame, the receiver sends a NACK (Negative Acknowledgment), and the sender retransmits all frames starting from the damaged/missing one.
  • Selective Repeat ARQ: The receiver buffers correctly received frames even if they are out of order. If a frame is missing or damaged, the receiver sends a NACK for only that specific frame. The sender then retransmits only the requested frame.

12. Network Commands

Useful commands for troubleshooting and managing network connectivity.

  • ping (Packet Internet Groper):
    • Tests network connectivity between two nodes.
    • Uses ICMP protocol.
    • Measures round-trip time in milliseconds (ms); lower ping means faster connection.
  • netstat (Network Statistics): Shows network status and protocol statistics (TCP, routing tables, network interface stats).
  • arp (Address Resolution Protocol): Displays or modifies the IP-to-MAC address translation tables. Used to find the MAC Address of a destination computer when its IP Address is known.
  • ipconfig : Used to view the IP addresses and other TCP/IP configuration details on Windows computers.
  • getmac : Used to view the MAC address of network devices.
  • hostname : Displays the current name of your Windows computer.
  • tracert (Traceroute):
    • Displays the route (path) packets take to reach a destination and measures transit delays.
    • Uses ICMP protocol.
    • Typically shows up to 30 routers/hops.
  • nslookup (Name Server Lookup): Finds the corresponding IP address of a domain name system ( DNS ) name.
  • taskkill : Used for ending processes.
  • systeminfo : Displays system information.
  • cls : Clears the screen.

13. Miscellaneous Important Concepts

  • Jitter: The variation in packet arrival times in data communication.
  • Fade Margin: In wireless communication, it's the difference between the received signal strength and the minimum threshold required for acceptable communication.
  • TDM (Time Division Multiplexing): A technique used to improve bandwidth efficiency in digital communication systems.
  • Spoofing: An attempt to gain or change IP Address or DNS information.
  • Maximum IPv4 Packet Size: 65,535 bytes ( 2 16 -1 ).