Search code examples
tcpmininetftrace

How to use ftrace for tcp probe?


I am trying to do an assignment (from another univ's coursepage) which has a line in the starter code (Python with mininet) as

os.system("rmmod tcp_probe; modprobe tcp_probe full=1")

Popen("cat /proc/net/tcpprobe > %s" % (outfile), shell=True)

which gives an error saying that tcp_probe has been disabled.

I found out by googling that tcp_probe has been deprecated in the linux kernel. However it just asks me to 'do the same using ftrace'. I have tried searching online but could not find out how to use ftrace to achieve the same.

Any help is appreciated.


Solution

  • tldr;

    Unfortunately, I could not find any way to get TCP tracepoints to work in Mininet, which is what ftrace would uses. The reason for this is that the mininet's /sys/kern/debug directory is empty, i.e., tracing cannot be enabled.

    Options:

    1. Using mininet-tracing (not recommended)

    There probably is a way to get the kernel to include this, or you could use https://github.com/mininet/mininet-tracing which might get you what you need, but I have seen reports that it is slow, and has been updated 9 years ago...

    2. Writing a new kernel module (I have tested this and it works)

    What I found as a solution instead, was to force printing for the TCP I had in mind and then take a look at the results that way. In order to enable this, you would essentially need to extend some of TCP's behaviour and (quite possibly) reuse the TCP module you have in mind. And create a new kernel module.

    Here I have provided an example that you can use. It logs socket information on each ACK. I also included a Makefile and a script to load/unload the kernel module. After you enable the module and let some traffic flow (assuming you are on a debian-based linux) you should be able to find the logs of your TCP in /var/log/kern.log.

    Note: This is a hacky way around the issue, but was good enough for my needs, and hopefully can help someone else too.