Skip to main content
The eBPF Event Interceptor includes test programs that demonstrate library usage and verify functionality. This guide covers building with tests, running the test programs, and understanding their output.

Building with Tests

Tests are disabled by default. Enable them with the SETUP_TESTS CMake option:
1

Configure build with tests

You’ll see confirmation in the output:
2

Build tests and libraries

Expected output:
3

Install tests and libraries

This installs:
  • Libraries to /opt/RealTimeKql/lib/
  • Test binaries to /tmp/
Test binaries are installed to /tmp by default. They will be removed on system reboot unless you move them to a persistent location.

Running TCP Tests

The TCP test program (tcpEventTest) monitors all TCP connections on the system.

Starting the Test

eBPF programs require root privileges or CAP_BPF capability to load and attach probes.

Expected Output

Once a TCP connection closes, you’ll see events:

Understanding TCP Test Output

PID

Process ID that owned the TCP connection

UID

User ID of the process

rx_b

Total bytes received on this connection

tx_b

Total bytes transmitted (acknowledged)

tcpi_segs_out

Number of TCP segments sent

tcpi_segs_in

Number of TCP segments received

Command

Process name (e.g., ssh, curl, wget)

SPT/DPT

Source and destination ports

Generating TCP Test Traffic

To see events, generate TCP traffic:
TCP events are generated when connections close (transition to TCP_CLOSE state). Active connections won’t produce events until they terminate.

Running UDP Tests

The UDP test program (udpEventTest) monitors all UDP traffic on the system.

Starting the Test

Expected Output

When UDP traffic occurs:

Understanding UDP Test Output

family

Address family: 2 = IPv4, 10 = IPv6

rx_b / tx_b

Bytes received and transmitted

rxPkts / txPkts

Number of packets received and sent

DPT

Destination port (53 = DNS, 123 = NTP, etc.)

Generating UDP Test Traffic

Unlike TCP, UDP events can be generated for active sockets, not just when they close. You may see multiple events for the same socket as traffic flows.

Test Program Structure

Both test programs follow a similar pattern:

TCP Test (tcpEvent/Test/mainer.c)

UDP Test (udpEvent/Test/mainer.c)

Creating Custom Test Scenarios

You can create custom test scenarios to validate specific behavior:

Testing TCP with Large Transfers

Testing UDP with DNS Queries

Testing Both Protocols

Understanding Test Locations

Source Code Structure

Installation Locations

After make install:
  • Libraries: /opt/RealTimeKql/lib/
    • libtcpEvent.so
    • libudpEvent.so
  • Tests: /tmp/
    • tcpEventTest
    • udpEventTest
Test binaries in /tmp are deleted on reboot. Copy them to a permanent location if needed:

Troubleshooting Tests

Error:
Solution: Rebuild with tests enabled:
Error:
Solution: Run with sudo:
Error:
Solution: Install libraries first:
Or check library path:
For TCP:
  • Events only appear when connections close
  • Generate test traffic: curl http://example.com
  • Check if processes are creating connections: ss -t
For UDP:
  • Events appear for send/receive operations
  • Generate test traffic: dig example.com
  • Try IPv6 traffic: dig AAAA example.com
Error in output:
Solution:
  • Check kernel version: uname -r
  • Ensure kernel headers are installed: sudo apt install linux-headers-$(uname -r)
  • Verify BCC is working: sudo python3 -c "from bcc import BPF"
If tests crash or leak memory:
Check kernel logs:

Automated Testing

Create an automated test suite:
Run it:

Next Steps

TCP Monitoring

Deep dive into TCP monitoring features

UDP Monitoring

Explore UDP monitoring capabilities

Building from Source

Customize and rebuild the interceptor

TCP API Reference

Complete TCP API documentation