flat
Measure UDP and TCP flow latency for both IPv4 and IPv6 using eBPF.
This repo is the companion to my blog posts about eBPF at https://thegraynode.io/tags/flat/.

Running The Program
You can install flat in two ways.
- Download the pre-compiled binary
- Compile from source
Download The Pre-compiled Binary
Download and unpack the binary with the default garbage collection algorithm:
wget https://github.com/pouriyajamshidi/flat/releases/latest/download/flat.tar.gz
tar xvf flat.tar.gz
Or with the new green tea garbage collection algorithm:
wget https://github.com/pouriyajamshidi/flat/releases/latest/download/flat-greenteagc.tar.gz
tar xvf flat-greenteagc.tar.gz
Then check out the examples.
Compile From Source
Clone the repository:
git clone https://github.com/pouriyajamshidi/flat .
Change directory to flat:
cd flat
[!TIP]
Simply run make and you will have all you need. If you do not want to use make, keep on reading.
While at the root of project directory, to compile the C code and generate the helper functions, run:
go generate ./...
Compile the Go program:
go build -ldflags "-s -w" -o flat cmd/flat.go
Examples
Run it with elevated privileges:
# Replace eth0 with your desired interface name
sudo ./flat -i eth0
# Or
sudo ./flat -i eth0 -ip 1.1.1.1
# Or
sudo ./flat -i eth0 -port 53
# Or
sudo ./flat -i eth0 -ip 1.1.1.1 -port 53
Flags
flat supports four flags at the moment:
| flag |
Description |
| -i |
interface to attach the probe to |
| -ip |
IP address to filter on (optional) |
| -port |
Port number to filter on (optional) |
| -h |
Show help message |
Acknowledgments
Heavily inspired by flowlat.