runExp.py
上传用户:joranyuan
上传日期:2022-06-23
资源大小:3306k
文件大小:3k
- #changed for getting odd results
- import os, sys, string, time
- tosRoot = '/home/acwarrie/tinyos-1.x'
- clearMotePath = tosRoot + '/apps/Blink'
- progPath = tosRoot + '/contrib/zmacForRelease/apps/MultiHopThroughput'
- #progPath = tosRoot + '/contrib/zmac/apps/SingleHopThroughput'
- #progPath = tosRoot + '/contrib/zmac/apps/TestBedTopology'
- resultPath = '/home/acwarrie/research/TestBedThroughput/results'
- #motesExceptSink = ['15', '17', '31', '32', '35', '36', '11', '13', '21', '22', '37', '38', '33', '34',
- # '2', '9', '10', '39', '1', '24', '27', '28', '8', '20']
- #motesExceptSink = ['11', '21', '22']
- #motesExceptSink2 = ['1', '10', '2', '22', '24', '9']
- motesExceptSink = ['21', '37', '38', '15', '17', '31', '32', '40', '41', '42', '43',
- '2', '3', '10', '9', '39',
- '24', '27', '28', '20', '1',
- '5', '14', '18', '19']
- sinkMote = '22'
- allMotes = ['1', '3', '2', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40' ,'41', '42', '43']
- def clearMotes():
- os.chdir(clearMotePath)
- # os.system('loadlistTB ' + ' '.join(motesExceptSink) + ' ' + sinkMote)
- os.system('loadlistTB ' + ' '.join(allMotes))
- time.sleep(10) #sleep for 10s
- os.system('rm -rf ' + resultPath + '/*')
- #for sendRate in [10000]:
- #for sendRate in [20, 500, 2000]:
- #for sendRate in [20, 50, 125, 133, 143, 154, 167, 182, 200, 222, 250, 285, 333, 400, 500, 666, 1000, 2000]:
- #for sendRate in [500, 600, 700, 800, 1000]:
- for sendRate in [20, 40, 80, 160, 320, 640, 1280, 2560]:
- #clear all the motes
- clearMotes()
-
- #compile changed program
- os.chdir(progPath)
- makeCmd = 'make SEND_RATE=' + str(sendRate) + ' mica2'
- print makeCmd
- os.system(makeCmd)
- # upload changed program
- # runCmd = 'make SEND_RATE=' + str(sendRate) + ' mica2 reinstall.' + sinkMote + ' EPRB=h' + sinkMote + ' &'
- runCmd = 'make SEND_RATE=' + str(sendRate) + ' mica2 reinstall.0 EPRB=h' + sinkMote + ' &'
- print runCmd
- os.system(runCmd) # this is for sink
- os.system('loadlistTB ' + ' '.join(motesExceptSink)) # this is for rest of the testbed
- time.sleep(20)
- runPath = resultPath + '/run_' + str(sendRate)
- os.mkdir(runPath)
- for mote in motesExceptSink + [sinkMote]:
- pid = os.spawnlp(os.P_NOWAIT, 'telmoteTB', 'telmoteTB', 'h' + mote, runPath + '/h_' + str(mote))
-
- time.sleep(500)
- os.system('killall -s 9 telnet')