feat: extended functionality for run_benchmarks script

now it also shifts all packets to the same time and merges them
This commit is contained in:
ITQ
2025-07-06 13:12:21 +03:00
parent aa13518eb3
commit 4512bf73b7
+41 -22
View File
@@ -10,7 +10,7 @@ PASSWORD="ubuntu"
SIZE="10" SIZE="10"
FILENAME="${SIZE}MB.file" FILENAME="${SIZE}MB.file"
TCPDUMP_DURATION=300 TCPDUMP_DURATION=3600
TCP_CC_COMBINATIONS=("reno reno" "reno bbr" "bbr reno" "bbr bbr") TCP_CC_COMBINATIONS=("reno reno" "reno bbr" "bbr reno" "bbr bbr")
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -21,8 +21,8 @@ else
echo "Using specified output directory: $OUTPUT_DIR" echo "Using specified output directory: $OUTPUT_DIR"
fi fi
for cmd in sshpass tcpdump; do for cmd in sshpass tcpdump capinfos editcap bc; do
if ! command -v $cmd &> /dev/null; then if ! command -v $cmd &>/dev/null; then
echo "Error: $cmd is not installed. Please install it first." echo "Error: $cmd is not installed. Please install it first."
exit 1 exit 1
fi fi
@@ -66,34 +66,45 @@ run_benchmark() {
base_name="${protocol}" base_name="${protocol}"
fi fi
pcap_file="${OUTPUT_DIR}/${base_name}.pcap" pcap_file="${OUTPUT_DIR}/${base_name}_unsynced.pcap"
pcap_file_synced="${OUTPUT_DIR}/${base_name}.pcap"
case $protocol in case $protocol in
http1) http1)
filter="tcp and port 80 and host ${CLIENT_IP} and host ${SERVER_IP}" ;; filter="tcp and port 80 and host ${CLIENT_IP} and host ${SERVER_IP}"
http2) ;;
filter="tcp and port 81 and host ${CLIENT_IP} and host ${SERVER_IP}" ;; http2)
http3) filter="tcp and port 81 and host ${CLIENT_IP} and host ${SERVER_IP}"
filter="udp and port 443 and host ${CLIENT_IP} and host ${SERVER_IP}" ;; ;;
tftp) http3)
filter="udp and host ${CLIENT_IP} and host ${SERVER_IP}" ;; filter="udp and port 443 and host ${CLIENT_IP} and host ${SERVER_IP}"
;;
tftp)
filter="udp and host ${CLIENT_IP} and host ${SERVER_IP}"
;;
esac esac
echo "Starting $protocol capture with filter: $filter" echo "Starting $protocol capture with filter: $filter"
timeout $TCPDUMP_DURATION tcpdump -i "$interface" -w "$pcap_file" "$filter" >/dev/null 2>&1 & timeout $TCPDUMP_DURATION \
tcpdump -i "$interface" -w "$pcap_file" "$filter" \
>/dev/null 2>&1 &
tcpdump_pid=$! tcpdump_pid=$!
sleep 2 sleep 2
case $protocol in case $protocol in
http1) http1)
run_vm "$CLIENT_VM" "curl -s -o /dev/null http://$SERVER_VM:80/$FILENAME" ;; run_vm "$CLIENT_VM" "curl -s -o /dev/null http://$SERVER_VM:80/$FILENAME?client=$client_cc&server=$server_cc"
http2) ;;
run_vm "$CLIENT_VM" "curl -s -o /dev/null --http2-prior-knowledge http://$SERVER_VM:81/$FILENAME" ;; http2)
http3) run_vm "$CLIENT_VM" "curl -s -o /dev/null --http2-prior-knowledge http://$SERVER_VM:81/$FILENAME?client=$client_cc&server=$server_cc"
run_vm "$CLIENT_VM" "./curl -s -o /dev/null --http3-only --insecure https://$SERVER_VM:443/$FILENAME" ;; ;;
tftp) http3)
run_vm "$CLIENT_VM" "rm -f $FILENAME; tftp $SERVER_VM -c get /var/www/$FILENAME" ;; run_vm "$CLIENT_VM" "./curl -s -o /dev/null --http3-only --insecure https://$SERVER_VM:443/$FILENAME"
;;
tftp)
run_vm "$CLIENT_VM" "rm -f $FILENAME; tftp $SERVER_VM -c get /var/www/$FILENAME"
;;
esac esac
sleep 4 sleep 4
@@ -101,10 +112,16 @@ run_benchmark() {
wait $tcpdump_pid 2>/dev/null wait $tcpdump_pid 2>/dev/null
echo "Capture saved to $pcap_file" echo "Capture saved to $pcap_file"
first_packet_time=$(capinfos -a -S "$pcap_file" 2>/dev/null | awk '/Earliest packet time/ {print $4}')
time_shift=$(echo "-$first_packet_time" | bc -l)
editcap -t "$time_shift" "$pcap_file" "$pcap_file_synced" >/dev/null 2>&1
rm $pcap_file
echo -e "Capture first packet time shifted to the beginning of epoch time, saved to $pcap_file_synced, old file removed"
} }
for combination in "${TCP_CC_COMBINATIONS[@]}"; do for combination in "${TCP_CC_COMBINATIONS[@]}"; do
read client_cc server_cc <<< "$combination" read client_cc server_cc <<<"$combination"
echo -e "\nRunning TCP benchmarks with ($client_cc/$server_cc) congestion control" echo -e "\nRunning TCP benchmarks with ($client_cc/$server_cc) congestion control"
set_tcp_cc "$CLIENT_VM" "$client_cc" set_tcp_cc "$CLIENT_VM" "$client_cc"
@@ -119,3 +136,5 @@ run_benchmark "http3" "" "" "udp"
run_benchmark "tftp" "" "" "udp" run_benchmark "tftp" "" "" "udp"
echo -e "\nAll benchmarks have been run, dumps have been stored in $OUTPUT_DIR" echo -e "\nAll benchmarks have been run, dumps have been stored in $OUTPUT_DIR"
mergecap -w $OUTPUT_DIR/merged.pcap "$OUTPUT_DIR"/*.pcap
echo -e "\nDumps have been merged: $OUTPUT_DIR/merged.pcap"