#!/bin/sh #################################################################### # This is a script to compile/run the "sim" protocol testing # simulation. # # written by: Tom Laramee 11/95 # # It: # - sets command line parameters # - removes old data files # - Generates GNUplot drivers to make the plots (calls sim.gnuplot.sh) # - compiles the program using "make" # - runs it if it compiles # # - It will run the program several times as it collects # statistics into a file: # data.utilization # # - The starting system arrival rate is $min, and it ends on $max, # incrementing by $incr each time (initialized below) # # - Then it runs "gnuplot" on the set of data to generate # a postscript version of the plot... # # - Then it "ghostviews" the plot. # # # The user can set how many times the simulation program will be # run by setting 3 variables near the top of this script. # These are: # max # min # incr # # and they control the system arrival rate. If you want to run the # simulation 10 times, for system arrival rates from 1 to 100, then # set: # min=1 # max=100 # incr=10 # #################################################################### # ------------------------ General script information binary=sim # the executable program name op1=data.utilization # "permanent" data files op2=a # temporary data file, this is produced # when you run the "sim" program plot1=data.plot1 # the data file for the plot which will be generated mag=-5 # magnification for ghostview # Set by user... ######################################################### # --------------- controls how to step through the simulation max=1000 # Maximum system arrival rate min=1 # Minimum system arrival rate incr=50 # System arrival rate step increment ######################################################### # Determine the number of cycles to go through temp=`echo $max $min | awk '{ print $1 - $2 }'` numcycles=`echo $temp $incr | awk '{ print $1 / $2 }'` # Make sure this number is an integer... numcycles=`echo $numcycles | awk -F. '{print $1 }'` # Set by user... ########################################################## # -------------------------------- Command line parameters N=1 # number of nodes C=2.048e6 # Channel capacity -bps- S=$min # System arrival rate ############################################################ echo echo sim: Command line parameters are as follows echo sim: echo sim: Description.....command line flag: value echo sim: --------------------------------------------- echo sim: Number of nodes............\(-n\): $N echo sim: Channel capacity...........\(-c\): $C \(bps\) echo sim: System arrival rate........\(-S\): $S \(frames per sec\) echo sim: # ---------------------------- Test for old output echo sim: Removing old output files... rm -f $op1 rm -f $op2 rm -f data.plot1.ps # ---------------------------- Create "permanent" data files echo sim: Creating permanent data files... touch $op1 # ---------------------------- Create GNUplot files... echo sim: Creating GNUplot files to generate the plots... # # This is where: sim.gnuplot.sh is called # sim.gnuplot.sh $op1 $N # ------------------------------ Compile new binary echo sim: Compiling... rm -f $binary make # ------------------------------ If it compiled, run it if [ -f $binary ] then echo sim: echo sim: Successful compilation... echo sim: Running for several different channel arrival rates echo sim: The number of cycles to cycle for is: $numcycles echo sim: Starting channel arrival rate: $min echo sim: Ending channel arrival rate: $max echo sim: In steps of: $incr echo sim: echo sim: Hit \ to continue... read stuff count=0 while [ $count -le $numcycles ] # cycle to numcycles do count=`expr $count + 1` echo sim: The count is: $count of `expr $numcycles + 1` echo sim: $binary -n $N $binary -n $N -S $S # RUN THE PROGRAM! cat $op2 >> $op1 # append the O/P from the program to the bottom of # the permenent data files for later viewing... # --------------------- make sure there is OP from the program if [ -f $op2 ] then echo sim: continue else echo sim: ERROR: No output from the simulation program echo sim: ERROR: This is a bad thing echo sim: ERROR: Your sim program probably crashed... exit 1 fi rm $op2 # remove the temporary data files... S=`echo $incr $S | awk '{print $1 + $2}'` # recalculate System arrival done echo sim: echo sim: Generating plots using gnuplot... # GNUplot generation echo sim: First gnuplot $plot1 #------------------ remove data files echo sim: Removing data files... rm -f $op1 #---------------- remove plot files echo sim: Removing GNUplot driver files... rm -f $plot1 echo sim: echo sim: The plot names are as follows: echo sim: $plot1.ps echo sim: # View them using ghostview ?? echo "sim: Would you like to ghostview the plots now? (y/n)" read answer2 if [ "$answer2" = y -o "$answer2" = Y ] then ghostview -landscape -magstep $mag $plot1.ps & sleep 6 fi fi echo sim: done echo exit 1 fi echo sim: echo sim: Apparently, the program did not compile/make - fix it echo sim: up and try again echo sim: