Beginner journey

OSI and TCP/IP Models Explained in Plain Words (With Attack Examples)

Every networking course starts with the OSI model, and many beginners just memorise seven names for the exam. Let us make it useful instead, by connecting every layer to a real attack and a real defence.

Is guide ka poora Hinglish version abhi taiyaar ho raha hai. Tab tak ise English mein padho.

OSI modelTCP/IPnetworking

Why layers at all?

Sending a message across the world is complicated. Layers split the problem into pieces, so each piece can be designed and fixed on its own. Your WiFi card does not need to know anything about WhatsApp, and WhatsApp does not need to know whether you are on WiFi or mobile data.

For security, layers give us a common language. If someone in a SOC says "we are seeing a layer 3 flood", or "this is a layer 7 issue", everyone knows roughly where to look.

A popular memory trick, from layer 1 up, is "Please Do Not Throw Sausage Pizza Away": Physical, Data Link, Network, Transport, Session, Presentation, Application.

Layers 1 to 3: getting bits from place to place

  • Layer 1, Physical: cables, radio signals, fibre. Attack example: someone plugs a rogue device into an open office network port. Defence: physical security and disabling unused ports.
  • Layer 2, Data Link: MAC addresses and switches inside a local network. Attack example: ARP spoofing, where an attacker on the same WiFi pretends to be the router to intercept traffic. Defence: switch security features, network segmentation and encrypted protocols.
  • Layer 3, Network: IP addresses and routing between networks. Attack example: IP spoofing or a flood of packets to overwhelm a link. Defence: firewalls, filtering and upstream DDoS protection.

Layer 4: Transport

This is where TCP and UDP live, along with ports. TCP gives reliable connections with the three way handshake you saw in Part 5. UDP is quicker but has no handshake.

Attack examples: port scanning to find open services, and SYN floods that open many half connections to exhaust a server. Defence: closing unused ports, firewalls that track connection state, and rate limiting. When you scan your own lab with nmap later in this series, you are working mostly at this layer.

Layers 5 to 7: sessions, formats and applications

  • Layer 5, Session: managing ongoing conversations between systems. In the real world, session handling is often done inside applications, for example login sessions using cookies or tokens. Attack example: session hijacking with a stolen cookie.
  • Layer 6, Presentation: data formats, character encoding and often encryption, such as TLS. Attack example: weak or outdated encryption settings. Defence: modern TLS configuration.
  • Layer 7, Application: the protocols apps speak, like HTTP, DNS, SMTP and SSH. Attack examples: SQL injection, phishing pages, credential stuffing and API abuse. Defence: secure coding, web application firewalls, strong authentication.

Most of the attacks you read about in news stories live at layer 7, because that is where the valuable data and the humans are.

The TCP/IP model the internet actually uses

OSI is a teaching model. The real internet was built on the TCP/IP model, described in standards like RFC 1122. It has four layers:

  1. Link: roughly OSI layers 1 and 2.
  2. Internet: OSI layer 3, mainly IP.
  3. Transport: OSI layer 4, TCP and UDP.
  4. Application: OSI layers 5, 6 and 7 combined.

Interviews often ask "difference between OSI and TCP/IP". A good simple answer: OSI is a seven layer reference model used for teaching and troubleshooting, TCP/IP is the four layer model that real internet protocols follow.

How to really learn the layers

Do not just memorise. Open Wireshark on your own computer, capture a few seconds of traffic while you load a website, and click one packet. You will see Ethernet or WiFi (layer 2), IP (layer 3), TCP (layer 4) and HTTP or TLS (upper layers) stacked like folders. Our Wireshark basics guide shows exactly how.

Make a one page table in your notes: layer, what it does, one attack, one defence. Revise it once a week. Ek baar samajh aa gaya, phir kabhi bhoologe nahi. Next, Part 7: building a safe home lab where you can practise all of this.

Frequently asked questions

Which model should I use in interviews? Know both. Explain using OSI layers, because most people know them, and mention that real protocols follow the TCP/IP model.

Where does HTTPS fit? HTTP is an application layer protocol. TLS, which adds encryption, is often placed at the presentation layer in OSI terms, and inside the application layer in TCP/IP terms. Interviewers mainly want to see that you understand what TLS does.

Educational content, not legal advice. Check official sources before you rely on it. If you have lost money, call 1930 now. Terms