Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write readme and refactor some code #493

Merged
merged 7 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 42 additions & 15 deletions eBPF_Supermarket/Network_Subsystem/tcp_watch/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
# eBPF-TCP-Watch
## 介绍
基于目前已有eBPF小工具,以及linux网络协议栈相关探测点,该项目在主机空间实现以下功能:
### 已完成
- 搭建基础开发框架和自动编译管道。
- 设计并实现TCP连接信息的记录
- 设计并实现各个TCP连接发送与接收包信息的记录
- 设计并实现TCP错误包信息的记录
- 实现从TCP包中抽取HTTP信息并记录
### TODO
- 增加运行时参数以提升可用性
## 组织结构
- tcpwatch.bpf.c:在各个内核探针点对TCP包信息、TCP连接信息以及各个包的HTTP1/1.1信息进行记录
- tcpwatch.c: 对bpf.c文件中记录的信息进行输出
- tcpwatch.h: 定义内核态与用户态程序共用的结构体
- data/:
- connects.log:符合Prometheus格式的连接信息
- err.log:符合Prometheus格式的错误包信息
- packets.log:符合Prometheus格式的包信息
- visual.py:暴露metrics接口给Prometheus,输出data文件夹下的所有信息
## 快速开始
### 安装依赖
- OS: Ubuntu 22.04LTS
```bash
sudo apt update
sudo apt install libbpf-dev clang llvm libelf-dev libpcap-dev gcc-multilib build-essential
git submodule update --init --recursive
```
### 编译运行
```bash
make
sudo ./tcpwatch
```
### 参数
```bash
Usage: tcpwatch [OPTION...]
Watch tcp/ip in network subsystem

- 记录TCP连接层面相关信息
- 记录TCP包层面相关信息
- 从TCP包中提取HTTP1/1.1相关信息
- 暴露HTTP接口提供给Prometheus以进行可视化

项目开发规划:

- [x] 搭建基础开发框架和自动编译管道。
- [x] 根据相关工具代码,设计并实现TCP连接信息的记录
- [x] 根据相关工具代码,设计并实现各个TCP连接发送与接收包信息的记录
- [ ] 更具相关工具代码,设计并实现TCP错误包信息的记录
- [ ] 调查相关资料,实现从TCP包中抽取HTTP信息并记录
- [ ] 讨论与Prometheus的连接方案并实现
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个还是要保留呀,这个其实很重要

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以分为:

  1. 已经具备能力
  2. todo 能力

- [ ] 设计并添加工具的控制参数,提高工具的可用性
- [ ] 编写相关文档
-a, --all set to trace CLOSED connection
-d, --dport=DPORT trace this destination port only
-s, --sport=SPORT trace this source port only
-?, --help Give this help list
--usage Give a short usage message
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
connection{sock="0xffff9ddca18cd780",src="10.0.2.15:56680",dst="220.181.38.149:80",backlog="0",maxbacklog="0",cwnd="10",ssthresh="2147483647",sndbuf="87040",wmem_queued="1280",rx="2.781K",tx="78",srtt="44112",duration="14882"} 0
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
packet{sock="",src="",dst="",ack="",seq="",mac_delay="",ip_delay="",tcp_delay=""} 0
packet{sock="0xffff9ddca18cd780",comm="curl",seq="2779274508",ack="504640002",mac_time="1",ip_time="3",tcp_time="14",rx="0"} 0
packet{sock="0xffff9ddca18cd780",comm="curl",seq="504640002",ack="2779274585",mac_time="45",ip_time="8",tcp_time="489",rx="1"} 0
packet{sock="0xffff9ddca18cd780",comm="curl",seq="504642722",ack="2779274585",mac_time="37",ip_time="4",tcp_time="194",rx="1"} 0
Loading