diff options
Diffstat (limited to 'extras/scripts')
21 files changed, 900 insertions, 0 deletions
diff --git a/extras/scripts/host-stack/cc_plots.py b/extras/scripts/host-stack/cc_plots.py new file mode 100755 index 00000000000..f7953f223d4 --- /dev/null +++ b/extras/scripts/host-stack/cc_plots.py @@ -0,0 +1,246 @@ +#!/usr/bin/env python3 + +import sys +import re +import argparse +import matplotlib.pyplot as plt +from matplotlib.lines import Line2D + + +class Point: + "CC event" + + def __init__(self, x, y): + self.x = x + self.y = y + + +def listx(points): + return list(map(lambda pt: pt.x, points)) + + +def listy(points): + return list(map(lambda pt: pt.y, points)) + + +def plot_data(d): + plt.figure(1) + + cwndx = listx(d["cwnd"]) + cwndy = listy(d["cwnd"]) + congx = listx(d["congestion"]) + congy = listy(d["congestion"]) + rcvrdx = listx(d["recovered"]) + rcvrdy = listy(d["recovered"]) + rxttx = listx(d["rxtTimeout"]) + rxtty = listy(d["rxtTimeout"]) + + # cwnd/ssthresh/cc events + plt.subplot(311) + plt.title("cwnd/ssthresh") + pcwnd = plt.plot(cwndx, cwndy, "r") + psst = plt.plot(cwndx, d["ssthresh"], "y-") + pcong = plt.plot(congx, congy, "yo") + precov = plt.plot(rcvrdx, rcvrdy, "co") + prxtt = plt.plot(rxttx, rxtty, "mo") + + marker1 = Line2D(range(1), range(1), color="r") + marker2 = Line2D(range(1), range(1), color="y") + marker3 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="y") + marker4 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="c") + marker5 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="m") + plt.legend( + (marker1, marker2, marker3, marker4, marker5), + ("cwnd", "ssthresh", "congestion", "recovered", "rxt-timeout"), + loc=4, + ) + axes = plt.gca() + axes.set_ylim([-20e4, max(cwndy) + 20e4]) + + # snd variables + plt.subplot(312) + plt.title("cc variables") + plt.plot(cwndx, d["space"], "g-", markersize=1) + plt.plot(cwndx, d["flight"], "b-", markersize=1) + plt.plot(cwndx, d["sacked"], "m:", markersize=1) + plt.plot(cwndx, d["lost"], "y:", markersize=1) + plt.plot(cwndx, d["cc-space"], "k:", markersize=1) + plt.plot(cwndx, cwndy, "ro", markersize=2) + + plt.plot(congx, congy, "y^", markersize=10, markerfacecolor="y") + plt.plot(rcvrdx, rcvrdy, "c^", markersize=10, markerfacecolor="c") + plt.plot(rxttx, rxtty, "m^", markersize=10, markerfacecolor="m") + + # plt.plot(cwndx, d["snd_wnd"], 'ko', markersize=1) + plt.legend( + ( + "snd-space", + "flight", + "sacked", + "lost", + "cc-space", + "cwnd", + "congestion", + "recovered", + "rxt-timeout", + ), + loc=1, + ) + + # rto/srrt/rttvar + plt.subplot(313) + plt.title("rtt") + plt.plot(cwndx, d["srtt"], "g-") + plt.plot(cwndx, [x / 1000 for x in d["mrtt-us"]], "r-") + plt.plot(cwndx, d["rttvar"], "b-") + plt.legend(["srtt", "mrtt-us", "rttvar"]) + axes = plt.gca() + # plt.plot(cwndx, rto, 'r-') + # axes.set_ylim([0, int(max(rto[2:len(rto)])) + 50]) + + # show + plt.show() + + +def find_pattern(file_path, session_idx): + is_active_open = 1 + listener_pattern = "l\[\d\]" + if is_active_open: + initial_pattern = "\[\d\](\.\d+:\d+\->\.\d+:\d+)\s+open:\s" + else: + initial_pattern = "\[\d\](\.\d+:\d+\->\.\d+:\d+)\s" + idx = 0 + f = open(file_path, "r") + for line in f: + # skip listener lines (server) + if re.search(listener_pattern, line) != None: + continue + match = re.search(initial_pattern, line) + if match == None: + continue + if idx < session_idx: + idx += 1 + continue + filter_pattern = str(match.group(1)) + "\s+(.+)" + print("pattern is %s" % filter_pattern) + f.close() + return filter_pattern + raise Exception("Could not find initial pattern") + + +def compute_time(min, sec, msec): + return int(min) * 60 + int(sec) + int(msec) / 1000.0 + + +def run(file_path, session_idx): + filter_sessions = 1 + filter_pattern = "" + + patterns = { + "time": "^\d+:(\d+):(\d+):(\d+):\d+", + "listener": "l\[\d\]", + "cc": "cwnd (\d+) flight (\d+) space (\d+) ssthresh (\d+) snd_wnd (\d+)", + "cc-snd": "cc_space (\d+) sacked (\d+) lost (\d+)", + "rtt": "rto (\d+) srtt (\d+) mrtt-us (\d+) rttvar (\d+)", + "rxtt": "rxt-timeout", + "congestion": "congestion", + "recovered": "recovered", + } + d = { + "cwnd": [], + "space": [], + "flight": [], + "ssthresh": [], + "snd_wnd": [], + "cc-space": [], + "lost": [], + "sacked": [], + "rto": [], + "srtt": [], + "mrtt-us": [], + "rttvar": [], + "rxtTimeout": [], + "congestion": [], + "recovered": [], + } + + if filter_sessions: + filter_pattern = find_pattern(file_path, session_idx) + f = open(file_path, "r") + + stats_index = 0 + start_time = 0 + + for line in f: + # skip listener lines (server) + if re.search(patterns["listener"], line) != None: + continue + # filter sessions + if filter_sessions: + match = re.search(filter_pattern, line) + if match == None: + continue + + original_line = line + line = match.group(1) + match = re.search(patterns["time"], original_line) + if match == None: + print("something went wrong! no time!") + continue + time = compute_time(match.group(1), match.group(2), match.group(3)) + if start_time == 0: + start_time = time + + time = time - start_time + match = re.search(patterns["cc"], line) + if match != None: + d["cwnd"].append(Point(time, int(match.group(1)))) + d["flight"].append(int(match.group(2))) + d["space"].append(int(match.group(3))) + d["ssthresh"].append(int(match.group(4))) + d["snd_wnd"].append(int(match.group(5))) + stats_index += 1 + continue + match = re.search(patterns["cc-snd"], line) + if match != None: + d["cc-space"].append(int(match.group(1))) + d["sacked"].append(int(match.group(2))) + d["lost"].append(int(match.group(3))) + match = re.search(patterns["rtt"], line) + if match != None: + d["rto"].append(int(match.group(1))) + d["srtt"].append(int(match.group(2))) + d["mrtt-us"].append(int(match.group(3))) + d["rttvar"].append(int(match.group(4))) + if stats_index == 0: + continue + match = re.search(patterns["rxtt"], line) + if match != None: + d["rxtTimeout"].append(Point(time, d["cwnd"][stats_index - 1].y + 1e4)) + continue + match = re.search(patterns["congestion"], line) + if match != None: + d["congestion"].append(Point(time, d["cwnd"][stats_index - 1].y - 1e4)) + continue + match = re.search(patterns["recovered"], line) + if match != None: + d["recovered"].append(Point(time, d["cwnd"][stats_index - 1].y)) + continue + + plot_data(d) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Plot tcp cc logs") + parser.add_argument( + "-f", action="store", dest="file", required=True, help="elog file in txt format" + ) + parser.add_argument( + "-s", + action="store", + dest="session_index", + default=0, + help="session index for which to plot cc logs", + ) + results = parser.parse_args() + run(results.file, int(results.session_index)) diff --git a/extras/scripts/host-stack/convert_evt b/extras/scripts/host-stack/convert_evt new file mode 100755 index 00000000000..1aba67d0268 --- /dev/null +++ b/extras/scripts/host-stack/convert_evt @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# This depends on c2cpel and cpeldump. Enable their compilation by: +# ccmake build-root/build-vpp-native/vpp/ +# and turning on VPP_BUILD_PERFTOOL + +BIN_PATH=../../../build-root/install-vpp-native/vpp/bin +C2CPEL_BIN=$BIN_PATH/c2cpel +CPELDUMP_BIN=$BIN_PATH/cpeldump + +$C2CPEL_BIN --in $1 --out /tmp/tmp_file.cpel +$CPELDUMP_BIN --in /tmp/tmp_file.cpel --out $2 diff --git a/extras/scripts/host-stack/perf-tests/conf/dpdk_mt.cli b/extras/scripts/host-stack/perf-tests/conf/dpdk_mt.cli new file mode 100644 index 00000000000..8df8ee1e38c --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/conf/dpdk_mt.cli @@ -0,0 +1,6 @@ +comment {SPDX-License-Identifier: Apache-2.0} +comment {Copyright (c) 2025 Cisco Systems, Inc.} +set int ip address HundredGigabitEthernet16/0/0 6.0.1.1/24 +set int state HundredGigabitEthernet16/0/0 up + +session enable diff --git a/extras/scripts/host-stack/perf-tests/conf/dpdk_st.cli b/extras/scripts/host-stack/perf-tests/conf/dpdk_st.cli new file mode 100644 index 00000000000..97aeb3916f8 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/conf/dpdk_st.cli @@ -0,0 +1,5 @@ +comment {SPDX-License-Identifier: Apache-2.0} +comment {Copyright (c) 2025 Cisco Systems, Inc.} +set int ip address HundredGigabitEthernet16/0/0 6.0.1.1/24 +set int state HundredGigabitEthernet16/0/0 up +session enable diff --git a/extras/scripts/host-stack/perf-tests/dpdk_mt b/extras/scripts/host-stack/perf-tests/dpdk_mt new file mode 100755 index 00000000000..6e095da4228 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/dpdk_mt @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS="${VPP_WS}"/extras/scripts/host-stack/perf-tests +CFG_DIR="${CFG_WS}"/conf +CFG_FILE=dpdk_mt.cli +BASE_DIR="${VPP_WS}"/build-root +BIN_FLAVOR=release + +DPDK_DEV=0000:16:00.0 +NUM_MBUFS=16536 +IF_RX_DESC=256 +IF_TX_DESC=256 +DPDK_CSUM=enable-tcp-udp-checksum + +SKIP_CORE=0 +MAIN_CORE=1 +WORKERS=4 +CFG_CORELIST_WKS="corelist-workers 2-5" + +HEAP_SIZE=4g +API_SIZE=1G +API_GLOBAL_SIZE=2000M +EVT_LOG_SIZE=400000 + +SOCK=/run/vpp-api.sock +SESSION_CFG="session { event-queue-length 100000 use-app-socket-api }" + +#QUIC_ENABLE=1 +#LOCAL_OSSL=/scratch/fcoras/openssl + +function usage() { + echo "Usage: cmd [-f release|debug] [-d dpdk_device_pci_address] [-w vpp_workspace]" +} + +while getopts "f:d:w:h" opt; do + case ${opt} in + h) usage + exit 0 + ;; + w) VPP_WS=$OPTARG + ;; + f) BIN_FLAVOR=$OPTARG + ;; + d) DPDK_DEV=$OPTARG + ;; + \?) echo "Usage: cmd [-f release|debug] [-d dpdk_device_pci_address]" + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +source "${CFG_WS}"/start_vpp.sh + +start_vpp diff --git a/extras/scripts/host-stack/perf-tests/dpdk_st b/extras/scripts/host-stack/perf-tests/dpdk_st new file mode 100755 index 00000000000..a35889f0238 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/dpdk_st @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS="${VPP_WS}"/extras/scripts/host-stack/perf-tests +CFG_DIR="${CFG_WS}"/conf +CFG_FILE=dpdk_st.cli +BASE_DIR="${VPP_WS}"/build-root +BIN_FLAVOR=release + +#DPDK_DISABLE=1 +DPDK_DEV=0000:16:00.0 +IF_RX_DESC=512 +IF_TX_DESC=256 +DPDK_CSUM=enable-tcp-udp-checksum + +NUM_MBUFS=16536 + +HEAP_SIZE=4g +API_SIZE=1G +API_GLOBAL_SIZE=2000M +EVT_LOG_SIZE=400000 + +MAIN_CORE=1 +WORKERS=1 +CFG_CORELIST_WKS="corelist-workers 2" + +SOCK=/run/vpp-api.sock +CLI_SOCK=/run/vpp/cli.sock +SESSION_CFG="session { event-queue-length 100000 use-app-socket-api }" + +TCP_CFG="tcp { max-rx-fifo 128m }" +TLS_CFG="tls { fifo-size 1m }" +#QUIC_ENABLE=1 +#LOCAL_OSSL=/scratch/fcoras/openssl + +function usage() { + echo "Usage: cmd [-f release|debug] [-d dpdk_device_pci_address] [-w vpp_workspace]" +} + +while getopts "f:d:w:h" opt; do + case ${opt} in + h) usage + exit 0 + ;; + w) VPP_WS=$OPTARG + ;; + f) BIN_FLAVOR=$OPTARG + ;; + d) DPDK_DEV=$OPTARG + ;; + \?) usage + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +source "${CFG_WS}"/start_vpp.sh + +start_vpp diff --git a/extras/scripts/host-stack/perf-tests/gdb_ldp_init b/extras/scripts/host-stack/perf-tests/gdb_ldp_init new file mode 100644 index 00000000000..7c2f28e2083 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/gdb_ldp_init @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +handle SIGUSR1 nostop noprint pass +set print pretty on +set exec-wrapper env 'LD_PRELOAD=/scratch/fcoras/vpp/build-root/build-vpp-native/vpp/lib/libvcl_ldpreload.so' +set environment LDP_DEBUG=1 +set environment VCL_CONFIG=/scratch/fcoras/vpp/extras/scripts/host-stack/perf-tests/vcl_perf.conf diff --git a/extras/scripts/host-stack/perf-tests/start_vpp.sh b/extras/scripts/host-stack/perf-tests/start_vpp.sh new file mode 100755 index 00000000000..27614713b76 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/start_vpp.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +if [ $BIN_FLAVOR = "debug" ] +then + BIN_DIR=install-vpp_debug-native + BIN_EXEC_PREFIX="gdb --args" +else + BIN_DIR=install-vpp-native + BIN_EXEC_PREFIX="gdb --args" +fi + +BIN_PATH=$BASE_DIR/$BIN_DIR + +if [ "$#" -eq 1 ] +then + echo $1 + CFG_FILE=$1 +fi + +CFG_MBUFS="" +if [ -n "$NUM_MBUFS" ]; then + CFG_MBUFS="buffers-per-numa $NUM_MBUFS" +fi + +if [ -z $HEAP_SIZE ]; then + HEAP_SIZE=4g +fi + +if [ -z $SKIP_CORE ]; then + SKIP_CORE=0 +fi + +if [ -z $SKIP_CORE ]; then + MAIN_CORE=1 +fi + +if [ -z $EVT_LOG_SIZE ]; then + EVT_LOG_SIZE=0 +fi + +if [ -z $API_GLOBAL_SIZE ]; then + API_GLOBAL_SIZE=64M +fi + +if [ -z $API_SIZE ]; then + API_SIZE=16M +fi + +if [ -z ${WORKERS+x} ]; then + WORKERS=0 + CFG_RX_QS=1 +else + CFG_WORKERS="workers $WORKERS" + CFG_RX_QS=$(( $WORKERS )) +fi + +SOCK_CFG="" +if [ -n "$SOCK" ]; then + SOCK_CFG="socksvr { socket-name ${SOCK} }" +fi + +if [ -z $IF_RX_DESC ]; then + IF_RX_DESC=4096 +fi + +if [ -z $IF_TX_DESC ]; then + IF_TX_DESC=4096 +fi + +API_PREFIX_CFG="" +if [ -n "$API_PREFIX" ]; then + API_PREFIX_CFG="prefix $API_PREFIX" +fi + +CLI_LISTEN_CFG="cli-listen localhost:5002" +if [ -n "$CLI_SOCK" ]; then + CLI_LISTEN_CFG="cli-listen $CLI_SOCK" +fi + +if [[ -z "$DPDK_DISABLE" ]]; then + DPDK_CFG="dpdk { \ + dev $DPDK_DEV { \ + num-tx-desc $IF_TX_DESC \ + num-rx-desc $IF_RX_DESC \ + num-rx-queues $CFG_RX_QS \ + } \ + $SOCK_MEM_CFG \ + $DPDK_CSUM \ + }" +else + DPDK_PLUGIN_DISABLE="plugin dpdk_plugin.so {disable}" +fi + +if [[ -n "$QUIC_ENABLE" ]]; then + QUIC_PLUGIN="plugin quic_plugin.so {enable}" +fi + +if [[ -n "$SRTP_ENABLE" ]]; then + SRTP_PLUGIN="plugin srtp_plugin.so {enable}" +fi + +# custom openssl locally built +LD_LIBP="" +if [[ -n "${LOCAL_OSSL}" ]]; then + LD_LIBP="LD_LIBRARY_PATH=${LOCAL_OSSL}" +fi + +function start_vpp +{ + sudo $LD_LIBP $BIN_EXEC_PREFIX $BIN_PATH/vpp/bin/vpp \ + unix { \ + interactive log /tmp/vpp.log \ + full-coredump \ + exec $CFG_DIR/$CFG_FILE \ + $CLI_LISTEN_CFG \ + poll-sleep-usec 0 \ + } \ + heapsize $HEAP_SIZE \ + api-trace { on } \ + api-segment { \ + global-size $API_GLOBAL_SIZE \ + api-size $API_SIZE \ + gid vpp \ + $API_PREFIX_CFG \ + } \ + vlib { \ + elog-events $EVT_LOG_SIZE \ + elog-post-mortem-dump \ + } \ + cpu { \ + skip-cores $SKIP_CORE \ + main-core $MAIN_CORE \ + $CFG_CORELIST_WKS \ + } \ + buffers { $CFG_MBUFS } \ + $DPDK_CFG \ + $SESSION_CFG \ + $TCP_CFG \ + $UDP_CFG \ + $SOCK_CFG \ + $TLS_CFG \ + plugins { \ + plugin unittest_plugin.so {enable} \ + plugin http_unittest_plugin.so {enable} \ + $QUIC_PLUGIN \ + $SRTP_PLUGIN \ + $DPDK_PLUGIN_DISABLE \ + } +} + diff --git a/extras/scripts/host-stack/perf-tests/vcl_client b/extras/scripts/host-stack/perf-tests/vcl_client new file mode 100755 index 00000000000..653aeef6c9f --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/vcl_client @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS=$VPP_WS/extras/scripts/host-stack/perf-tests +BIN=$VPP_WS/build-root/build-vpp-native/vpp/bin/vcl_test_client +GDB_ENV=$CFG_WS/gdb_vcl_env +VCL_CFG=$CFG_WS/vcl_perf.conf +PARAMS=$@ + +sudo taskset --cpu-list 10 sh -c "VCL_CONFIG=$VCL_CFG $BIN -c $PARAMS" diff --git a/extras/scripts/host-stack/perf-tests/vcl_iperf_client b/extras/scripts/host-stack/perf-tests/vcl_iperf_client new file mode 100755 index 00000000000..94a8b6c4912 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/vcl_iperf_client @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS=$VPP_WS/extras/scripts/host-stack/perf-tests +BIN_PATH=iperf3 +LDP_VAR=$VPP_WS/build-root/install-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so +VCL_CFG=$CFG_WS/vcl_perf.conf +PARAMS=$@ + +sudo taskset --cpu-list 6-11 sh -c "LD_PRELOAD=$LDP_VAR VCL_CONFIG=$VCL_CFG $BIN_PATH -4 -c $PARAMS" + +# for tls +# CERT=$CFG_WS/selfsigned.crt +# KEY=$CFG_WS/selfsigned.key +# sudo taskset --cpu-list 6-10 sh -c "LDP_TRANSPARENT_TLS=2 LDP_TLS_CERT_FILE=$CERT LDP_TLS_KEY_FILE=$KEY VCL_CONFIG=$VCL_CFG LD_PRELOAD=$LDP_VAR $BIN_PATH -4 -c $PARAMS" + +# for debugging +# LDP_SCRIPT=$CFG_WS/gdb_ldp_init +# sudo gdb --command=$LDP_SCRIPT --args $BIN_PATH -4 -s $PARAMS diff --git a/extras/scripts/host-stack/perf-tests/vcl_iperf_server b/extras/scripts/host-stack/perf-tests/vcl_iperf_server new file mode 100755 index 00000000000..92dd1fcea5f --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/vcl_iperf_server @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS=$VPP_WS/extras/scripts/host-stack/perf-tests +BIN_PATH=iperf3 +LDP_VAR=$VPP_WS/build-root/install-vpp-native/vpp/lib/x86_64-linux-gnu/libvcl_ldpreload.so +VCL_CFG=$CFG_WS/vcl_perf.conf +PARAMS=$@ + +sudo taskset --cpu-list 6-11 sh -c "LD_PRELOAD=$LDP_VAR VCL_CONFIG=$VCL_CFG $BIN_PATH -4 -s $PARAMS" + +# for tls testing +# CERT=$CFG_WS/selfsigned.crt +# KEY=$CFG_WS/selfsigned.key +# sudo taskset --cpu-list 6-11 sh -c "LDP_TRANSPARENT_TLS=1 LDP_TLS_CERT_FILE=$CERT LDP_TLS_KEY_FILE=$KEY LD_PRELOAD=$LDP_VAR VCL_CONFIG=$VCL_CFG $BIN_PATH -4 -s $PARAMS" + +# debugging +# LDP_SCRIPT=/home/fcoras/vpp/gdb_ldp_init +# sudo gdb --command=$LDP_SCRIPT --args $BIN_PATH -4 -s $PARAMS diff --git a/extras/scripts/host-stack/perf-tests/vcl_perf.conf b/extras/scripts/host-stack/perf-tests/vcl_perf.conf new file mode 100644 index 00000000000..791d5fd3eaa --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/vcl_perf.conf @@ -0,0 +1,16 @@ +vcl { + # SPDX-License-Identifier: Apache-2.0 + # Copyright (c) 2025 Cisco Systems, Inc. + rx-fifo-size 4000000 + tx-fifo-size 4000000 + + app-scope-local + app-scope-global + + segment-size 10000000000 + add-segment-size 10000000000 + + app-socket-api /var/run/vpp/app_ns_sockets/default + use-mq-eventfd + event-queue-size 500000 +} diff --git a/extras/scripts/host-stack/perf-tests/vcl_server b/extras/scripts/host-stack/perf-tests/vcl_server new file mode 100755 index 00000000000..4ecc2f1f3a9 --- /dev/null +++ b/extras/scripts/host-stack/perf-tests/vcl_server @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Cisco Systems, Inc. + +VPP_WS=${VPP_WS:-/scratch/fcoras/vpp} +CFG_WS=$VPP_WS/extras/scripts/host-stack/perf-tests +BIN=$VPP_WS/build-root/build-vpp-native/vpp/bin/vcl_test_server +GDB_ENV=$CFG_WS/gdb_init_tls +VCL_CFG=$CFG_WS/vcl_perf.conf +PARAMS=$@ + +sudo taskset --cpu-list 6-11 sh -c "VCL_CONFIG=$VCL_CFG $BIN $PARAMS"
\ No newline at end of file diff --git a/extras/scripts/host-stack/vcl-ldpreload/README.rst b/extras/scripts/host-stack/vcl-ldpreload/README.rst new file mode 100644 index 00000000000..7168697ec01 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/README.rst @@ -0,0 +1,40 @@ +.. _vcl_ldpreload_doc: + +LD_PRELOAD the VCL +================== + +vcl-ldpreload is a LD_PRELOAD library that uses the VPP Communications Library (VCL). + +User can LD_PRELOAD any application that uses POSIX socket API. + +NOTE: The sources have been moved to ``vpp/src/vcl`` and ``libvcl_ldpreload.so`` is built with VPP and can be found in +``vpp/build-root/install-vpp[_debug]-native/vpp/lib`` + +1. Running the demo +------------------- + +Run test script without parameters to see help menu: + +:: + + export WS_ROOT= (e.g. /scratch/my_name/vpp) + $WS_ROOT/test/scripts/socket_test.sh + + +2. Docker iPerf examples +------------------------ + +These launch xterms. To quit, close xterms and run following docker kill cmd (WARNING: This will kill all docker containers!) ‘docker kill $(docker ps -q)’ + +Docker iPerf using default Linux Bridge + +:: + + $WS_ROOT/test/scripts/socket_test.sh -bi docker-kernel + + +Docker iPerf using VPP + +:: + + $WS_ROOT/test/scripts/socket_test.sh -bi docker-preload diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_test.sh b/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_test.sh new file mode 100755 index 00000000000..73f2911b57c --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_test.sh @@ -0,0 +1,94 @@ +#! /bin/bash +# +# nginx_test.sh +# +# Run specified app using LD_PRELOAD to fetch a page from +# nginx running in vpp1 net-namespace. +# +# Specify the following environment variables: +# +# STRACE_ONLY - Run app with strace instead of LD_PRELOAD. +# TEST_APP - App to run (default: curl) +# + +# Configuration variables. +# +vpp_dk_name="NGINX" +# Comment out the next line to run the VPP release version +debug="_debug" +vpp_app="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/bin/vpp" + +check_for_vpp() { + local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\"" + running_vpp="$(eval $grep_for_vpp)" +} + +# Verify Environment. +if [ -z "$WS_ROOT" ] ; then + echo "ERROR: WS_ROOT environment variable not set!" >&2 + echo " Please set WS_ROOT to VPP workspace root directory." >&2 + exit 1 +fi + +if [ -z "$VCL_LDPRELOAD_LIB_DIR" ] ; then + echo "ERROR: VCL_LDPRELOAD_LIB_DIR environment variable not set!" >&2 + echo " Please set VCL_LDPRELOAD_LIB_DIR to " >&2 + echo " $WS_ROOT/build-root/install-vpp[_debug]-native/vpp/lib." >&2 + exit 1 +fi + +TEST_APP="${TEST_APP:-curl}" +LDP_DIR="${WS_ROOT}/extras/vcl-ldpreload" +LDP_TEST_DIR="${LDP_TEST_DIR:-${LDP_DIR}/test}" +LDP_LIB="${LDP_LIB:-${VCL_LDPRELOAD_LIB_DIR}/libvcl_ldpreload.so.0.0.0}" + +if [ ! -f "$LDP_LIB" ] ; then + echo "ERROR: Missing VCL-LDPRELOAD Library: $LDP_LIB" + echo " Run 'cd $WS_ROOT; make build[-release] ' !" + exit 1 +fi + +if [ -n "$STRACE_ONLY" ] ; then + echo "Running strace -tt $TEST_APP http://$nginx_addr" + strace -tt $TEST_APP http://$nginx_addr +else + check_for_vpp + if [ -z "$running_vpp" ] ; then + echo -e "\nConfiguring network interfaces" + sudo ip link del dev vpp_dk + sudo ip link add name vpp_dk type veth peer name vpp1 + sudo ip link set dev vpp_dk up + sudo ethtool --offload vpp_dk rx off tx off + sudo ip link set dev vpp1 up + sudo ethtool --offload vpp1 rx off tx off + sudo ip link set dev lo up + sudo brctl addif docker0 vpp_dk + + echo "Starting VPP " + sudo rm -f /dev/shm/* + sudo xfce4-terminal --title VPP --command "$vpp_app unix { interactive exec $LDP_TEST_DIR/common/vpp_docker.conf full-coredump coredump-size unlimited } api-segment { gid $(id -g) }" & +# sudo $vpp_app unix { cli-listen localhost:5002 exec $LDP_TEST_DIR/common/vpp_docker.conf } api-segment { gid $(id -g) } + sleep 4 + fi + + if [ -z "$(docker ps -qf name=$vpp_dk_name)" ] ; then + echo -e "\nStarting NGINX in docker container ($vpp_dk_name)" + echo "docker run --rm --name $vpp_dk_name -v $LDP_TEST_DIR/common/nginx_welcome.html:/usr/share/nginx/html/index.html:ro -d nginx" + docker run --rm --name $vpp_dk_name -v $LDP_TEST_DIR/common/nginx_welcome.html:/usr/share/nginx/html/index.html:ro -d nginx + + export LD_LIBRARY_PATH="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/lib/:$LDP_DIR/src/.libs:" + + # Extract nginx IPv4 address from docker bridge + # + nginx_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '{print $2}' | sed -e 's,/16,,' -e 's,",,g' -e 's/,//') + + if [ -z "$nginx_addr" ] ; then + echo "ERROR: Unable to determine docker container address!" + exit 1 + fi + fi + + echo -e "\nRunning wget" + echo -e "LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr\n" + LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr +fi diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_welcome.html b/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_welcome.html new file mode 100644 index 00000000000..c3850904482 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/common/nginx_welcome.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html lang="en" xml:lang="en"> +<head> +<title>Welcome to nginx!</title> +<style> + body { + width: 35em; + margin: 0 auto; + font-family: Tahoma, Verdana, Arial, sans-serif; + } +</style> +</head> +<body> +<h1>Welcome to nginx!</h1> +<p>If you see this page, the nginx web server is successfully installed and +working. Further configuration is required.</p> + +<p>For online documentation and support please refer to +<a href="http://nginx.org/">nginx.org</a>.<br/> +Commercial support is available at +<a href="http://nginx.com/">nginx.com</a>.</p> + +<p><em>Thank you for using nginx.</em></p> +</body> +</html> diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/common/vpp_docker.conf b/extras/scripts/host-stack/vcl-ldpreload/test/common/vpp_docker.conf new file mode 100644 index 00000000000..4d18bb2d208 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/common/vpp_docker.conf @@ -0,0 +1,3 @@ +create host-interface name vpp1 +set int state host-vpp1 up +set int ip address host-vpp1 172.17.0.123/24 diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/curl_test.sh b/extras/scripts/host-stack/vcl-ldpreload/test/curl_test.sh new file mode 100755 index 00000000000..5c8d2f4a9d4 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/curl_test.sh @@ -0,0 +1,22 @@ +#! /bin/bash +# +# curl_test.sh - VCL-LDPRELOAD curl test. +# +# Run curl using LD_PRELOAD to fetch a page from +# nginx running in vpp1 net-namespace. +# +# + +# Verify Environment. +if [ -z "$WS_ROOT" ] ; then + echo "ERROR: WS_ROOT environment variable not set!" >&2 + echo " Please set WS_ROOT to VPP workspace root directory." >&2 + exit 1 +fi + +LDP_DIR="${WS_ROOT}/extras/vcl-ldpreload" +LDP_TEST_DIR="${LDP_TEST_DIR:-${LDP_DIR}/test}" +VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-${WS_ROOT}/build-root/install-vpp_debug-native/vpp/lib}" + +TEST_APP="${TEST_APP:-curl}" +source $LDP_TEST_DIR/common/nginx_test.sh diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_curl.sh b/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_curl.sh new file mode 100755 index 00000000000..a5d6be3dfee --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_curl.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +if [ -z "$WS_ROOT" ] ; then + echo "ERROR: WS_ROOT environment variable is not set!" + exit 1 +fi + +source $WS_ROOT/extras/vcl-ldpreload/env.sh +tmp_gdb_cmdfile="/tmp/gdb_cmdfile_curl.$$" + +trap "rm -f $tmp_gdb_cmdfile" SIGINT SIGTERM EXIT + +cat <<EOF > $tmp_gdb_cmdfile +set confirm off +source $WS_ROOT/extras/gdb/gdb_cmdfile.vpp +set exec-wrapper env LD_PRELOAD=$VCL_LDPRELOAD_LIB_DIR/libvcl_ldpreload.so.0.0.0 +start +EOF + +gdb_in_emacs() { + sudo -E emacs --eval "(gdb \"gdb -x $tmp_gdb_cmdfile -i=mi --args $*\")" --eval "(setq frame-title-format \"CURL-DEBUG (VCL-LDPRELOAD)\")" +} + +# Extract nginx IPv4 address from docker bridge +# +nginx_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '{print $2}' | sed -e 's,/16,,' -e 's,",,g' -e 's/,//') + +if [ -z "$nginx_addr" ] ; then + echo "ERROR: Unable to determine docker container address!" + exit 1 +fi + +gdb_in_emacs /usr/bin/curl http://$nginx_addr diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_vpp.sh b/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_vpp.sh new file mode 100755 index 00000000000..460e4077e53 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/emacs_gdb_vpp.sh @@ -0,0 +1,23 @@ +#! /bin/bash + +if [ -z "$WS_ROOT" ] ; then + echo "ERROR: WS_ROOT environment variable is not set!" + exit 1 +fi + +source $WS_ROOT/extras/vcl-ldpreload/env.sh +tmp_gdb_cmdfile="/tmp/gdb_cmdfile_vpp.$$" + +trap "rm -f $tmp_gdb_cmdfile" SIGINT SIGTERM EXIT + +cat <<EOF > $tmp_gdb_cmdfile +set confirm off +source $WS_ROOT/extras/gdb/gdb_cmdfile.vpp +start +EOF + +gdb_in_emacs() { + sudo -E emacs --eval "(gdb \"gdb -x $tmp_gdb_cmdfile -i=mi --args $*\")" --eval "(setq frame-title-format \"VPP-DEBUG\")" +} +sudo rm -f /dev/shm/* +gdb_in_emacs $WS_ROOT/build-root/install-vpp_debug-native/vpp/bin/vpp unix { interactive exec $LDP_TEST_DIR/common/vpp_docker.conf } api-segment { gid $(id -g) } diff --git a/extras/scripts/host-stack/vcl-ldpreload/test/wget_test.sh b/extras/scripts/host-stack/vcl-ldpreload/test/wget_test.sh new file mode 100755 index 00000000000..78b34f9e481 --- /dev/null +++ b/extras/scripts/host-stack/vcl-ldpreload/test/wget_test.sh @@ -0,0 +1,22 @@ +#! /bin/bash +# +# wget_test.sh - VCL-LDPRELOAD wget test. +# +# Run wget using LD_PRELOAD to fetch a page from +# nginx running in vpp1 net-namespace. +# +# + +# Verify Environment. +if [ -z "$WS_ROOT" ] ; then + echo "ERROR: WS_ROOT environment variable not set!" >&2 + echo " Please set WS_ROOT to VPP workspace root directory." >&2 + exit 1 +fi + +LDP_DIR="${WS_ROOT}/extras/vcl-ldpreload" +LDP_TEST_DIR="${LDP_TEST_DIR:-${LDP_DIR}/test}" +VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$WS_ROOT/build-root/install-vpp_debug-native/vpp/lib}" + +TEST_APP="${TEST_APP:-wget}" +source $LDP_TEST_DIR/common/nginx_test.sh |