# Introduction
This project collect some metrics for TCP. For doing that, I use eBPF.

## Requirements
For executing and loading the eBPF program and to send data to InfluxDB, you need to install some packages:

```
```

## Compile eBPF program
First, you need to dump the vmlinux header file, which contains all definitions codes of your Linux kernel:

```
sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
```

After that, you can compile the eBPF code:

```
$ clang-11 -g -O2 -target bpf -c tp_tcp.c -o tp_tcp.o
```

Now, I made a C script which can load the eBPF program and attach it:

```
$ gcc load_bpf.c -o load_bpf -lbpf
```

And you can execute it, but, you need to have the root privileges:

```
$ sudo ./load_bpf
```


## InfluxDB
I use this [project](https://github.com/nigelargriffiths/InfluxDB-C-client) for sending data to InfluxDB.

The documentation of that project is [here](https://www.influxdata.com/blog/influxdb-c-client-library-for-capturing-statistics/)
