--- README-DNH.TXT.orig Sat Jul 16 10:47:30 2005 +++ README-DNH.TXT.orig Wed Nov 9 21:18:37 2005 @@ -1,5 +1,3 @@ -Please see http://www.rahul.net/dholmes/ctorrent/ for the latest version -of this information. Enhanced CTorrent @@ -23,15 +21,48 @@ Notes - Use of the -P option (or changing the peer ID in btconfig.h) is - recommended, as some other clients and trackers assume that Ctorrent + Beginning with dnh1.1 the default peer ID has been changed for + convenience, as some other clients and trackers assume that Ctorrent is "buggy" and won't cooperate with it. [Guess what, there are plenty - of others with bugs too.] It isn't necessary to impersonate another - known client; just changing or adding one letter or number should be - sufficient. + of others with bugs too.] The -P option is still available if you wish + to use a different peer ID, but it is no longer necessary to do so in + order to avoid this "ban". + +Changes for "dnh1.1" Release + + These are just corrections to the previous release that I felt were + necessary. Much more improvement is coming in the next release. + + Bug/code fixes + * Peer count would increase on each tracker update if there were no + seeders. + * RequestQueue::CopyShuffle() changed to use a pointer argument. + * Fixed some incorrectness in PendingQueue::Delete() and + PendingQueue::DeleteSlice() which could cause a memory leak. + * Fixed random-chance inversion bug in PeerList::UnChokeCheck() + affecting choice for optimistic unchoking. + + Improvements + * Move StopDLTimer() call from RequestPiece() to RequestCheck(), + which could occasionally affect peer download rate measurement. + * Most clients do not like a slice size of 128K even though it is + the max allowed by the BT specification. Changed max slice size to + 64K. Note that the maximum piece length is 2MB (2097152); if you + need to download a torrent with a larger piece size you can change + the value of cfg_req_queue_length in btconfig.h from 64 to 128. + * Contact tracker immediately upon becoming (or starting as) a + seeder. + * Changed SendModule() to send only one slice at a time. This will + help with fairly distributing upload bandwidth among the unchoked + peers. + * Changed default peer ID prefix to '-CD0101-', indicating + CTorrent-dnh1.1 release. Changes for "dnh1" Release + This is the first release. "dnh" identifies this patchset, and "1" + indicates release version 1 of the patchset. + Patches * Incorporates the following patches. The number is the Request ID from the [10]SourceForge patches page, which you can reference for @@ -169,41 +200,53 @@ Download - [12]FreeBSD patch file + Release dnh1.1 + + [12]dnh1 to dnh1.1 patch file + A patch file of changes to release dnh1 to bring it up to dnh1.1. + ___________________________________ + + Release dnh1 + + [13]FreeBSD patch file A patch file of changes to the CTorrent 1.3.4 base, including the patches from the FreeBSD ports tree. + Note: Thanks to Florent Thoumie, as of 29 Jul 2005 this patchset is + included in the FreeBSD port. If you update your ports tree (or at + least net/ctorrent) and install from there, you will have these + updates without downloading the file and patching manually. - [13]Patch file + [14]Patch file A patch file of changes to the CTorrent 1.3.4 base. - [14]FreeBSD patched source + [15]FreeBSD patched source This includes the patches from the FreeBSD ports tree. - [15]Linux/Windows/Other patched source - Please [16]let me know if you encounter any portability issues, as I + [16]Linux/Windows/Other patched source + Please [17]let me know if you encounter any portability issues, as I don't have a test environment set up for these platforms. Resources - [17]CTorrent Home Page + [18]CTorrent Home Page Outdated, but you may find some useful info (particularly the FAQ). - [18]CTorrent SourceForge Project + [19]CTorrent SourceForge Project Hosts the CTorrent codebase, bug reports, patches, and forum. - [19]Custom CTorrent + [20]Custom CTorrent A page by the author of the "get1file" patch and other fixes. It contains a custom version and a GUI for CTorrent. - [20]BitTorrent + [21]BitTorrent The official BitTorrent home page. - [21]BitTorrent wiki + [22]BitTorrent wiki Various documentation. - [22]BitTorrent protocol specification (official version) + [23]BitTorrent protocol specification (official version) - [23]BitTorrent protocol specification (wiki version) + [24]BitTorrent protocol specification (wiki version) References @@ -218,15 +261,16 @@ 9. http://sourceforge.net/projects/ctorrent/ 10. http://sourceforge.net/tracker/?atid=598034&group_id=91688&func=browse 11. http://groups.yahoo.com/group/BitTorrent/message/1260 - 12. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1-fbsd.diff - 13. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1.diff - 14. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1-fbsd.tar.gz - 15. http://www.rahul.net/dholmes/ctorrent/ctorrent-dnh1.tar.gz - 16. mailto:dholmes@ct.boxmail.com - 17. http://ctorrent.sourceforge.net/ - 18. http://sourceforge.net/projects/ctorrent/ - 19. http://customctorrent.ifreepages.com/ - 20. http://bittorrent.com/ - 21. http://wiki.theory.org/CategoryBitTorrent - 22. http://www.bittorrent.com/protocol.html - 23. http://wiki.theory.org/BitTorrentSpecification + 12. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-dnh1-dnh1.1.diff + 13. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1-fbsd.diff + 14. http://www.rahul.net/dholmes/ctorrent/patchset-ctorrent-1.3.4-dnh1.diff + 15. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1-fbsd.tar.gz + 16. http://www.rahul.net/dholmes/ctorrent/ctorrent-1.3.4-dnh1.tar.gz + 17. mailto:dholmes@ct.boxmail.com + 18. http://ctorrent.sourceforge.net/ + 19. http://sourceforge.net/projects/ctorrent/ + 20. http://customctorrent.ifreepages.com/ + 21. http://bittorrent.com/ + 22. http://wiki.theory.org/CategoryBitTorrent + 23. http://www.bittorrent.com/protocol.html + 24. http://wiki.theory.org/BitTorrentSpecification --- btconfig.h.dnh1 Thu Jul 7 19:38:00 2005 +++ btconfig.h.dnh1 Wed Nov 9 20:02:24 2005 @@ -4,11 +4,11 @@ extern size_t cfg_req_slice_size; #define MAX_METAINFO_FILESIZ 4194304 -#define cfg_max_slice_size 131072 +#define cfg_max_slice_size 65536 #define cfg_req_queue_length 64 #define MAX_PF_LEN 8 #define PEER_ID_LEN 20 -#define PEER_PFX "-CT1304-" +#define PEER_PFX "-CD0101-" extern size_t cfg_cache_size; --- btcontent.cpp.dnh1 Wed Jul 13 20:18:42 2005 +++ btcontent.cpp.dnh1 Wed Oct 26 20:51:47 2005 @@ -614,7 +614,7 @@ { if( pBF->IsFull() ){ if( !m_seed_timestamp ){ - Tracker.Reset(15); + Tracker.Reset(1); Self.ResetDLTimer(); Self.ResetULTimer(); ReleaseHashTable(); --- btrequest.cpp.dnh1 Wed Jul 13 20:19:06 2005 +++ btrequest.cpp.dnh1 Wed Nov 9 20:58:20 2005 @@ -44,14 +44,14 @@ rq.rq_head = (PSLICE) 0; } -int RequestQueue::CopyShuffle(RequestQueue &rq) +int RequestQueue::CopyShuffle(RequestQueue *prq) { PSLICE ps; if( rq_head ) _empty_slice_list(&rq_head); - if( rq.IsEmpty() ) return 0; - for (ps = rq.GetHead(); ps; ps = ps->next) { + if( prq->IsEmpty() ) return 0; + for (ps = prq->GetHead(); ps; ps = ps->next) { if (random()&01) { if (Add(ps->index, ps->offset, ps->length) < 0) return -1; } @@ -289,8 +289,8 @@ int i = 0; for ( ; i < PENDING_QUEUE_SIZE && pq_count; i++){ if( (PSLICE) 0 != pending_array[i] && idx == pending_array[i]->index){ - delete pending_array[i]; - pending_array[i] = (PSLICE) 0; + _empty_slice_list(&(pending_array[i])); + pq_count--; } } return 0; @@ -308,6 +308,7 @@ if( rq.Remove(idx, off, len) == 0 ) pending_array[i] = rq.GetHead(); rq.Release(); + if( (PSLICE) 0 == pending_array[i] ) pq_count--; } } return 0; --- btrequest.h.dnh1 Wed Jul 13 20:16:57 2005 +++ btrequest.h.dnh1 Wed Oct 26 20:33:42 2005 @@ -31,7 +31,7 @@ int IsValidRequest(size_t idx,size_t off,size_t len); void operator=(RequestQueue &rq); - int CopyShuffle(RequestQueue &rq); + int CopyShuffle(RequestQueue *prq); size_t Qsize(); int IsEmpty() const { return rq_head ? 0 : 1; } --- peer.cpp.dnh1 Fri Jul 15 19:56:17 2005 +++ peer.cpp.dnh1 Tue Nov 8 20:34:11 2005 @@ -156,7 +156,7 @@ if(peer){ if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n", peer, this, peer->request_q.GetRequestIdx() ); - return (request_q.CopyShuffle(peer->request_q) < 0) ? -1 : SendRequest(); + return (request_q.CopyShuffle(&peer->request_q) < 0) ? -1 : SendRequest(); } } // Doesn't have a piece that's already in progress--choose another. BitField tmpBitField; @@ -186,7 +186,7 @@ btPeer *peer = WORLD.Who_Can_Duplicate(this, idx); if(arg_verbose) fprintf( stderr, "Duping: %p to %p (#%u)\n", peer, this, peer->request_q.GetRequestIdx() ); - return (request_q.CopyShuffle(peer->request_q) < 0) ? + return (request_q.CopyShuffle(&peer->request_q) < 0) ? -1 : SendRequest(); }else{ // not endgame mode btPeer *peer = WORLD.Who_Can_Abandon(this); // slowest choice @@ -194,7 +194,6 @@ // Cancel a request to the slowest peer & request it from this one. if(arg_verbose) fprintf( stderr, "Reassigning %p to %p (#%u)\n", peer, this, peer->request_q.GetRequestIdx() ); - peer->StopDLTimer(); // RequestQueue class "moves" rather than "copies" in assignment! request_q = peer->request_q; @@ -500,6 +499,7 @@ if(m_state.local_interested && SetLocal(M_NOT_INTERESTED) < 0) return -1; if(!request_q.IsEmpty()) StartDLTimer(); + else StopDLTimer(); return 0; } @@ -690,7 +690,7 @@ Self.StartULTimer(); } - for(; !reponse_q.IsEmpty() && CouldReponseSlice() && !BandWidthLimitUp(); ) + if( !reponse_q.IsEmpty() && CouldReponseSlice() && !BandWidthLimitUp() ) if( ReponseSlice() < 0) return -1; return (!m_state.remote_choked && request_q.IsEmpty()) ? RequestCheck() : 0; --- peerlist.cpp.dnh1 Fri Jul 15 21:00:39 2005 +++ peerlist.cpp.dnh1 Wed Oct 26 20:42:42 2005 @@ -721,7 +721,7 @@ // if(loster->GetLastUnchokeTime() < peer_array[MAX_UNCHOKE]->GetLastUnchokeTime()) { // if loser is empty and current is not, loser gets 75% chance. if( loster->bitfield.IsEmpty() && !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty() - && random()&03 ) { + && random()&3 ) { btPeer* tmp = peer_array[MAX_UNCHOKE]; peer_array[MAX_UNCHOKE] = loster; loster = tmp; @@ -732,7 +732,7 @@ // transformed to: if loser is empty or current isn't, or 25% chance, // then loser wins. if( !peer_array[MAX_UNCHOKE]->bitfield.IsEmpty() || loster->bitfield.IsEmpty() - || !random()&03 ) { + || !(random()&3) ) { btPeer* tmp = peer_array[MAX_UNCHOKE]; peer_array[MAX_UNCHOKE] = loster; loster = tmp; --- tracker.cpp.dnh1 Fri Jul 15 21:09:00 2005 +++ tracker.cpp.dnh1 Wed Oct 26 20:28:45 2005 @@ -109,12 +109,14 @@ return -1; } + m_peers_count = 0; + if(!decode_query(buf,bufsiz,"interval",(const char**) 0,&i,QUERY_INT)){return -1;} if(m_interval != (time_t)i) m_interval = (time_t)i; if(decode_query(buf,bufsiz,"complete",(const char**) 0,&i,QUERY_INT)) { - m_peers_count = i; + m_peers_count += i; } if(decode_query(buf,bufsiz,"incomplete",(const char**) 0,&i,QUERY_INT)) { m_peers_count += i;