Ubuntu12.10编译MPTCP

来源:互联网 发布:什么是访客网络设置 编辑:程序博客网 时间:2024/06/07 12:06

http://blog.csdn.net/xiaodoubao124/article/details/50150677

准备工作

1、操作系统:Ubuntu-12.10-desktop-i386(32位)或者Ubuntu-14.04-desktop-amd64 (64位)
2、Mptcp源码:从官网下载 http://multipath-tcp.org/snapshots/
我下载的是mptcp_2015_11_17.tar.gz

安装系统编译mptcp源码

1、安装操作系统,并安装好网卡驱动。网卡驱动安装见上一篇博客。
2、确保操作系统有Linux源码,没有的话需要编译源码。
之后的操作需要root用户
3、Ubuntu的apt源有的需要更新,特别是12.10的源需要更新,从网上找一个 更新源,然后apt-get update更新一下,用于后面安装软件。14.04的一般用 自带的源即可。附上ubuntu12.10可用更新源(因为网上很多其他源都已经不可用了)

#deb cdrom:[Ubuntu 12.10 _Quantal Quetzal_ - Release amd64 (20121017.5)]/ quantal main restricted# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to# newer versions of the distribution.deb http://old-releases.ubuntu.com/ubuntu/ quantal main restricteddeb-src http://old-releases.ubuntu.com/ubuntu/ quantal main restricted## Major bug fix updates produced after the final release of the## distribution.deb http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricteddeb-src http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu## team. Also, please note that software in universe WILL NOT receive any## review or updates from the Ubuntu security team.deb http://old-releases.ubuntu.com/ubuntu/ quantal universedeb-src http://old-releases.ubuntu.com/ubuntu/ quantal universedeb http://old-releases.ubuntu.com/ubuntu/ quantal-updates universedeb-src http://old-releases.ubuntu.com/ubuntu/ quantal-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu## security team.deb http://old-releases.ubuntu.com/ubuntu/ quantal multiversedeb-src http://old-releases.ubuntu.com/ubuntu/ quantal multiversedeb http://old-releases.ubuntu.com/ubuntu/ quantal-updates multiversedeb-src http://old-releases.ubuntu.com/ubuntu/ quantal-updates multiverse## N.B. software from this repository may not have been tested as## extensively as that contained in the main release, although it includes## newer versions of some applications which may provide useful features.## Also, please note that software in backports WILL NOT receive any review## or updates from the Ubuntu security team.deb http://old-releases.ubuntu.com/ubuntu/ quantal-backports main restricted universe multiversedeb-src http://old-releases.ubuntu.com/ubuntu/ quantal-backports main restricted universe multiversedeb http://old-releases.ubuntu.com/ubuntu quantal-security main restricteddeb-src http://old-releases.ubuntu.com/ubuntu quantal-security main restricteddeb http://old-releases.ubuntu.com/ubuntu quantal-security universedeb-src http://old-releases.ubuntu.com/ubuntu quantal-security universedeb http://old-releases.ubuntu.com/ubuntu quantal-security multiversedeb-src http://old-releases.ubuntu.com/ubuntu quantal-security multiverse
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

4、安装openssh-server,因为之后的操作想在windows下用putty远程操作,所以需要安装配置openssh-server
sudo apt-get install openssh-server
sshd start
重启操作系统后,OK,可以远程。
5、在配置MPTCP编译的时候需要一些依赖环境需要提前安装好。
安装libncurses5-dev:apt-get install libncurses5-dev
安装基本的编程库(gcc,make等):apt-get install build-essential
6、把MPTCP源码放在/usr/src/目录下。
7、解压MPTCP源码包
tar xvf mptcp_2015_11_17.tar.gz
8、解压后进入到MPTCP目录
cd mptcp_2015_11_17
9、开始配置MPTCP编译
make menuconfig

这里写图片描述
需要选择编译时,*表示直接编译到内核中,M表示以模块的方式编译,之后使用需要加载该模块才可以。这里注意几个配置的地方:

① 如果操作系统是32位的话,第一个64-bit kernel就不要选中,如果操作系统是64位的话就要选中64-bit kernel
② 进入Networking support->Networking options

这里写图片描述
③ 这里的Networking support->Networking options->IP: advanced router->IP: policy routing 这个要开启。
④ 先选中MPTCP protocol 这样一些拥塞控制算法才会出现在TCP :advanced congestion control 里。
⑤ 选中MPTCP protocol后下面的MPTCP:advanced path-manager control 也要选中,进到里面,选中MPTCP Full-Mesh Path-Manager和MPTCP ndiff-ports。这里选择*。下面的Default MPTCP Path-Manager 选择Full mesh。
这里写图片描述
⑥ 之后退出到Networking support->Networking options,找到TCP :advanced congestion control ,进入到里面。这里是拥塞控制算法,需要哪些就选择哪些,是直接编译到内核,M是编译成模块,使用的时候要先加载模块。这里必要的用选择了CUBIC ,Vegas,Veno,LIA(MPTCP Link Increase),Olia (MPTCP Opportunistic Linked Increase),wVegas,Balia.这里也可以选择默认的算法。
这里写图片描述
⑦ 配置好拥塞控制算法后退出到Networking support->Networking options。这里需要注意IPv6部分,要么选择*直接编译到内核,要么不选择,不可以选择成M作为模块。
⑧ 保存配置,退出。

10、开始编译MPTCP内核。
当前目录是/usr/src/mptcp_2015_11_17。输入命令make,开始编译。
11、编译并安装模块。
编译完成后,输入命令 make modules_install,开始编译安装模块。
12、安装
上述完成之后,输入命令 make install ,开始安装MPTCP。
13、安装完成之后,重启。
重启之后会发现在/proc/sys/net/目录下生成了mptcp文件夹,这里包含一些运行 时配置 mptcp的参数。

