home rss search February 01, 2018

aria2


a metalink, bittorrent and file download client

aria2 is a lightweight multi-protocol and multi-server command line download tool. aria2 supports HTTP, HTTPS, FTP, BitTorrent and Metalink and can be manipulated via integrated JSON-RPC and XML-RPC interfaces.-aria2.sourceforge.net

Aria2 can use use metalinks files to simultaneously download ISOs from multiple servers as well as serve as a complete bit torrent client making aria2 a great utility. The client uses less then ten(10) megabytes of RAM so aria2 can run on an appliance or atom box without issue. Aria2, the CLI command is aria2c, can also be scripted. You can run external scripts or commands before, after or during a file or bittorrent download which make this tool incredibly powerful. In fact, we have found aria2 works so well, we have retired rTorrent in favor of aria2.

What interfaces are available ?

Aria2 is a simple text based, command line interface. If you have used wget or curl in an xterm then aria2 looks very similar. Pass the aira2c command a url or torrent file and the program will start downloading the file. You will see status messages about the download speed and any notices or errors the program encounters. We really like the simplified interface as it is easy to use in a "screen" or "tmux" session.

A browser based Web GUI is also available. Take a look at the webui-aria2 project located at sourceforge. webui-aria2 offers a very nice minimalist real time interface to aria2 running in daemon mode. The instillation of webui-aria2 is straight forward and instructions are in the link.

aria2 package install

The install of aria2 is quite simple and can be downloaded by most package managers. Here are a few examples to get you started:

FreeBSD 10.x
   portmaster www/aria2
      -OR-
   pkg install aria2

Ubuntu 12.x / 13.x
   apt-get install aria2

OpenBSD 5.x
   pkg_add -i aria2

the aria2.conf configuration file

The following is the aria2.conf configuration file we use and it needs to be placed in $HOME/.aria2/aria2.conf . We recommend using a config file so you do not have to keep adding command line arguments for every download. We find aria2 is quite friendly to those wishing to customize the client. The configuration file may look long, but we tried to add insights and comments as best we could.

#
## aria2 config
#
# man page  = http://aria2.sourceforge.net/manual/en/html/aria2c.html
# file path = $HOME/.aria2/aria2.conf

# Download Directory: specify the directory all files will be downloaded to.
# When this directive is commented out, aria2 will download the files to the
# current directory where you execute the aria2 binary.
#dir=/download/


# Bit Torrent: If the speed of the incoming data (download) from other peers is
# greater then the peer-speed-limit, then do not allow any more connections
# than max-peers. The idea is to limit the amount of clients our system will
# connect with to reduce our overall load when we are already saturating our
# incoming bandwidth.  Make sure to set the the peer-speed-limit to your
# preferred incoming (download) speed. Speeds must be whole numbers so 5.5M is
# illegal, but 5500K is valid.  For unlimited connections set
# request-peer-speed-limit something high like 10000M (10gig).
 bt-max-peers=0
 bt-request-peer-speed-limit=0


# Bit Torrent: the max upload speed for all torrents combined. Again, only
# whole numbers are valid. We find a global upload limit is more flexible then
# an upload limit per torrent. Zero(0) is unrestricted upload spreeds.
 max-overall-upload-limit=0


# Bit Torrent: When downloading a torrent remove ALL trackers from the listing.
# This is a good way to only use distributed hash table (DHT) and Peer eXchange
# (PeX) for connections. We find start up of the torrent takes a little longer
# with all trackers disabled, but helps reduce the load on trackers.
 bt-exclude-tracker="*"
 bt-external-ip=127.0.0.1


# Bit Torrent: ports and protocols used for bit torrent TCP and UDP
# connections. Make sure DHT is enabled in order to connect to UDP trackers as
# well as negotiating with DHT and PEX peers. Use xboxlive port 3074 for
# obfuscation.
 dht-listen-port=3074
 enable-dht=true
 enable-peer-exchange=true
 listen-port=3074


# When running aria2 on FreeBSD with ZFS, disable disk-cache due to ZFS's use
# of Adaptive Replacement Cache (ARC). ZFS can also take advantage of the
# "sparse files" format which is significantly faster then pre allocation of
# file space. For other file systems like EXT4 and XFS you can test
# file-allocation with "prealloc" and "falloc" to see which file-allocation
# allows arai2 to start quicker and use less disk I/O.
 disk-cache=0
 file-allocation=none


