OSI Model & TCP-IP Security

πŸ“ Concept Note β€” CSF & NS Unit II | Source: MCA Sem III Syllabus


The Problem It Solves

To defend a network, you must understand how networks work at every layer. Each layer has its own vulnerabilities and defences. Without this knowledge, you can’t:

  • Identify which layer an attack is targeting
  • Deploy the right defence at the right layer
  • Analyse network traffic effectively
  • Troubleshoot security issues

OSI Model β€” 7 Layers with Security Context

The Open Systems Interconnection (OSI) model divides network communication into 7 layers:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Layer 7  APPLICATION    β”‚ HTTP, DNS, FTP, SMTP   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 6  PRESENTATION   β”‚ SSL/TLS, Encryption    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 5  SESSION        β”‚ Session management     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 4  TRANSPORT      β”‚ TCP, UDP               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 3  NETWORK        β”‚ IP, ICMP, Routers      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 2  DATA LINK      β”‚ MAC, Switches, ARP     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Layer 1  PHYSICAL       β”‚ Cables, Hubs, Signals  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’‘ Memory trick: β€œAll People Seem To Need Data Processing” (top to bottom) or β€œPlease Do Not Throw Sausage Pizza Away” (bottom to top)


Layer 7 β€” Application Layer

What it does: Provides network services directly to user applications (email, web browsers, file transfer)

Protocols: HTTP, HTTPS, FTP, SMTP, DNS, SSH, Telnet, SNMP

Security attacks at this layer:

  • HTTP injection β€” Injecting malicious code into web requests
  • SQL injection β€” Manipulating database queries through web forms
  • Cross-Site Scripting (XSS) β€” Injecting scripts into web pages
  • DNS poisoning β€” Redirecting DNS queries to malicious servers
  • Phishing β€” Fraudulent applications/emails

Defences:

  • Web Application Firewalls (WAF)
  • Input validation and output encoding
  • HTTPS (TLS encryption)
  • DNS Security Extensions (DNSSEC)

Layer 4 β€” Transport Layer

What it does: End-to-end communication, reliability (TCP), speed (UDP)

Protocols: TCP (reliable, connection-oriented), UDP (fast, connectionless)

Security attacks at this layer:

  • TCP SYN Flood β€” Sends thousands of half-open connections, exhausting server resources
    Attacker β†’ SYN β†’ Server
    Server β†’ SYN-ACK β†’ (attacker never responds)
    Server waits... resources consumed
    Γ— 1000s of connections = server crashes
    
  • UDP flood β€” Overwhelming target with UDP packets
  • Port scanning β€” Discovering open services

Defences:

  • SYN cookies
  • Rate limiting
  • Firewall rules (block unused ports)
  • TLS for encrypted transport

Layer 3 β€” Network Layer

What it does: Routing packets between networks, logical addressing (IP addresses)

Protocols: IP (IPv4/IPv6), ICMP, IGMP

Security attacks at this layer:

  • IP spoofing β€” Forging the source IP address in packets
  • ICMP flood (Ping of Death) β€” Overwhelming with ping requests
  • Route manipulation β€” Redirecting traffic through attacker’s network
  • IP fragmentation attacks β€” Exploiting packet reassembly

Defences:

  • Ingress/egress filtering
  • IPsec (encrypted IP communication)
  • Anti-spoofing rules on routers
  • Access Control Lists (ACLs)

What it does: Node-to-node data transfer, MAC addressing, error detection

Protocols: Ethernet, ARP, PPP

