Page 1 of 1
Need to auto. find the fastest server.
Posted: Mon 25 Feb 2013, 00:26
by sunburnt
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?
.
Posted: Tue 26 Feb 2013, 12:37
by Karl Godt
The country list can be obtained like
Code: Select all
COUNTRIES=`ls -1 /usr/share/locale`
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 .
Re: Need to auto. find the fastest server.
Posted: Tue 26 Feb 2013, 17:56
by L18L
sunburnt wrote:# Also... I`m using ping to test speed, but is there a better way to do it?.
example:
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.
Posted: Tue 26 Feb 2013, 19:16
by vovchik
Dear Terry,
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
' *****************
and run bing like this:
perhaps suppressing the bing output.
With kind regards,
vovchik
Posted: Wed 27 Feb 2013, 01:05
by sunburnt
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.
.
Posted: Wed 27 Feb 2013, 08:46
by vovchik
Dear Terry,
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
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.
Posted: Wed 27 Feb 2013, 19:56
by sunburnt
Thanks vovchik, I`ll add the code to bing.
If a web site`s slow responding I think it`s already failed.
And parsing mirrors should be quick or it cuts into download time.
That reason and easy selection for the user is why I like regions.