Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide
[linux-block.git] / samples / pktgen / pktgen_sample01_simple.sh
CommitLineData
6f094797 1#!/bin/bash
b2441318 2# SPDX-License-Identifier: GPL-2.0
6f094797
JDB
3#
4# Simple example:
5# * pktgen sending with single thread and single interface
6# * flow variation via random UDP source port
7#
8basedir=`dirname $0`
9source ${basedir}/functions.sh
10root_check_run_with_sudo "$@"
11
12# Parameter parsing via include
13# - go look in parameters.sh to see which setting are avail
14# - required param is the interface "-i" stored in $DEV
15source ${basedir}/parameters.sh
16#
17# Set some default params, if they didn't get set
0f06a678
MKL
18if [ -z "$DEST_IP" ]; then
19 [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
20fi
6f094797
JDB
21[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
22# Example enforce param "-m" for dst_mac
23[ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
69137ea6 24[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
6f094797
JDB
25
26# Base Config
27DELAY="0" # Zero means max speed
6f094797
JDB
28
29# Flow variation random source port between min and max
30UDP_MIN=9
31UDP_MAX=109
32
33# General cleanup everything since last run
34# (especially important if other threads were configured by other scripts)
35pg_ctrl "reset"
36
37# Add remove all other devices and add_device $DEV to thread 0
38thread=0
39pg_thread $thread "rem_device_all"
40pg_thread $thread "add_device" $DEV
41
42# How many packets to send (zero means indefinitely)
43pg_set $DEV "count $COUNT"
44
45# Reduce alloc cost by sending same SKB many times
46# - this obviously affects the randomness within the packet
47pg_set $DEV "clone_skb $CLONE_SKB"
48
49# Set packet size
50pg_set $DEV "pkt_size $PKT_SIZE"
51
52# Delay between packets (zero means max speed)
53pg_set $DEV "delay $DELAY"
54
55# Flag example disabling timestamping
56pg_set $DEV "flag NO_TIMESTAMP"
57
58# Destination
59pg_set $DEV "dst_mac $DST_MAC"
0f06a678 60pg_set $DEV "dst$IP6 $DEST_IP"
6f094797
JDB
61
62# Setup random UDP port src range
63pg_set $DEV "flag UDPSRC_RND"
64pg_set $DEV "udp_src_min $UDP_MIN"
65pg_set $DEV "udp_src_max $UDP_MAX"
66
67# start_run
68echo "Running... ctrl^C to stop" >&2
69pg_ctrl "start"
70echo "Done" >&2
71
72# Print results
73echo "Result device: $DEV"
74cat /proc/net/pktgen/$DEV