Security attacks at this layer:

  • ARP spoofing/poisoning β€” Associating attacker’s MAC with a legitimate IP
    Normal:  Gateway IP 192.168.1.1 β†’ MAC AA:BB:CC:DD:EE:FF
    Attack:  Gateway IP 192.168.1.1 β†’ MAC [ATTACKER'S MAC]
    Result:  All traffic meant for gateway goes to attacker (MitM)
    
  • MAC flooding β€” Overwhelming switch’s MAC table, causing it to act like a hub
  • VLAN hopping β€” Escaping VLAN isolation

Defences:

  • Dynamic ARP Inspection (DAI)
  • Port security (limit MACs per port)
  • 802.1X authentication
  • VLAN configuration best practices

Attack Mapping to OSI Layers

AttackLayerProtocol ExploitedDefence
ARP SpoofingL2ARPDAI, static ARP
MAC FloodingL2EthernetPort security
IP SpoofingL3IPIngress filtering
ICMP FloodL3ICMPRate limiting
TCP SYN FloodL4TCPSYN cookies
Port ScanningL4TCP/UDPFirewall rules
HTTP InjectionL7HTTPWAF, input validation
DNS PoisoningL7DNSDNSSEC
SQL InjectionL7HTTPParameterised queries

TCP/IP Model

The practical model used on the internet β€” maps to OSI:

TCP/IP Model          OSI Model
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Application  β”‚  ←  β”‚ Application  β”‚
β”‚              β”‚  ←  β”‚ Presentation β”‚
β”‚              β”‚  ←  β”‚ Session      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Transport    β”‚  ←  β”‚ Transport    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Internet     β”‚  ←  β”‚ Network      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Network      β”‚  ←  β”‚ Data Link    β”‚
β”‚ Access       β”‚  ←  β”‚ Physical     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’‘ Memory trick: β€œNITA” (bottom to top)


IPv4 Addressing

Structure

  • 32-bit address, written as 4 octets: 192.168.1.100
  • Each octet = 8 bits (0–255)

Classes (classful β€” largely historical)

ClassRangeDefault MaskPurpose
A1.0.0.0 – 126.255.255.255/8 (255.0.0.0)Large networks
B128.0.0.0 – 191.255.255.255/16 (255.255.0.0)Medium networks
C192.0.0.0 – 223.255.255.255/24 (255.255.255.0)Small networks
D224.0.0.0 – 239.255.255.255β€”Multicast
E240.0.0.0 – 255.255.255.255β€”Experimental

Private vs Public IP Ranges

Private RangeCIDRCommonly Used For
10.0.0.0 – 10.255.255.25510.0.0.0/8Large enterprise LANs
172.16.0.0 – 172.31.255.255172.16.0.0/12Medium networks
192.168.0.0 – 192.168.255.255192.168.0.0/16Home/small office

πŸ’‘ Private IPs are not routable on the internet. NAT (Network Address Translation) converts private β†’ public when accessing the internet.

Subnetting Basics (CIDR)

CIDR notation (/n) says how many leading bits are the network part; the rest are host bits. An IPv4 address is 32 bits, so hosts = 2

  • /24 = 256 addresses (254 usable) β€” 255.255.255.0
  • /16 = 65,536 addresses β€” 255.255.0.0
  • /8 = 16.7 million addresses β€” 255.0.0.0

2 addresses are never usable for hosts: the network address (all host bits 0) and the broadcast (all host bits 1). That’s why /24 gives 256 βˆ’ 2 = 254 usable.

Worked example β€” 192.168.1.0/24:

  • Network bits = 24, host bits = 8 β†’ 2⁸ = 256 addresses
  • Network address: 192.168.1.0 Β· Broadcast: 192.168.1.255
  • Usable host range: 192.168.1.1 β†’ 192.168.1.254
  • Split it into two /25 subnets (host bits 7 β†’ 128 each): 192.168.1.0/25 (.1–.126) and 192.168.1.128/25 (.129–.254). Smaller subnets = tighter segmentation, limiting lateral movement.

Rule of thumb: bigger /n = smaller network. /32 is a single host; /30 (4 addresses, 2 usable) is common for point-to-point links.

IPv6 Overview

  • 128-bit addresses (vs 32-bit IPv4)
  • Written as 8 groups of 4 hex digits: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Massive address space: 3.4 Γ— 10³⁸ addresses
  • Built-in IPsec support

Common Ports β€” Security Critical

PortProtocolServiceSecurity Note
22TCPSSHSecure remote access βœ…
23TCPTelnetUnencrypted β€” never use ❌
25TCPSMTPEmail sending β€” often targeted for spam
53TCP/UDPDNSTargeted for DNS attacks, tunnelling
80TCPHTTPUnencrypted web traffic
443TCPHTTPSEncrypted web traffic βœ…
3389TCPRDPRemote Desktop β€” common attack target

πŸ”— Full reference: Common Ports & Protocols Reference


DNS Resolution Process

1. User types www.example.com in browser
2. Browser checks local cache β†’ Not found
3. OS checks hosts file (/etc/hosts) β†’ Not found
4. Query sent to Recursive DNS Resolver (ISP's DNS)
5. Resolver checks its cache β†’ Not found
6. Resolver queries Root DNS Server β†’ "Ask .com TLD server"
7. Resolver queries .com TLD Server β†’ "Ask example.com's authoritative server"
8. Resolver queries Authoritative DNS Server β†’ "IP is 93.184.216.34"
9. Resolver caches the result and returns IP to browser
10. Browser connects to 93.184.216.34

DNS Record Types

RecordPurposeExample
AMaps domain to IPv4example.com β†’ 93.184.216.34
AAAAMaps domain to IPv6example.com β†’ 2606:2800:220:1:…
MXMail server for domainexample.com β†’ mail.example.com
CNAMEAlias for another domainwww.example.com β†’ example.com
TXTText records (SPF, DKIM)SPF records for email auth
NSAuthoritative name serversns1.example.com

HTTPS β€” What It Protects and What It Doesn’t

What HTTPS Protects βœ…

  • Encryption of data in transit (confidentiality)
  • Integrity verification (data not tampered with)
  • Authentication of server identity (via SSL/TLS certificate)

What HTTPS Does NOT Protect ❌

  • Does not guarantee the website is legitimate (attackers can get HTTPS certificates)
  • Does not protect data at rest on the server
  • Does not prevent server-side vulnerabilities (SQLi, XSS still possible)
  • Does not hide which domain you’re visiting (SNI reveals it)
  • Does not protect against malware on the endpoint


Tags

cybersecurity csf-ns concepts osi-model tcp-ip networking ipv4 dns ports


Resources

  • Course: MCA Sem III β€” CSF & NS, Unit II
  • β€œNetwork Security Essentials” β€” William Stallings
  • Related: Cyber Security MOC for navigation