Skip to content
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
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,24 @@ jobs:
- name: Run tests
run: sudo make test

test_asan:
name: AddressSanitizer Tests
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install Build Dependencies
run: |
sudo apt-get update
sudo apt-get install libnl-3-dev libnl-route-3-dev libnl-genl-3-dev libjansson-dev libwebsockets-dev libncurses5-dev libpcap-dev pkgconf libcap-dev

- name: Build dependencies
run: make deps/toptalk messages

- name: Run AddressSanitizer tests
run: make test-asan
env:
ASAN_OPTIONS: abort_on_error=1

32 changes: 31 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ config:
@echo "Feature Flags:"
@echo " DISABLE_IMPAIRMENTS = $(DISABLE_IMPAIRMENTS) (set to 1 to disable)"
@echo " DISABLE_PCAP = $(DISABLE_PCAP) (set to 1 to disable)"
@echo " ENABLE_WEBRTC_PLAYBACK = $(ENABLE_WEBRTC_PLAYBACK) (set to 1 to enable, requires libdatachannel)"

$(SUBDIRS):
@echo "Making $@"
Expand Down Expand Up @@ -92,7 +93,7 @@ cppcheck:
cppcheck --enable=style,warning,performance,portability messages/ server/ cli-client/

clang-analyze:
scan-build make messages server cli-client
scan-build $(MAKE) messages server cli-client

coverage:
CFLAGS="-fprofile-arcs -ftest-coverage" $(MAKE) clean test
Expand All @@ -115,3 +116,32 @@ test: $(TESTDIRS)
$(TESTDIRS):
@echo "Test $@"
@$(MAKE) --silent -C $(@:test-%=%) test

# AddressSanitizer testing
.PHONY: test-asan
test-asan:
@echo "Running AddressSanitizer tests..."
@$(MAKE) -C server test-asan
@echo "All ASan tests passed!"

.PHONY: test-video-asan
test-video-asan:
@echo "Running video AddressSanitizer tests..."
@$(MAKE) -C server test-video-asan
@echo "All video ASan tests passed!"

# Fuzzing targets
.PHONY: fuzz-build
fuzz-build:
@echo "Building fuzz harnesses..."
@$(MAKE) -C server/fuzz

.PHONY: fuzz
fuzz: fuzz-build
@echo "Running fuzzer (press Ctrl+C to stop)..."
@$(MAKE) -C server/fuzz run-fuzz-rtp

.PHONY: fuzz-quick
fuzz-quick: fuzz-build
@echo "Running 60-second fuzz session..."
@$(MAKE) -C server/fuzz fuzz-quick
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ JitterTrap is a real-time network performance analysis tool for engineers workin
- **Connection State** — visual markers for SYN, FIN, RST events
- **Congestion Events** — detects zero window, duplicate ACKs, retransmissions, ECN

**Video & Audio Stream Analysis**
- Automatic detection of RTP video streams (H.264, H.265, VP8/VP9) and MPEG-TS
- Codec identification, resolution, framerate, and bitrate extraction
- Jitter measurement and packet loss tracking per stream
- Optional in-browser video playback via WebRTC (requires `ENABLE_WEBRTC_PLAYBACK=1`)

**Network Impairment Emulation**
- Inject delay, jitter, and packet loss on egress traffic
- Scriptable impairment programs for automated testing
Expand Down Expand Up @@ -80,7 +86,15 @@ Build:
cd jittertrap
make

Run `make help` to see build configuration options.
Run `make help` to see build configuration options, or `make config` to see current settings.

### Optional Features

**WebRTC Video Playback** — watch detected video streams in your browser:

make ENABLE_WEBRTC_PLAYBACK=1

