BitTorrent System Unit web server
- 'metainfo' file ( .torrent)
- traker
- original dwonloader
- downloder
Metainfo file Structure - announce : tracker의 URL
- info
- For the case of the single-file mode
- name : 파일 이름
- length : 파일 사이즈
- piece length : 한 piece의 사이즈
- pieces : pieces의 개수, 연속된 각 piece의 hash값 (SHA1 사용 - 20byte)
- md5sum : (optional) 파일의 MD5 sum 값 (32byte hexadecimal string)
- nodes : DHT 인경우 (HOST, Port 정보)
- For the case of the multi-file mode
- name : 최상위 폴더 이름
- piece length : 한 piece의 사이즈
- pieces : pieces의 개수, 연속된 각 piece의 hash값 (SHA1 사용 - 20byte)
- files
- length : 파일 사이즈
- path : Directory인 경우 , 리스트로 구성되며 리스트의 제일 마지막 값이 파일 이름-> test1\test2\a.avi 인경우 : 4:pathl5:test15:test25:a.avie => path['test1', 'test2', 'a.avi']
- md5sum : (optional) 파일의 MD5 sum 값 (32byte hexadecimal string)
- nodes : DHT 인경우 (HOST, Port 정보)
- announce-list : (opional) tracker list
- create date : (opional) torrent 생성 시간, Unix epoch format (1-Jan-1970 00:00:00 UTC부터의 초)
- comment : (opional) 주석
- created by : (opional) torrent를 생성한 program의 이름 및 버전
- example
* Metainfo files are encoded dictionaries with the following keys -
md={
announce=>'url',
info=>{
name=>'top-level-file-or-directory-name',
piece length=>12345,
pieces=>'md5sums',
length=>12345,
-or-
files=>[
{
length=>12345,
path=>['sub','directory','path','and','filename']
}, ... {}
]
}
Tracker HTTP/HTTPS Protocol - info_hash : Metainfo File의 info key의 SHA1 hash값 (20byte), urlencode 필요
- peer_id : client가 실행할때 생성된 client의 unique ID (20byte string)
- port : client가 listen하는 port (보통 6881~6889 사용)
- uploaded : 업로드 받은 양의 합 (bytes)
- downloaded : 다운로드 받은 양의 합 (bytes)
- left
- event
- started : tracker에 첫번째 요청 시
- stopped : client를 종료 시
- completed : 다운로드 완료시 (실행시 이미 다운로드 완료되었다면 보내지 않음)
- ip : (optional) client IP 주소
- numwant : (optional) client가 tracker로 부터 받고 자 하는 peer의 수('0'도 가능), 기본값 50(numwant key를 사용하지 않을 경우)
- key : (optional)
- trakerid : (optional)
- example
* Tracker GET requests have the following keys urlencoded -
req = {
info_hash => 'hash'
peer_id => 'random-20-character-name'
ip => 'ip-address' -or- 'dns-name'
port => '12345'
uploaded => '12345'
downloaded => '12345'
left => '12345'
event => 'started', 'completed' -or- 'stopped'
}
Tracker response Key - failure reason : error string (no other keys)
- interval : client가 tracker에게 요청하는 시간 간격
- complete : seeder의 수
- incomplete : leecher의 수
- peers
- example
* Tracker responses are bencoded dictionaries.
resp = {
failure reason => 'error text'
- or -
interval => 12345
peers => {
peer id => 'identifier'
ip => 'ip-address' -or- 'hostname'
port => 12345
}
}
Peer Wire protocol (TCP) Handshake handshake:<pstrlen><pstr><reserved><info_hash><peer_id> pstrlen : <pstr>의 문자열 크기 pstr : protocol reserved : 8 reserved bytes (현재는 모두 0) info_hash : Metainfo File의 info key의 SHA1 hash값 (20byte) peer_id : tracker에 등록(?)한 client의 unique ID (20byte string) Message From : <length prefix><message ID><payload> keep-alive:<len=0000> choke:<len=0001><id=0>
unchoke:<len=0001><id=1> interested:<len=0001><id=2>
not interested:<len=0001><id=3>
have:<len=0005><id=4><piece index>
bitfield:<len=0001+X><id=5><bitfield> request:<len=0013><id=6><index><begin><length> piece:<len=0009+X><id=7><index><begin><block> cancel:<len=0013><id=8><index><begin><length> port:<len=0003><id=9><listen-port> Reference http://wiki.theory.org/BitTorrentSpecificationhttp://www.bittorrent.com/protocol.html http://dessent.net/btfaq/ http://computer.howstuffworks.com/bittorrent.htm http://lists.ibiblio.org/pipermail/bittorrent/
이 글과 관련있는 글을 자동검색한 결과입니다 [?]