作者rusynth (stw)
看板Network
標題[問答] 關於 Computer Networking 書上的 rdt 2.2 receiver
時間Fri Aug 24 12:52:22 2012
James F. Kurose 的 Computer Networking: A Top-down Approach 5th edition
第三章 Transport Layer 的 3.4 節 -- Principles of Reliable Data Transfer
其中的 rdt 2.2 receiver 的 Finite State Machine
Λ
----------
oncethru=0 ↘
┌─────────┐
│ │
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || ┌--→ │ │
has_seq1(rcvpkt)) │ │ Wait for call 0 │→
-------------------------------------- │ │ from below │
if (oncethru == 1) └---- │ │
udt_send(sndpkt) │ │
└─────────┘
我不懂的地方是,為什麼要增加 oncethru 這個變數呢?
為什麼左邊那個遞迴的部分,不乾脆改成底下這樣:
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq1(rcvpkt))
--------------------------------------------------------
sndpkt=make_pkt(ACK,1,checksum)
udt(send(sndpkt)
就好了呢?這樣就不需要增加 oncethru 這個變數了不是嗎?
而且使用 oncethru,且一開始 oncethru=0
萬一 receiver 第一個接收到的 packet 就是 corrupt 的 packet
由於一開始 oncethru=0,結果底下的 udt_send(sndpkt) 並不執行
這樣豈不是 sender 根本就不知道第一個 packet 就已經 corrupt 了
然後 sender 就一直卡在 wait for ACK 0 這邊動彈不得?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.254.0.106
→ a40136:為什麼我翻了好幾本都是 08/25 01:22
→ a40136:rdt_rcv(rcvpkt) && (corrupt(rcvpkt) ||has_seq1(rcvpkt)) 08/25 01:22
→ a40136:------------------------------------------------------- 08/25 01:22
→ a40136:udt(send(sndpkt) 沒你說的那行 08/25 01:23
→ rusynth:不可能直接udt_send(sndpkt),因為這個時候sndpkt是空的 08/25 02:18
→ rusynth:必須先執行sndpkt=make_pkt(ACK,1,checksum) 08/25 02:19
→ rusynth:可是第五版書上卻是用oncethru來檢查,可是這樣的話,第一 08/25 02:20
→ rusynth:個packet出錯的話,receiver根本不會回傳任何訊息... 08/25 02:20
→ rusynth:我手上只有第五版的書,難道說前幾版不是這樣寫的? 08/25 02:21
→ rusynth:改成這樣或許還比較合理: 08/25 02:26
→ rusynth:if (oncethru==0) 08/25 02:27
→ rusynth: sndpkt=make_pkt(ACK,1,checksum) 08/25 02:27
→ rusynth: udt_send(sndpkt) 08/25 02:27
→ rusynth:if (oncethru==1) 08/25 02:28
→ rusynth: udt_send(sndpkt) 08/25 02:28
→ rusynth:謝謝 ^^ 看來是書籍版本不同的問題。我剛剛也找了一個 08/25 02:41
→ rusynth:不管新舊版本,只要第一個packet出錯,整個系統就不會運作 08/25 02:43