#!/bin/csh

setenv NS_PROTO_SCRIPT dsr.tcl

foreach run ( 3 4 )
  foreach speed ( 20 )
    foreach senders ( 30 )
        foreach rules ( 512 )
          mkdir /usr/home/jorjeta/busy/$rules-$speed

          foreach pt ( 0 60 300 30 120 600 )
	    echo ----------------------------------------------------------
  	    echo 'Run:    ' $run
	    echo 'PktSize:' $rules bytes/packet
	    echo 'PktFreq:' 4 packets/source/second
	    echo 'Senders:' $senders CBR sources
	    echo 'Speed:  ' $speed meters/second
	    echo 'Pause:  ' $pt seconds of rest
	    echo 'PID:    ' $$
	    echo 'Start:  ' `date`
	    echo ----------------------------------------------------------

	 	
	    time cat /usr/home/jorjeta/ns/ns-src/scen/scen-1500x300-50-$pt-$speed-$run.gz | gzip -dc >! \
                 /usr/home/jorjeta/ns/ns-src/scen/scen-$$

	    time ./ns cmu/dsr/run.tcl -x 1500 -y 300 \
                 -cp /usr/home/jorjeta/ns/ns-src/scen/cbr-50-$senders-4-1-$rules \
                 -sc /usr/home/jorjeta/ns/ns-src/scen/scen-$$ -nn 50 -stop 900 \
                 -tr /usr/home/jorjeta/busy/tmp-$$ >! out-$rules-$speed

            time cmu/scripts/totals.pl /usr/home/jorjeta/busy/tmp-$$ AGT 50 > \
                 /usr/home/jorjeta/busy/$rules-$speed/agt-$pt-$senders-$run

            time cmu/scripts/totals.pl /usr/home/jorjeta/busy/tmp-$$ RTR 50 > \
                 /usr/home/jorjeta/busy/$rules-$speed/rtr-$pt-$senders-$run

            time cmu/scripts/post-totals.pl \
                 /usr/home/jorjeta/busy/$rules-$speed/agt-$pt-$senders-$run \
                 AGT DSR > \
                 /usr/home/jorjeta/busy/$rules-$speed/sum_50_`echo $pt`_`echo $run`_cbr_`echo $senders`_4_agt.m

            time cmu/scripts/post-totals.pl \
                 /usr/home/jorjeta/busy/$rules-$speed/rtr-$pt-$senders-$run \
                 RTR DSR > \
                 /usr/home/jorjeta/busy/$rules-$speed/sum_50_`echo $pt`_`echo $run`_cbr_`echo $senders`_4_rtr.m
	       
            time gzip -9 /usr/home/jorjeta/busy/tmp-$$
	    mv /usr/home/jorjeta/busy/tmp-$$.gz /usr/home/jorjeta/busy/$rules-$speed/trace-$pt-$senders-$run

	    rm -f /usr/home/jorjeta/busy/scen-$$
	  end
        end
      end
    end
  end
end

