Tutorials/c0WiFi/Tutorial5: wishful_edca.rb

File wishful_edca.rb, 2.7 KB (added by seskar, 19 months ago)

WiSHFUL EDCA Management Tutorial Script

Line 
1# -*- coding: utf-8 -*-
2defProperty('contr', 'node2-1', 'WiSHFUL Controller Node')
3defProperty('path','/root/wishful/examples/edca/',"Path to WiSHFUL configuration directory")
4defProperty('accesspoints', 'node1-3,node1-5', "node ID for access point")
5defProperty('clients', 'node1-4,node1-6', "node ID for client nodes")
6defProperty('channel', 11, "WiFi channel to use")
7defProperty('duration', 60, "Seconds to run the application")
8
9defApplication('controller') do |app|
10  app.description = 'WiSHFUL Simple Controller Program'
11  app.path = property.path+'wishful_simple_controller'
12  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
13end
14
15defApplication('agent') do |app|
16  app.description = 'WiSHFUL Simple Agent Program'
17  app.path = property.path+'wishful_simple_agent'
18  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
19end
20
21
22defGroup( 'Controllers', property.contr ) do |node|
23  node.addApplication( "controller" ) do |app|
24    app.setProperty('config', property.path+'controller_config.yaml')
25  end
26end
27
28@i = 0
29defGroup('AP', property.accesspoints) do |node|
30  node.addApplication( "agent" ) do |app|
31    app.setProperty('config', property.path+'agent_config.yaml')
32  end
33  node.addApplication("test:app:iperf") do |app|
34    app.setProperty('server', true)
35    app.setProperty('reportstyle','O')
36    app.setProperty('oml-server', "oml:3003")
37    app.setProperty('oml-id', "#{@i}")
38    app.setProperty('oml-exp-id', "#{Experiment.ID}")   
39  end
40  node.net.w0.mode = "master"
41  node.net.w0.type = 'g'
42  node.net.w0.channel = property.channel.to_s
43  @i = @i + 1
44  node.net.w0.essid = "WiSHFUL#{@i}"
45  node.net.w0.ip = "192.168.0.#{@i}"
46end
47
48@j = 0
49defGroup('client', property.clients) do |node|
50  @j = @j + 1
51  node.addApplication( "agent" ) do |app|
52    app.setProperty('config', property.path+'agent_config.yaml')
53  end
54  node.addApplication("test:app:iperf") do |app|
55    app.setProperty('client', "192.168.0.#{@j}")
56    app.setProperty('time', 20)
57    app.setProperty('interval', 5)
58    app.setProperty('reportstyle','O')
59    app.setProperty('oml-server', "oml:3003")
60    app.setProperty('oml-id', "#{@i}")
61    app.setProperty('oml-exp-id', "#{Experiment.ID}")
62  end
63  node.net.w0.mode = "managed"
64  node.net.w0.type = 'g'
65  node.net.w0.channel = property.channel.to_s
66  node.net.w0.essid = "WiSHFUL#{@j}"
67  @i = @i + 1
68  node.net.w0.ip = "192.168.0.#{@i}"
69end
70
71onEvent(:ALL_UP_AND_INSTALLED) do |event|
72  info "Wait for all nodes to come up" 
73  wait 20
74  allGroups.startApplications
75  info "Both controller and agent are started; running for #{property.duration}" 
76  wait property.duration
77  allGroups.stopApplications
78  info "Both controller and agent are stopped..." 
79  Experiment.done
80end
81