I`m making a download GUI.
It needs to find the fastest server from a list for the region the PC is in.
This saves the user from having to pick from a long list of servers.
It would be nice to auto. find the region, but it looks difficult to do.
So the user would probably select the region to speed the search.
N. America, S. America, Australia ( Pacific ), Asia, Europe, Africa.
Testing within countries will not find the fastest server in that region.
And the region list is much shorter to pick from than a country list.
# Also... I`m using ping to test speed, but is there a better way to do it?
.
Need to auto. find the fastest server.
The country list can be obtained like as it does the Puppy code in the setup scripts quicksetup andor rc.country . A reagion list would need a manually brewed and typed database file .
Code: Select all
COUNTRIES=`ls -1 /usr/share/locale`
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: Need to auto. find the fastest server.
example:sunburnt wrote:# Also... I`m using ping to test speed, but is there a better way to do it?.
time wget http://www.taek1do.de
real 0m0.576s
user 0m0.007s
sys 0m0.090s
time ping www.taek1do.de
real 0m2.890s
user 0m0.003s
sys 0m0.007s
wget is more relevant I think.
Dear Terry,
Because ping is usually slow, I would try using my bing prog with L18L's timing method:
and run bing like this:
perhaps suppressing the bing output.
With kind regards,
vovchik
Because ping is usually slow, I would try using my bing prog with L18L's timing method:
Code: Select all
' ***********************************************************
' PROGRAM: bing.bac
' PURPOSE: to check whether a network connection is alive
' AUTHOR: Peter van Eerten (network.bac)
' MODDED: vovchik (Puppy Linux forum)
' command line argument feature added
' COMMENTS: http://www.basic-converter.org/network.bac.html
' DEPENDS: bash, bacon
' PLATFORM: Puppy Linux (actually, any *nix)
' DATE: 30-05-2010
' VERSION: 0.1a
' ***********************************************************
' *****************
' DECLARATIONS
' *****************
OPTION SOCKET 1
GLOBAL site$, port$ TYPE STRING
CONST version$ = "0.1a"
' *****************
' END DECLARATIONS
' *****************
' *****************
' SUBROUTINES
' *****************
' ------------
SUB USAGE()
' ------------
PRINT NL$,"bing - BaCon network check - ", version$,NL$
PRINT "Usage: bing IP port", NL$
PRINT "Where:", NL$
PRINT " IP = a site such as 'www.google.com' or"
PRINT " an IP address such as '192.168.0.1'"
PRINT " port = a TCP/IP port number, such as '80' for http",NL$
PRINT "Example: bing www.google.com 80", NL$
END
END SUB
' ------------
SUB GET_ARGS()
' ------------
SPLIT ARGUMENT$ BY " " TO array$ SIZE argcnt
IF argcnt < 3 THEN
USAGE
ELSE
IF VAL(array$[2]) > 0 THEN
site$ = array$[1]
port$ = array$[2]
ELSE
PRINT NL$, "Input arguments contain bad values."
USAGE
END IF
END IF
END SUB
' ------------
SUB SHOW_RESULTS(NUMBER OK)
' ------------
IF OK THEN
PRINT NL$, "All OK. Site '", site$, "' is reachable.", NL$
ELSE
PRINT NL$, "Site '", site$, "' not reachable! ", ERR$(ERROR), NL$
END
END IF
END SUB
' ------------
SUB DNS_INTERRUPT()
' ------------
PRINT NL$, "That DNS lookup took too long! Exiting...", NL$
END
END SUB
' *****************
' END SUBROUTINES
' *****************
' *****************
' MAIN
' *****************
GET_ARGS
TRAP LOCAL
CATCH GOTO NETWORK_ERROR
ALARM DNS_INTERRUPT, 2
OPEN CONCAT$(site$, ":", port$) FOR NETWORK AS mynet
CLOSE NETWORK mynet
ALARM DNS_INTERRUPT, 0
SHOW_RESULTS(TRUE)
END
' ------------
LABEL NETWORK_ERROR
' ------------
SHOW_RESULTS(FALSE)
' *****************
' END MAIN
' *****************
Code: Select all
time bing www.google.com 80
With kind regards,
vovchik
Thanks guys, a tough subject I`ve found.
Hey Karl Godt; It`s been awhile...
/usr/share/locale has: /en, /en_US, /fi, and: locale.alias => /etc/locale.alias
Dosn`t "fi" = Finland?
I`m not sure of a method to parse the country from this.
L18L; That`s probably much better than using ping. Good idea!
Vovchik; How have you been? This too looks more useful than ping.
I`ll compile it and see how it works, should be like using wget.
I scraped the Ubuntu country mirrors web page and got a text list.
I`ll make a regions list from it, but auto. detecting the country is good.
Still, doing it by regions would better assure getting a good mirror.
Luxembourg, Serbia, Kuwait, and others have only one slow mirror.
.
Hey Karl Godt; It`s been awhile...
/usr/share/locale has: /en, /en_US, /fi, and: locale.alias => /etc/locale.alias
Dosn`t "fi" = Finland?
I`m not sure of a method to parse the country from this.
L18L; That`s probably much better than using ping. Good idea!
Vovchik; How have you been? This too looks more useful than ping.
I`ll compile it and see how it works, should be like using wget.
I scraped the Ubuntu country mirrors web page and got a text list.
I`ll make a regions list from it, but auto. detecting the country is good.
Still, doing it by regions would better assure getting a good mirror.
Luxembourg, Serbia, Kuwait, and others have only one slow mirror.
.
Dear Terry,
This is a little mod for the SHOW_RESULTS sub. It obviates the need to call the external "time" routine:
With kind regards,
vovchik
PS. If some slow-to-respond sites are generating a "non-reachable" error, you could change the timeout setting in the "main" part of the prog as follows:
That would give up to 5 seconds for a response from a slow server.
This is a little mod for the SHOW_RESULTS sub. It obviates the need to call the external "time" routine:
Code: Select all
' ------------
SUB SHOW_RESULTS(NUMBER OK)
' ------------
IF OK THEN
PRINT NL$, "All OK. Site '", site$, "' is reachable."
PRINT "Elapsed time: ";
PRINT (float)TIMER/1000 FORMAT "%.3g"
PRINT " seconds"
ELSE
PRINT NL$, "Site '", site$, "' not reachable! ", ERR$(ERROR), NL$
END
END IF
END SUB
vovchik
PS. If some slow-to-respond sites are generating a "non-reachable" error, you could change the timeout setting in the "main" part of the prog as follows:
Code: Select all
ALARM DNS_INTERRUPT, 5