2014-12-05 66 views
0

我正在開發一個BitTorrent客戶端,並且無法獲得我的請求的答案。BitTorrent協議無法獲得我的請求的答案

爲了進行調試,我使用Wireshark跟蹤了uTorrent和傳輸之間的對話,並嘗試在客戶端模仿相同的對話。但它仍然不起作用。

下面是我的客戶端和傳輸之間發生的示例對話。 (我的客戶也使用-TR---作爲前綴的對等ID,這僅用於測試目的,我會更改)

縮進的消息來自傳輸,其他消息來自我的客戶端發送的消息。

請注意,由於我的客戶端不支持快速擴展功能,因此此對話與uTorrent和傳輸會話的方式不完全相同。 (BEP 6)

(輸出從Wireshark的拍攝,開始的行--是我的意見)

00000000 13 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 .BitTorr ent prot 

00000010 6f 63 6f 6c 00 00 00 00 00 10 00 00 f8 9e 0d fd ocol.... ........ 

00000020 9c fc a8 52 d9 7a d6 af a4 4d 8f 73 ce 70 b6 36 ...R.z.. .M.s.p.6 

00000030 2d 54 52 32 38 34 30 2d 36 68 61 67 76 30 73 70 -TR2840- 6hagv0sp 

00000040 34 67 37 6b          4g7k 
--^my handshake to transmission 

    00000000 13 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 .BitTorr ent prot 

    00000010 6f 63 6f 6c 00 00 00 00 00 10 00 04 f8 9e 0d fd ocol.... ........ 

    00000020 9c fc a8 52 d9 7a d6 af a4 4d 8f 73 ce 70 b6 36 ...R.z.. .M.s.p.6 

    00000030 2d 54 52 32 38 34 30 2d 72 73 35 68 71 67 32 68 -TR2840- rs5hqg2h 

    00000040 6e 70 68 64          nphd 
    --^transmission answers to my handshake 

00000044 00 00 00 1a 14 00 64 31 3a 6d 64 31 31 3a 75 74 ......d1 :md11:ut 

00000054 5f 6d 65 74 61 64 61 74 61 69 33 65 65 65  _metadat ai3eee 
    --^my extended handshake to transmission 

    00000044 00 00 00 72 14 00 64 31 3a 65 69 31 65 31 3a 6d ...r..d1 :ei1e1:m 

    00000054 64 31 31 3a 75 74 5f 6d 65 74 61 64 61 74 61 69 d11:ut_m etadatai 

    00000064 33 65 65 31 33 3a 6d 65 74 61 64 61 74 61 5f 73 3ee13:me tadata_s 

    00000074 69 7a 65 69 31 34 37 65 31 3a 70 69 35 31 34 31 izei147e 1:pi5141 

    00000084 33 65 34 3a 72 65 71 71 69 35 31 32 65 31 31 3a 3e4:reqq i512e11: 

    00000094 75 70 6c 6f 61 64 5f 6f 6e 6c 79 69 31 65 31 3a upload_o nlyi1e1: 

    000000A4 76 31 37 3a 54 72 61 6e 73 6d 69 73 73 69 6f 6e v17:Tran smission 

    000000B4 20 32 2e 38 34 65 00 00 00 02 05 80    2.84e.. .... 
    --^transmission's extended handshake and bitfield 

    000000C0 00 00 00 01 01         ..... 
    --^transmission unchokes me 

00000062 00 00 00 01 02         ..... 
--^my interested message 

00000067 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ [email protected] 

00000077 00            . 
--^piece request 

-- no answers ... 

00000078 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ [email protected] 

00000088 00            . 
--^piece request again, with 10 seconds interval 

-- again no answers... 

00000089 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ [email protected] 

00000099 00            . 
--^piece request again, with 10 seconds interval 

-- no answers... 

任何想法,我究竟做錯了什麼?

謝謝。

編輯:我更新了我的客戶剛剛發送interested後,發送unchoke,但我仍然有同樣的問題...

回答

0

的問題是,我是請求一塊比洪流的總面積較大。

我使用的洪流有2個文件,共12KB。然而,torrent torrent文件的大小是16KB,即使torrent文件只有一個文件,並且總共有12KB,我也要求16KB文件。

請求12KB而不是16KB後,問題就解決了。