BitTorrent协议中字节的含义

时间:2013-02-23 10:12:34

标签: bittorrent

我打算尝试编写简单的BitTorrent客户端。我当然读过 http://wiki.theory.org/BitTorrentSpecification。我首先分析了两个客户之间的沟通。我有两个字段的含义问题 - 以下十六进制转储中的粗体字。


Deluge发送给rTorrent的第一个数据包:

00000000  13                                                |.               | - protocol name length (1) - 0x13 = 19

00000000     42 69 74 54 6f 72 72  65 6e 74 20 70 72 6f 74  | BitTorrent prot| - protocol name (19)
00000010  6f 63 6f 6c                                       |ocol            |

00000010              00 00 00 00  00 18 00 05              |    ........    | - reserved extension bytes (8)

00000010                                       ab 20 ef 66  |            . .f| - info_hash (20)
00000020  c8 ee de 47 99 a2 75 40  20 75 ee 7b c6 4e 2f dd  |...G..u@ u.{.N/.|   


00000030  2d 44 45 31 33 33 30 2d  42 6c 78 37 6c 69 7a 7e  |-DE1330-Blx7liz~| - peer_id (20)
00000040  4a 54 2e 6a                                       |JT.j|               Deluge 1.3.3

从rTorrent到Deluge的回答:

00000000  13                                                |.               | - protocol name length (1) - 0x13 = 19

00000000     42 69 74 54 6f 72 72  65 6e 74 20 70 72 6f 74  | BitTorrent prot| - protocol name (19)
00000010  6f 63 6f 6c                                       |ocol            |

00000010              00 00 00 00  00 10 00 00              |    ........    | - reserved extension bytes (8)

00000010                                       ab 20 ef 66  |            . .f| - info_hash (20)
00000020  c8 ee de 47 99 a2 75 40  20 75 ee 7b c6 4e 2f dd  |...G..u@ u.{.N/.|

00000030  2d 6c 74 30 43 39 30 2d  b6 eb 22 ae 31 e3 89 90  |-lt0C90-..".1...| - peer_id (20)
00000040  2a 9b af a9                                       |*...            |   libTorrent (rakshasa) 0.12.9

00000040              00 00 00 6e                           |    ...n        | - message length? (4) - 0x6E = 110

00000040                           14 00                    |        ..      | - something (2) - message id?

00000040                                 64 31 3a 65 69 30  |          d1:ei0| - bencoded dictionary (108)
00000050  65 31 3a 6d 64 31 31 3a  75 74 5f 6d 65 74 61 64  |e1:md11:ut_metad|   { 'e': 0,
00000060  61 74 61 69 32 65 36 3a  75 74 5f 70 65 78 69 31  |atai2e6:ut_pexi1|     'metadata_size': 1702,
00000070  65 65 31 33 3a 6d 65 74  61 64 61 74 61 5f 73 69  |ee13:metadata_si|     'm': {'ut_metadata': 2, 'ut_pex': 1}, 
00000080  7a 65 69 31 37 30 32 65  31 3a 70 69 35 30 30 39  |zei1702e1:pi5009|     'reqq': 2048,
00000090  34 65 34 3a 72 65 71 71  69 32 30 34 38 65 31 3a  |4e4:reqqi2048e1:|     'p': 50094, 
000000a0  76 31 37 3a 6c 69 62 54  6f 72 72 65 6e 74 20 30  |v17:libTorrent 0|     'v': 'libTorrent 0.12.9' }
000000b0  2e 31 32 2e 39 65                                 |.12.9e     |        

000000b0                    00 00  00 0c 05                 |      .....|      - something (5) - checksum?

0 个答案:

没有答案