mIRC Home    About    Download    Register    News    Help

Print Thread
Detect current upload bandwidth usage #164481 12/11/06 07:23 PM
Joined: Aug 2003
Posts: 22
W
WRFan Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Aug 2003
Posts: 22
How can I detect current overall UPLOAD speed on mirc (dcc/xdcc) in kb/s and set it to a variable so that I can call it in a remote script?

Re: Detect current upload bandwidth usage #164482 12/11/06 10:20 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Since there is no such thing as xdcc in mirc, rather thats a fileserver methodology to server files, i assume you just want to get the total bandwidth of all your sends.

Code:
alias current.upload.bw {
  var %t = 0, %i = $send(0)
  while (%i) { if ($send(%i).status == active) { inc %t $send(%i).cps } | dec %i }
  return %t
}



usage //echo -a $current.upload.bw

Re: Detect current upload bandwidth usage #164483 15/11/06 08:27 PM
Joined: Aug 2003
Posts: 22
W
WRFan Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Aug 2003
Posts: 22
thanx very much.
I actually came up with the idea to look at some other xdcc script to extract the function, so I checked out the Polaris Mirc version as well as the 666serv xdcc server, ripping some code snippets, while adjusting them at the same time a little bit to my needs. looks like this:

Code:
  
alias remcursp {
var %cps = 0
var %send = 1
if ($send(0) <= 0) { 
; if no uploads:
; stopping speedcheck timer
; erasing session upload record, halting script
timer1 off  | $xdcc_global_write(recordsession,0) | halt
}
else  {
var %cps = $calc(%cps + $send(%send).cps)
inc %send
}
}


Then the script checks whether the current upload speed is > than the RECORD upload speeds (session and overall) recorded in a text file. If it is, the script writes the new records to ini file, overwriting the old values:

Code:
if (%cps > $xdcc_global_read(recordsession)) 
{  
$xdcc_global_write(recordsession,%cps)
}
if (%cps > $xdcc_global_read(recordoverallbytes)) 
{
$xdcc_global_write(recordoverallbytes,%cps)
}


However, the entire idea of displaying the CURRENT bandwidth in connection with displaying the OVERALL RECORD upload speed as well as the SESSION RECORD upload speed, poses a certain problem: If you want to write the record speeds into a text file, you have to start a timer. Such a timer is set in my script to 20 sec., i.e., it checks every 20 sec. for the current upload speed and if it's higher than the record values in the file, the new records are written to file. Yet what happens if the xdcc server displays the ad in a channel PRIOR to noticing that the record speeds in the text file have been topped in the past 1-19 sec? Then the ad would look awkward, it would say

Quote:

** 2 packs ** 1 of 1 slots open, Min: 1kB/s, Record: 23.44KB/sec
** Bandwidth Usage ** Current: 26.44KB/sec, Record: 23.44KB/sec


see? because the 20 seconds are not over yet, the current speed would look higher than the record speeds. So I came up with the following idea:

Code:
 
if (%cps > $xdcc_global_read(recordsession))  { var %recordsession = %cps }
else { var %recordsession = $xdcc_global_read(recordsession) }
....
 


this way recordspeeds = currentspeed, if currentspeed > than record speeds as recorded in the text file at the moment when the xdcc ad appears in the channel. grin

The whole idea was about writing a xdcc script that can be loaded into the standard version of Mirc, while at the same time simulating IROffer behaviour, because IROffer is the standard out there so that many other scripts (XDCC Klipper for example) don't recognise other xdcc servers ads due to a varying syntax. So I re-wrote one of the existing xdcc scripts, which is now hardly distinguishable from IROffer (ad syntax, error syntax)

Re: Detect current upload bandwidth usage #164484 15/11/06 11:48 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Why not just have the timer go off every second or two? I wrote a nice DCC Speed Window script that displays total upload and total download bandwidth (and a combined up+down total) in a nice mini window at the top right of my mIRC window and it updates every couple of seconds. Everytime it updates the display, it also checks the current bandwidth for both upload and download against the records and changes the records if necessary. You can then echo the records to yourself or display them in a channel. This is always running on my computer and it doesn't slow me down at all with it checking that often.

If you are interested in it, let me know and I can display it here after I am at home.


Invision Support
#Invision on irc.irchighway.net
Re: Detect current upload bandwidth usage #164485 18/11/06 12:02 AM
Joined: Aug 2003
Posts: 22
W
WRFan Offline OP
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Aug 2003
Posts: 22
Quote:
This is always running on my computer and it doesn't slow me down at all with it checking that often.

If you are interested in it, let me know and I can display it here after I am at home


thanx, but personally I don't need a script that echoes current speed, I just needed one for my xdcc server to display the speed in the channel ads. I first set the timer to 3 seconds, but then I thought maybe it would take away too many cpu resources, so I increased the time interval. I have a very very old computer, you know... wink