# Bit Torrent: fully encrypt the negotiation as well and the payload of all bit
# torrent traffic. With this configuration, encryption is required and all old,
# non-encrypted clients are ignored (dropped). This may help avoid some ISPs
# rate limiting P2P clients, but will also reduce the amount of clients aria2
# will talk to.
 bt-force-encryption=true
 bt-min-crypto-level=arc4
 bt-require-crypto=true


# Bit Torrent: Download the torrent file into memory (RAM) if there is no need
# to save the .torrent file itself. This option works with both magnet and
# torrent URL links.
 follow-torrent=mem


# Bit Torrent: The amount of time and the upload-to-download ratio you wish to
# seed to. If either the seed time limit ( minutes ) or the seed ratio is
# reached, torrent seeding will stop. You can set seed-time to zero(0) to
# disable seeding completely.
 seed-ratio=100
 seed-time=0


# Bit Torrent: timeout values for servers and clients.
#bt-tracker-connect-timeout=10
#bt-tracker-interval=900
#bt-tracker-timeout=10


# Bit Torrent: scripts or commands to execute before, during or after a
# download finishes.
# on-bt-download-complete=/path/to/script.sh
# on-download-complete=/path/to/script.pl
# on-download-error=/path/to/script
# on-download-pause=/path/to/script.sh
# on-download-start=/path/to/script.pl
# on-download-stop=/path/to/script


# Network: maximum socket receive buffer in bytes. 1M can sustain 1Gbit/sec.
# Default: 0 which is disabled.
 socket-recv-buffer-size=1M


# Event Multiplexing: set polling to the OS type you are using. For FreeBSD,
# OpenBSD and NetBSD set to "kqueue". For Linux set to "epoll".
 event-poll=kqueue


# Certificate Authority PEM : specify the full path to the OS certificate
# authority pem file to verify the peers. On FreeBSD with OpenSSL the following
# file path is valid. Without a valid pem file aria2 will print out the error,
# "[ERROR] Failed to load trusted CA certificates from no. Cause:
# error:02001002:system library:fopen:No such file or directory"
 ca-certificate=/usr/local/openssl/cert.pem


# Data Integrity: check the MD5 / SHA256 hash of metalink downloads as well as
# the hash of bit torrent chunks as our client receives them. CPU time is
# reasonably low for the high value of real time verified data. Note:
# check-integrity set as true will show "ERROR - Checksum error detected" for
# magnet links which can be ignored.
#check-integrity=true
 realtime-chunk-checksum=true


# File Names: Resume file downloads if we have a partial copy. Do not rename
# the file or make another copy if the same file is downloaded a second time.
 allow-overwrite=true
 always-resume=true
 auto-file-renaming=false
 continue=true
 remote-time=true


# User Agent: Disable the identification string of our client. If you connect
# to a server which requires a certain id string you can always add one here.
# Trackers should never use client id strings as security authentication or
# access control.
 peer-id-prefix=""
 user-agent=""


# Status Summery messages are disabled since the status of the download is
# updated in real time on the CLI anyways.
 summary-interval=0


# FTP: use passive ftp which is firewall friendly and reuse the ftp data
# connection when asking for multiple resources from the same server for
# efficiency.
 ftp-pasv=true
 ftp-reuse-connection=true


# Metalink: Set the country code to prefer mirrors closest to you. Prefer more
# secure https mirrors over http and ftp servers.
 metalink-language=en-US
 metalink-location=us
 metalink-preferred-protocol=https


# Disconnect from https, http or ftp servers who do not upload data to us
# faster then the specified value. Aria2 will then find another mirror in the
# metalink file which might be quicker. If there are no more mirrors left then
# the current slow mirror is still used. This value is NOT used for bit torrent
# connections though. NOTE: we hope to convince the developer to add a
# lower-speed value or even a minimal client U/D ratio to bit torrent some day
# to kick off leachers too.
 lowest-speed-limit=50K


# Concurrent downloads: Set the number of different servers to download from
# concurrently; i.e. in parallel. If we are downloading a single file then
# split that file into the same amount of streams. Make sure to keep in mind
# that if the amount of parallel downloads times the lowest-speed-limit is
# greater then your total download bandwidth then you will drop servers
# incorrectly. For example, we have ten(10) connections at a minimum of
# 50KiB/sec which equals 500KiB/sec. If our total download bandwidth is not at
# least 500KiB/sec then arai2 will think the mirrors are too slow and drop
# connection slowing down the whole download. Do not set the
# max-connection-per-server greater then three(3) as to avoid abusing a single
# server.
 max-concurrent-downloads=10
 max-connection-per-server=3
 min-split-size=5M
 split=10


