本文阐述了控制网关中软件的实现,一个是检测和控制MPTCP传输参量的程序。
由于控制网关是Linux平台,根据Linux平台的特点,在Linux内核中已经编译了MPTCP的传输层文件的基础上,本网关软件的研发采用“Shell编程”+“MPTCP配置文件”的方案,从而实现对传输参量的方便可靠监控。
具体来说,Shell脚本是跟Windows下的批处理文件类似的脚本程序,可以将各类命令预装入一个文件中,因此通过Shell脚本程序访问预编译进内核的MPTCP配置文件,也就是说Shell编程可作为MPTCP配置文件的编程接口。网关控制软件的框架如下所示:
MPTCP的主要配置文件有:mptcp_enabled、mptcp_checksum、mptcp_syn_retries、mptcp_debug、mptcp_path_manager.
这些配置文件具有不同的监控传输参量的功能,功能说明如下:
mptcp_enabled:控制MPTCP的开关,实现MPTCP与传统TCP之间的切换;
mptcp_checksum:控制MPTCP传输层中数据序列号校验和(DSS-checksum)的开关,DSS-checksum主要跟传输可靠性相关;
mptcp_syn_retries:指定SYN的重传次数,SYN里包含了MP_CAPABLE选项字段。通过此配置文件,SYN将不会包含MP_CAPABLE选项,这是为了处理会丢弃含有未知TCP选项的SYN的网络中间件;
mptcp_debug:调试MPTCP,控制是否打印debug报告文件;
mptcp_path_manager:MPTCP路径管理,有三个不同的配置值,分别是default/ndiffports/fullmesh,分别可以选择单路、多路或者全路进行传输。其中单路是指跟传统TCP状态一样还是用单一的TCP子流进行传输,多路是当前所有TCP子流中用户选择x条子流数进行传输,全路是指将当前所有可用的TCP子流应用到网络传输中[7]。
通过预留的编程接口,在Shell脚本程序里访问以上所述的配置文件,从而监控当前的传输参量,对MPTCP进行传输管理,程序的算法设计如下:
根据此算法设计图,用Shell编程语言编写可以访问MPTCP配置文件的Shell脚本程序,实现对当前传输参量的监控。
Shell脚本程序的详细代码如下:
#!/bin/bash command=./mptcp_configure.sh echo "***********************************************************************" echo "List of configurations:" echo "1.mptcp_checksum:Values is 0 or 1,disabled/enabled mptcp checksum. If one side has it enabled, DSS-checksums will be used" echo echo "2.mptcp_debug:Values range from 0 to 1,disabled/enabled mptcp debug" echo echo "3.mptcp_enabled:Values range from 0 to 1,disabled/enabled mptcp" echo echo "4.mptcp_path_manager:Posible values are default/fullmesh/ndiffports 'default': This path-manager actually does not do anything. 'fullmesh': It will create subflows among all available subflows. 'ndiffports': This one will create X subflows across the same pair of IP-addresses, modifying the source-port." echo echo "5.mptcp_syn_retries:Possible values are integers.Default is 3. Specifies how often we retransmit a SYN with the MP_CAPABLE-option. After this, the SYN will not contain the MP_CAPABLE-option." echo echo "6.quit:QUit the process" echo "***********************************************************************" read -p "Check the present values and choose what you want to modify [1-6]:" choice case $choice in 1) echo "The present value is:" sysctl -n net.mptcp.mptcp_checksum echo "To disable/enable checksum,please input 0/1:" read -p "" checksum while [ $checksum != 0 ] && [ $checksum != 1 ] do echo "Configure failed!Please input 0/1:" read -p "" checksum1 checksum=$checksum1 done sysctl -w net.mptcp.mptcp_debug=$checksum echo "Configure succeeded!!!" echo $command ;; 2) echo "The present value is:" sysctl -n net.mptcp.mptcp_debug echo "To disable/enable debug,please input 0/1:" read -p "" debug while [ $debug != 0 ] && [ $debug != 1 ] do echo "Configure failed!Please input 0/1:" read -p "" debug1 debug=$debug1 done sysctl -w net.mptcp.mptcp_debug=$debug echo "Configure succeeded!!!" echo $command ;; 3) echo "The present value is:" sysctl -n net.mptcp.mptcp_enabled echo "To disable/enable mptcp,please input 0/1:" read -p "" mptcp while [ $mptcp != 0 ] && [ $mptcp != 1 ] do echo "Configure failed!Please input 0/1:" read -p "" mptcp1 mptcp=$mptcp1 done sysctl -w net.mptcp.mptcp_enabled=$mptcp echo "Configure succeeded!!!" echo $command ;; 4) echo "The present value is:" sysctl -n net.mptcp.mptcp_path_manager echo "Set path manager mode default/fullmesh/ndiffports:" read -p "" pm if [ "$pm" == "ndiffports" ]; then sysctl -w net.mptcp.mptcp_path_manager=$pm echo "The present number of subflows is:" sysctl -n net.mptcp.mptcp_ndiffports echo "Please input X[1-4] to control the number of subflows:" read -p "" x while [ $x != 1 ] && [ $x != 2 ] && [ $x != 3 ] && [ $x != 4 ] do echo "Configure failed!Please input 1-4:" read -p "" x1 x=$x1 done sysctl -w net.mptcp.mptcp_ndiffports=$x echo "Configure succeeded!!!" echo $command else while [ "$pm" != "default" ] && [ "$pm" != "fullmesh" ] do echo "Configure failed!Please input default/fullmesh/ndiffports:" read -p "" pm1 pm=$pm1 done sysctl -w net.mptcp.mptcp_path_manager=$pm echo "Configure succeeded!!!" $command fi ;; 5) echo "The present value is:" sysctl -n net.mptcp.mptcp_syn_retries echo "To set up syn_retries,please input number from 0 to 10:" read -p "" retries while [ 0 -gt $retries ] | [ 10 -lt $retries ] do echo "Configure failed!Please input 0-10:" read -p "" retries1 retries=$retries1 done sysctl -w net.mptcp.mptcp_syn_retries=$retries echo "Configure succeeded!!!" echo $command ;; 6) cd /home/leo/unix ;; *) echo "invalid input!!!" ;; esac
本系统成功在安装并编译了MPTCP的网关里编写了网关软件,网关软件实现了如下功能:
1)利用MPTCP的预留接口控制传输参量,达到根据网络环境变化调整传输参量的目的;
2)网关软件供用户实时查看传输层参量,获知当前网络传输情况,以此可选择是否调整;
3)将Linux命令集成到了一个程序中,提供了不同于传统Linux终端的界面,具有用户友好的操作。