# PKG multi-connection download



## vocom (May 7, 2022)

I have a very slow speed when downloading packages via pkg. Lots of other people have also reported this problem. I think the problem is that our ISPs have limited single connection speeds. Since I have no speed problem downloading with Internet Download Manager on Windows. This software uses multiple connections (8 by default) for downloads. I have a speed of about 150 KB/sec with a single connection. The only way I can use all of my bandwidth is by downloading a single file with multiple connections. 
How can I change pkg settings for this? If it's not possible, is there any other solution?


----------



## a6h (May 8, 2022)

pkg(8) uses MaxMind GeoLite geo-DNS. Use a VPN to connect to a different mirror.

_– Off-topic about IDM:_

IDM is closed-source, but AFAIK:
It checks 'Accept-Ranges HTTP response header' to find out whether partial request/download is possible or not. Which means you can also resume/pause the download ('Accept-Ranges'). It also checks whether it's possible to download a single file from multiple servers. Then it starts a multiple (1-32) thread/segment/stream/request download — Caution: not to be confused with pthread.h multithreading, or segments and/or SOCK_STREAM concepts of tcp(4).

If the server is slow, or the ISP is puting a limit on a single TCP connection, then that process (multiple connections plus resuming) improve the speed – sort of similar to torrent-ing.

To sum-up: it doesn't increase the bandwidth, but utilises connections to it max.


----------



## Alexander88207 (May 8, 2022)

a6h said:


> pkg(8) uses MaxMind GeoLite geo-DNS. Use a VPN to connect to a different mirror.



I think a better solution would be to copy /etc/pkg/FreeBSD.conf to /usr/local/etc/pkg/repos/FreeBSD.conf and edit this file to the needs.


----------



## vocom (May 8, 2022)

a6h said:


> pkg(8) uses MaxMind GeoLite geo-DNS. Use a VPN to connect to a different mirror. _– Off-topic about IDM:_ IDM is closed-source, but AFAIK: It checks 'Accept-Ranges HTTP response header' to find out whether partial request/download is possible or not. Which means you can also resume/pause the download ('Accept-Ranges'). It also checks whether it's possible to download a single file from multiple servers. Then it start a multiple (1-32) thread/segment/stream/request download — Caution: not to be confused with pthread.h multithreading, or segments and/or SOCK_STREAM concepts of tcp(4). If the server is slow, or the ISP is puting a limit on a single TCP connection, then that process (multiple connections plus resuming) improve the speed – sort of similar to torrent-ing. To sum-up: it doesn't increase the bandwidth, but utilise connections to it max.



I've tried VPNs. No difference.


----------



## SirDice (May 12, 2022)

A VPN tunnel is a single connection. fetch(3) is used by pkg(8) and will also only create a single connection.



vocom said:


> If it's not possible, is there any other solution?


Call your ISP and complain. Tell them you're not getting what you're paying for. Not everything can be solved on your side of the internet connection, maybe your ISP is having bandwidth issues, connection issues, whatever. All issues that are out of your reach to solve.


----------

