Code Search for Developers
 
 
  

start-net-expt.sh from EmStar at Krugle


Show start-net-expt.sh syntax highlighted

#!/bin/sh -x

#
#  start-net-expt.sh
#
#  Runs a multi-node net experiment
#

usage() {
	echo "start-net-expt.sh --start <time> --sleepperiod <period> --betweenperiod <period> --shortsleep <period> --rootnode <node id> --pktsize <size> --totalpkts <num pkts> --cycleperiod <period> --txwindow <period> --log <output dir>"
	exit 1
}

NODEID=`cat /etc/id`

export LD_LIBRARY_PATH=/home/emstar/lib

dosleep() { 
  START_SLEEP=$1
  MAXFAIL=$(( $1 + 5 ))
  echo "Sleeping for $1.$2 seconds.. until $START_SLEEP "
  if ! /home/emstar/bin/attime --clock gps --time $START_SLEEP --maxfail $MAXFAIL ; then
    echo "maxfail exceeded on sleep"
    exit 1
  fi
}

run() {
  CURR_OFFSET_SEC=`echo $START | sed s/\\\.[0-9]*//`
  CURR_OFFSET_USEC=`echo $START | sed s/[0-9]*\\\.//`

  while true; do
      echo 1 > /dev/sync/params/command
      /usr/bin/killall -19 gsyncd
      
      CURR_OFFSET_SEC=$(( $CURR_OFFSET_SEC + $SHORTSLEEP ))
      dosleep $CURR_OFFSET_SEC $CURR_OFFSET_USEC
      
      CURR_OFFSET_SEC=$(( $CURR_OFFSET_SEC + $SHORTSLEEP ))
      /home/emstar/devel/scale/scaled -U udp0 -T $CURR_OFFSET_SEC.$CURR_OFFSET_USEC -r $ROOTNODE -s $PKTSIZE -t $TOTALPKTS -p $CYCLEPERIOD -w $TXWINDOW -l $OUTDIR &
      disown
      
      CURR_OFFSET_SEC=$(( $CURR_OFFSET_SEC + $SLEEPPERIOD ))
      dosleep $CURR_OFFSET_SEC $CURR_OFFSET_USEC

      killall -9 scaled
      killall -9 udpd

      echo 0 > /dev/sync/params/command
      /usr/bin/killall -9 gsyncd

      CURR_OFFSET_SEC=$(( $CURR_OFFSET_SEC + $BETWEENPERIOD ))
      dosleep $CURR_OFFSET_SEC $CURR_OFFSET_USEC
  done
}

killall -9 udpd

while [ $1 ] ; do 
  case "$1" in 
    --start)
        START=$2
	shift
	shift
	;;        
    --sleepperiod)
        SLEEPPERIOD=$2
	shift
	shift
	;;
    --betweenperiod)
        BETWEENPERIOD=$2
	shift
	shift
	;;        
    --shortsleep)
        SHORTSLEEP=$2
	shift
	shift
	;;        
    --rootnode)
        ROOTNODE=$2
	shift
	shift
	;;
    --pktsize)
        PKTSIZE=$2
	shift
	shift
	;;        
    --totalpkts)
        TOTALPKTS=$2
	shift
	shift
	;;        
    --cycleperiod)
        CYCLEPERIOD=$2
	shift
	shift
	;;        
    --txwindow)
        TXWINDOW=$2
	shift
	shift
	;;        
    --log)
        OUTDIR=$2
	shift
	shift
	;;        
    *)
	usage
	;;    
  esac 
done

run





See more files for this project here

EmStar

EmStar is a software system for developing and deploying wireless sensor networks involving Linux-based platforms. As the wireless sensor network community has attempted to deploy more complex designs---large-scale, long-lived systems that need self-organization and adaptivity---a number of difficult software design issues have arisen. Advances in software design have not kept pace with the capabilities of hardware. This is because designing for an adaptive, efficient, and useful sensor network has turned out to be surprisingly complex and difficult. EmStar is a Linux-based software framework, whose goal is to dramatically reduce this complexity, enabling work to be shared and reused, and simplifying and speeding the design of new sensor network applications.

Project homepage: http://cvs.cens.ucla.edu/emstar/
Programming language(s): C,Shell Script
License: other

  global-start-net-expt-short.sh
  global-start-net-expt.sh
  start-net-expt.sh