~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/samples/pktgen/pktgen_sample01_simple.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /samples/pktgen/pktgen_sample01_simple.sh (Architecture sparc64) and /samples/pktgen/pktgen_sample01_simple.sh (Architecture mips)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 #                                                   3 #
  4 # Simple example:                                   4 # Simple example:
  5 #  * pktgen sending with single thread and sin      5 #  * pktgen sending with single thread and single interface
  6 #  * flow variation via random UDP source port      6 #  * flow variation via random UDP source port
  7 #                                                   7 #
  8 basedir=`dirname $0`                                8 basedir=`dirname $0`
  9 source ${basedir}/functions.sh                      9 source ${basedir}/functions.sh
 10 root_check_run_with_sudo "$@"                      10 root_check_run_with_sudo "$@"
 11                                                    11 
 12 # Parameter parsing via include                    12 # Parameter parsing via include
 13 # - go look in parameters.sh to see which sett     13 # - go look in parameters.sh to see which setting are avail
 14 # - required param is the interface "-i" store     14 # - required param is the interface "-i" stored in $DEV
 15 source ${basedir}/parameters.sh                    15 source ${basedir}/parameters.sh
 16                                                    16 
 17 # Trap EXIT first                                  17 # Trap EXIT first
 18 trap_exit                                          18 trap_exit
 19                                                    19 
 20 #                                                  20 #
 21 # Set some default params, if they didn't get      21 # Set some default params, if they didn't get set
 22 if [ -z "$DEST_IP" ]; then                         22 if [ -z "$DEST_IP" ]; then
 23     [ -z "$IP6" ] && DEST_IP="198.18.0.42" ||      23     [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
 24 fi                                                 24 fi
 25 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"               25 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
 26 # Example enforce param "-m" for dst_mac           26 # Example enforce param "-m" for dst_mac
 27 [ -z "$DST_MAC" ] && usage && err 2 "Must spec     27 [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
 28 [ -z "$COUNT" ]   && COUNT="100000" # Zero mea     28 [ -z "$COUNT" ]   && COUNT="100000" # Zero means indefinitely
 29 if [ -n "$DEST_IP" ]; then                         29 if [ -n "$DEST_IP" ]; then
 30     validate_addr${IP6} $DEST_IP                   30     validate_addr${IP6} $DEST_IP
 31     read -r DST_MIN DST_MAX <<< $(parse_addr${     31     read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
 32 fi                                                 32 fi
 33 if [ -n "$DST_PORT" ]; then                        33 if [ -n "$DST_PORT" ]; then
 34     read -r UDP_DST_MIN UDP_DST_MAX <<< $(pars     34     read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
 35     validate_ports $UDP_DST_MIN $UDP_DST_MAX       35     validate_ports $UDP_DST_MIN $UDP_DST_MAX
 36 fi                                                 36 fi
 37                                                    37 
 38 # Flow variation random source port between mi     38 # Flow variation random source port between min and max
 39 UDP_SRC_MIN=9                                      39 UDP_SRC_MIN=9
 40 UDP_SRC_MAX=109                                    40 UDP_SRC_MAX=109
 41                                                    41 
 42 # General cleanup everything since last run        42 # General cleanup everything since last run
 43 # (especially important if other threads were      43 # (especially important if other threads were configured by other scripts)
 44 [ -z "$APPEND" ] && pg_ctrl "reset"                44 [ -z "$APPEND" ] && pg_ctrl "reset"
 45                                                    45 
 46 # Add remove all other devices and add_device      46 # Add remove all other devices and add_device $DEV to thread 0
 47 thread=0                                           47 thread=0
 48 [ -z "$APPEND" ] && pg_thread $thread "rem_dev     48 [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
 49 pg_thread $thread "add_device" $DEV                49 pg_thread $thread "add_device" $DEV
 50                                                    50 
 51 # How many packets to send (zero means indefin     51 # How many packets to send (zero means indefinitely)
 52 pg_set $DEV "count $COUNT"                         52 pg_set $DEV "count $COUNT"
 53                                                    53 
 54 # Reduce alloc cost by sending same SKB many t     54 # Reduce alloc cost by sending same SKB many times
 55 # - this obviously affects the randomness with     55 # - this obviously affects the randomness within the packet
 56 pg_set $DEV "clone_skb $CLONE_SKB"                 56 pg_set $DEV "clone_skb $CLONE_SKB"
 57                                                    57 
 58 # Set packet size                                  58 # Set packet size
 59 pg_set $DEV "pkt_size $PKT_SIZE"                   59 pg_set $DEV "pkt_size $PKT_SIZE"
 60                                                    60 
 61 # Delay between packets (zero means max speed)     61 # Delay between packets (zero means max speed)
 62 pg_set $DEV "delay $DELAY"                         62 pg_set $DEV "delay $DELAY"
 63                                                    63 
 64 # Flag example disabling timestamping              64 # Flag example disabling timestamping
 65 pg_set $DEV "flag NO_TIMESTAMP"                    65 pg_set $DEV "flag NO_TIMESTAMP"
 66                                                    66 
 67 # Destination                                      67 # Destination
 68 pg_set $DEV "dst_mac $DST_MAC"                     68 pg_set $DEV "dst_mac $DST_MAC"
 69 pg_set $DEV "dst${IP6}_min $DST_MIN"               69 pg_set $DEV "dst${IP6}_min $DST_MIN"
 70 pg_set $DEV "dst${IP6}_max $DST_MAX"               70 pg_set $DEV "dst${IP6}_max $DST_MAX"
 71                                                    71 
 72 if [ -n "$DST_PORT" ]; then                        72 if [ -n "$DST_PORT" ]; then
 73     # Single destination port or random port r     73     # Single destination port or random port range
 74     pg_set $DEV "flag UDPDST_RND"                  74     pg_set $DEV "flag UDPDST_RND"
 75     pg_set $DEV "udp_dst_min $UDP_DST_MIN"         75     pg_set $DEV "udp_dst_min $UDP_DST_MIN"
 76     pg_set $DEV "udp_dst_max $UDP_DST_MAX"         76     pg_set $DEV "udp_dst_max $UDP_DST_MAX"
 77 fi                                                 77 fi
 78                                                    78 
 79 [ ! -z "$UDP_CSUM" ] && pg_set $dev "flag UDPC     79 [ ! -z "$UDP_CSUM" ] && pg_set $dev "flag UDPCSUM"
 80                                                    80 
 81 # Setup random UDP port src range                  81 # Setup random UDP port src range
 82 pg_set $DEV "flag UDPSRC_RND"                      82 pg_set $DEV "flag UDPSRC_RND"
 83 pg_set $DEV "udp_src_min $UDP_SRC_MIN"             83 pg_set $DEV "udp_src_min $UDP_SRC_MIN"
 84 pg_set $DEV "udp_src_max $UDP_SRC_MAX"             84 pg_set $DEV "udp_src_max $UDP_SRC_MAX"
 85                                                    85 
 86 # Run if user hits control-c                       86 # Run if user hits control-c
 87 function print_result() {                          87 function print_result() {
 88     # Print results                                88     # Print results
 89     echo "Result device: $DEV"                     89     echo "Result device: $DEV"
 90     cat /proc/net/pktgen/$DEV                      90     cat /proc/net/pktgen/$DEV
 91 }                                                  91 }
 92 # trap keyboard interrupt (Ctrl-C)                 92 # trap keyboard interrupt (Ctrl-C)
 93 trap true SIGINT                                   93 trap true SIGINT
 94                                                    94 
 95 if [ -z "$APPEND" ]; then                          95 if [ -z "$APPEND" ]; then
 96     # start_run                                    96     # start_run
 97     echo "Running... ctrl^C to stop" >&2           97     echo "Running... ctrl^C to stop" >&2
 98     pg_ctrl "start"                                98     pg_ctrl "start"
 99     echo "Done" >&2                                99     echo "Done" >&2
100                                                   100 
101     print_result                                  101     print_result
102 else                                              102 else
103     echo "Append mode: config done. Do more or    103     echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
104 fi                                                104 fi
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php