方法一:只编译tcp模块,应用到系统
1、安装build环境[内核头文件和devel包一定要跟内核版本一致,出现冲突则卸载之前老的]
| 
					 1  | 
						yum install kernel-devel-`uname -r` kernel-header-`uname -r` gcc -y  | 
					
2、下载要编译的tcp代码
| 
					 1 2 3 4 5  | 
						mkdir tcp-test cd tcp-test wget -SO tcp_tsunami.c http://download.zhoufengjie.cn/software/mod/tcp/tcp_tsunami.c --header="User-Agent:Tyumen Kernel"  | 
					
3、编译和安装tcp模块
| 
					 1 2 3 4 5 6 7 8 9 10 11  | 
						echo "obj-m:=tcp_tsunami.o" > Makefile make -C /lib/modules/`uname -r`/build M=`pwd` modules CC=/usr/bin/gcc chmod +x ./tcp_tsunami.ko cp -rf ./tcp_tsunami.ko /lib/modules/`uname -r`/kernel/net/ipv4 insmod tcp_tsunami.ko depmod -a  | 
					
4、使用对应的tcp模块
| 
					 1 2 3 4 5  | 
						echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=tsunami" >> /etc/sysctl.conf sysctl -p  | 
					
5、核对模块是否使用了
sysctl -a|grep tcp_congestion_control
看到参数输出是此模块即可
方法二:直接打包到内核中【为了方便内部查看,我改了一下名字】
1、下载4.9.186的内核,要下载处理最新的内核或者别的内核参见:https://www.kernel.org/
2、解压内核:
yum install xz -y
xd -d linux-4.9.186.tar.xz
tar xvf linux-4.9.186.tar
3、下载魔改内核tcp文件
cd linux-4.9.186/net/ipv4/
wget -SO tcp_ngaatcp.c http://download.zhoufengjie.cn/software/mod/tcp/tcp_ngaatcp.c –header=”User-Agent:Tyumen Kernel”
4、修改配置文件
[因为直接放在ipv4目录下,所以不用单独创建,直接改现有的配置。如果单独做的目录,则创建一个Kconfig文件],[关于这个配置的有趣形象解释参照:https://blog.csdn.net/qq_33487044/article/details/81949703]
vi Kconfig输入如下内容:
| 
					 1 2 3 4 5  | 
						config TCP_CONG_NGAATCP     tristate "the tcp mod change from bbr"     default M     help       this is a tcp mod change from bbr.It requires the fq ("Fair Queue") pacing packet scheduler.  | 
					
如果大家跟我用的应该内核文件版本,或者对应模块只希望跟我的启用相同的模块,这里大家可以直接下载我的Kconfig
| 
					 1  | 
						wget -SO Kconfig http://download.zhoufengjie.cn/software/mod/tcp/4.9.186-Kconfig --header="User-Agent:Tyumen Kernel"  | 
					
5、修改编译配置
vi Makefile输入如下内容:
| 
					 1  | 
						obj-$(CONFIG_TCP_CONG_NGAATCP) += tcp_ngaatcp.o  | 
					
大家如果用和我响应版本的内核,可以下载我的Makefile
| 
					 1  | 
						wget -SO Makefile http://download.zhoufengjie.cn/software/mod/tcp/4.9.186-Makefile --header="User-Agent:Tyumen Kernel"  | 
					
6、打包内核压缩包
压缩内核压缩包:
| 
					 1 2 3 4 5  | 
						rm -f linux-4.9.186.tar tar cvf linux-4.9.186.tar linux-4.9.186 xz -z linux-4.9.186.tar  | 
					
7、编译内核
内核打包方法基础请参照【在线ppt,按方向键切页】:http://ppt.zhoufengjie.cn/kernel/centos7/#intro
本教程修改的为4.9.186版本的内核。
内核的编译config配置文件如果想用的我话,下载地址为:
| 
					 1  | 
						wget -SO config-x86_64 http://download.zhoufengjie.cn/software/mod/tcp/4.9.186-config-x86_64 --header="User-Agent:Tyumen Kernel"  | 
					
8、安装内核
安装,重启设备
9、启用
同方法一
i am from Italy hello. Can you help me translate? /rardor