Changes between Version 2 and Version 3 of GEC20Agenda/LabWiki/ModuleA/Finish


Ignore:
Timestamp:
06/05/14 15:51:10 (10 years ago)
Author:
zink@cs.umass.edu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GEC20Agenda/LabWiki/ModuleA/Finish

    v2 v3  
    11= Module A Finish =
     2
     3= 1. Release Resources =
     4After you are done with this experiment, release your resources using the reservation tool of choice. [[BR]]
     5Simply follow the tutorial on [http://groups.geni.net/geni/wiki/GENIExperimenter/Tutorials/PortalSimpleLayer2Example/TeardownExperiment TeardownExperiment] to tear down your experiment and release the resources you reserved.
     6
     7
     8= 2. Sample Applications =
     9
     10Now you can start designing and running your own experiments. Some examples are here:
     11
     12[https://github.com/mytestbed/oml4r/tree/master/examples How to use OML4r]
     13
     14== 2.1 !OpenFlow Statistics Measurement ==
     15
     16ofcollect.rb
     17{{{
     18
     19#!/usr/bin/env ruby
     20require 'rubygems'
     21require 'oml4r'
     22require 'file-tail'
     23APPNAME = "ofstats"
     24class MPThroughput < OML4R::MPBase
     25   name :ofthroughput
     26   param :pathtype, :type => :string
     27   param :numflows, :type => :int64
     28   param :numbytes, :type => :int64
     29   param :numpacket, :type => :int64
     30   param :throughput, :type => :int64
     31   param :units,        :type => :string
     32   param :instput, :type => :int64
     33   param :units2,       :type => :string
     34end
     35class OFStatsWrapper
     36  def initialize(args)
     37     @addr = nil
     38     @if_num = ' '
     39     @trema_port = ' '
     40     @trema_path = ' '
     41     @verbose = true
     42     @numeric = ' '
     43     OML4R::init(args, :appName => "#{APPNAME}_wrapper", :domain => 'foo', :collect => 'file:-') {  |argParser|
     44       argParser.banner = "Reports OpenFlow stat measurements via OML\n\n"
     45       argParser.on("-f" , "--file_path ADDRESS", "Path where output is saved"){ |address| @addr = address }
     46       argParser.on("-i","--interface IFNUM","Interface number"){ |if_num| @if_num ="#{if_num.to_i()}" }
     47       argParser.on("-q", "--no-quiet ","Don't show of stats output on console"){ @verbose = false }
     48       argParser.on("-n", "--[no]-numeric ", "No attempt twill be made to look up symbolic names for host addresses"){ @numeric ='-n' }
     49    }
     50     unless @addr !=nil
     51      raise "You did not specify path of file (-p option)"
     52    end
     53end
     54class MyFile < File
     55  include File::Tail
     56end
     57def start()
     58                log = MyFile.new("#{@addr}")
     59                log.interval = @if_num
     60                log.backward(10)
     61                puts "#{@if_num}"
     62                log.tail { |line| print line
     63                processOutput(line)
     64                }
     65end
     66def processOutput(output)
     67  column = output.split(" ")
     68      puts "Each line process"
     69      # Inject the measurements into OML
     70      MPThroughput.inject("#{column[0]}", column[1], column[2],
     71                                column[3], column[4], "#{column[5]}",
     72                                column[6], "#{column[7]}")
     73end
     74end
     75begin
     76  app = OFStatsWrapper.new(ARGV)
     77  app.start()
     78  rescue SystemExit
     79  rescue SignalException
     80     puts "OFWrapper stopped."
     81  rescue Exception => ex
     82  puts "Error - When executing the wrapper application!"
     83  puts "Error - Type: #{ex.class}"
     84  puts "Error - Message: #{ex}\n\n"
     85  # Uncomment the next line to get more info on errors
     86  # puts "Trace - #{ex.backtrace.join("\n\t")}"
     87end
     88OML4R::close()
     89# Local Variables:
     90# mode:ruby
     91# End:
     92# vim: ft=ruby:sw=2
     93}}}
     94
     95OEDL script
     96{{{
     97
     98defProperty('source1', "nowcastbox-sdxdemo", "ID of a resource")
     99defProperty('intervalcol',"1", "Interval to Tail")
     100
     101defProperty('pathfile', "/tmp/flowstats.out", "Path to file")
     102
     103
     104
     105defApplication('ofstats') do |app|
     106  app.description = 'Simple Definition for the of-collect application'
     107  # Define the path to the binary executable for this application
     108  app.binary_path = '/usr/local/bin/ofcollect.rb'
     109  app.defProperty('target', 'Address to output file', '-f', {:type => :string})
     110  app.defProperty("interval","Interval",'-i', {:type => :string})
     111  app.defMeasurement('wrapper_ofthroughput') do |m|
     112    m.defMetric(':pathtype', :string)
     113    m.defMetric('throughput',:int64)
     114    m.defMetric('instput',:int64)
     115  end
     116end
     117defGroup('Source1', property.source1) do |node|
     118  node.addApplication("ofstats") do |app|
     119    app.setProperty('target', property.pathfile)
     120    app.setProperty('interval', property.intervalcol)
     121    app.measure('wrapper_ofthroughput', :samples => 1)
     122  end
     123end
     124
     125
     126onEvent(:ALL_UP_AND_INSTALLED) do |event|
     127  info "Starting the collect"
     128  after 2 do
     129    group('Source1').startApplications
     130  end
     131  after 800 do
     132    info "Stopping the collect"
     133    allGroups.stopApplications
     134    Experiment.done
     135  end
     136end
     137
     138defGraph 'Throughput' do |g|
     139  g.ms('wrapper_ofthroughput').select(:oml_ts_client, :throughput, :pathtype)
     140  g.caption "Throughput of Flows"
     141  g.type 'line_chart3'
     142  g.mapping :x_axis => :oml_ts_client, :y_axis => :throughput, :group_by => :pathtype
     143  g.xaxis :legend => 'oml_ts'
     144  g.yaxis :legend => 'Throughput', :ticks => {:format => 's'}
     145end
     146defGraph 'InstantaneousThroughput' do |g|
     147  g.ms('wrapper_ofthroughput').select(:oml_ts_client, :instput, :pathtype)
     148  g.caption "Throughput of Flows"
     149  g.type 'line_chart3'
     150  g.mapping :x_axis => :oml_ts_client, :y_axis => :instput, :group_by => :pathtype
     151  g.xaxis :legend => 'oml_ts'
     152  g.yaxis :legend => 'Instantaneous Throughput', :ticks => {:format => 's'}
     153end
     154
     155}}}