#!/bin/sh # ---- Configuration SRCDIR=/usr/src SRCIF=bge0 SRC_ADDR=192.168.100.104 DST_ADDR=192.168.100.2 FUNC=${1-tx} # COUNT=100 LEN=64 THREADS=1 # ---- # Copyright (c) 2020 Hiroki Sato # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. LOG=netmap_test-`date +%Y%m%d-%H%M%S`.log err() { echo "ERROR: " $* 1>&2; exit 1; } NETMAPDIR=$SRCDIR/tools/tools/netmap # build pkg-gen first (cd $NETMAPDIR && make obj && make) case $? in 0) # do nothing ;; *) err "building of pkg-gen failed." ;; esac PKTGEN_CMD=`cd $NETMAPDIR && make -V.OBJDIR`/pkt-gen SRC_MAC=`arp -an | awk "/$SRC_ADDR/{print \\$4}"` if [ -z "$SRC_MAC" ]; then err "$SRC_ADDR not found on this host." fi if ping -o -c 2 $DST_ADDR > /dev/null 2>&1; then DST_MAC=`arp -an | awk "/$DST_ADDR/{print \\$4}"` else err "$DST_ADDR did not respond." fi CMD="$PKTGEN_CMD -A -p $THREADS -c 0 -f $FUNC -i $SRCIF -n $COUNT -l $LEN -s $SRC_ADDR -S $SRC_MAC -d $DST_ADDR -D $DST_MAC " ( echo COMMAND: $CMD $CMD ) 2>&1 | tee $LOG echo "--> logfile: $LOG"