Read BitTorrent Summary
I have read the BitTorrent source code for a while. The main clues are as follows:
Parseargs
|
V
Rawserver = rawserver (doneflag, config ['timeout _ check_interval '], config ['timeout'], errorfunc = errorfunc)
|
V
Storage = storage (files, open, path. exists, path. getsize)
|
V
Storagewrapper = storagewrapper (storage, config ['Download _ slice_size '], pieces, info ['piece length'], finished, failed, statusfunc, doneflag, config ['check _ hashes '], data_flunked)
|
V
Choker = choker (config ['max _ uploads'], rawserver. add_task, finflag. isset, config ['min _ uploads'])
|
V
Upmeasure = measure (config ['max _ rate_period '],
Config ['upload _ rate_fudge '])
|
V
Ratemeasure = ratemeasure (storagewrapper. get_amount_left ())
|
V
Picker = piecepicker (LEN (pieces), config ['rarest _ first_cutoff '], config ['rarest _ first_priority_cutoff'])
|
V
Downloader = downloader (storagewrapper, Picker,
Config ['request _ backlog'], config ['max _ rate_period '],
Len (pieces), downmeasure, config ['snub _ time'],
Ratemeasure. data_came_in)
|
V
Connecter = connecter (make_upload, downloader, choker,
Len (pieces), upmeasure, config ['max _ upload_rate '] * 1024, rawserver. add_task)
|
V
Encoder = encoder (connecter, rawserver,
Myid, config ['max _ message_length '], rawserver. add_task,
Config ['keepalive _ interval'], infohash, config ['max _ initiate'])
|
V
Rerequest = rerequester (response ['announce '], config ['rerequest _ interval'],
Rawserver. add_task, connecter. how_many_connections,
Config ['min _ peers'], encoder. start_connection,
Rawserver. external_add_task, storagewrapper. get_amount_left,
Upmeasure. get_total, downmeasure. get_total, listen_port,
Config ['IP'], myid, infohash, config ['HTTP _ timeout'], errorfunc,
Config ['max _ initiate'], doneflag)
|
V
Downloaderfeedback (choker, rawserver. add_task, statusfunc,
Upmeasure. get_rate, downmeasure. get_rate,
Upmeasure. get_total_megs, downmeasure. get_total_megs, ratemeasure. get_time_left,
Ratemeasure. get_size_left, file_length, finflag,
Config ['display _ interval '], spewflag)
|
V
Rawserver. listen_forever (encoder)
Storage. Close ()
Rerequest. Announce (2)
I analyzed it in this order. After the analysis, I mainly analyzed these classes. At this time, it was really a bit
"No secret under the source code", let's continue to look at the secret under the source code.