Requires [libdatachannel](https://github.com/paullouisageneau/libdatachannel) to be installed. This library is not yet packaged for most distributions and must be built from source.

## Running JitterTrap

Expand Down
25 changes: 23 additions & 2 deletions cli-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,29 @@ INCLUDES = \
-I . \
-I ../messages/include/ \

LDLIBS := -lwebsockets -ljansson -lrt $(LDLIBS)
CFLAGS := -W -Wall -pedantic -std=c11 -g -pthread $(CFLAGS)
# Build type: debug (default) or release
BUILD_TYPE ?= debug

CFLAGS_HARDENED = \
-fPIC \
-fstack-protector \
--param ssp-buffer-size=4 \
-fPIE -pie -Wl,-z,relro,-z,now \
-Warray-bounds \
-Wstringop-overflow

ifeq ($(BUILD_TYPE),release)
CFLAGS_OPT = -O2 -D_FORTIFY_SOURCE=2
CFLAGS_SANITIZER =
LDFLAGS_SANITIZER =
else
CFLAGS_OPT = -Og
CFLAGS_SANITIZER = -fsanitize=address -fno-omit-frame-pointer
LDFLAGS_SANITIZER = -fsanitize=address
endif

LDLIBS := -lwebsockets -ljansson -lrt $(LDFLAGS_SANITIZER) $(LDLIBS)
CFLAGS := -W -Wall -pedantic -std=c11 -g $(CFLAGS_OPT) -pthread $(CFLAGS_HARDENED) $(CFLAGS_SANITIZER) $(CFLAGS)

MESSAGES = ../messages/jt-messages.a

Expand Down
58 changes: 47 additions & 11 deletions deps/toptalk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@ LIB = toptalk.a
TEST = test-toptalk
TEST_RTT = test-tcp-rtt
TEST_WINDOW = test-tcp-window
TEST_VIDEO = test-video-detect
TEST_RTSP = test-rtsp-tap

SRC = \
decode.c \
intervals.c \
intervals_user.c \
rtsp_tap.c \
tcp_rtt.c \
tcp_window.c
tcp_window.c \
video_detect.c \
video_metrics.c

HEADERS = \
intervals.h \
decode.h \
flow.h \
intervals.h \
rtsp_tap.h \
tcp_rtt.h \
tcp_window.h
tcp_window.h \
video_detect.h \
video_metrics.h

ifndef INTERVAL_COUNT
INTERVAL_COUNT = 8
Expand All @@ -35,21 +43,37 @@ endif
PKGCONFIG_PCAP = $$(pkg-config --libs libpcap)
PKGCONFIG_CURSES = $$(pkg-config --cflags --libs ncursesw)

LDFLAGS := -lrt -lpthread \
$(PKGCONFIG_PCAP) \
$(PKGCONFIG_CURSES) \
$(LDFLAGS)
# Build type: debug (default) or release
BUILD_TYPE ?= debug

CFLAGS_HARDENED = \
-fPIC \
-fstack-protector \
--param ssp-buffer-size=4 \
-fPIE -pie -Wl,-z,relro,-z,now
-fPIE -pie -Wl,-z,relro,-z,now \
-Warray-bounds \
-Wstringop-overflow

ifeq ($(BUILD_TYPE),release)
CFLAGS_OPT = -O2 -D_FORTIFY_SOURCE=2
CFLAGS_SANITIZER =
LDFLAGS_SANITIZER =
else
CFLAGS_OPT = -Og
CFLAGS_SANITIZER = -fsanitize=address -fno-omit-frame-pointer
LDFLAGS_SANITIZER = -fsanitize=address
endif

LDFLAGS := -lrt -lpthread \
$(PKGCONFIG_PCAP) \
$(PKGCONFIG_CURSES) \
$(LDFLAGS_SANITIZER) \
$(LDFLAGS)

CFLAGS := -g -Wall -pedantic -std=c11 $(DEFINES) $(CFLAGS_HARDENED) $(CFLAGS)
CFLAGS := -g $(CFLAGS_OPT) -Wall -pedantic -std=c11 $(DEFINES) $(CFLAGS_HARDENED) $(CFLAGS_SANITIZER) $(CFLAGS)

.PHONY: all
all: $(LIB) $(TEST) $(TEST_RTT) $(TEST_WINDOW) $(PROG)
all: $(LIB) $(TEST) $(TEST_RTT) $(TEST_WINDOW) $(TEST_VIDEO) $(TEST_RTSP) $(PROG)

%.o: %.c %.h Makefile ../make.config make.config
$(COMPILE.c) $(DEFINES) $< -o $@
Expand Down Expand Up @@ -77,12 +101,24 @@ $(TEST_WINDOW): $(LIB) test_tcp_window.c
@echo Building $(TEST_WINDOW)
$(CC) -o $(TEST_WINDOW) test_tcp_window.c timeywimey.c $(LIB) $(LDLIBS) $(LDFLAGS) $(CFLAGS)

$(TEST_VIDEO): $(LIB) test_video_detect.c
@echo Building $(TEST_VIDEO)
$(CC) -o $(TEST_VIDEO) test_video_detect.c $(LIB) $(LDLIBS) $(LDFLAGS) $(CFLAGS)

$(TEST_RTSP): $(LIB) test_rtsp_tap.c
@echo Building $(TEST_RTSP)
$(CC) -o $(TEST_RTSP) test_rtsp_tap.c $(LIB) $(LDLIBS) $(LDFLAGS) $(CFLAGS)

.PHONY: test
test: $(TEST) $(TEST_RTT) $(TEST_WINDOW)
test: $(TEST) $(TEST_RTT) $(TEST_WINDOW) $(TEST_VIDEO) $(TEST_RTSP)
@echo "Running RTT unit tests (no root required)..."
@./$(TEST_RTT) && echo -e "RTT unit tests OK\n"
@echo "Running window unit tests (no root required)..."
@./$(TEST_WINDOW) && echo -e "Window unit tests OK\n"
@echo "Running video detection unit tests (no root required)..."
@./$(TEST_VIDEO) && echo -e "Video detection unit tests OK\n"
@echo "Running RTSP tap unit tests (no root required)..."
@./$(TEST_RTSP) && echo -e "RTSP tap unit tests OK\n"
@echo "Running integration test (needs sudo for promiscuous network access)..."
@sudo ./$(TEST) && echo -e "Integration test OK\n"

Expand All @@ -96,5 +132,5 @@ clang-analyze: clean

.PHONY: clean
clean:
rm $(LIB) $(PROG) $(TEST) $(TEST_RTT) $(TEST_WINDOW) *.o *.a || true
rm $(LIB) $(PROG) $(TEST) $(TEST_RTT) $(TEST_WINDOW) $(TEST_VIDEO) $(TEST_RTSP) *.o *.a || true
rm *.gcno *.gcov *.gcda || true
Loading