#!/bin/sh #################################################################### # This is a script to compile/run my DCF 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 3 files: # data.utilization # data.packetdelay # data.queuelength # # - 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 3 sets of data to generate # postscript versions of the 3 plots... # # - Then it "ghostviews" the plots. # # written by: Tom Laramee 12/95 # #################################################################### # ------------------------ General script information binary=dcf op1=data.utilization # "permanent" data files op2=data.packetdelay op3=data.queuelength op4=data.re_arrivals op5=a # temporary data files op6=b op7=c op8=d plot1=data.plot1 plot2=data.plot2 plot3=data.plot3 plot4=data.plot4 D=0 # are we debugging? mag=-5 # magnification for ghostview # Set by user... ######################################################### # --------------- controls how to step through the system 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=10 # number of nodes L=100 # Channel length -meters- T=3.3e-7 # Propagation Delay -sec- C=2.048e6 # Channel capacity -bps- X=2048 # Number of bits/packet A=8 # bits/ACK B=30 # Max number of buffers/node Cmax=1024 # max contention window size Cmin=4 # min window contention size P=0.0 # Prob a packet is received without error S=$min # System arrival rate ############################################################ SIFS=`echo 2.5 $T | awk '{print $1 * $2}'` # SIFS = 2.5*prop delay DIFS=`echo 4.0 $T | awk '{print $1 * $2}'` # DIFS = 4.0*prop delay T3=`echo 3.0 $T | awk '{print $1 * $2}'` # T3 = 3.0*prop delay true=0 while true do 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 length.............\(-l\): $L \(meters\) echo sim: Propagation delay..........\(-T\): $T \(sec\) echo sim: Channel capacity...........\(-c\): $C \(bps\) echo sim: Number of bits/packet......\(-x\): $X \(bits\) echo sim: Number of bits/ACK.........\(-a\): $A \(bits\) echo sim: Max number of buffers/node.\(-b\): $B echo sim: Max contention window size.\(-u\): $Cmax echo sim: Min window contention size.\(-v\): $Cmin echo sim: Prob[successful packet]....\(-p\): $P echo sim: SIFS.......................\(-s\): $SIFS \(sec\) echo sim: DIFS.......................\(-d\): $DIFS \(sec\) echo sim: T3.........................\(-t\): $T3 \(sec\) echo sim: System arrival rate........\(-S\): $S \(frames per sec\) echo sim: echo sim: Please enter a Probablity that there will be an echo "sim: unsuccessful packet transmission (ex 0.0, 0.2, 0.5):" read P echo "sim: Got: [$P] as an answer" 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 $op1 rm -f $op2 rm -f $op3 rm -f $op4 rm -f $op5 rm -f $op6 rm -f $op7 rm -f data.plot1.ps rm -f data.plot2.ps rm -f data.plot3.ps # ---------------------------- Create "permanent" data files echo sim: Creating permanent data files... touch $op1 touch $op2 touch $op3 touch $op4 # ---------------------------- Create GNUplot files... echo sim: Creating GNUplot files to generate the plots... sim.gnuplot.sh $op1 $op2 $op3 $op4 $N $P # ------------------------------ 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 -p $P -S $S $binary -D $D -n $N -p $P -S $S -l $L -T $T -c $C -x $X -a $A -b $B -u $Cmax -v Cmin cat $op5 >> $op1 # append the O/P to the bottom cat $op6 >> $op2 # of the permenent data files cat $op7 >> $op3 # for later viewing... cat $op8 >> $op4 # --------------------- make sure there is OP from the program if [ -f $op4 -a -f $op5 -a -f $op6 ] then echo sim: continue else echo sim: ERROR: No output from the simulation program echo sim: \(Your program probably crashed\) exit 1 fi rm $op5 # remove the temporary data files... rm $op6 rm $op7 rm $op8 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 echo sim: Second gnuplot $plot2 echo sim: Third gnuplot $plot3 # echo sim: Fourth # gnuplot $plot4 #------------------ remove data files echo sim: Removing data files... rm -f $op1 rm -r $op2 rm -f $op3 rm -f $op4 #---------------- remove plot files echo sim: Removing GNUplot driver files... rm -f $plot1 rm -r $plot2 rm -f $plot3 rm -f $plot4 echo sim: echo sim: The plot names are as follows: echo sim: $plot1.ps echo sim: $plot2.ps echo sim: $plot3.ps # echo sim: $plot4.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 ghostview -landscape -magstep $mag $plot2.ps & sleep 6 ghostview -landscape -magstep $mag $plot3.ps & sleep 6 # ghostview -landscape -magstep $mag $plot4.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: done