Jump to content

seeking for the fastest mirror?


aru
 Share

Recommended Posts

I've just wrote this dirty script to know which is the fastest server of a list:

#! /bin/bash

# classifies a list of mirrors by ping response speed.

# dump input from stdin, such as:

#  ping.test < mirror_list

# usage (options allowed):

#  ping.test    ---> list sorted by response speed in ms.

#  ping.test -q  ---> outputs [ONLY] the fastest server.

#  ping.test -v  ---> verbose mode.

 

# cmdline options:

while getopts ":qv" opt; do

  case $opt in

      q) exec 2>/dev/null ;; # quiet mode; only outputs fastest server.

      v) verbose=1 ;;        # full output.

      *) echo >&2 "ERROR: CMDLINE opts allowed are -q or -v" && exit 1;;

  esac

done

 

# sorting

PING_atempts=5 # change

echo >&2 "Be patient, this might take a while..."

LIST="$(while read mirror; do echo >&2 "Testing \"$mirror\"";

    speed="$(ping -q -c $PING_atempts $mirror 2>&1 |\

    awk -F '/' '{if(/^rtt/){print $5}}')" # rtts avg

    printf "%-25s ----> %s\n" $mirror $speed; done;)"

SORTED_LIST=$(echo "$LIST" | sort -k 3)

 

# output

if [ "$verbose" == "1" ]; then

    echo >&2 "Sorting results, time is in ms:"

    echo "${SORTED_LIST}"

else

    echo "${SORTED_LIST}" | sed -n "1s/ .*//p"

fi

 

I've just written it right now, but I feel it may interest some of you, so that's why I've made this post.

 

As is wrote it only allows as imput a file with only a server name or ip per line, such as:

~$ cat mirrors_list
mandrake.mirrors.pair.com
mirrors.secsup.org
ftp.esat.net
ftp-linux.cc.gatech.edu
jungle.metalab.unc.edu
mirrors.usc.edu
~$

 

It has already tree types of output; just showing two:

 

the verbose mode which shows all the servers of the list ordered by ping response speed:

~$ ./ping.test -v < mirrors_list
Be patient, this might take a while...
Testing "mandrake.mirrors.pair.com"
Testing "mirrors.secsup.org"
Testing "ftp.esat.net"
Testing "ftp-linux.cc.gatech.edu"
Testing "jungle.metalab.unc.edu"
Testing "mirrors.usc.edu"
Sorting results, time is in ms:
ftp.esat.net              ----> 242.439
mirrors.secsup.org        ----> 300.747
mandrake.mirrors.pair.com ----> 321.749
ftp-linux.cc.gatech.edu   ----> 355.572
jungle.metalab.unc.edu    ----> 385.254
mirrors.usc.edu           ----> 412.407
~$

 

and the quiet mode, which only shows the name of the fastest:

~$ ./ping.test -q < mirrors_list
ftp.esat.net
~$

 

This last mode and the default mode (not shown) are quite handy for scripts or for 'out of the box' usage, ie:

~$ wget -c "$(./ping.test -q < mirrors_list)/file/to/download.ext"

 

This kind of silly and fast written scripts are those that use to be helpful, so may some of you keep a copy of it for whenever you might need such function

 

HTH

 

PS. Improvements/modifications are allowed and wellcome

Link to comment
Share on other sites

Keep those those dirty scripts comming Mi amigo. :thanks:

 

Fastest i found from the UK: http://ftp.heanet.ie/pub/mandrake/Mandrake...l/iso/10.1/i586

 

Others:

 

Last modified: Tue Dec 7 18:31:42 2004

Australia

* ftp://mirror.pacific.net.au/linux/Mandrak...l/iso/10.1/i586 (Sydney)

 

Austria

* ftp://ftp.tugraz.at/mirror/Mandrakelinux/...l/iso/10.1/i586 (Graz)

* http://gd.tuwien.ac.at/pub/linux/Mandrakel...l/iso/10.1/i586 (Vienna)

 

Belgium

* ftp://ftp.belnet.be/packages/mandrakelinu...l/iso/10.1/i586

 

Czech Republic

* ftp://mandrake.contactel.cz/Mandrakelinux...l/iso/10.1/i586

* http://ftp.sh.cvut.cz/MIRRORS/Mandrake/man...l/iso/10.1/i586 (Prague)

 

Denmark

* http://klid.dk/homeftp/mandrakelinux/official/iso/10.1/i586 (Danish only)

 

Finland

