Knowledge / Computer Science and Engineering / OSI and TCP/IP models

OSI and TCP/IP models

Computer Science and Engineering (B.E./B.Tech) · Computer networks · free study notes for exams, placements and interviews

In short

A network model is a layered blueprint that splits the job of moving data between two machines into independent layers, each offering a defined service to the layer above and using the service of the layer below. The OSI reference model (ISO/IEC 7498-1, also published as ITU-T X.200) defines seven layers and is the teaching and vocabulary standard; the TCP/IP model (RFC 1122) defines four layers and is what the Internet actually runs. Every Indian university computer-networks paper and GATE CS set opens with layer functions, PDUs and encapsulation, and almost every networking interview — TCS, Infosys, Wipro, HCL, Cisco India, Jio, Airtel, Nokia and Ericsson India, Tata Communications — begins with "explain the OSI layers" or "which layer does a switch work at". Network engineers also use the layers daily as a fault-isolation ladder (CCNA-style "troubleshoot bottom-up").

Explained

Why layering, and the three words that get confused

The seven OSI layers, layer by layer

  1. Physical (L1): transmits raw bits. Covers voltage/optical levels, bit encoding (NRZ, Manchester, 4B/5B), bit rate and bit duration, media (UTP Cat 6, single/multimode fibre, radio), connectors and pinouts, topology, transmission mode (simplex, half-duplex, full-duplex), baseband vs broadband, multiplexing (TDM, FDM, WDM). Devices: repeater, hub, media converter, cables.
  2. Data link (L2): makes a raw bit pipe into a reliable-enough link between two directly connected nodes — framing, physical (MAC) addressing, error detection/correction, flow control, and medium access. Split by IEEE 802 into LLC (802.2) and MAC sublayers. Devices: NIC, bridge, L2 switch, wireless access point. (Mechanisms are treated in the data-link note.)
  3. Network (L3): end-to-end delivery across multiple networks — logical addressing (IP), routing/forwarding, fragmentation and reassembly, internetworking between dissimilar networks, congestion control and accounting. Protocols: IPv4/IPv6, ICMP, IGMP, routing protocols ride on it. Device: router, L3 switch.
  4. Transport (L4): the first true end-to-end (host-to-host, process-to-process) layer — service-point addressing by port numbers, segmentation and reassembly, connection establishment and release, reliability (ACK, retransmission, sequencing), flow control and congestion control. TCP, UDP, SCTP. Device: firewall doing port filtering, L4 load balancer.
  5. Session (L6−1 = L5): dialog control (who transmits when — half-duplex token management), session establishment and release, and synchronisation/checkpointing so a long transfer resumes from the last checkpoint rather than the start. Seen in RPC, NetBIOS, SIP-like signalling; absent as a separate layer in TCP/IP.
  6. Presentation (L6): syntax and semantics of the data — character-code translation (ASCII, EBCDIC, Unicode/UTF-8), abstract syntax notation (ASN.1, BER/DER, XDR), compression (JPEG, MPEG, gzip) and encryption/decryption. TLS is commonly mapped here or at L5.
  7. Application (L7): services the user or program actually invokes — HTTP, SMTP/IMAP/POP3, FTP, DNS, DHCP, SNMP, Telnet/SSH, SMB/NFS, and the network-virtual-terminal, file-transfer and directory abstractions OSI defined (FTAM, X.400, X.500).

Mnemonics: bottom-up "Please Do Not Throw Sausage Pizza Away"; top-down "All People Seem To Need Data Processing".

The TCP/IP model and the hourglass

Encapsulation, decapsulation and PDUs

LayerPDUAddress / identifierTypical protocolsDevice
ApplicationData / messageURL, hostname, email idHTTP, DNS, SMTP, SNMP, FTPProxy, L7 firewall
PresentationData—TLS, ASN.1, JPEG, MIME—
SessionDatasession idRPC, NetBIOS, SIP—
TransportSegment / datagramPort number (0-65535)TCP, UDP, SCTPL4 firewall, load balancer
NetworkPacket / datagramIP addressIPv4, IPv6, ICMP, OSPFRouter, L3 switch
Data linkFrameMAC address (48-bit)Ethernet 802.3, Wi-Fi 802.11, PPP, HDLCSwitch, bridge, NIC, AP
PhysicalBit / symbol—1000BASE-T, SONET/SDH, DWDM, DSLRepeater, hub, transceiver

