Enhance channel hopping by adding dynamic hop interval calculation based on observation duration
This commit is contained in:
parent
dcbd240bb5
commit
27d64d2bed
2 changed files with 20 additions and 6 deletions
17
runtest.sh
17
runtest.sh
|
@ -169,6 +169,8 @@ for ((COUNTER = 1; COUNTER <= NUM_TESTS; COUNTER++)); do
|
|||
|
||||
log "Test run $COUNTER of $NUM_TESTS"
|
||||
for ((i = 1; i <= NUM_SAMPLES; i++)); do
|
||||
OBS_START=$(date +%s)
|
||||
|
||||
if [ "$LISTENER_ENABLED" -eq 1 ]; then
|
||||
LISTENER_SAMPLE_FILE="${TEST_FILE%.csv}-listener-$COUNTER-$i.csv"
|
||||
|
||||
|
@ -176,12 +178,23 @@ for ((COUNTER = 1; COUNTER <= NUM_TESTS; COUNTER++)); do
|
|||
|
||||
READY_FILE="/tmp/listener_ready_${COUNTER}_${i}"
|
||||
|
||||
log "Launching listener with args: --main-iface $INTERFACE --monitor-iface $LISTEN_INTERFACE --outfile $LISTENER_SAMPLE_FILE ${LISTENER_ARGS[*]}"
|
||||
ADAPTIVE_ARGS=("${LISTENER_ARGS[@]}")
|
||||
if [[ " ${LISTENER_ARGS[*]} " =~ "--channel-hop" ]]; then
|
||||
NUM_CHANNELS=15 # Update if your list changes
|
||||
OBS_NOW=$(date +%s)
|
||||
ESTIMATED_OBS_DURATION=$((OBS_NOW - OBS_START))
|
||||
HOP_INTERVAL=$((ESTIMATED_OBS_DURATION / (NUM_CHANNELS + 1)))
|
||||
[[ "$HOP_INTERVAL" -lt 2 ]] && HOP_INTERVAL=2 # Don't go too fast
|
||||
log "Estimated observation time: ${ESTIMATED_OBS_DURATION}s → Setting hop interval: ${HOP_INTERVAL}s"
|
||||
ADAPTIVE_ARGS+=("--hop-interval" "$HOP_INTERVAL")
|
||||
fi
|
||||
|
||||
log "Launching listener with args: --main-iface $INTERFACE --monitor-iface $LISTEN_INTERFACE --outfile $LISTENER_SAMPLE_FILE ${ADAPTIVE_ARGS[*]}"
|
||||
sudo "${SCRIPT_DIRECTORY}/listener.py" \
|
||||
--main-iface "$INTERFACE" \
|
||||
--monitor-iface "$LISTEN_INTERFACE" \
|
||||
--outfile "$LISTENER_SAMPLE_FILE" \
|
||||
"${LISTENER_ARGS[@]}" > >(tee "$READY_FILE") &
|
||||
"${ADAPTIVE_ARGS[@]}" > >(tee "$READY_FILE") &
|
||||
LISTENER_PID=$!
|
||||
|
||||
# Wait for the READY_FILE to contain "LISTENING_STARTED"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue