I changed the bandwidth output to be in kB/s
Also added two flags -D -U
use them to limit how bandwidth is used for each
example: $ctorrent -U 5 -D 100 some.torrent
this *should* limit upload to 5kB and download to 100kB
Please let me know if this does not work
Logged In: NO
Dear Nobody,
Please upload the patch.
Thank you,
Nobody ;)
Logged In: YES
user_id=860819
sorry thought I did :-(
diff -Naur btconfig.cpp btconfig.cpp
--- btconfig.cpp 2004-09-08 16:10:51.000000000 -0700
+++ btconfig.cpp 2005-02-16 13:29:22.495150128 -0800
@@ -11,7 +11,8 @@
int cfg_max_listen_port = 2706;
int cfg_min_listen_port = 2106;
-int cfg_max_bandwidth = -1;
+int cfg_max_bandwidth_down = -1;
+int cfg_max_bandwidth_up = -1;
time_t cfg_seed_hours = 72;
diff -Naur btconfig.h btconfig.h
--- btconfig.h 2004-09-08 16:10:51.000000000 -0700
+++ btconfig.h 2005-02-16 10:28:35.704113008 -0800
@@ -22,6 +22,8 @@
extern time_t cfg_seed_hours;
extern int cfg_max_bandwidth;
+extern int cfg_max_bandwidth_down;
+extern int cfg_max_bandwidth_up;
// arguments global value
extern char *arg_metainfo_file;
diff -Naur ctorrent.cpp ctorrent.cpp
--- ctorrent.cpp 2004-09-08 16:10:51.000000000 -0700
+++ ctorrent.cpp 2005-02-16 13:29:48.525192960 -0800
@@ -99,7 +99,7 @@
int param_check(int argc, char **argv)
{
int c, l;
- while ( ( c = getopt(argc,argv,"b:B:cC:e:fl:M:m:P:p:s:tu:xhH")) != -1)
+ while ( ( c = getopt(argc,argv,"b:cC:D:e:fl:M:m:P:p:s:tu:U:xhH")) != -1)
switch( c ){
case 'b':
arg_bitfield_file = new char[strlen(optarg) + 1];
@@ -154,9 +154,13 @@
arg_flg_force_seed_mode = 1;
break;
- case 'B':
- cfg_max_bandwidth = atoi(optarg);
+ case 'D':
+ cfg_max_bandwidth_down = (int)(strtod(optarg, NULL) * 1024);
break;
+
+ case 'U':
+ cfg_max_bandwidth_up = (int)(strtod(optarg, NULL) * 1024);
+ break;
case 'P':
l = strlen(optarg);
@@ -227,6 +231,8 @@
fprintf(stderr,"-M max_peers\tMax peers count.\n");
fprintf(stderr,"-m min_peers\tMin peers count.\n");
fprintf(stderr,"-B rate\t\tMax bandwidth (unit KB/s)\n");
+ fprintf(stderr,"-D rate\t\tMax bandwidth down (unit KB/s)\n");
+ fprintf(stderr,"-U rate\t\tMax bandwidth up (unit KB/s)\n");
fprintf(stderr,"-P peer_id\tSet Peer ID ["PEER_PFX"]\n");
fprintf(stderr,"\nMake metainfo(torrent) file Options:\n");
fprintf(stderr,"-t\t\tWith make torrent. must specify this option.\n");
diff -Naur httpencode.cpp httpencode.cpp
--- httpencode.cpp 2004-09-08 16:10:51.000000000 -0700
+++ httpencode.cpp 2005-02-16 10:28:35.706112704 -0800
@@ -88,7 +88,7 @@
/* path */
if( *p != '/' ) return -1;
- for( ; *p && *p != '?'; p++,path++) *path = *p;
+ for( ; *p; p++,path++) *path = *p;
*path = '\0';
return 0;
}
diff -Naur peer.cpp peer.cpp
--- peer.cpp 2004-09-08 16:10:51.000000000 -0700
+++ peer.cpp 2005-02-16 13:37:34.279387560 -0800
@@ -335,7 +335,7 @@
int btPeer::RequestCheck()
{
- if( BandWidthLimit() ) return 0;
+ if( BandWidthLimitDown() ) return 0;
if( BTCONTENT.pBF->IsFull() ){
if( bitfield.IsFull() ){ return -1; }
@@ -395,10 +395,17 @@
return stream.Send_Buffer((char*)BTCONTENT.GetShakeBuffer(),68);
}
-int btPeer::BandWidthLimit()
+int btPeer::BandWidthLimitUp()
{
- if( cfg_max_bandwidth <= 0 ) return 0;
- return ((Self.RateDL() + Self.RateUL()*2) / 1024 >=
cfg_max_bandwidth) ?
+ if( cfg_max_bandwidth_up <= 0 ) return 0;
+ return ((Self.RateUL()) >= cfg_max_bandwidth_up) ?
+ 1:0;
+}
+
+int btPeer::BandWidthLimitDown()
+{
+ if( cfg_max_bandwidth_down <= 0 ) return 0;
+ return ((Self.RateDL()) >= cfg_max_bandwidth_down) ?
1:0;
}
@@ -406,7 +413,7 @@
{
int yn = 0;
if( stream.out_buffer.Count() || // data need send in buffer.
- (!reponse_q.IsEmpty() && CouldReponseSlice() && !BandWidthLimit())
||
+ (!reponse_q.IsEmpty() && CouldReponseSlice() && !
BandWidthLimitUp()) ||
P_CONNECTING == m_status ) // peer is connecting
yn = 1;
return yn;
@@ -414,7 +421,7 @@
int btPeer::CouldReponseSlice()
{
- if(!m_state.local_choked &&
+ if(!m_state.local_choked &&
(stream.out_buffer.LeftSize() > reponse_q.GetRequestLen() + 4 *
1024 ))
return 1;
return 0;
diff -Naur peer.h peer.h
--- peer.h 2004-09-08 16:10:51.000000000 -0700
+++ peer.h 2005-02-16 13:06:39.175406232 -0800
@@ -96,6 +96,8 @@
int CouldReponseSlice();
int BandWidthLimit();
+ int BandWidthLimitUp();
+ int BandWidthLimitDown();
public:
BitField bitfield;
btStream stream;
diff -Naur peerlist.cpp peerlist.cpp
--- peerlist.cpp 2004-09-08 16:10:51.000000000 -0700
+++ peerlist.cpp 2005-02-16 12:42:04.884532512 -0800
@@ -185,16 +185,16 @@
// show status line.
if( m_pre_dlrate.TimeUsed(pnow) ){
printf("\r ");
- printf("\r%c %u,[%u/%u/%u],%u,%u | %u,%u E:%u",
+ printf("\r%c %u,[%u/%u/%u],%.2f,%.2f ",
LIVE_CHAR[m_live_idx],
m_peers_count,
BTCONTENT.pBF->Count(),
BTCONTENT.pBF->NBits(),
Pieces_I_Can_Get(),
- Self.RateDL(), Self.RateUL(),
- m_pre_dlrate.RateMeasure(Self.GetDLRate()),
- m_pre_ulrate.RateMeasure(Self.GetULRate()),
- Tracker.GetRefuseClick());
+ ((float)Self.RateDL()/1024), ((float)Self.RateUL()/1024));
+ //(m_pre_dlrate.RateMeasure(Self.GetDLRate())/1024),
+ //(m_pre_ulrate.RateMeasure(Self.GetULRate())/1024));
+ //Tracker.GetRefuseClick());
fflush(stdout);
m_pre_dlrate = Self.GetDLRate();
m_pre_ulrate = Self.GetULRate();
Logged In: YES
user_id=860819
Please note that the download rate setting still needs some testing and
work. the upload rate limit takes a few minutes to adjust to the proper
setting
Logged In: NO
could you please submit the patch as a file, the posted diff's are not useable
thank you