* ftp://ftp.song.fi/pub/mirrors/Mandrake-li...l/iso/10.1/i586 (Espoo)

 

France

* ftp://ftp.ciril.fr/pub/linux/mandrakelinu...l/iso/10.1/i586 (Nancy)

* ftp://ftp.free.fr/mirrors/ftp.mandrake-li...l/iso/10.1/i586 (Paris)

* ftp://ftp.lip6.fr/pub/linux/distributions...l/iso/10.1/i586 (Paris)

* ftp://ftp.proxad.net/pub/Distributions_Li...l/iso/10.1/i586

* ftp://linux.ups-tlse.fr/Mandrakelinux/official/iso/10.1/i586 (Toulouse)

 

Germany

* ftp://ftp-stud.fht-esslingen.de/pub/Mirro...l/iso/10.1/i586 (Esslingen)

* ftp://ftp.gwdg.de/pub/linux/mandrakelinux...l/iso/10.1/i586 (Goettingen)

* ftp://ftp.tu-chemnitz.de/pub/linux/mandra...l/iso/10.1/i586 (Chemnitz)

* ftp://sunsite.informatik.rwth-aachen.de/p...l/iso/10.1/i586 (Aachen)

* http://wftp.tu-chemnitz.de/pub/linux/mandr...l/iso/10.1/i586 (Chemnitz)

 

Greece

* ftp://ftp.ntua.gr/pub/linux/mandrake/official/iso/10.1/i586 (Athens)

 

Hungary

* ftp://ftp.fsn.hu/pub/linux/distributions/...l/iso/10.1/i586

 

Ireland

* http://ftp.heanet.ie/pub/mandrake/Mandrake...l/iso/10.1/i586

 

Italy

* ftp://bo.mirror.garr.it/pub/mirrors/Mandr...l/iso/10.1/i586 (Bologna)

 

Japan

* ftp://ftp.kddlabs.co.jp/Linux/packages/Ma...l/iso/10.1/i586

* ftp://ftp.riken.go.jp/pub/Linux/mandrake/...l/iso/10.1/i586

* ftp://ftp.riken.jp/Linux/mandrake/official/iso/10.1/i586

* http://ftp.riken.jp/Linux/mandrake/official/iso/10.1/i586

 

Netherlands

* ftp://ftp.nluug.nl/pub/os/Linux/distr/Man...l/iso/10.1/i586 (Amsterdam)

* ftp://ftp.surfnet.nl/pub/os/Linux/distr/M...l/iso/10.1/i586 (Amsterdam)

 

New Zealand

* ftp://mirror.inspire.net.nz/mandrake/official/iso/10.1/i586

 

Poland

* ftp://ftp.ps.pl/mirrors/mandrake/official/iso/10.1/i586 (Szczecin)

* ftp://ftp.tuniv.szczecin.pl/pub/linux/man...l/iso/10.1/i586

 

Singapore

* http://mirror.averse.net/pub/Mandrakelinux...l/iso/10.1/i586

 

Spain

* http://ftp.rediris.es/pub/linux/distributi...l/iso/10.1/i586

 

Sweden

* ftp://ftp.sunet.se/pub/Linux/distribution...l/iso/10.1/i586 (Uppsala)

 

Switzerland

* ftp://mirror.switch.ch/mirror/mandrake/of...l/iso/10.1/i586

* ftp://sunsite.cnlab-switch.ch/mirror/mand...l/iso/10.1/i586 (Zurich)

 

Taiwan

* ftp://ftp.isu.edu.tw/pub/Linux/Mandrakeli...l/iso/10.1/i586

* ftp://linux.ntcu.net/dists/mandrake/official/iso/10.1/i586

 

United Kingdom

* ftp://anorien.csc.warwick.ac.uk/Mandrakel...l/iso/10.1/i586 (Coventry)

* http://text.mirror.ac.uk/mirror/sunsite.ui...l/iso/10.1/i586

* http://www.mirror.ac.uk/sites/sunsite.uio....l/iso/10.1/i586 (Canterbury)

 

United States

* ftp://distro.ibiblio.org/pub/Linux/distri...l/iso/10.1/i586 (North Carolina)

* ftp://ftp.cs.ucr.edu/pub/mirrors/mandrake...l/iso/10.1/i586 (California)

* ftp://ftp.ndlug.nd.edu/pub/Mandrakelinux/...l/iso/10.1/i586 (Indiana)

* ftp://ftp.phys.ttu.edu/pub/mandrakelinux/...l/iso/10.1/i586 (Texas)

