4.3.20 · HinglishComputer Networks

TCP reliability — seq - ack numbers, retransmission, cumulative ACK

2,440 words11 min readRead in English

4.3.20 · Coding › Computer Networks


TCP ko yeh sab chahiye hi kyun?

"Reliability" yahan precisely kya hai? Do guarantees:

  • No loss: app jo bhi byte likhti hai woh eventually doosri app tak pahunch jaati hai (ya connection toot jaata hai).
  • In order: bytes receiving app ko exactly usi order mein deliver hote hain jis order mein bheje gaye the.

Sequence numbers — bytes ko number karna


ACK numbers — cumulative acknowledgement

Figure — TCP reliability — seq - ack numbers, retransmission, cumulative ACK

Retransmission — loss kaise repair hota hai

Do complementary mechanisms hain.

1. Timeout-based retransmission (RTO)

2. Fast retransmit (duplicate-ACK based)


Sab kuch milake: Cumulative ACK kyun great bhi hai aur limited bhi

Recall Feynman: ek 12-saal ke bachche ko samjhao

Socho tum ek lambi chitthi ek numbered page at a time mail kar rahe ho. Tumhara dost email nahi karta "page 5 mila, page 7 mila." Woh kehta hai "Mujhe page 4 tak sab kuch hai, ab page 5 bhejo." Agar koi page mail mein kho jaata hai, woh kehta rehta hai "ab bhi page 5 chahiye!" Kuch baar yeh sunne ke baad, tum bas page 5 dobara mail karte ho — aur jab woh land karta hai, tumhare dost ke paas suddenly pages 5, 6, AUR 7 hote hain (woh extra pages apni desk pe rakh raha tha), toh woh kehta hai "ab mujhe page 7 tak sab hai!" Woh "page X tak sab kuch" wala message cumulative ACK hai, aur lost page ko dobara mail karna retransmission hai.


Common mistakes (steel-manned)


Active recall

TCP ka sequence number kya represent karta hai?
Segment ke pehle data byte ka stream position; yeh cover karta hai.
Cumulative ACK number kaise compute hota hai?
ACK = (highest contiguous byte received) + 1 = next expected byte.
TCP packets ki jagah bytes ko kyun number karta hai?
Taaki har byte ki permanent identity ho; resends/splits/merges sab unambiguous rahein chahe segment sizes change ho jayein.
Initial Sequence Number random kyun hota hai, 0 kyun nahi?
Purani delayed segments (pichli connection ki) se confusion se bachne ke liye, aur sequence-injection attacks resist karne ke liye.
Duplicate ACK kya indicate karta hai?
Ek baad wala segment out of order aaya jabki ek pehle wala abhi missing hai — yaani gap hai; jo named segment hai woh buffer hua hai, lost nahi.
Kitne duplicate ACKs ke baad fast retransmit trigger hota hai, aur kya resend hota hai?
3 duplicate ACKs ke baad; sender woh segment resend karta hai jo ACK number se shuru hota hai (jo missing hai).
RTO formula aur uske terms batao.
RTO = SRTT + 4·RTTVAR, jahan SRTT smoothed RTT hai aur RTTVAR RTT variation (mean deviation) hai.
Cumulative ACK ek lost ACK ko self-healing kyun banata hai?
Baad wala ACK ek bada number carry karta hai jo already sab kuch cover kar leta hai jo lost ACK karta, toh lost ACK irrelevant ho jaata hai.
Ek ACK kabhi kabhi kaafi saare bytes forward kyun jump karta hai?
Ek single hole fill karne se jo bhi out-of-order data buffer mein tha woh sab connect ho jaata hai, toh contiguous prefix (aur isliye ACK) aage leap karta hai.
Cumulative ACK ki kya limitation hai jo SACK fix karta hai?
Cumulative ACK received-but-non-contiguous ranges report nahi kar sakta; SACK receiver ko exactly batane deta hai ki uske paas kaun se extra blocks hain.
Repeated timeouts pe RTO ka kya hota hai?
Har baar double ho jaata hai (exponential backoff) taaki congested network overload na ho.
Kya SYN aur FIN flags sequence numbers consume karte hain?
Haan, har ek ek sequence number consume karta hai, isliye ISN x wale SYN ka ACK x+1 hota hai.

Connections

  • TCP three-way handshake — jahan ISNs exchange hote hain aur SYN ek seq number consume karta hai.
  • Sliding window flow control — window bound karta hai ki kitne unacked bytes outstanding ho sakte hain.
  • TCP congestion control — fast retransmit fast recovery ke saath pair karta hai; dup ACKs cwnd logic drive karte hain.
  • Selective ACK (SACK) — cumulative ACK ki inability fix karta hai gaps precisely report karne ki.
  • Go-Back-N vs Selective Repeat — TCP ek hybrid hai jo SACK ke saath selective repeat ki taraf lean karta hai.
  • IP unreliable datagram service — woh lossy substrate jiske liye TCP compensate karta hai.
  • RTT estimation / Jacobson's algorithm — RTO timer ke peeche ka math.

Concept Map

drops reorders dups

TCP must fix

number every byte

starts

prevents

consume 1 seq

next byte expected

receiver computes

equals highest contiguous plus 1

resends unacked

repairs loss

missing triggers

IP lossy postman

Unreliable delivery

Reliable in-order byte stream

Sequence numbers

Random ISN

Stale segment confusion

SYN and FIN flags

Cumulative ACK

Confirms whole prefix

Retransmission timer

Retransmission