Comparing the two models, and why OSI "lost"

AspectOSITCP/IP
Layers74 (RFC 1122); 5 in the common hybrid
OriginISO/ITU-T committee, 1977-1984; model first, protocols laterARPANET working code (1974-1983), model documented afterwards
Service/protocol/interfaceClearly separated and formally definedNot cleanly separated; a weakness as a general model
Transport serviceConnection-oriented onlyBoth: TCP (connection-oriented) and UDP (connectionless)
Network layerBoth connectionless and connection-oriented (CLNP, X.25)Connectionless only (IP)
Session and presentationSeparate layersMerged into the application layer
ReliabilityAttempted at link and transport layersEnd-to-end at transport; link kept simple
StatusReference and teaching model, vocabularyOperational Internet standard

Using the layers in practice (troubleshooting ladder)

  1. L1: link light, cable/SFP, ethtool, interface error counters, signal level.
  2. L2: MAC/ARP table, VLAN, duplex mismatch, arp -a, show mac address-table.
  3. L3: ping, traceroute/tracert, ip route, TTL expiry, MTU/fragmentation issues.
  4. L4: telnet host port, nc -zv, netstat -an/ss -tlnp, firewall rule and port blocking.
  5. L5-L7: nslookup/dig, curl -v, certificate validity, HTTP status codes, application logs.
  6. Wireshark/tcpdump show the model directly: each captured packet expands as Frame → Ethernet II → IP → TCP → HTTP, one tree node per layer. This is the single most convincing lab answer in an interview.

Key points

Formulas and examples

Frame size = payload + Σ(headers) + Σ(trailers). Ethernet II: 14 B header (6 dst + 6 src + 2 type) + 4 B FCS = 18 B; on-wire adds 8 B preamble/SFD + 12 B inter-frame gap = 20 B.
Protocol efficiency η = payload bytes / total bytes transmitted (dimensionless, usually %)
Overhead % = (total − payload) / payload × 100
Transmission (store-and-forward) delay = L / R, L in bits, R in bit/s
Propagation delay = d / v, d in m, v ≈ 2 × 10⁸ m/s in fibre/copper (≈ 3 × 10⁸ in air)
Total one-way delay = Σ(L/R) + Σ(d/v) + Σ(processing) + Σ(queuing)
Goodput = R × η (bit/s); Bandwidth-delay product BDP = R × RTT (bits)
Number of segments = ⌈file size / MSS⌉; MSS = MTU − IP header − TCP header (1500 − 20 − 20 = 1460 B)
Maximum frame rate = R / (8 × on-wire frame bytes) frames/s

Example 1 - overhead of a full-size TCP/IP/Ethernet frame. 1460 B application payload.

Example 2 - the same stack with a 1-byte payload (why small packets are wasteful).

Example 3 - total bytes actually sent for a 2 MiB file. File = 2,097,152 B, MSS = 1460 B.

Example 4 - delay budget and BDP, Mumbai to Chennai. Route ≈ 1,300 km of fibre, three 100 Mbit/s links (two routers in between), 1518 B frames, 50 µs processing per router.

Example 5 - VoIP: header overhead dominates. G.711 voice, 160 B payload every 20 ms (50 packets/s).

Payload sizeIP packetOn-wire bytesEfficiency
1 B41 B84 B1.19%
160 B (VoIP)200 B238 B67.2%
1460 B (MSS)1500 B1538 B94.93%
8960 B (jumbo)9000 B9038 B99.14%

Where it is used

Interview questions

Common mistakes

Related topics

Data link layer: framing, error control and MAC · IP addressing and subnetting · TCP, UDP, HTTP and DNS · Routing algorithms and protocols · Socket programming · Network security: firewalls, VPN and IDS

Open in the Knowledge reader →Find jobs →