2021年8月3日 星期二

[TCP實驗環境搭建紀錄2] Linux kernel 修改 bypass TSQ 判斷機制

前情提要:

在之前的buffer float 實驗中,了解到Linux kernel 利用 TCP  Small Queue(TSQ) 機制,限制單TCP steam 在本機 TX queue (NIC ring buffer + QDisc queue) 注入的Packet 數量。

因此需要修改kernel code bypass TSQ 檢查機制,製造local tx queue buffer float 的可能性。

Temp load修改方案:

tcp_output.c 

function: tcp_write_xmit:

        if (skb->len > limit &&
            unlikely(tso_fragment(sk, skb, limit, mss_now, gfp)))
            break;

        //if (tcp_small_queue_check(sk, skb, 0))
        //  break;

        /* Argh, we hit an empty skb(), presumably a thread
         * is sleeping in sendmsg()/sk_stream_wait_memory().
         * We do not want to send a pure-ack packet and have
         * a strange looking rtx queue with empty packet(s).
         */
        if (TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq)
            break;


function: tcp_xmit_retransmit_queue:

        if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))
            continue;

        //if (tcp_small_queue_check(sk, skb, 1))
        //  break;

        if (tcp_retransmit_skb(sk, skb, segs))
            break;


註解掉以上兩處TSQ check and break 判斷式,bypass TSQ 檢查機制。

預期TCP stack 就能無限制注入packet 到 local tx queue 了。



2021年8月2日 星期一

[TCP實驗環境搭建紀錄1]修改Linux kernal code, 重新編譯與安裝

OS: Ubuntu 21.04

PC: NUC10

參考資料:https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

 

Step0: 安裝Ubuntu 21.04

 


 

 

 

 


 Step1-1: 設定編譯環境-修改 apt source list





 Step1-2: 設定編譯環境

sudo apt update

sudo apt-get build-dep linux linux-image-$(uname -r)

sudo apt-get install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf

 

 Step2: 根據目前內核版本取得linux source code

apt-get source linux-image-unsigned-$(uname -r)


Step3: 根據需要修改source code









Step4: 修改debian.master/changelog 中的 version number

5.11.0-25 -> 5.11.0.26


Step5: build kernel

LANG=C fakeroot debian/rules clean
LANG=C fakeroot debian/rules binary-headers binary-generic binary-perarch 


Step6: install kernel













sudo dpkg -i *.deb

Setp7: Reboot and check kernel version number 是否更新