• 从bnbt tracker源码分析bt客户端与traker的通信


    we already have some article analyse BNBT , including analyse the basic routine and the most import part around communication with bt clients.

    this article also talks about the communication via traker_announce.cpp.

    BT客户端据此向tracker发送GET请求,例如:
    GET http://192.168.0.1:2222/announce?info_hash=w%3D%1E%FB%A2%09%8C%E5k%2A%9F%A03PQ%3E%12%2CMq&peer_id=-BC0092-%89v%5E%0A%8Cf%EB%90%B1%0D%EE%DE&port=14479&natmapped=1&localip=192.168.0.65&port_type=lan&uploaded=0&downloaded=0&left=0&numwant=200&compact=1&no_peer_id=1&key=31526&event=started HTTP/1.1

    BT client send this GET method via HTTP protocol, with lots of parameters in the request.

    Then, HERE IS WHAT TRACKER DO as a response:

      1. disassemble the http request  , and verify the request parmeters , return and log if not verification goes wrong.
      2. record the peers state according to the request event:(stopped, completed, started). Add unique peer if started or remove unique peer if stopped.
      3. return the peer list to the bt clients. (may cause randomize if tracker contains more than the bt client ask for numbers of peer in return )

    Tracker did NOT tell the difference of seed and lecher in returning peers. In another word ,  the return peers might contain peers which has nothing.

    BT client then communication with the return peers , to see who has the part it wants.

    during handshakes protocol:

    1. am_chocking
    2. am_interested
    3. peer_chocking
    4. peer_interested

     

    • am_chocking 该值若为 1,表明客户端将远程 peer 阻塞。此时如果 peer 发送数据请求给客户端,客户端将不会理会。也就是说,一旦将 peer 阻塞,peer 就无法从客户端下载到数据;该值若为 0,则刚好相反,即表明 peer 未被阻塞,允许 peer 从客户端下载数据
    • am_interested 该值若为 1,表明客户端对远程的 peer 感兴趣。 peer 拥有某个 piece,而客户端没有,则客户端对peer 感兴趣。该值若为 0,则刚好相反,即表明客户端对 peer 不感兴趣,peer 拥有的所有 piece,客户端都拥有
    • peer_chocking 该值若为 1,表明 peer 将客户端阻塞。此时,客户端无法从 peer 处下载到数据。该值若为 0,表明客户端可以向 peer 发送数据请求,客户端将进行响应
    • peer_interested 该值若为 1,表明 peer 对客户端感兴趣。也即客户端拥有某个 piece,而 peer 没有。该值若为 0,表明 peer 对客户端不感兴趣

    ps: after knowing how bnbt tracker handler the web pages message via combining string with parameters , I find it so ugly to do such kind of jobs in c , and think of how simple python can do such kind of job by template method.

    EOF

  • 相关阅读:
    odoo API装饰器one、model、multi的区别
    odoo配置界面设置字段默认值
    redhat_6.5下载地址
    常用在线工具链接
    odoo开发环境搭建(四):python开发工具IDE pycharm配置
    odoo开发环境搭建(三):安装odoo依赖的python包
    odoo开发环境搭建(二):安装Ubuntu 17虚拟机
    odoo开发环境搭建(一):安装VMware Workstation
    火狐浏览器网页截屏插件
    copy代码的时候,如何去掉代码前边的编号
  • 原文地址:https://www.cnblogs.com/no7dw/p/2877295.html
Copyright © 2020-2023  润新知