#!/bin/bash # Test script to demonstrate ETCP debug output echo "=== Testing ETCP Debug Output ===" echo "This script demonstrates the comprehensive debug output added to ETCP and loadbalancer modules" echo "" echo "1. Testing with ETCP debug output enabled:" echo " Command: ./src/utun -d 'etcp:debug' --help" echo "" # Create a minimal config for testing cat > test_debug.conf << EOF [instance] node_id = 0x1122334455667788 priv_key = 67b705a92b41bcaae105af2d6a17743faa7b26ccebba8b3b9b0af05e9cd1d5fb pub_key = 1c55e4ccae7c4470707759086738b10681bf88b81f198cc2ab54a647d1556e17c65e6b1833e0c771e5a39382c03067c388915a4c732191bc130480f20f8e00b9 [tun] ip = 10.0.0.1 port = 1234 [peer] node_id = 0x8877665544332211 ip = 127.0.0.1 port = 1235 pub_key = 1c55e4ccae7c4470707759086738b10681bf88b81f198cc2ab54a647d1556e17c65e6b1833e0c771e5a39382c03067c388915a4c732191bc130480f20f8e00b9 EOF echo "2. Configuration file created for testing" echo "" echo "3. Available debug levels:" echo " - etcp:trace - Most detailed output (function entry/exit, packet details)" echo " - etcp:debug - Detailed operational info (packet processing, state changes)" echo " - etcp:info - Important events (connections, errors)" echo " - etcp:warn - Warnings only" echo " - etcp:error - Errors only" echo "" echo "4. Example debug configurations:" echo " -d 'etcp:trace' # Maximum ETCP detail" echo " -d 'etcp:debug,loadbalancer:debug' # ETCP + loadbalancer detail" echo " -d 'etcp:info,timing:debug' # ETCP info + timing detail" echo " -d 'all:debug' # Everything at debug level" echo "" echo "5. Key debug areas covered:" echo " ✓ Connection creation/destruction" echo " ✓ Packet transmission and reception" echo " ✓ ACK processing and retransmission" echo " ✓ RTT calculation and jitter analysis" echo " ✓ Load balancer link selection" echo " ✓ Bandwidth measurement and updates" echo " ✓ Gap detection and packet delivery" echo " ✓ Timer operations (retransmission, ACK)" echo " ✓ Memory management (allocation/free)" echo "" echo "6. To see debug output in action, run:" echo " ./src/utun -c test_debug.conf -d 'etcp:trace,loadbalancer:trace' -f" echo "" echo "=== Debug Output Summary ===" echo "The ETCP and loadbalancer modules now have comprehensive debug output using the DEBUG_* macros." echo "This will help you trace every operation, packet flow, timing calculation, and state change." echo "" # Clean up rm -f test_debug.conf