# RPC Interface: To access aria2 through XML-RPC API, like using webui-aria2.
#enable-rpc
#rpc-listen-all
#rpc-user=username
#rpc-passwd=passwd


# Daemon Mode: To run aria2 in the background as a daemon. Use daemon mode to
# start aria2 on reboot or when using an RPC interface like webui-aria2.
#daemon


#
#
# Reference: the following options arethe developers defaults. We kept them
# here for reference.

# bt-max-open-files=100
# bt-save-metadata=false
# bt-stop-timeout=0
# bt-tracker="udp://tracker.openbittorrent.com:80/announce"
 check-certificate=true
 conditional-get=true
# dht-entry-point="dht.transmissionbt.com:6881"
# dht-file-path=$HOME/.aria2/dht.dat
# dht-message-timeout=10
 disable-ipv6=true
 http-accept-gzip=true
# log=$HOME/.aria2/aria2.log
# log-level=debug

### EOF ###

How do I use aria2c ?

There are many examples of how to run aria2 on the aria2 wiki and we suggest you check their page after you are done here. The Wiki assumes you have not setup an aria2.conf configuration file yet and shows each line with command line arguments. Since we have already setup a aria2.conf file all of our preferred configuration options are already set; there is no need to use command line arguments. Aria2 is now incredibly easy to use by simply passing a URL, a bittorrent URL, a magnet link or pre-downloaded bit torrent file. Here are some examples.

Standard ISO download of Ubuntu 12.x LTS server. The ISO will be saved from the Ubuntu.com http server and placed into your current directory.

aria2c http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-amd64.iso

Metalink download of Ubuntu 12.x LTS server. The metalink XML file will be downloaded and a country local server with the highest value preference (0-100) will be selected from the list. The file will be downloaded to the local directory.

aria2c http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-amd64.metalink

Bittorrent download of Ubuntu 12.x LTS server. The torrent file will be download to memory and the torrent will start downloading to the current directory.

aria2c http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-amd64.iso.torrent

Bittorrent file of Ubuntu 12.x LTS server we already downloaded with another program link wget. The torrent will start downloading to the current directory.

wget http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-amd64.iso.torrent
 --and then--
aria2c ubuntu-12.04.3-server-amd64.iso.torrent

Bittorent magnet link download. Magnet links contain question marks so put the link in quotes to pass to aria2.

aria2c "magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcad53426&dn=download"

Multiple link downloads. Simply add all the Magnet links or URL links after the aria2s command.

aria2c "magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcad53426&dn=download" "magnet:?xt=urn:btih:4dee65101db281ac9c46344cd6b175cdcad53426&dn=download2
  --OR--
aria2c "http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-amd64.iso.torrent" "http://releases.ubuntu.com/13.10/ubuntu-13.10-desktop-amd64.metalink" "http://releases.ubuntu.com/10.04/ubuntu-10.04.4-server-i386.iso" 

Questions?

Why does aria2 trigger "Listen queue overflow" warnings ?

Aria2's max queue length is set to one (maxqlen=1) by default. When you see "Listen queue overflow" lines in /var/log/messages it means aria2 can not handle that amount of extra incoming connections queued from connecting clients. After the connection has been established it is placed in the listen queue of the listen socket. To see the current listen queues state, you may run the command "netstat -Lan".

On FreeBSD, changing the kern.ipc.somaxconn to a larger value will not help. The somaxconn is the system level accept queue and the OS is not the problem here, the aria2 application is. Here is an example log line. The "0xfffff800bd648620" string is the pcb id for the current running instance of aria2.

Jan 01 01:02:03 calomel kernel: sonewconn: pcb 0xfffff800bd648620: Listen queue overflow: 2 already in queue awaiting acceptance

At this point we have not found a solution to make aria2 accept more connections at a faster pace. The queue cap may be a framework problem or programming limit introduced by the developer to accept all connections serially.

Can I background the aria2c client processes when not using daemon mode ?

Yes, you can background the client, but we suggest using "screen" or "tmux" instead. Before starting aria2c start a virtual terminal session using "screen" or "tmux", we like tmux. Once inside the virtual terminal run the aria2 command and use "Ctrl-b d" to detach the tmux session. aria2c will run in the terminal in the background and you can re-attach the session using "tmux a".


Contact Us RSS Feed Google Site Search