如何使用 ftrace 进行 tcp 探测? [英] How to use ftrace for tcp probe?

查看:80
本文介绍了如何使用 ftrace 进行 tcp 探测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一个作业(来自另一个大学的课程页面),其中在入门代码(Python 和 mininet)中有一行作为

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)

给出一个错误,指出 tcp_probe 已被禁用.

which gives an error saying that tcp_probe has been disabled.

我通过谷歌搜索发现 tcp_probe 已经已弃用 在 linux 内核中.然而,它只是要求我使用 ftrace 做同样的事情".我试过在线搜索,但找不到如何使用 ftrace 来实现相同的效果.

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.

感谢任何帮助.

推荐答案

tldr;

不幸的是,我找不到任何方法让 TCP 跟踪点在 Mininet 中工作,而这正是 ftrace 将使用的.原因是mininet的/sys/kern/debug目录为空,即无法启用tracing.

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.

选项:

1.使用 mininet-tracing(不推荐)

可能有一种方法可以让内核包含此内容,或者您​​可以使用 https://github.com/mininet/mininet-tracing 这可能会让你得到你需要的东西,但我看到报告说它很慢,并且已经在 9 年前更新了......

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.编写一个新的内核模块(我已经测试过了,它可以工作)

我找到的解决方案是强制打印我想到的 TCP,然后以这种方式查看结果.为了实现这一点,您本质上需要扩展 TCP 的一些行为并(很可能)重用您想到的 TCP 模块.并创建一个新的内核模块.

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.

此处我提供了一个您可以使用的示例.它在每个 ACK​​ 上记录套接字信息.我还包含了一个 Makefile 和一个脚本来加载/卸载内核模块.在您启用模块并让一些流量流动后(假设您使用的是基于 debian 的 linux),您应该能够在 /var/log/kern.log 中找到您的 TCP 日志.

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.

这篇关于如何使用 ftrace 进行 tcp 探测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