配置路由

路由的配置有两种方法,一种是使用自动配置脚本,一种是自己手动配置。这里需要注意的是Ubuntu 系统关于网卡的配置有两套方法,一个是通过配置文件/etc/network/interface来配置IP 和网关,一个是通过系统设置里有网络管理。这两个方法不能同时生效,当修改/etc/network/interface后,网络管理自动失效。在本次实验环境中经过测试,使用系统设置里的网络管理成功率较高,所以选择使用系统设置->网络管理,通过界面来设置网卡IP 和网关。还需要注意,这里的IP地址必须手动固定IP 信息,不可以DHCP自动分配
因为本实验环境要求服务器端只有一个网卡,所以可以忽略下面的配置,下面的配置针对于有两个网卡情况的网络配置。
Eht0 : 192.168.1.45 网关:192.168.1.15
Eth1 :192.168.2.45 网关:192.168.2.15
将上面的信息配置通过系统设置->网络管理手动配置完成。接下来的路由表配置有两种方法。

a.使用自动配置脚本。
从官网下载自动配置脚本
mptcp_up :
https://github.com/multipath-tcp/mptcp-scripts/blob/master/scripts/rt_table/mptcp_up
mptcp_down:
https://github.com/multipath-tcp/mptcp-scripts/blob/master/scripts/rt_table/mptcp_down
下载之后把mptcp_up脚本放在/etc/network/if-up.d/目录下,修改权限。把mptcp_down脚本放在/etc/network/if-post-down.d/目录下,修改权限。
在运行脚本之前需要特别注意,在本地打开脚本检查一下里面是否有一些因为编码不同造成的一些多余符号,特别是空格和换行符等,确认无误后,root执行mptcp_up,执行后会在/.etc/iproute2/rt_table文件中发现多了两个路由表的名称,一个eth0 一个eth1。这时路由配置已经完成。可以通过命令查看。
# ip rule show
0: from all lookup local
32764: from 192.168.1.45 lookup 2
32765: from 192.168.2.45 lookup 1
32766: from all lookup main
32767: from all lookup default

# ip route
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.45
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.45
default via 192.168.1.15 dev eth0

# ip route show table 1
192.168.1.0/24 dev eth0 scope link
default via 192.168.1.15 dev eth0

# ip route show table 2
192.168.2.0/24 dev eth1 scope link
default via 192.168.2.15 dev eth1

b.手动配置路由信息。
现在/etc/iproute2/rt_tables文件中添加两个路由表1和2,表号只要不和已经存在的重复就可以。然后执行下面的命令配置路由表规则。

# This creates two different routing tables, that we use based on the source-address.  ip rule add from 192.168.1.45 table 1  ip rule add from 192.168.2.45 table 2  # Configure the two different routing tables  ip route add 192.168.1.0/24 dev eth0 scope link table 1  ip route add default via 192.168.1.15  dev eth0 table 1  ip route add 192.168.2.0/24 dev eth1 scope link table 2  ip route add default via 1192.168.2.15 dev eth1 table 2  # default route for the selection process of normal internet-traffic  ip route add default scope global nexthop via 192.168.1.15 dev eth0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

可以把这些规则写在/etc/rc.local 文件中,每次开机自动执行。

mptcp配置

编译好mptcp以后开机mptcp是自动启用的,关于mptcp开启关闭和路径管理还有拥塞控制算法是可以运行时配置的。分别介绍配置方法。参考官网说明:
http://multipath-tcp.org/pmwiki.php/Users/ConfigureMPTCP
1.开启/关闭mptcp
用root用户执行 sysctl net.mptcp.mptcp_enabled=1
1表示开启Mptcp,0表示关闭。
2、选择mptcp路径管理
sysctl net.mptcp.mptcp_path_manager=’fullmesh’
路径管理有fullmesh ,ndiffports 和之前编译mptcp时选择的有关。
3、选择拥塞控制算法
sysctl net.ipv4.tcp_congestion_control.=’olia’
或者 echo ‘olia’ >/proc/sys/net/ipv4/tcp_congestion_control
这里可以选择的算法和之前编译mptcp时的配置有关。

编译自己的拥塞控制算法

以下操作用root用户
1、将算法代码放在目录/usr/src/mptcp_2015_11_17/net/mptcp下
2、修改文件权限 chmod 777 filename
3、修改Makefile文件
vi Makefile
在Makefile 文件中添加一句:
obj-m +=mptcp_mveno.o
其中mptcp_mveno是新添叫算法的源代码文件名称。
保存退出之后,运行make -C /usr/.src/mptcp_2015_11_17 M=$PWD modules
编译算法模块,如果出错修改错误。成功编译后在目录下生成mptcp_mveno.o 和 mptcp_mveno.ko文件,使用命令加载模块:
Insmod mptcp_mveno.ko
成功加载后就可以修改mptcp拥塞控制算法,使用新算法。
echo ‘mveno’ >/proc/sys/net/ipv4/tcp_congestion_control
注意这里算法的名称mveno是在算法源代码中有相关注册的,必须和源代码中注册的名称一致。

配置apache服务器

测试是从服务器上wget文件下来,所以要在服务器上配置apache。
sudo apt-get install apache2 重启
/etc/init.d/apache2 start
完成配置。客户端也编译配置好mptcp和路由之后,从客户端wget 服务器 文件,在网 卡上抓包分析。

说明:所有编译和配置步骤官网上均有说明
MPTCP官网 http://mptcp.info.ucl.ac.be

0 0
原创粉丝点击