rogerxu / rogerxu.github.io

Roger Xu's Blog
2 stars 2 forks source link

net-speeder #180

Open rogerxu opened 6 years ago

rogerxu commented 6 years ago

snooda/net-speeder: net-speeder 在高延迟不稳定链路上优化单线程下载速度

rogerxu commented 6 years ago

yum

Fix yum repository

$ cd /etc/yum.repos.d/
$ ls
CentOS-Base.repo
$ vim CentOS-Base.repo
remark out baseurl
$ yum install -y deltarpm

Python

Upgrade python

$ yum update -y python
$ python --version

pip

Install pip

$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip --version

Shadowsocks

Install shadowsocks

$ pip install shadowsocks

Configuration via Config File

Create a config file /etc/shadowsocks.json. Example:

{
    "server": "0.0.0.0",
    "server_port": 443,
    "local_address": "127.0.0.1",
    "local_port": 1080,
    "password": "mypassword",
    "timeout": 300,
    "method": "rc4-md5",
    "fast_open": false,
    "workers": 2
}

To run in the foreground:

$ ssserver -c /etc/shadowsocks.json

To run in the background:

$ ssserver -c /etc/shadowsocks.json -d start
$ ssserver -c /etc/shadowsocks.json -d stop

Speedtest

Install speedtest

$ pip install speedtest-cli
$ speedtest --list | grep -i 'shanghai'
5083) Shanghai Branch, China Unicom (Shanghai, China)

Test network speed

$ speedtest --server=5083

EPEL

epel: https://fedoraproject.org/wiki/EPEL/zh-cn

Install epel

$ yum install epel-release

Install dependencies

$ yum install libnet libpcap libnet-devel libpcap-devel

net-speeder

$ wget https://github.com/snooda/net-speeder/archive/master.zip
$ unzip master.zip

Build

Build with Linux Cooked interface (venetX, OpenVZ):

$ sh build.sh -DCOOKED

Build with standard interface (Xen, KVM, physical machine)

$ sh build.sh
$ cp net_speeder /usr/bin

Run

Run

$ net_speeder venet0 "ip"

Add to boot script

$ echo 'nohup net_speeder venet0 "ip host `hostname -i` and src port 443" >/dev/null 2>&1 &' >> /etc/rc.d/rc.local

/etc/rc.d/rc.local

nohup net_speeder venet0 "ip host `hostname -i` and src port 443" >/dev/null 2>&1 &