Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/pktgen.tar
Назад
pktgen_sample04_many_flows.sh 0000755 00000005553 14722071350 0012347 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script example for many flows testing # # Number of simultaneous flows limited by variable $FLOWS # and number of packets per flow controlled by variable $FLOWLEN # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # NOTICE: Script specific settings # ======= # Limiting the number of concurrent flows ($FLOWS) # and also set how many packets each flow contains ($FLOWLEN) # [ -z "$FLOWS" ] && FLOWS="8000" [ -z "$FLOWLEN" ] && FLOWLEN="10" # Base Config DELAY="0" # Zero means max speed if [[ -n "$BURST" ]]; then err 1 "Bursting not supported for this mode" fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Single destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Randomize source IP-addresses pg_set $dev "flag IPSRC_RND" pg_set $dev "src_min 198.18.0.0" pg_set $dev "src_max 198.19.255.255" # Limit number of flows (max 65535) pg_set $dev "flows $FLOWS" # # How many packets a flow will send, before flow "entry" is # re-generated/setup. pg_set $dev "flowlen $FLOWLEN" # # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow # being send back-to-back, before next flow is selected # incrementally. This helps lookup caches, and is more realistic. # pg_set $dev "flag FLOW_SEQ" done # Run if user hits control-c function print_result() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap true SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result pktgen_sample05_flow_per_thread.sh 0000755 00000005170 14722071350 0013331 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script will generate one flow per thread (-t N) # - Same destination IP # - Fake source IPs for each flow (fixed based on thread number) # # Useful for scale testing on receiver, to see whether silo'ing flows # works and scales. For optimal scalability (on receiver) each # separate-flow should not access shared variables/data. This script # helps magnify any of these scaling issues by overloading the receiver. # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$BURST" ] && BURST=32 [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Single destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup source IP-addresses based on thread number pg_set $dev "src_min 198.18.$((thread+1)).1" pg_set $dev "src_max 198.18.$((thread+1)).1" # Setup burst, for easy testing -b 0 disable bursting # (internally in pktgen default and minimum burst=1) if [[ ${BURST} -ne 0 ]]; then pg_set $dev "burst $BURST" else info "$dev: Not using burst" fi done # Run if user hits control-c function print_result() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap true SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result pktgen_sample02_multiqueue.sh 0000755 00000005052 14722071350 0012360 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Multiqueue: Using pktgen threads for sending on multiple CPUs # * adding devices to kernel threads # * notice the naming scheme for keeping device names unique # * nameing scheme: dev@thread_number # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # # Required param: -i dev in $DEV source ${basedir}/parameters.sh [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely # Base Config DELAY="0" # Zero means max speed [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 # (example of setting default params in your script) if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Notice config queue to map to cpu (mirrors smp_processor_id()) # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number pg_set $dev "flag QUEUE_MAP_CPU" # Base config of dev pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" # Flag example disabling timestamping pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $dev "flag UDPSRC_RND" pg_set $dev "udp_src_min $UDP_MIN" pg_set $dev "udp_src_max $UDP_MAX" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done functions.sh 0000644 00000011424 14722071350 0007113 0 ustar 00 # # Common functions used by pktgen scripts # - Depending on bash 3 (or higher) syntax # # Author: Jesper Dangaaard Brouer # License: GPL set -o errexit ## -- General shell logging cmds -- function err() { local exitcode=$1 shift echo "ERROR: $@" >&2 exit $exitcode } function warn() { echo "WARN : $@" >&2 } function info() { if [[ -n "$VERBOSE" ]]; then echo "INFO : $@" >&2 fi } ## -- Pktgen proc config commands -- ## export PROC_DIR=/proc/net/pktgen # # Three different shell functions for configuring the different # components of pktgen: # pg_ctrl(), pg_thread() and pg_set(). # # These functions correspond to pktgens different components. # * pg_ctrl() control "pgctrl" (/proc/net/pktgen/pgctrl) # * pg_thread() control the kernel threads and binding to devices # * pg_set() control setup of individual devices function pg_ctrl() { local proc_file="pgctrl" proc_cmd ${proc_file} "$@" } function pg_thread() { local thread=$1 local proc_file="kpktgend_${thread}" shift proc_cmd ${proc_file} "$@" } function pg_set() { local dev=$1 local proc_file="$dev" shift proc_cmd ${proc_file} "$@" } # More generic replacement for pgset(), that does not depend on global # variable for proc file. function proc_cmd() { local result local proc_file=$1 local status=0 # after shift, the remaining args are contained in $@ shift local proc_ctrl=${PROC_DIR}/$proc_file if [[ ! -e "$proc_ctrl" ]]; then err 3 "proc file:$proc_ctrl does not exists (dev added to thread?)" else if [[ ! -w "$proc_ctrl" ]]; then err 4 "proc file:$proc_ctrl not writable, not root?!" fi fi if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $@ > $proc_ctrl" fi # Quoting of "$@" is important for space expansion echo "$@" > "$proc_ctrl" || status=$? if [[ "$proc_file" != "pgctrl" ]]; then result=$(grep "Result: OK:" $proc_ctrl) || true if [[ "$result" == "" ]]; then grep "Result:" $proc_ctrl >&2 fi fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\"" fi } # Old obsolete "pgset" function, with slightly improved err handling function pgset() { local result if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $1 > $PGDEV" fi echo $1 > $PGDEV local status=$? result=`cat $PGDEV | fgrep "Result: OK:"` if [[ "$result" == "" ]]; then cat $PGDEV | fgrep Result: fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$1 > $PGDEV\"" fi } [[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT ## -- General shell tricks -- function root_check_run_with_sudo() { # Trick so, program can be run as normal user, will just use "sudo" # call as root_check_run_as_sudo "$@" if [ "$EUID" -ne 0 ]; then if [ -x $0 ]; then # Directly executable use sudo info "Not root, running with sudo" sudo "$0" "$@" exit $? fi err 4 "cannot perform sudo run of $0" fi } # Exact input device's NUMA node info function get_iface_node() { local node=$(</sys/class/net/$1/device/numa_node) if [[ $node == -1 ]]; then echo 0 else echo $node fi } # Given an Dev/iface, get its queues' irq numbers function get_iface_irqs() { local IFACE=$1 local queues="${IFACE}-.*TxRx" irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:) [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:) [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\ do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\ done) [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE" echo $irqs } # Given a NUMA node, return cpu ids belonging to it. function get_node_cpus() { local node=$1 local node_cpu_list local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \ /sys/devices/system/node/node$node/cpulist` for cpu_range in $node_cpu_range_list do node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }` done echo $node_cpu_list } # Given a single or range of port(s), return minimum and maximum port number. function parse_ports() { local port_str=$1 local port_list local min_port local max_port IFS="-" read -ra port_list <<< $port_str min_port=${port_list[0]} max_port=${port_list[1]:-$min_port} echo $min_port $max_port } # Given a minimum and maximum port, verify port number. function validate_ports() { local min_port=$1 local max_port=$2 # 0 < port < 65536 if [[ $min_port -gt 0 && $min_port -lt 65536 ]]; then if [[ $max_port -gt 0 && $max_port -lt 65536 ]]; then if [[ $min_port -le $max_port ]]; then return 0 fi fi fi err 5 "Invalid port(s): $min_port-$max_port" } pktgen_sample06_numa_awared_queue_irq_affinity.sh 0000755 00000006556 14722071350 0016432 0 ustar 00 #!/bin/bash # # Multiqueue: Using pktgen threads for sending on multiple CPUs # * adding devices to kernel threads which are in the same NUMA node # * bound devices queue's irq affinity to the threads, 1:1 mapping # * notice the naming scheme for keeping device names unique # * nameing scheme: dev@thread_number # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # # Required param: -i dev in $DEV source ${basedir}/parameters.sh # Base Config DELAY="0" # Zero means max speed [ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 node=`get_iface_node $DEV` irq_array=(`get_iface_irqs $DEV`) cpu_array=(`get_node_cpus $node`) [ $THREADS -gt ${#irq_array[*]} -o $THREADS -gt ${#cpu_array[*]} ] && \ err 1 "Thread number $THREADS exceeds: min (${#irq_array[*]},${#cpu_array[*]})" # (example of setting default params in your script) if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((i = 0; i < $THREADS; i++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. # Set the queue's irq affinity to this $thread (processor) # if '-f' is designated, offset cpu id thread=${cpu_array[$((i+F_THREAD))]} dev=${DEV}@${thread} echo $thread > /proc/irq/${irq_array[$i]}/smp_affinity_list info "irq ${irq_array[$i]} is set affinity to `cat /proc/irq/${irq_array[$i]}/smp_affinity_list`" # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # select queue and bind the queue and $dev in 1:1 relationship queue_num=$i info "queue number is $queue_num" pg_set $dev "queue_map_min $queue_num" pg_set $dev "queue_map_max $queue_num" # Notice config queue to map to cpu (mirrors smp_processor_id()) # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number pg_set $dev "flag QUEUE_MAP_CPU" # Base config of dev pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" # Flag example disabling timestamping pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $dev "flag UDPSRC_RND" pg_set $dev "udp_src_min $UDP_MIN" pg_set $dev "udp_src_max $UDP_MAX" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((i = 0; i < $THREADS; i++)); do thread=${cpu_array[$((i+F_THREAD))]} dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen_bench_xmit_mode_netif_receive.sh 0000755 00000006037 14722071350 0014475 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Benchmark script: # - developed for benchmarking ingress qdisc path # # Script for injecting packets into RX path of the stack with pktgen # "xmit_mode netif_receive". With an invalid dst_mac this will only # measure the ingress code path as packets gets dropped in ip_rcv(). # # This script don't really need any hardware. It benchmarks software # RX path just after NIC driver level. With bursting is also # "removes" the SKB alloc/free overhead. # # Setup scenarios for measuring ingress qdisc (with invalid dst_mac): # ------------------------------------------------------------------ # (1) no ingress (uses static_key_false(&ingress_needed)) # # (2) ingress on other dev (change ingress_needed and calls # handle_ing() but exit early) # # config: tc qdisc add dev $SOMEDEV handle ffff: ingress # # (3) ingress on this dev, handle_ing() -> tc_classify() # # config: tc qdisc add dev $DEV handle ffff: ingress # # (4) ingress on this dev + drop at u32 classifier/action. # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Using invalid DST_MAC will cause the packets to get dropped in # ip_rcv() which is part of the test if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$BURST" ] && BURST=1024 [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config of dev pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Inject packet into RX path of stack pg_set $dev "xmit_mode netif_receive" # Burst allow us to avoid measuring SKB alloc/free overhead pg_set $dev "burst $BURST" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen_sample03_burst_single_flow.sh 0000755 00000005677 14722071350 0013726 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script for max single flow performance # - If correctly tuned[1], single CPU 10G wirespeed small pkts is possible[2] # # Using pktgen "burst" option (use -b $N) # - To boost max performance # - Avail since: kernel v3.18 # * commit 38b2cf2982dc73 ("net: pktgen: packet bursting via skb->xmit_more") # - This avoids writing the HW tailptr on every driver xmit # - The performance boost is impressive, see commit and blog [2] # # Notice: On purpose generates a single (UDP) flow towards target, # reason behind this is to only overload/activate a single CPU on # target host. And no randomness for pktgen also makes it faster. # # Tuning see: # [1] http://netoptimizer.blogspot.dk/2014/06/pktgen-for-network-overload-testing.html # [2] http://netoptimizer.blogspot.dk/2014/10/unlocked-10gbps-tx-wirespeed-smallest.html # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$BURST" ] && BURST=32 [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # No need for clones when bursting [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup burst, for easy testing -b 0 disable bursting # (internally in pktgen default and minimum burst=1) if [[ ${BURST} -ne 0 ]]; then pg_set $dev "burst $BURST" else info "$dev: Not using burst" fi done # Run if user hits control-c function control_c() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap control_c SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" parameters.sh 0000644 00000006134 14722071350 0007250 0 ustar 00 # # SPDX-License-Identifier: GPL-2.0 # Common parameter parsing for pktgen scripts # function usage() { echo "" echo "Usage: $0 [-vx] -i ethX" echo " -i : (\$DEV) output interface/device (required)" echo " -s : (\$PKT_SIZE) packet size" echo " -d : (\$DEST_IP) destination IP" echo " -m : (\$DST_MAC) destination MAC-addr" echo " -p : (\$DST_PORT) destination PORT range (e.g. 433-444) is also allowed" echo " -t : (\$THREADS) threads to start" echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)" echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB" echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely" echo " -b : (\$BURST) HW level bursting of SKBs" echo " -v : (\$VERBOSE) verbose" echo " -x : (\$DEBUG) debug" echo " -6 : (\$IP6) IPv6" echo "" } ## --- Parse command line arguments / parameters --- ## echo "Commandline options:" while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do case $option in i) # interface export DEV=$OPTARG info "Output device set to: DEV=$DEV" ;; s) export PKT_SIZE=$OPTARG info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes" ;; d) # destination IP export DEST_IP=$OPTARG info "Destination IP set to: DEST_IP=$DEST_IP" ;; m) # MAC export DST_MAC=$OPTARG info "Destination MAC set to: DST_MAC=$DST_MAC" ;; p) # PORT export DST_PORT=$OPTARG info "Destination PORT set to: DST_PORT=$DST_PORT" ;; f) export F_THREAD=$OPTARG info "Index of first thread (zero indexed CPU number): $F_THREAD" ;; t) export THREADS=$OPTARG info "Number of threads to start: $THREADS" ;; c) export CLONE_SKB=$OPTARG info "CLONE_SKB=$CLONE_SKB" ;; n) export COUNT=$OPTARG info "COUNT=$COUNT" ;; b) export BURST=$OPTARG info "SKB bursting: BURST=$BURST" ;; v) export VERBOSE=yes info "Verbose mode: VERBOSE=$VERBOSE" ;; x) export DEBUG=yes info "Debug mode: DEBUG=$DEBUG" ;; 6) export IP6=6 info "IP6: IP6=$IP6" ;; h|?|*) usage; err 2 "[ERROR] Unknown parameters!!!" esac done shift $(( $OPTIND - 1 )) if [ -z "$PKT_SIZE" ]; then # NIC adds 4 bytes CRC export PKT_SIZE=60 info "Default packet size set to: set to: $PKT_SIZE bytes" fi if [ -z "$F_THREAD" ]; then # First thread (F_THREAD) reference the zero indexed CPU number export F_THREAD=0 fi if [ -z "$THREADS" ]; then export THREADS=1 fi export L_THREAD=$(( THREADS + F_THREAD - 1 )) if [ -z "$DEV" ]; then usage err 2 "Please specify output device" fi if [ -z "$DST_MAC" ]; then warn "Missing destination MAC address" fi if [ -z "$DEST_IP" ]; then warn "Missing destination IP address" fi if [ ! -d /proc/net/pktgen ]; then info "Loading kernel module: pktgen" modprobe pktgen fi pktgen_bench_xmit_mode_queue_xmit.sh 0000755 00000004346 14722071350 0014054 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Benchmark script: # - developed for benchmarking egress qdisc path, derived (more # like cut'n'pasted) from ingress benchmark script. # # Script for injecting packets into egress qdisc path of the stack # with pktgen "xmit_mode queue_xmit". # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" # Burst greater than 1 are invalid for queue_xmit mode if [[ -n "$BURST" ]]; then err 1 "Bursting not supported for this mode" fi [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config of dev pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Inject packet into TX qdisc egress path of stack pg_set $dev "xmit_mode queue_xmit" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen_sample01_simple.sh 0000755 00000004407 14722071350 0011454 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Simple example: # * pktgen sending with single thread and single interface # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include # - go look in parameters.sh to see which setting are avail # - required param is the interface "-i" stored in $DEV source ${basedir}/parameters.sh # # Set some default params, if they didn't get set if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Example enforce param "-m" for dst_mac [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac" [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 # General cleanup everything since last run # (especially important if other threads were configured by other scripts) pg_ctrl "reset" # Add remove all other devices and add_device $DEV to thread 0 thread=0 pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $DEV # How many packets to send (zero means indefinitely) pg_set $DEV "count $COUNT" # Reduce alloc cost by sending same SKB many times # - this obviously affects the randomness within the packet pg_set $DEV "clone_skb $CLONE_SKB" # Set packet size pg_set $DEV "pkt_size $PKT_SIZE" # Delay between packets (zero means max speed) pg_set $DEV "delay $DELAY" # Flag example disabling timestamping pg_set $DEV "flag NO_TIMESTAMP" # Destination pg_set $DEV "dst_mac $DST_MAC" pg_set $DEV "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $DEV "flag UDPDST_RND" pg_set $DEV "udp_dst_min $DST_MIN" pg_set $DEV "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $DEV "flag UDPSRC_RND" pg_set $DEV "udp_src_min $UDP_MIN" pg_set $DEV "udp_src_max $UDP_MAX" # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results echo "Result device: $DEV" cat /proc/net/pktgen/$DEV
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка