DSC/dc_trial2: dsc-wildcard.rb

File dsc-wildcard.rb, 5.8 KB (added by seskar, 11 years ago)

Example script for competitive game

Line 
1# To run with default defProperty values:
2# > omf-5.4 exec dsc-wildcard.rb
3# To override defProperty values from command line:
4# > omf-5.4 exec dsc-wildcard.rb -- --team1 dsc-teamA --team2 dsc-teamC --runtime 20
5defProperty('team1','dsc-teamA','Team 1 nodes')
6defProperty('team2','dsc-teamB','Team 2 nodes')
7
8defProperty('freq', '1700000000', "Center frequency")
9defProperty('server', 'localhost', "name of pkt server")
10defProperty('port', '5123', "pkt server port")
11defProperty('runtime', 100, "Run time (s)")
12
13# Two topologies for the competitive tournament
14
15team1 = Topology["system:topo:#{property.team1}"]
16team2 = Topology["system:topo:#{property.team2}"]
17
18defApplication('test:app:bot1_rx', 'bot1_rx.py') { |a|
19 a.version(2, 0, 4)
20 a.shortDescription = ""
21 a.description = ""
22 a.path = "export LC_ALL=C;/root/gnuradio/gr-digital/examples/narrowband/bot1_rx.py"
23 a.defProperty('args', "Argument list", nil,
24 {:dynamic => false, :type => :string})
25 a.defProperty('freq', "center frequency in Hz", '-f',
26 {:dynamic => false, :type => :string})
27 a.defProperty('rx-gain', "receive gain in dB", '--rx-gain',
28 {:dynamic => false, :type => :string})
29 a.defProperty('bitrate', "specify bitrate", '-r',
30 {:dynamic => false, :type => :string})
31 a.defProperty('modulation', "modulation: psk, cpm, qpsk, dqpsk, gfsk,qam, dbpsk, bpsk, gmsk [default=psk]", '-m',
32 {:dynamic => false, :type => :string})
33 a.defProperty('constellation-points', "set constellation - power of two for psk, power of 4 for QAM [default=16]", '-p',
34 {:dynamic => false, :type => :string})
35 a.defProperty('server', "server adress", '-s',
36 {:dynamic => false, :type => :string})
37 a.defProperty('port', "port number", '-o',
38 {:dynamic => false, :type => :string})
39}
40
41defApplication('test:app:bot1_tx', 'bot1_tx.py') { |a|
42 a.version(2, 0, 4)
43 a.shortDescription = ""
44 a.description = ""
45 a.path = "export LC_ALL=C;/root/gnuradio/gr-digital/examples/narrowband/bot1_tx.py"
46 a.defProperty('args', "Argument list", nil,
47 {:dynamic => false, :type => :string})
48 a.defProperty('freq', "center frequency in Hz", '-f',
49 {:dynamic => false, :type => :string})
50 a.defProperty('tx-gain', "transmit gain in dB", '--tx-gain',
51 {:dynamic => false, :type => :string})
52 a.defProperty('tx-amplitude', "transmitter digital amplitude [0,1) [default=0.25]", '--tx-amplitude',
53 {:dynamic => false, :type => :string})
54 a.defProperty('bitrate', "specify bitrate", '-r',
55 {:dynamic => false, :type => :string})
56 a.defProperty('modulation', "modulation: psk, cpm, qpsk, dqpsk, gfsk,qam, dbpsk, bpsk, gmsk [default=psk]", '-m',
57 {:dynamic => false, :type => :string})
58 a.defProperty('constellation-points', "set constellation - power of two for psk, power of 4 for QAM [default=16]", '-p',
59 {:dynamic => false, :type => :string})
60 a.defProperty('server', "server adress", '-s',
61 {:dynamic => false, :type => :string})
62 a.defProperty('port', "port number", '-o',
63 {:dynamic => false, :type => :string})
64 a.defProperty('burst', "number of packets in each burst", '-b',
65 {:dynamic => false, :type => :string})
66 a.defProperty('sleep', "msec between bursts", '-t',
67 {:dynamic => false, :type => :string})
68}
69
70defGroup('rx_node1', team1.getNodeByIndex(0).to_s ) { |n|
71 n.addApplication('test:app:bot1_rx') { |app|
72 app.setProperty('freq', property.freq)
73 app.setProperty('rx-gain','30')
74 app.setProperty('modulation','bpsk')
75 app.setProperty('bitrate','1.25M')
76 app.setProperty('server','10.10.0.10')
77 app.setProperty('port','5125')
78 }
79}
80
81defGroup('tx_node1', team1.getNodeByIndex(1).to_s ) { |n|
82 n.addApplication('test:app:bot1_tx') { |app|
83 app.setProperty('freq', property.freq)
84 app.setProperty('tx-gain','30')
85 app.setProperty('modulation','bpsk')
86 app.setProperty('bitrate','1.25M')
87 app.setProperty('tx-amplitude','0.5')
88 app.setProperty('server','10.10.0.10')
89 app.setProperty('port','5123')
90 app.setProperty('burst','100')
91 app.setProperty('sleep','1000')
92 }
93}
94
95defGroup('rx_node2', team2.getNodeByIndex(0).to_s ) { |n|
96 n.addApplication('test:app:bot1_rx') { |app|
97 app.setProperty('freq', property.freq)
98 app.setProperty('rx-gain','30')
99 app.setProperty('modulation','dqpsk')
100 app.setProperty('bitrate','2.5M')
101 app.setProperty('server','10.10.0.10')
102 app.setProperty('port','5125')
103 }
104}
105
106defGroup('tx_node2', team2.getNodeByIndex(1).to_s ) { |n|
107 n.addApplication('test:app:bot1_tx') { |app|
108 app.setProperty('freq', property.freq)
109 app.setProperty('tx-gain','30')
110 app.setProperty('modulation','dqpsk')
111 app.setProperty('bitrate','2.5M')
112 app.setProperty('tx-amplitude','0.5')
113 app.setProperty('server','10.10.0.10')
114 app.setProperty('port','5123')
115 app.setProperty('burst','100')
116 app.setProperty('sleep','2000')
117 }
118}
119
120#onEvent(:ALL_UP) {
121onEvent(:ALL_UP_AND_INSTALLED) { |event|
122 info "Give machines some time to warm up"
123 wait 1
124
125 info "Start packet server"
126 consoleExec("/usr/local/bin/pkt_server_bot --port 5123 --duration #{property.runtime+5} --team1 #{property.team1} --team2 #{property.team2} &")
127
128 wait 2
129 info "Start benchmark_rx,tx"
130 allGroups.startApplications
131
132 wait 5
133 info "send signal to packet server to start serving packets"
134 consoleExec("/usr/local/bin/dsc_send_start.py &") # may be rename this signal
135
136 wait property.runtime
137
138 info "Stop eveything"
139 allGroups.stopApplications
140
141 wait 2
142 consoleExec("ssh root@#{team1.getNodeByIndex(0).to_s} 'pkill python' ") # Just in case kill rx side
143 consoleExec("ssh root@#{team2.getNodeByIndex(0).to_s} 'pkill python' ") # Just in case kill rx side
144
145 info "Finish it."
146 Experiment.done
147}