* ftp://ftp.uwsg.indiana.edu/linux/mandrake...l/iso/10.1/i586 (Indiana)

* ftp://hosef.ics.hawaii.edu//Mandrakelinux...l/iso/10.1/i586 (Hawaii)

* ftp://mirrors.secsup.org/pub/linux/mandra...l/iso/10.1/i586

* http://www.gtlib.cc.gatech.edu/pub/mandrak...l/iso/10.1/i586 (Georgia)

Link to comment
Share on other sites

Thanks anon!

 

Let's see the output of your list... and the fastest is...

~$ date
mar dic  7 20:36:25 CET 2004
~$ sed -n "s@.*://\(.[^/]*\)/.*@\1@p;" < anon_list | ./ping.test -v
Testing "mirror.pacific.net.au"
Testing "ftp.tugraz.at"
Testing "gd.tuwien.ac.at"
[... stripped ...]
Testing "hosef.ics.hawaii.edu"
Testing "mirrors.secsup.org"
Testing "www.gtlib.cc.gatech.edu"
Sorting results, time is in ms:
ftp.rediris.es            ----> 188.634
ftp.ciril.fr              ----> 200.706
ftp.free.fr               ----> 203.926
[... stripped ...]
ftp.song.fi               ----> 1028.130
ftp.gwdg.de               ----> 1608.493
ftp.cs.ucr.edu            ----> 1813.283
~$

 

oooh, surprise! the spanish mirror is the fastest for me in spain :lol2:

 

btw, noticed few problems when run, no error reported if the server is offline and the sort method has to be refined. But those things have to wait, now I'm moving from /dev/computer to /dev/television to see the match VALENCIA CF vs Werder Bremen!

Edited by aru
Link to comment
Share on other sites

the script is fixed:

#! /bin/bash

# classifies a list of mirrors by ping response speed.

# dump input from stdin, such as:

#  ping.test < mirror_list

# usage (options allowed):

#  ping.test    ---> list sorted by response speed in ms.

#  ping.test -q  ---> outputs [ONLY] the fastest server.

#  ping.test -v  ---> verbose mode.

                                                                                                                                                 

# cmdline options:

while getopts ":qv" opt; do

  case $opt in

      q) exec 2>/dev/null ;; # quiet mode; only outputs fastest server.

      v) verbose=1 ;;        # full output.

      *) echo >&2 "ERROR: CMDLINE opts allowed are -q or -v" && exit 1;;

  esac

done

                                                                                                                                                 

# sorting

PING_atempts=5 # change

echo >&2 "Be patient, this might take a while..."

LIST="$(while read mirror; do echo >&2 "Testing \"$mirror\"";

    speed="$(ping -q -c $PING_atempts $mirror 2>&1 |\

    awk -F '/' '{if(/^rtt/){print $5}}')" # rtts avg

    if [ "$speed" != "" ]; then

    printf "%-25s ----> %s\n" $mirror $speed;

    fi; done; )"

SORTED_LIST=$(echo "$LIST" | sort -n -k 3)

                                                                                                                                                 

# output

if [ "$verbose" == "1" ]; then

    echo >&2 "Sorting results, time is in ms:"

    echo "${SORTED_LIST}"

else

    echo "${SORTED_LIST}" | sed -n "1s/ .*//p"

fi

                                                                                                                                                 

 

now I'm really unmounting /dev/computer, the match has already begin :lol2:

Edited by aru
Link to comment
Share on other sites

as online gamers the world over are aware, ping times aren't a particularly accurate test of bandwidth, and vice versa. You can have high bandwidth and high ping (high ping is bad), or low bandwidth and low ping. A far more useful test would be to download a moderately sized file (say, a megabyte) and test the transfer speed. Ping *can* be an indicator, a server with a very high ping is unlikely to give you good transfer speeds, but one with very low ping certainly isn't guaranteed to give you a good transfer either.

Link to comment
Share on other sites

I'm not intestested in *real* bandwidth tests since my conection is a plain 56kb modem, so I need to do the quickest test possible; but if you want to implement that aditional test to my script, that will be trivial, just use wget to download the listing of a ftp directory for all the ftp servers and strip the average download timings from the output of each and sort it.

 

You only need to change the lines

speed="$(ping -q -c $PING_atempts $mirror 2>&1 |\
   awk -F '/' '{if(/^rtt/){print $5}}')" # rtts avg

with the average download speed from the wget output. The rest of the script can remain as it is.

 

or easier ping a high amount of data

Edited by aru
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...