added SDT option to basicrange.py example
(Boeing r1889)
This commit is contained in:
parent
3422d13851
commit
c04c0a9ef3
1 changed files with 27 additions and 8 deletions
|
@ -16,16 +16,25 @@ from core.misc.utils import mutecall
|
|||
from core.mobility import BasicRangeModel
|
||||
from core.netns.vnet import EbtablesQueue
|
||||
|
||||
def test(numnodes):
|
||||
# node list
|
||||
n = []
|
||||
# node list - global so you can play using 'python -i'
|
||||
# e.g. >>> n[0].session.shutdown()
|
||||
n = []
|
||||
|
||||
def test(options):
|
||||
prefix = ipaddr.IPv4Prefix("10.83.0.0/16")
|
||||
session = pycore.Session(persistent = True)
|
||||
wlanid = numnodes + 1
|
||||
if options.enablesdt:
|
||||
session.location.setrefgeo(47.57917,-122.13232,50.0) # GUI default
|
||||
session.location.refscale = 100.0
|
||||
session.options.enablesdt = True
|
||||
session.options.sdturl = options.sdturl
|
||||
wlanid = options.numnodes + 1
|
||||
net = session.addobj(cls = pycore.nodes.WlanNode, name = "wlan%d" % wlanid,
|
||||
objid = wlanid, verbose = True)
|
||||
net.setmodel(BasicRangeModel, BasicRangeModel.getdefaultvalues())
|
||||
for i in xrange(1, numnodes + 1):
|
||||
values = list(BasicRangeModel.getdefaultvalues())
|
||||
#values[0] = 5000000 # 5000km range
|
||||
net.setmodel(BasicRangeModel, values)
|
||||
for i in xrange(1, options.numnodes + 1):
|
||||
tmp = session.addobj(cls = pycore.nodes.LxcNode, name = "n%d" % i,
|
||||
objid = i)
|
||||
tmp.newnetif(net, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
|
||||
|
@ -33,6 +42,10 @@ def test(numnodes):
|
|||
tmp.setposition(10, 10, 100*i)
|
||||
n.append(tmp)
|
||||
|
||||
# example setting node n2 to a high altitude
|
||||
#n[1].setposition(10, 10, 2000000) # 2000km
|
||||
#session.sdt.updatenode(n[1].objid, 0, 10, 10, 2000000)
|
||||
|
||||
n[0].term("bash")
|
||||
# wait for rate seconds to allow ebtables commands to commit
|
||||
time.sleep(EbtablesQueue.rate)
|
||||
|
@ -42,10 +55,16 @@ def main():
|
|||
usagestr = "usage: %prog [-h] [options] [args]"
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
|
||||
parser.set_defaults(numnodes = 2)
|
||||
parser.set_defaults(numnodes = 2, enablesdt = False,
|
||||
sdturl = "tcp://127.0.0.1:50000/")
|
||||
parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
|
||||
help = "number of nodes to test; default = %s" %
|
||||
parser.defaults["numnodes"])
|
||||
parser.add_option("-s", "--sdt", dest = "enablesdt", action = "store_true",
|
||||
help = "enable SDT output")
|
||||
parser.add_option("-u", "--sdturl", dest = "sdturl", type = "string",
|
||||
help = "URL for SDT connection, default = %s" % \
|
||||
parser.defaults["sdturl"])
|
||||
|
||||
def usage(msg = None, err = 0):
|
||||
sys.stdout.write("\n")
|
||||
|
@ -65,7 +84,7 @@ def main():
|
|||
|
||||
start = datetime.datetime.now()
|
||||
|
||||
test(options.numnodes)
|
||||
test(options)
|
||||
|
||||
print >> sys.stderr, \
|
||||
"elapsed time: %s" % (datetime.datetime.now() - start)
|
||||
|
|
Loading…
Reference in a new issue