TheHingineer

  • Computer Networks


  • CN Part-1

  • CN Part-2

  • CN Part-3

  • CN Part-4

  • CN Part-5

  •  IPv4 and IPv6 Protocols in Computer Networks

     IP (Internet Protocol) kya hai?

    • Internet Protocol (IP) Network Layer ka core communication protocol hai jo internet par sabhi devices ke beech packets route aur address karne ka kaam karta hai.

    • IP ek Connectionless aur Best-effort Delivery protocol hai. Iska matlab yeh hai ki IP packet bhejne se pehle connection establish nahi karta, aur packet lost ya corrupt hone par guarantee nahi leta (reliability Transport Layer ke TCP dwara manage ki jaati hai).

    • Internet par do major versions exist karte hain: IPv4 (Internet Protocol Version 4) aur IPv6 (Internet Protocol Version 6).

     1. IPv4 (Internet Protocol Version 4)

    • IPv4 1981 mein IETF dwara RFC 791 ke roop mein standardize hua tha aur yeh modern internet ka backbone hai.

    • IPv4 32-bit (4 Bytes) addresses use karta hai. Iska matlab total address capacity 2^32 = 4,294,967,296 (lagbhag 4.3 billion) addresses hoti hai.

    • Notation: Dotted Decimal notation (e.g., 192.168.1.1).

    IPv4 Datagram Header Format

    IPv4 header ka minimum size 20 Bytes aur maximum size (options ke saath) 60 Bytes hota hai:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |Version|  IHL  |Type of Service|          Total Length         |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |         Identification        |Flags|      Fragment Offset    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |  Time to Live |    Protocol   |        Header Checksum        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                       Source IP Address                       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                    Destination IP Address                     |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                    Options (0 to 40 Bytes)                    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    Header Field Size Purpose aur Explanation
    Version 4 bits IP version define karta hai (IPv4 ke liye binary 0100).
    IHL (Internet Header Length) 4 bits Header length in 32-bit (4-byte) words. Minimum value 5 (5 * 4 = 20 Bytes), maximum 15 (15 * 4 = 60 Bytes).
    Type of Service (ToS / DiffServ) 8 bits Quality of Service (priority, delay, throughput, reliability) specify karta hai.
    Total Length 16 bits Pure IP packet ka total size (Header + Data). Maximum possible length: 2^16 - 1 = 65,535 Bytes.
    Identification, Flags, Offset 16 + 3 + 13 bits IP Fragmentation ke liye use hote hain (DF – Don’t Fragment flag, MF – More Fragments flag).
    TTL (Time to Live) 8 bits Hop counter. Har router packet aage pass karte waqt TTL ko 1 se decrement karta hai. TTL = 0 hone par packet drop ho jaata hai taaki routing loops prevent ho sakein.
    Protocol 8 bits Batata hai upper layer protocol kaunsa hai (e.g. 1 for ICMP, 6 for TCP, 17 for UDP).
    Header Checksum 16 bits Sirf IP header ki integrity check karne ke liye 16-bit 1’s complement checksum.
    Source / Dest IP 32 bits each Sender aur Receiver ke 32-bit IPv4 addresses.

     2. IPv6 (Internet Protocol Version 6)

    • Smartphones, IoT devices aur internet users badhne ki wajah se IPv4 ke 4.3 billion addresses deplete (exhaust) ho gaye. Is problem ko permanently resolve karne ke liye IPv6 design kiya gaya.

    • IPv6 128-bit (16 Bytes) addresses use karta hai. Iska address space: 2^128 ≈ 3.4 * 10^38 addresses.

    • Notation: 8 groups of 4 Hexadecimal digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).

    • Zero compression rule: Consecutive zero fields ko double colon (::) se replace kiya ja sakta hai (e.g., 2001:db8::1).

    IPv6 Base Header (Fixed 40 Bytes)

    IPv6 header ko streamlined banaya gaya hai. Iska size fixed 40 Bytes hota hai jisme sirf 8 essential fields hote hain:

    -> Version (4 bits): 0110 (Version 6)
    -> Traffic Class (8 bits): IPv4 ke ToS jaisa QoS packet priority
    -> Flow Label (20 bits): Real-time streams (audio/video) ke packets ko special handling provide karta hai
    -> Payload Length (16 bits): 40-byte header ke baad aane wale data ka size
    -> Next Header (8 bits): Identifies extension headers ya upper layer protocol (TCP/UDP)
    -> Hop Limit (8 bits): IPv4 ke TTL jaisa
    -> Source Address (128 bits / 16 Bytes)
    -> Destination Address (128 bits / 16 Bytes)

     IPv4 vs IPv6 Comparison (Exam High-Yield!)

    Feature IPv4 IPv6
    Address Length 32 bits (4 Bytes) 128 bits (16 Bytes)
    Address Format Dotted-Decimal (e.g. 192.168.1.1) Hexadecimal with Colons (e.g. fe80::1)
    Header Size Variable: 20 to 60 Bytes Fixed: 40 Bytes
    Checksum Header Checksum present (calculated at every hop) No Header Checksum (processing faster hoti hai)
    Fragmentation Routers aur Sender dono fragment kar sakte hain Sirf Sending host fragment karta hai (Path MTU discovery)
    Security IPSec optional add-on tha IPSec built-in and mandatory feature hai
    Broadcast Broadcast supported No broadcast (Multicast aur Anycast use hote hain)

     Summary Table

    IP Version Summary
    IPv4 32-bit address, 20-60 byte variable header, TTL field, 4.3 billion address pool.
    IPv6 128-bit address, 40 byte fixed header, Flow Label, 3.4 * 10^38 pool, built-in IPSec.
    Scroll to Top