0001
0002
0003
0004
0005
0006
0007
0008 basedir=`dirname $0`
0009 source ${basedir}/functions.sh
0010 root_check_run_with_sudo "$@"
0011
0012
0013
0014
0015 source ${basedir}/parameters.sh
0016
0017
0018 if [ -z "$DEST_IP" ]; then
0019 [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
0020 fi
0021 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
0022
0023 [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
0024 [ -z "$COUNT" ] && COUNT="100000"
0025 if [ -n "$DEST_IP" ]; then
0026 validate_addr${IP6} $DEST_IP
0027 read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
0028 fi
0029 if [ -n "$DST_PORT" ]; then
0030 read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
0031 validate_ports $UDP_DST_MIN $UDP_DST_MAX
0032 fi
0033
0034
0035 UDP_SRC_MIN=9
0036 UDP_SRC_MAX=109
0037
0038
0039
0040 [ -z "$APPEND" ] && pg_ctrl "reset"
0041
0042
0043 thread=0
0044 [ -z "$APPEND" ] && pg_thread $thread "rem_device_all"
0045 pg_thread $thread "add_device" $DEV
0046
0047
0048 pg_set $DEV "count $COUNT"
0049
0050
0051
0052 pg_set $DEV "clone_skb $CLONE_SKB"
0053
0054
0055 pg_set $DEV "pkt_size $PKT_SIZE"
0056
0057
0058 pg_set $DEV "delay $DELAY"
0059
0060
0061 pg_set $DEV "flag NO_TIMESTAMP"
0062
0063
0064 pg_set $DEV "dst_mac $DST_MAC"
0065 pg_set $DEV "dst${IP6}_min $DST_MIN"
0066 pg_set $DEV "dst${IP6}_max $DST_MAX"
0067
0068 if [ -n "$DST_PORT" ]; then
0069
0070 pg_set $DEV "flag UDPDST_RND"
0071 pg_set $DEV "udp_dst_min $UDP_DST_MIN"
0072 pg_set $DEV "udp_dst_max $UDP_DST_MAX"
0073 fi
0074
0075 [ ! -z "$UDP_CSUM" ] && pg_set $dev "flag UDPCSUM"
0076
0077
0078 pg_set $DEV "flag UDPSRC_RND"
0079 pg_set $DEV "udp_src_min $UDP_SRC_MIN"
0080 pg_set $DEV "udp_src_max $UDP_SRC_MAX"
0081
0082
0083 function print_result() {
0084
0085 echo "Result device: $DEV"
0086 cat /proc/net/pktgen/$DEV
0087 }
0088
0089 trap true SIGINT
0090
0091 if [ -z "$APPEND" ]; then
0092
0093 echo "Running... ctrl^C to stop" >&2
0094 pg_ctrl "start"
0095 echo "Done" >&2
0096
0097 print_result
0098 else
0099 echo "Append mode: config done. Do more or use 'pg_ctrl start' to run"
0100 fi