Skip to content

Latest commit

 

History

311 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/.

flat in action

Running The Program

You can install flat in two ways.

  1. Download the pre-compiled binary
  2. Compile from source

Download The Pre-compiled Binary

Download, verify, and install the latest release to /usr/local/bin (Linux amd64 or arm64):

ARCH=$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/') &&
cd "$(mktemp -d)" &&
curl -fLO "https://github.com/pouriyajamshidi/flat/releases/latest/download/flat_linux_${ARCH}.tar.gz" &&
curl -fLO https://github.com/pouriyajamshidi/flat/releases/latest/download/checksums.txt &&
sha256sum -c --ignore-missing checksums.txt &&
tar xf "flat_linux_${ARCH}.tar.gz" flat &&
sudo install flat -D -t /usr/local/bin/

Then check out the examples.

Compile From Source

You will need Go, clang, llvm, and the libbpf headers (on Debian/Ubuntu: sudo apt install clang llvm libbpf-dev).

Clone the repository:

git clone https://github.com/pouriyajamshidi/flat

Change directory to flat:

cd flat

Tip

Simply run make and you will have the flat binary. 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

If you compiled from source, run sudo ./flat from the project directory instead.

When both -ip and -port are given, a flow must match both.

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.

About

Measure UDP and TCP connection latency for IPv4 and IPv6 using eBPF and Go

Topics

Resources

Stars

82 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages