Sign in to follow this  
Followers 0
gamerman2360

Connection Speed

13 posts in this topic

Is there a way to get your connection speed? I guess you could time a ping to a place but that seems unrelyable... Any ideas?

Share this post


Link to post
Share on other sites



I think he means the actually speed.


Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Both would help me alot. Can it be done?

[edit]

Oops, forgot to answer the OS question. Does it matter which OS? I'm trying to make a program that displays bits of info about the computer in a message box. I'm kinda hoping it would work on most of the current operating systems all the way back to 95. Here is what I have so far:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0.92
; Author:        Steve B
;
; Script Function:
;   Gets bits of system info and displays them in a messagebox.
;
; ----------------------------------------------------------------------------

#NoTrayIcon
Dim $IP[4]
If @IPAddress1 == "0.0.0.0" Then $IP[0] = " (None)"
If @IPAddress2 == "0.0.0.0" Then $IP[1] = " (None)"
If @IPAddress3 == "0.0.0.0" Then $IP[2] = " (None)"
If @IPAddress4 == "0.0.0.0" Then $IP[3] = " (None)"

MsgBox(0, "System Info", "User Name: " & @UserName & @CRLF & _
    "Computer Name: " & @ComputerName & @CRLF & _
    "-----------" & @CRLF & _
    "Resolution: " & @DesktopWidth & "x" & @DesktopHeight & @CRLF & _
    "Color Depth: " & @DesktopDepth & @CRLF & _
    "Refresh Rate: " & @DesktopRefresh & @CRLF & _
    "-----------" & @CRLF & _
    "HomeDrive: " & @HomeDrive & "\" & @CRLF & _
    "OS Version: " & @OSVersion & @CRLF & _
    "OS Lang: " & @OSLang & " (" & _Language() & ")" & @CRLF & _
    "OS ServicePack: " & @OSServicePack & @CRLF & _
    "-----------" & @CRLF & _
    "IP Address 1: " & @IPAddress1 & $IP[0] & @CRLF & _
    "IP Address 2: " & @IPAddress2 & $IP[1] & @CRLF & _
    "IP Address 3: " & @IPAddress3 & $IP[2] & @CRLF & _
    "IP Address 4: " & @IPAddress4 & $IP[3] & @CRLF)

