<s> import optparse , sys , os , datetime , time <EOL> from core import pycore <EOL> from core . misc import ipaddr <EOL> from core . misc . utils import mutecall <EOL> from core . mobility import BasicRangeModel <EOL> from core . netns . vnet import EbtablesQueue <EOL> n = [ ] <EOL> def test ( options ) : <EOL> prefix = ipaddr . IPv4Prefix ( "<STR_LIT>" ) <EOL> session = pycore . Session ( persistent = True ) <EOL> if options . enablesdt : <EOL> session . location . setrefgeo ( <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ) <EOL> session . location . refscale = <NUM_LIT> <EOL> session . options . enablesdt = True <EOL> session . options . sdturl = options . sdturl <EOL> wlanid = options . numnodes + <NUM_LIT:1> <EOL> net = session . addobj ( cls = pycore . nodes . WlanNode , name = "<STR_LIT>" % wlanid , <EOL> objid = wlanid , verbose = True ) <EOL> values = list ( BasicRangeModel . getdefaultvalues ( ) ) <EOL> net . setmodel ( BasicRangeModel , values ) <EOL> for i in xrange ( <NUM_LIT:1> , options . numnodes + <NUM_LIT:1> ) : <EOL> tmp = session . addobj ( cls = pycore . nodes . LxcNode , name = "<STR_LIT>" % i , <EOL> objid = i ) <EOL> tmp . newnetif ( net , [ "<STR_LIT>" % ( prefix . addr ( i ) , prefix . prefixlen ) ] ) <EOL> tmp . setposition ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:100> * i ) <EOL> n . append ( tmp ) <EOL> n [ <NUM_LIT:0> ] . term ( "<STR_LIT>" ) <EOL> time . sleep ( EbtablesQueue . rate ) <EOL> def main ( ) : <EOL> usagestr = "<STR_LIT>" <EOL> parser = optparse . OptionParser ( usage = usagestr ) <EOL> parser . set_defaults ( numnodes = <NUM_LIT:2> , enablesdt = False , <EOL> sdturl = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = int , <EOL> help = "<STR_LIT>" % <EOL> parser . defaults [ "<STR_LIT>" ] ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" % parser . defaults [ "<STR_LIT>" ] ) <EOL> def usage ( msg = None , err = <NUM_LIT:0> ) : <EOL> sys . stdout . write ( "<STR_LIT:\n>" ) <EOL> if msg : <EOL> sys . stdout . write ( msg + "<STR_LIT>" ) <EOL> parser . print_help ( ) <EOL> sys . exit ( err ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> if options . numnodes < <NUM_LIT:2> : <EOL> usage ( "<STR_LIT>" % options . numnodes ) <EOL> for a in args : <EOL> sys . stderr . write ( "<STR_LIT>" % a ) <EOL> start = datetime . datetime . now ( ) <EOL> test ( options ) <EOL> print >> sys . stderr , "<STR_LIT>" % ( datetime . datetime . now ( ) - start ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
