#!/bin/sh #################################################################### # This is a script to compile/run my protocol #5 program with the # proper command line options, and will allow variable command line # parameters... # # It: # - sets command line parameters # - removes old data files # - Generates GNUplot drivers to make the plots # - compiles the program using "make" # - runs it if it compiles # # - It will run the program several times as it collects # statistics into 2 files: # a.Final # b.Final # # - Then it runs "gnuplot" on the 2 sets of data to generate # postscript versions of the 2 plots... # # - Then it "ghostviews" the plots. # # Tom Laramee 12/95 # #################################################################### # --------------------------------------- General script information binary=p5 # name of executable opA=a # temporary data files opB=b plot1=data3.plot1 # GNUPLOT data files plot2=data3.plot2 mag=-5 # magnification for ghostview MaxStep=10 # max Window size or channel length to simulate for stepper=1 # step for "channel length" and "window size" in plots constW=7 #the constants for plots of different P1, P2 constL=3 sleepTime=4 # Set by user... ########################################################## # -------------------------------- Command line parameters A=8 # A = bits per ack C=14400 # C = channel capacity l=$constL # l = channel length ( in frames ) D=2800 # D = number of bits / data frame E=0.0 # E = prob that a bit is in error H=400 # H = header bits / frame L=0.0 # L = prob that a frame or ack is lost or damaged p=0.0 # p = (P1) prob that a data frame is lost or damaged P=0.2 # P = (P2) prob that an ACK frame is lost or damaged S=25 # S = channel arrival rate W=$constW # W = window size d=0 # d = debugging mode (0=NO, 1=YES) m=4000 # m = MAXEVENTS for simulation M=100 # M = MAXPACKETS for simulation ############################################################ # true=0 while true do echo echo sim: This script will generate 2 plots: echo sim: 1\) Channel utilization vs. Channel Length for const Window size \($constW\) echo sim: 2\) Channel utilization vs. Window Size for const Channel Length \($constL\) echo sim: echo sim: ...while varying P2 - the probability that there is a lost/damaged echo sim: ACK frame \(0.2, 0.4, 0.8\) echo sim: echo sim: Command line parameters are as follows... echo sim: ------------------------------------------------ echo sim: Bits per ack................................: $A echo sim: Channel capacity \(bps\)......................: $C echo sim: Channel length \( in frames \)................: $l echo sim: Number of bits / data frame.................: $D echo sim: Header bits / frame.........................: $H echo sim: Prob that a frame or ack is lost or damaged.: $L echo sim: Prob that a data frame is lost or damaged...: $p echo sim: Prob that an ACK frame is lost or damaged...: $P echo sim: Channel arrival rate........................: $S echo sim: Window size.................................: $W echo sim: Debugging mode..............................: $d echo sim: MAXEVENTS for simulation....................: $m echo sim: MAXPACKETS for simulation...................: $M echo sim: echo "sim: Ready to begin (y/n) ??" echo sim: Reminder: some files are about to be removed here... read answer if [ "$answer" = n -o "$answer" = N ] then exit 1 fi if [ "$answer" = y -o "$answer" = Y ] then # ---------------------------- Test for old output echo sim: Removing old output files... rm -f $opA rm -f $opA.1 rm -f $opA.2 rm -f $opA.3 rm -f $opB rm -f $opB.1 rm -f $opB.2 rm -f $opB.3 rm -f data.plot1.ps rm -f data.plot2.ps rm -f $opA.Final rm -f $opB.Final # ---------------------------- Create "permanent" data files echo sim: Creating permanent data files... touch $opA.1 touch $opA.2 touch $opA.3 touch $opA.Final touch $opB.1 touch $opB.2 touch $opB.3 touch $opB.Final # ---------------------------- Create GNUplot files... echo sim: Creating GNUplot files to generate the plots... sim3.gnuplot.sh $opA.Final $opB.Final $W $l $p $P # ------------------------------ Compile new binary echo sim: Compiling... rm -f $binary make # ------------------------------ If it compiled, run it if [ -f $binary ] then echo sim: echo sim: Running for several values of P1 \(0.2, 0.4, 0.8\) - window size = $constW echo sim: Hit \ to continue... read stuff l=0 W=$constW # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN LOOP while [ $l -le $MaxStep ] # cycle for 10 channel lengths do P=0.2 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opA >> $opA.1 # append the O/P to the bottom P=0.4 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opA >> $opA.2 # append the O/P to the bottom P=0.8 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opA >> $opA.3 # append the O/P to the bottom firstEntry=`cat $opA.1 | awk -F: '{ print $1 }'` seconEntry=`cat $opA.1 | awk -F: '{ print $2 }'` thirdEntry=`cat $opA.2 | awk -F: '{ print $2 }'` fourtEntry=`cat $opA.3 | awk -F: '{ print $2 }'` finalEntry=`echo $firstEntry $seconEntry $thirdEntry $fourtEntry` echo $finalEntry >> $opA.Final rm -f $opA.1 # remove the temporary data files... rm -f $opA.2 rm -f $opA.3 l=`echo $stepper $l | awk '{print $1 + $2}'` done # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END LOOP echo sim: echo sim: Running for several values of P1 \(0.2, 0.4, 0.8\) - channel length = $constL echo sim: l=$constL W=1 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN LOOP while [ $W -le $MaxStep ] # cycle for 10 channel lengths do P=0.2 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opB >> $opB.1 # append the O/P to the bottom P=0.4 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opB >> $opB.2 # append the O/P to the bottom P=0.8 echo sim: $binary -l $l -W $W -p $p -P $P $binary -A $A -C $C -l $l -D $D -H $H -L $L -p $p -P $P -S $S -W $W -d $d -M $M cat $opB >> $opB.3 # append the O/P to the bottom firstEntry=`cat $opB.1 | awk -F: '{ print $1 }'` seconEntry=`cat $opB.1 | awk -F: '{ print $2 }'` thirdEntry=`cat $opB.2 | awk -F: '{ print $2 }'` fourtEntry=`cat $opB.3 | awk -F: '{ print $2 }'` finalEntry=`echo $firstEntry $seconEntry $thirdEntry $fourtEntry` echo $finalEntry >> $opB.Final rm -f $opB.1 # remove the temporary data files... rm -f $opB.2 rm -f $opB.3 W=`echo $stepper $W | awk '{print $1 + $2}'` done # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END LOOP echo sim: echo sim: Generating plots using gnuplot... # GNUplot generation echo sim: First gnuplot $plot1 echo sim: Second gnuplot $plot2 #------------------ remove data files echo sim: Removing data files... rm -f $opA rm -r $opB #---------------- remove plot files echo sim: Removing GNUplot driver files... rm -f $plot1 rm -f $plot2 rm -f $opA.Final rm -f $opB.Final echo sim: echo sim: The plot names are as follows: echo sim: $plot1.ps echo sim: $plot2.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 $sleepTime ghostview -landscape -magstep $mag $plot2.ps & sleep $sleepTime 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: done