Func _Language()
    Select
        Case StringInStr("0413,0813", @OSLang)
            Return "Dutch"
        Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009,_
                        2409,2809,2c09,3009,3409", @OSLang)
            Return "English"
        Case StringInStr("040c,080c,0c0c,100c,140c,180c", @OSLang)
            Return "French"
        Case StringInStr("0407,0807,0c07,1007,1407", @OSLang)
            Return "German"
        Case StringInStr("0410,0810", @OSLang)
            Return "Italian"
        Case StringInStr("0414,0814", @OSLang)
            Return "Norwegian"
        Case StringInStr("0415", @OSLang)
            Return "Polish"
        Case StringInStr("0416,0816", @OSLang)
            Return "Portuguese"
        Case StringInStr("040a,080a,0c0a,100a,140a,180a,1c0a,200a,_
                        240a,280a,2c0a,300a,340a,380a,3c0a,400a,_
                        440a,480a,4c0a,500a", @OSLang)
            Return "Spanish"
        Case StringInStr("041d,081d", @OSLang)
            Return "Swedish"
        Case Else
            Return "Other"
    EndSelect
EndFunc
Edited by gamerman2360

Share this post


Link to post
Share on other sites

Very rough but I think it works properly

MsgBox(0, "Connection Speed", DownloadSpeed())
Func DownloadSpeed()
    Local $Download = "http://www.google.com/index.htm"
    Local $TempFile = @TempDir & "\Temp.temp"
    $Size = InetGetSize($Download)
    If $Size = 0 Then Return (-1)
    $Time = TimerInit()
    $Success = InetGet($Download, $TempFile, 1, 0)
    If $Success = 0 Then Return(-1)
    $Time = TimerDiff($Time)
    $Rate = ($Size / $Time) * 1024
    FileDelete($TempFile)
    Return Round($Rate) & " kb/s"
EndFunc  ;==>DownloadSpeed

Share this post


Link to post
Share on other sites

Now is there a set option, like the in registry that says your connection speed?

@AutoIt Smith

It works, tho I was hoping to avoid downloading stuff. Thanks :P.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I don't think I'll include download speed (tested). The two following scripts seem to return 2 really different answers... Plus it would depend on your location and a bunch of other stuff. :P

MsgBox(0, "Connection Speed", _
    "Connection Speed: " & DownloadSpeed() & @CRLF & _
    "Connection Speed 2: " & DownloadSpeed2())

Func DownloadSpeed(); Made by AutoIt Smith
    Local $Download = "http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"; 531914 KB/Sec
    Local $TempFile = @TempDir & "\Temp.temp"
    $Size = InetGetSize($Download)
    If $Size = 0 Then Return "(Not Connected)"
    $Time = TimerInit()
    $Success = InetGet($Download, $TempFile, 1, 0)
    If $Success = 0 Then Return "(Not Connected)"
    $Time = TimerDiff($Time)
    $Rate = ($Size / $Time) * 1024
    FileDelete($TempFile)
    Return Round($Rate) & " KB/Sec"
EndFunc;==>DownloadSpeed

Func DownloadSpeed2(); Made by AutoIt Smith
    Local $Download = "http://www.google.com/index.htm"; 17073 KB/Sec
    Local $TempFile = @TempDir & "\Temp.temp"
    $Size = InetGetSize($Download)
    If $Size = 0 Then Return "(Not Connected)"
    $Time = TimerInit()
    $Success = InetGet($Download, $TempFile, 1, 0)
    If $Success = 0 Then Return "(Not Connected)"
    $Time = TimerDiff($Time)
    $Rate = ($Size / $Time) * 1024
    FileDelete($TempFile)
    Return Round($Rate) & " KB/Sec"
EndFunc;==>DownloadSpeed
Edited by gamerman2360

Share this post


Link to post
Share on other sites

It returns the avialible download speed of that current SECOND. As long as the values are within 10 kilobytes of each other it works fine. You can call it 10 times it would take about 12 seconds and average out the results.

It's just a quick method. But it works.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ok, I guess you have to get 10 and adverage it out... I've tested that and it works.

[delete & edit]

I keep getting resoluts that flop between 14KB/Sec and 50KB/Sec. 14 on google and 50 on autoit. Why?

Edited by gamerman2360

Share this post


Link to post
Share on other sites

AutoIt is PHP, Google is HTML. Usage differences at time of running. Inproper files, CPU Usage at the time of running. There are MANY factors.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Now is there a set option, like the in registry that says your connection speed?

Of course not, the connection speed may vary from time to time and it depends on several things.

It works, tho I was hoping to avoid downloading stuff. Thanks

There are two main factors that affect your connection: available traffic and current latency. Traffic needs some downloading to be measured, latency needs some pinging to be measured. That's how internet works.

Here is a function that I use to measure the download speed in a script(not a working example but will give you an idea):

$netfile = InetGet($urlfile, @ScriptDir & "/update.rar", 1, 1)
        If $netfile = 0 Then UpdateFail()
        While @InetGetActive
            $oldspeed = @InetGetBytesRead
            Sleep(250)
            $newspeed = @InetGetBytesRead
            $speed = Int(($newspeed - $oldspeed) * 4 / 1024)
        Wend

In addition your traffic speed depends on MANY factors. I.e. I have a 1024 DSL connection which has a maximum of 1024 kbps available traffic for downloading and 256 kbps of maximum traffic for uploading. If you download something from me, you can only get the maximum speed of 256 kbps (approximately 23-24 KB /s) even if you have an available internet connection of 10 Mbit. If you and somebody else download at the same time from me, you will get maximum 12 KB /s each, and so on.

It may sounds irrelevant but search on google about Distributed Denial of Service Attacks (DDoS) and you 'll get the point of how things work.

Edited by erebus

Share this post


Link to post
Share on other sites

You might try Googling "internet connection speed test" and hijack (for lack of a nicer term in my still sleeping brain) whatever files they're downloading, or open a hidden IE window with their pages, "click" the button that makes the thing go, and parse the output... This would simulate the user actually going to one of those sites and testing for themselves.

And, as several others have said, the results will be different depending on your network (how many people sharing your connection, and what is promised vs what is delivered by your ISP), the network on the other end (the speed testing websites), how busy your machine is, etc. I tend to use at least 2 or 3 sites (maybe 2 or 3 geographically separate servers [just so you know they're not using the same connection] from the same website) when I'm testing and use an average.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0