This tutorial explains building OpenWrt images with out-of-tree MPTCP (MPTCPv0 & MPTCPv1) support.
Disclaimer: We can no longer use out-of-tree MPTCP on OpenWrt 22.03 and newer since upstream MPTCP (supports only MPTCPv1) is included instead. I will write a tutorial for building OpenWrt with upstream MPTCP in the future.
There are a few reasons to build your own image to use MPTCP instead of using solutions like OpenMPTCPRouter:
- Only a few devices are supported.
- Firmware is heavily bloated, making it impossible to run the image for devices with small flash.
Official out-of-tree MPTCP patches won't work with the kernel used on OpenWrt
Official out-of-tree MPTCP patches only support minor releases of the Linux kernel (starting with 4.9). OpenWrt uses patch releases of the Linux kernel.
Because of this reason, you can't use the patches from the official website.
http://multipath-tcp.org/patches/
Wikipedia page explaining major, minor and patch versions.
I maintain my own patches for patch versions of the Linux kernel by diff
'ing the official out-of-tree MPTCP branch against the upstream kernel it’s based off of, here:
Building the image
For OpenWrt 21.02
Clone the repository and checkout the commit
git clone https://git.openwrt.org/openwrt/openwrt.git && \
cd openwrt && \
git checkout v21.02.2
Download the patch to target/linux/generic/hack-5.4
curl -L 'https://github.com/arinc9/openwrt/raw/openwrt-21.02-mptcpv0/target/linux/generic/hack-5.4/999-mptcp_v0.96.patch' -o target/linux/generic/hack-5.4/999-mptcp_v0.96.patch
For OpenWrt 19.07
Clone the repository and checkout the commit
git clone https://git.openwrt.org/openwrt/openwrt.git && \
cd openwrt && \
git checkout v19.07.9
Download the patch to target/linux/generic/hack-4.14
curl -L 'https://github.com/arinc9/openwrt/raw/openwrt-19.07-mptcpv0/target/linux/generic/hack-4.14/999-mptcp_v0.94.patch' -o target/linux/generic/hack-4.14/999-mptcp_v0.94.patch
Disclaimer: 19.07
uses kernel 4.14
which MPTCP v0.94 is used instead. MPTCP v0.94 does not support MPTCPv1.
Update feeds and configure menuconfig
./scripts/feeds clean && ./scripts/feeds update -a && ./scripts/feeds install -a && make menuconfig -j$(nproc)
Configure the device model and enable luci
at LuCI -> Collections
by pressing "y".
Test the patches to see if they apply
make target/linux/{clean,prepare} V=s
Configure kernel menuconfig, this will take a while
make kernel_menuconfig -j$(nproc)
Enable MPTCP protocol
then MPTCP: advanced path-manager control
& MPTCP: advanced scheduler control
at Networking support -> Networking options
by pressing "y".
Enable MPTCP Full-Mesh Path-Manager
then choose Default MPTCP Path-Manager
as Full mesh
at Networking support -> Networking options -> MPTCP: advanced path-manager control
by pressing "Enter".
If you'd like to enable MPTCP TCP congestion controls and set default, you can do so at TCP: advanced congestion control
.
Finally, make the image
make -j$(nproc)
Using shadowsocks-libev & v2ray
- v2ray is recommended for use instead of shadowsocks-libev because of significantly better performance.
v2ray
v2ray-core: https://github.com/arinc9/v2ray-openwrt
luci-app-v2ray: https://github.com/kuoruan/luci-app-v2ray
shadowsocks-libev
opkg update && opkg install luci-app-shadowsocks-libev shadowsocks-libev-config shadowsocks-libev-ss-local shadowsocks-libev-ss-redir shadowsocks-libev-ss-rules shadowsocks-libev-ss-server shadowsocks-libev-ss-tunnel
Here's my Multipath TCP knowledgebase:
Here's the aggregation solution I use:
It took me 3 days to test the patches and make the guide. Have fun!
Updates
- 05/01/2021 Update: Made a list of packages to install for use with LuCI.
- 04/03/2021 Update: Updated snapshot commit to the latest kernel version which the kernel patches work.
- 23/05/2021 Update: Here's the knowledgebase I created about Multipath TCP.
- 09/06/2021 Update: Updated snapshot commit to the latest kernel version which the kernel patches work, removed unneeded patches from 19.07 and snapshot, changed patch directory from specific platform to generic & made shadowsocks optional.
- 11/06/2021 Update: Fixed the download location of the patch which broke the tutorial. Sorry about that.
- 19/06/2021 Update: Changed disclaimer about official MPTCP patches, added steps for OpenWrt-21.02, changed steps to enable MPTCP support using kernel menuconfig & moved openmptcprouter feed from MPTCP support to proxy tools.
- 23/06/2021 Update: Removed OpenMPTCPRouter feed & changed the way of installing the proxy tools.
- 18/07/2021 Update: Updated snapshot commit to the latest kernel version which the kernel patches work, simplified cloning the repository, added visual explanation to enabling MPTCP on the kernel menuconfig, included MPTCP scheduler, option to enable TCP congestion controls and change the default TCP congestion control.
- 03/11/2021 Update: Updated to the latest OpenWrt-21.02 version which the kernel patches work. Renamed snapshot to trunk and added warning about newer kernel versions. Updated the URL to retreive the MPTCPv0 patch for OpenWrt-21.02 & trunk.
- 23/12/2021 Update: Replaced the patches from Ysurac with mine as I maintain my own patches now. Added support for OpenWrt 19.07.8. Wishing everyone a happy new year!
- 04/01/2022 Update: Added accurate information about MPTCPv0 & MPTCPv1 and out-of-tree & upstream implementations. Put my Multipath TCP & Aggregation Solution pages on the post.
- 20/01/2022 Update: Slight syntax changes to retrieve patches with
curl
. - 02/04/2022 Update: Remove building for trunk as it's not possible anymore. Add a disclaimer about it. Remove mentions to the patch supporting certain patch versions of the Linux kernel as the patch can be slightly modified to apply to any patch version of the Linux kernel. Update the patches to apply to the kernel versions used on OpenWrt 21.02.2 and 19.07.9.