Reputation: 11
I know that every bit of bitfield's binary indicates whether there is a file piece in this position. So I think the length of bitfield binary == the length of pieces SHA1 array (20 bytes SHA1), or sometimes the last byte of bitfield is not filled up, it will be slightly larger than the number of pieces SHA1 array (Up to 7).
But the situation I encountered is:
bitfield (I received after handshack): 0x2d23488034b692d61862810a44049b72cd58c28210922b72482a05291554c510d209729e8c1c80520878d556c488e2200210962434569004af82486550152a04113108244d3fa020819242c5002d0e41440410081630228948b80a02006202188a79000882236fd413489a70a0a040481024f8f89732d8028011c4108aa2a32120ac403320410967a4611ed72cc005dda008d408954411c1406ac424922d8010149b208fd408580051905c1b100298ec0000049d290c049050293601850b4a373080041152b5a80def30a700038525a020821b603022041c174cab2124174161800c6d1d031000f043af0888652f2cb34885099d0a5296009052e0c185f02a065ab0b0090082305a4930068188bc252c960105402845004640041410119e4140a9131a000cf930378aae619485346083223b17a00905a8a0b04415c458c12cec20046da0388062d4224344765510085c90a45876e506969588515740a8d0ae6c4e170a0000084b210421f0829c2a6000001e743f30a048b20c1c94532222c11b0c6aa8a939315c65a07e011114048335844a00b020822122400801558086408a102141f128c203e497c20961804e500660288211067240088451be91748129806692441060a90c8871302d9039a7c0226810005008805813c956cc6403e203850c904605c43610628a884004e830122301f1c4809c300ca50902284344210403cce332580209a21099b30a80c0080c4ae0385b9a921320214096000947e44c010a746fa9a6a0908a502a85850893a12170cc654123110052a424da040318c00ce008d0084058812100802c5430cdc30180000838150e18000c300111c608aecd40024d021092060933780603bc092009280099111392521d0218b48244c852c81e461003c00200005401581c04443b07d06465000380ab2c8934646e00108a4004d45135471524328000012068890029302100110500b54806c9028a1713bac1b68201828032050611393d247255149e403c28a896501848448ca01c60422001e0248201d9071107a0014008818c3606516100ed9080a2b39900629db10538288c410871a002e82162762000b120420e054000504160a88e6420607002d10107a0828909603750a45c92164201208839989420829440b9841c7201d06944fb00031008010010c240b276f1b5710ae01b5801810a8a881a184aaa3b02004800b7292841f0220481018290702a9c9d668884000404685626228068d11a888c4e06198282490032aae8ac82a2021086129c8180ca93302e1080046505c1a61a4515c15cc09140112c81000320528801fe832a094051a1002b419818c9a3b18090109f845c94451053b20ad522804b2ecd00c3914e60aa32511400428cce4400806218184e424d52040108018191c40422962185127a2b8108242d0103e0d0182fd60824265c1807792009c50c9ad41224ea3d09b5de044c601038006fc88a200490e0c55b04828780006689300700205814b01af32c64229708c29371a3a011c2da6a8564d00158238da0601942784a09c50c1cc0001419fa0108059c48152a3410000080248098889644a580081001a23d0450021015050cb03000047422cd80d224830120109002158a6904d00403024480809c32329c05c0b2061a21082258b160802419c281c00006a430c894baa406396b024dc23e0410313302409c410920290968c9044a946d3000208e9681c301a0f460592092c820c8c01009c130a8aa0d81c5086020094054a0340d9a5e30195400110a234382639883210010a4d3952c6309370271059c46385c1c300580e201aa42e1f83658845afb6a2451227a910b009082c8a581020d8dd02034080402f620404aa00a44ec9190980b9108e56cf1215419d2c232827031a23400680f1b5f037850932a060002600491242748b44002911048020078120a260000153146112a2014f3464d139a2c71258b800b434344e0310948f64d0800140311b050513a14ee2b762100de9290c88160058a92c501900c088e10c1c729462e3489e60b8c10051006c8141592ba809f19508d48854c2d4000200d6010318244ef0c2004009a0800860d442264636d008fd028709e9361a89018ac3a97978600cf41821904247b214a1170388890d25006166a010142125812051288b2d4033480e2e0680a0022c121164142891091a0464aa8084a648929428233044444051a2023520a0340002486280c440949a2350164402281598df201109d21380c05405a0101412813d08db4424009a340969023844198999a38bc1341054882a44085124116eb03191a241c4347d274500602c2439d2d62888ca50a21833320a44d3802809884460d290490026408888b858650290d80407232e811c828e241ee620401e5463021b64d034240425e4c39767e9049528240423090d2
The length of the bitfield above is: 1733(bytes) => 13864(bits)
So I think the torrent file's pieces should have 13864 SHA1s.
But the pieces field has 262710(bytes) => 262710/20==13136(SHA1s).
Obviously 13864 is much greater than 13136. Why?
Upvotes: 1
Views: 118
Reputation: 69
According to https://wiki.theory.org/BitTorrentSpecification#Messages this might be a lazy bitfield, where the field length is deliberately incorrect
Upvotes: -1