4.3.25 · D1 · HinglishComputer Networks

FoundationsHTTP - 2 — multiplexing, header compression (HPACK), server push

4,085 words19 min read↑ Read in English

4.3.25 · D1 · Coding › Computer Networks › HTTP - 2 — multiplexing, header compression (HPACK), server

Yeh page har woh word, number, aur symbol build karta hai jis par parent note rely karta hai — "byte kya hota hai" se shuru hokar "yahan ka kya matlab hai" tak. Agar parent note ne kuch bina explain kiye keh diya, toh hum yahan explain karte hain.


1. Bit, byte, aur hum powers of two mein count kyun karte hain

Kisi bhi protocol se pehle, woh sabse chhoti cheez hai jo computer store karta hai: ek bit — ek single switch jo ya toh hai ya . Ek line mein aath bits mila ke ek byte banta hai.

Yeh topic ko kyun chahiye: parent note mein har "frame header is 9 bytes", har "24-bit Length", har "one byte for a whole header" literally inhi bulbs ko count kar raha hai. Agar bulbs nahi dikh rahe, toh woh numbers meaningless hain.

Figure s01 — kya dikhata hai: aath bulbs mila ke ek byte banta hai. Pattern 0110 1010 ko lit bulbs = se draw kiya gaya hai; har column ko uska place-value label kiya gaya hai. Lit place-values add karne par () dikhta hai ki bulbs ki ek row kaise ek number ban jaati hai. Aage badhne se pehle caption ko bulb-by-bulb padho.

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push
  • , toh 7 bits se tak hold karte hain.
  • , toh 8 bits se tak hold karte hain (yeh patterns hain, lekin sabse bada single number hai).
  • — parent ka "default max frame size" yahi hai (possible values ki count; sabse bada hai).
  • ek 24-bit Length field ke patterns ki sankhya hai, toh yeh se tak values name karta hai — sabse bada single Length hai, nahi.
  • ≈ 2.1 billion — Stream IDs ki sankhya (yeh hum niche dekhenge).
Recall Max value

kyun hai, kyun nahi? Kyunki ko bhi ek valid pattern mante hain ::: bits ke saath patterns milte hain jinka number hai, toh sabse bada single number hai.


2. Text vs binary — "binary framing" ka matlab asal mein kya hai

HTTP/1.1 ek text protocol hai: yeh literally G, E, T letters, ek space, phir path bhejta hai — print karne par human-readable hota hai. HTTP/2 ek binary protocol hai: yeh fixed slots mein raw numbers bhejta hai, spelled-out words nahi.

Yahan hex kyun: wire bytes hai, aur ek byte = do hex digits, yeh aath bits se kaafi clean padha jaata hai. Har "" niche sirf ek byte hai is shorthand mein likha hua.

Yeh topic ko kyun chahiye: parent ki puri "Text → binary framing" line isi distinction par tiki hui hai. Binary HTTP/2 ko allow karta hai puri header line ko ek byte mein pack karne ke liye (parent ka Section 4) — spelled-out text ke saath impossible. Aur bina ek fixed byte order ke, do machines same Length ya Stream ID ko do alag numbers ki tarah padhte, isliye har field diagram niche big-endian, most-significant-byte-first assume karta hai.


3. Powers, exponents, aur notation , ,

Parent ke HPACK section mein teen math notations use hain jinhe define nahi kiya gaya. Yeh rahi unki definitions.

