Track a packet as it goes through the kernel (linux)

前端 未结 2 956
Happy的楠姐
Happy的楠姐 2021-02-04 12:48

I have two machines which are set up to use Ip-Security and machine A (lets call them A and B) has a socket which is bound to a particular UDP port on the local machine and it p

2条回答
  •  忘掉有多难
    2021-02-04 13:15

    Please refer to the project named SystemTap. It allows you to insert user-friendly scripts hooking into any kernel code, without recompiling the kernel. For example:

    probe function("ip_rcv").call {
        printf("%d:   ->ip_rcv()\n", gettimeofday_ms()) 
    }
    

    It will emit a kernel print for every received packet in the network layer. Of course, you would need to read the sources to follow from there deeper into the network stack.

    SystemTap is very capable and quite documented about the various hooks that can be inserted.

提交回复
热议问题