3

Back when I used linux there was a program that would find you the fastest Debian package repository based on your location. Is there a similar one for CTAN? I've been manually picking ones that I think are physically close to me and basing it on the ping time, but that isn't super reliable. Just asking as I'm on a 100+ MBit/s download connection, but it still takes hours for me to install LaTeX and a very long time to update packages.

13
  • I've got a much slower Internet connection and the full TL installs within 45minutes.
    – user31729
    Jan 7, 2016 at 20:23
  • @HenriMenke Wouldn't the fact that is on a different continent from me slow things down some?
    – Canageek
    Jan 7, 2016 at 20:28
  • @Canageek You can at least see which mirrors are up here. Jan 7, 2016 at 20:41
  • @HenriMenke TeXLive Manager will give me a list of mirrors, but I can only guess where they are physically located (which worked fine when I lived down the road from a uni hosting one of them, but now that I'm 4500 km away I get much slower rates from that mirror)
    – Canageek
    Jan 7, 2016 at 20:44
  • Why do you specify one at all? Did you have problems letting it pick automatically?
    – cfr
    Jan 7, 2016 at 22:07

2 Answers 2

3

Assuming you're on Linux you can use this command to find the fastest mirror:

netselect -vv -t40 -s20 $(\
  curl -sSL http://dante.ctan.org/mirmon/ | \
  grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | \
  cut -d\" -f2 \
) | \
cut -c7- | \
LC_ALL=C xargs -tn1 -i curl -sSL -w "%{time_total} %{speed_download} {}\n" -o /dev/null {}FILES.byname | \
sort -n

This will give you the 20 fastest mirrors (actually measured download speed). It'll rank them by speed (fastest on top) and tell you how long it took to download the file list (/FILES.byname) and the average download speed.
It's also a fair bit verbose and will tell you what it does along the way. You can reduce the verbosiy by removing the -t flag in the xargs command and by removing 1 or both -v flags from the netselect command. Adjust the number of total servers you want to check for download speed with the parameter -s20.

Below is a version you can use in a shell script, that will only output the fastest mirror and nothing else. Very usefull for shell scripts.

netselect -t40 -s20 $(\
  curl -sSL http://dante.ctan.org/mirmon/ | \
  grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | \
  cut -d\" -f2 \
) | \
cut -c7- | \
LC_ALL=C xargs -n1 -i curl -sSL -w "%{time_total} {}\n" -o /dev/null {}FILES.byname | \
sort -n | \
head -n1 | \
cut -d\  -f2
1

netselect is no longer available using Ubuntu, so I've included a more general (if much slower) version of this answer that does not rely on it:

curl -sSL http://dante.ctan.org/mirmon/ | grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | cut -d\" -f2 | LC_ALL=C xargs -n1 -i curl -sSL -w "%{time_total} %{speed_download} {}\n" -o /dev/null {}FILES.byname | sort -n

This wasn't working for me today for some reason, so I used:

#!/bin/bash
if [ -z "$1" ]
then
    for mirror in `curl -sSL http://dante.ctan.org/mirmon/ | grep -oE '<TD ALIGN=RIGHT><A HREF="[^"]*' | cut -d\" -f2`
    do
        (
            host=`echo $mirror |sed s,.*//,,|sed s,/.*,,`
            echo -e `ping $host -c1 | grep time=|sed s,.*time=,,`:'  \t\t'$mirror
        ) &
        done
    wait
    exit 1
fi

and then piped that to sort -n

1
  • Choose Arch :). AUR still has it. Don't know if it still works, mind: last updated 25th Sep 2018!
    – cfr
    Nov 26, 2020 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.