Building with Tests
Tests are disabled by default. Enable them with theSETUP_TESTS CMake option:
1
Configure build with tests
2
Build tests and libraries
3
Install tests and libraries
- 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
Expected Output
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:Running UDP Tests
The UDP test program (udpEventTest) monitors all UDP traffic on the system.
Starting the Test
Expected Output
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
Aftermake install:
- Libraries:
/opt/RealTimeKql/lib/libtcpEvent.solibudpEvent.so
- Tests:
/tmp/tcpEventTestudpEventTest
Troubleshooting Tests
Test binary not found
Test binary not found
Error:Solution: Rebuild with tests enabled:
Permission denied
Permission denied
Error:Solution: Run with sudo:
Library not found
Library not found
Error:Solution: Install libraries first:Or check library path:
No events appearing
No events appearing
For TCP:
- Events only appear when connections close
- Generate test traffic:
curl http://example.com - Check if processes are creating connections:
ss -t
- Events appear for send/receive operations
- Generate test traffic:
dig example.com - Try IPv6 traffic:
dig AAAA example.com
Probe attachment failed
Probe attachment failed
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"
Memory leaks or crashes
Memory leaks or crashes
If tests crash or leak memory:Check kernel logs:
Automated Testing
Create an automated test suite: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