Yeh topic ko kyun chahiye: parent ke prefix-integer trick mein (I' mod 128) + 128 emit hota hai aur I' ← floor(I'/128) update hota hai. Yeh exactly "leftover eggs ek 7-bit carton mein, phir full cartons count karo" hai, tab tak repeat karo jab tak kuch na bache. Hum niche parent ka example verify karte hain.

Figure s02 — kya dikhata hai: ke liye teen output bytes coloured boxes ke roop mein, left se right: prefix 31 (blue, "full, I overflowed"), phir 154 (orange, 26 + 128, continuation flag on), phir 10 (green, last byte). Arrows working value ko box se box carry karte hain, aur bottom line arithmetic reproduce karta hai. Arrows trace karo aur ko shrink hote dekho.

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push

4. Stream ID, odd/even, aur label idea

Ek Stream ID sirf ek whole number hai jo frame header ke 31 bits mein likha jaata hai. Yeh woh label hai jo kehta hai "yeh chunk conversation number 3 ka hai."

Yeh topic ko kyun chahiye: multiplexing (parent §3) interleaved chunks ko is label se reassemble karta hai. Server push (parent §5) ek even ID reserve karta hai taaki ek pushed resource client request se clash na kare. Aur parent ka SETTINGS frame kahi toh rehna chahiye — yeh stream pe rehta hai, connection-wide channel. 31-bit size possible labels deta hai — kaafi zyada.


5. Frame — ek labeled chunk

Ab hum parent ka frame formula symbol-by-symbol padh sakte hain. Ek frame ek fixed 9-byte header hota hai jiske baad payload aata hai.

Figure s03 — kya dikhata hai: 9-byte header ek single left-to-right strip ke roop mein draw kiya gaya hai, har field ek coloured box jiska width bit-count ke proportional hai (Length sabse wide 24 pe, phir Stream ID 31 pe, R ek sliver 1 pe). Har box ke neeche labels bit-count dete hain; call-out arrows Length pe "default mein se zyada nahi" aur Stream ID pe "odd = client, even = server push, 0 = connection" mark karte hain. Strip wahi byte layout hai jo wire pe dikh ta.

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push

Yeh topic ko kyun chahiye: har bada idea inhi frames ka stream hai. Ek message (request ya response) = ek HEADERS frame + zero ya zyada DATA frames jo ek Stream ID share karte hain. Multiplexing = alag Stream IDs ke frames ko ek connection pe interleave karna.


6. HTTP/2 ke neeche ki layers — TCP, TLS, aur RTT

HTTP/2 wire ko directly touch nahi karta; yeh do lower layers ke upar ride karta hai jinke baare mein parent assume karta hai ki tum jaante ho.

Yeh topic ko kyun chahiye:

  • Parent ka "one handshake vs six" TCP+TLS RTTs ke baare mein claim hai: vs that.
  • Famous "TCP-level head-of-line blocking abhi bhi exist karta hai" mistake isliye hai kyunki TCP in-order bytes par insist karta hai — ek lost packet har stream ko stall kar deta hai. Isliye HTTP-3-and-QUIC transport switch karta hai.
Recall Multiplexing application HOL blocking kyun remove kar sakta hai lekin transport HOL blocking kyun nahi?

Streams HTTP layer pe independent hain, lekin sab ek TCP byte-stream share karte hain ::: TCP bytes ko strictly in order deliver karta hai, isliye ek lost packet sabhi streams ko retransmission ka intezaar karne par majboor karta hai — ek transport-level stall jise HTTP/2 dodge nahi kar sakta.


7. Compression prerequisites — Huffman, varint, aur CRIME idea

HPACK (parent §4) teen ideas ko stitchkar jodta hai jinke apne vault notes hain. Inhe HTTP/2 ke liye koi nayi machinery nahi banaayi gayi — HPACK inhe sirf combine karta hai, isliye abhi inse milna parent ke §4 ko magic ki jagah assembly ki tarah readable banata hai.

Figure s04 — kya dikhata hai: ek header field HPACK mein enter karta hai aur do forks mein se ek leta hai. Fork A (green, "already known") → ek varint index number → tiny output. Fork B (orange, "new literal") → Huffman-coded characters → small output. Ek red guard box labelled "fixed table, no adaptive mixing" dono forks ke aage baitha hai caption ke saath "CRIME length-leak blocks karta hai." Jo bhi fork applicable ho use follow karo aur dekho kaunsa tool shrinking karta hai.

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push

Yeh topic ko kyun chahiye: bina Huffman ke "literal header encoded in fewer bits" explain nahi kar sakte; bina varint ke index bytes nahi padh sakte; bina CRIME idea ke parent ka "HPACK sirf gzip nahi hai" explain nahi kar sakte.


8. Sab kuch topic ko kaise feed karta hai

Neeche ka map top-to-bottom padha jaata hai: ek arrow ka matlab "Y samajhne se pehle chahiye." Bottom node "HTTP 2 topic" parent note hai; har doosra node is page pe build ek foundation hai. Koi bhi path neeche follow karo aur tum in ideas ko sikhane ke order mein retrace karoge.

  • Left branch (blue foundations): bit/bytepowers of twoStream ID aur frame headermultiplexing.
  • Transport branch: TCP in-order bytes dono multiplexing aur TCP HOL blocking caveat ko feed karta hai.
  • Right branch (compression): Huffman, varint prefix int, aur CRIME idea teeno HPACK ko feed karte hain.
  • Push branch: even Stream ID server push ko feed karta hai.

bit and byte

powers of two 2 to the N

Stream ID 31 bits

frame header 9 bytes

text vs binary and endianness

multiplexing

TCP in-order bytes

TCP HOL blocking

Huffman coding

HPACK

varint prefix int

CRIME attack idea

even Stream ID

server push

HTTP 2 topic


Equipment checklist

Khud ko test karo — answer reveal karne se pehle bol ke dekho.

bits kitne distinct patterns dikhaa sakte hain?
(numbers se tak), jahan ek nonnegative whole number hai.
Ek 24-bit Length field sabse bada kaunsa single number name kar sakta hai?
( patterns hain, lekin sabse bada value ek kum hai).
kya hai, aur yeh HTTP/2 mein kahan aata hai?
— default maximum frame payload size.
Ek text protocol aur ek binary protocol mein kya fark hai?
Text meaning readable characters aur separators mein carry karta hai; binary fixed byte positions aur lengths mein meaning carry karta hai.
prefix ka matlab kya hai, aur ek byte mein kitne hex digits hote hain?
Yeh ek hexadecimal (base-16) number mark karta hai; ek byte = do hex digits.
HTTP/2 multi-byte fields wire pe kis byte order mein appear hote hain?
Network byte order = big-endian, most significant byte pehle.
kya compute karta hai?
ko se divide karne ke baad remainder (ek value se tak).
ka matlab kya hai?
ko nearest whole number tak neeche round karo.
Prefix-integer algorithm mein kya hai aur uski initial value kya hai?
ka overflow part jo prefix mein fit nahi hua; yeh se start hota hai.
Varint continuation bytes sirf 7 bits value kyun carry karte hain?
Har byte ka top bit ek continuation flag hai (1 = more bytes follow, 0 = last), 7 bits value ke liye bachte hain.
Stream ID kya hai aur yeh kitne bits ka hai?
Ek number jo batata hai koi frame kis stream ka hai; 31 bits (top bit Reserved hai).
Client kaunsi parity ka Stream ID use karta hai, aur server push kaunsa?
Client odd IDs use karta hai, server push even IDs — taaki kabhi collide na karein.
Stream ID 0 kis kaam aata hai?
Yeh connection-level frames jaise SETTINGS, PING, WINDOW_UPDATE, aur GOAWAY ke liye reserved hai.
9-byte frame header ke paanch fields ke naam batao.
Length (24), Type (8), Flags (8), R (1), Stream ID (31).
HTTP/2 kin do lower layers pe ride karta hai, aur har ek kya guarantee deta hai?
TCP (reliable in-order bytes) aur TLS (encryption/privacy).
TCP HTTP/2 ke andar bhi head-of-line blocking kyun cause karta hai?
TCP bytes ko strictly in order deliver karta hai, isliye ek lost packet sabhi streams ko retransmission tak wait karne par majboor karta hai.
HPACK banane mein teeno prior ideas kaunse hain, aur har ek ka kya kaam hai?
Varint (index numbers shrink karta hai), Huffman (literal text shrink karta hai), aur CRIME-awareness (fixed non-adaptive design dictate karta hai).

Parent pe wapas jao: HTTP/2 topic note · Prev generation: HTTP-1.1 · Next: HTTP-3-and-QUIC.