自己硕士论文的第一个点是数据中心网络传输控制方面的文章,然后除了实验仿真,也考虑过做下真实实验,只是真实实验除了要改Linux的源码,还要用VHDL或者Verilog对NetFPGA做些修改,工作量上感觉博士生搞这个还行,硕士生的话时间有些不够用。
以前Linux的发行版的也接触过Ubuntu、RedHat、Suse、CentOS、Fedora,常用的操作还算比较熟悉,回想下也没具体看过linux的源码是怎样的,一直看的ns2中tcp协议的代码,出于好奇,今天还是想看下Ubuntu中tcp协议是如何实现的,然后去网上找查看tcp/ip协议的源码,找了很久也没找到相关的内容,看到有些人给出的路径,我也用”find / -iname ipv4″的方法去找ipv4文件,但是所有的路径下只有Kconfig和Makefile文件,最后还是google靠谱些,在Ubuntu的社区找到了方法,下面是一段介绍:
This page will describe how to easily build the kernel.
/* The majority of users that are interested in building their own kernel are doing so because they have installed Ubuntu on their system and they wish to make a small change to the kernel for that system. In many cases the user just wants to make a kernel configuration change.
The purpose of this page is to give that user a minimum amount of information for them to meet the goal of making a simple change to the kernel, building it and installing their kernel. It is not intended to be the definitive guide to doing Ubuntu kernel development.
Obtaining the source for an Ubuntu release
There are a number of different ways of getting the kernel sources. The two main ways will be documented here.
If you have installed a version of Ubuntu and you want to make changes to the kernel that is installed on your system, use the apt-get method (described below) to obtain the sources.
However, if you wish to get the most up to date sources for the Ubuntu release you are running and make changes to that, use the git method (described below) to obtain the sources.
apt-get
The source code which generated a specific binary package may be obtained using the apt-get source <package> command. For example to obtain the source for the currently running kernel you can use the command:
-
apt-get source linux-image-$(uname -r)
git
All of the Ubuntu Kernel source is maintained under git. The source for each release is maintained in its own git repository on kernel.ubuntu.com. To obtain a local copy you can simply git clone the repository for the release you are interested in as shown below.
-
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<release codename>.git
For example to obtain the precise tree:
-
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git
用第一种方法,直接apt-get source linux-image-$(uname -r)安装完成,然后sudo apt-get build-dep linux-image-$(uname -r)安装一些必要的包来配置环境
完成这一步以后,已经可以在相应的目录下看到源码,比如原本/usr/src/linux-headers-4.4.0-92/net/ipv4/目录下只有Makefile、Kconfig和netfilter文件,而进入新安装的目录下
所有的源代码都可以看到了,用vim打开tcp_dctcp.c,查看dctcp的源码
接下来是对内核进行更改并且选择应用更改后的linux内核(如何切换linux内核的教程还挺多的),然后测试自己更改后内核效果如何。
Modifying the configuration
This step can be skipped if no configuration changes are wanted. The build process will use a configuration that is put together from various sub-config files. The simplest way to modify anything here is to run:
-
chmod a+x debian/rules chmod a+x debian/scripts/* chmod a+x debian/scripts/misc/* fakeroot debian/rules clean fakeroot debian/rules editconfigs # you need to go through each (Y, Exit, Y, Exit..) or get a complaint about config later
This takes the current configuration for each architecture/flavour supported and calls menuconfig to edit its config file. The chmod is needed because the way the source package is created, it loses the executable bits on the scripts.
In order to make your kernel “newer” than the stock Ubuntu kernel from which you are based you should add a local version modifier. Add something like “+test1” to the end of the first version number in the debian.master/changelog file, before building. This will help identify your kernel when running as it also appears in uname -a. Note that when a new Ubuntu kernel is released that will be newer than your kernel (which needs regenerating), so care is needed when upgrading. NOTE: do not attempt to use CONFIG_LOCALVERSION as this _will_ break the build.
Building the kernel
Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:
-
fakeroot debian/rules clean # quicker build: fakeroot debian/rules binary-headers binary-generic binary-perarch # if you need linux-tools or lowlatency kernel, run instead: fakeroot debian/rules binary
If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version “4.8.0-17.19” on an amd64 system, these three (or four) .deb packages would be produced:
-
cd .. ls *.deb linux-headers-4.8.0-17_4.8.0-17.19_all.deb linux-headers-4.8.0-17-generic_4.8.0-17.19_amd64.deb linux-image-4.8.0-17-generic_4.8.0-17.19_amd64.deb
on later releases you will also find a linux-extra- package which you should also install if present.
Testing the new kernel
Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:
-
sudo dpkg -i linux*4.8.0-17.19*.deb sudo reboot */
湘ICP备18012315号-1