Changes between Initial Version and Version 1 of GENIFIRE/Labwiki/Part2a/DesignSetup


Ignore:
Timestamp:
07/07/14 03:36:05 (10 years ago)
Author:
divyashri.bhat@gmail.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIFIRE/Labwiki/Part2a/DesignSetup

    v1 v1  
     1= Part 2 Design and Setup =
     2
     3== 1 Write Application for !OpenFlow Statistics Measurement ==
     4
     5=== 1.1 Get Flow Statistics you want to measure ===
     6
     7Define stats_reply in /root/learning-switch-copy.rb as follows
     8
     9
     10{{{
     11def stats_reply (dpid, message)
     12    puts "[flow stats_reply #{@my_switch}]---------------------------------"
     13    byte_count = 0
     14    packet_count = 0
     15    flow_count = 0
     16    throughput = 0
     17    inst_throughput =0
     18    total_flow_count = message.stats.length
     19    if(total_flow_count != 0)
     20      message.stats.each do | flow_msg |
     21        # WARNING: This only works for the EXACT case of two actions. If we add more than two actions the flow monitoring
     22        # will break.
     23        flow_ip = flow_msg.match
     24          puts "This is the message #{flow_ip.nw_src}"
     25            flow_count = flow_count + 1
     26            byte_count += flow_msg.byte_count
     27            packet_count += flow_msg.packet_count
     28            if flow_msg.duration_sec + flow_msg.duration_nsec/1000000000 != 0
     29              throughput += flow_msg.byte_count/(flow_msg.duration_sec + flow_msg.duration_nsec/1000000000)
     30              file = File.open("/tmp/flowstats.out", "a")
     31                  file.puts "#{flow_ip.nw_src} #{flow_count.to_s} #{byte_count} #{packet_count} #{throughput} Bps"
     32                   file.close
     33            end
     34      end
     35      end
     36    @prev_byte_count = byte_count
     37  end
     38
     39}}}
     40
     41=== 1.2 Define Flow Statistics measurement points ===
     42
     43{{{
     44class MPThroughput < OML4R::MPBase
     45   name :ofthroughput
     46   param :srcaddr, :type => :string
     47   param :numflows, :type => :int64
     48   param :numbytes, :type => :int64
     49   param :numpacket, :type => :int64
     50   param :throughput, :type => :int64
     51   param :units,      :type => :string
     52end
     53}}}
     54
     55=== 1.3 Parse Measurement Fields ===
     56
     57{{{
     58def processOutput(output)
     59  column = output.split(" ")
     60      puts "Each line process"
     61      # Inject the measurements into OML
     62      MPThroughput.inject("#{column[0]}", column[1], column[2], column[3], column[4], "#{column[5]}")
     63end
     64}}}
     65
     66=== 1.4 Write application Script ===
     67{{{
     68
     69!/usr/bin/env ruby
     70require 'rubygems'
     71require 'oml4r'
     72require 'file-tail'
     73APPNAME = "ofstats"
     74class MPThroughput < OML4R::MPBase
     75   name :ofthroughput
     76   param :srcaddr, :type => :string
     77   param :numflows, :type => :int64
     78   param :numbytes, :type => :int64
     79   param :numpacket, :type => :int64
     80   param :throughput, :type => :int64
     81   param :units,      :type => :string
     82end
     83class OFStatsWrapper
     84  def initialize(args)
     85     @addr = nil
     86     @if_num = ' '
     87     @trema_port = ' '
     88     @trema_path = ' '
     89     @verbose = true
     90     @numeric = ' '
     91     OML4R::init(args, :appName => "#{APPNAME}_wrapper", :domain => 'foo', :collect => 'file:-') {  |argParser|
     92       argParser.banner = "Reports OpenFlow stat measurements via OML\n\n"
     93       argParser.on("-f" , "--file_path ADDRESS", "Path where output is saved"){ |address| @addr = address }
     94       argParser.on("-i","--interface IFNUM","Interface number"){ |if_num| @if_num ="#{if_num.to_i()}" }
     95       argParser.on("-q", "--no-quiet ","Don't show of stats output on console"){ @verbose = false }
     96       argParser.on("-n", "--[no]-numeric ", "No attempt twill be made to look up symbolic names for host addresses"){ @numeric ='-n' }
     97    }
     98     unless @addr !=nil
     99      raise "You did not specify path of file (-p option)"
     100    end
     101end
     102class MyFile < File
     103  include File::Tail
     104end
     105def start()
     106                log = MyFile.new("#{@addr}")
     107                log.interval = @if_num
     108                log.backward(3)
     109                puts "#{@if_num}"
     110                log.tail { |line| print line
     111                processOutput(line)
     112                }
     113end
     114def processOutput(output)
     115  column = output.split(" ")
     116      puts "Each line process"
     117      # Inject the measurements into OML
     118      MPThroughput.inject("#{column[0]}", column[1], column[2], column[3], column[4], "#{column[5]}")
     119end
     120end
     121begin
     122  app = OFStatsWrapper.new(ARGV)
     123  app.start()
     124  rescue SystemExit
     125  rescue SignalException
     126     puts "OFWrapper stopped."
     127  rescue Exception => ex
     128  puts "Error - When executing the wrapper application!"
     129  puts "Error - Type: #{ex.class}"
     130  puts "Error - Message: #{ex}\n\n"
     131  # Uncomment the next line to get more info on errors
     132  # puts "Trace - #{ex.backtrace.join("\n\t")}"
     133end
     134OML4R::close()
     135# Local Variables:
     136# mode:ruby
     137# End:
     138# vim: ft=ruby:sw=2
     139}}}
     140
     141== 2. Write OEDL Script to run in !LabWiki ==
     142
     143
     144=== 2.1 Define Resource name ===
     145
     146Here you will identify the nodes you used for the tutorial as a combination of the <node-slicename>
     147
     148
     149{{{
     150defProperty('source1', "switch1-rspecforMax", "ID of a resource")
     151defProperty('source2', "switch2-rspecforMax", "ID of a resource")
     152defProperty('source3', "switch1-rspecforMax", "ID of a resource")
     153defProperty('theSender1', "nodeb-rspecforMax", "ID of a resource")
     154defProperty('theSender2', "nodec-rspecforMax", "ID of a resource")
     155defProperty('theSender3', "noded-rspecforMax", "ID of a resource")
     156defProperty('theSender4', "nodec-rspecforMax", "ID of a resource")
     157defProperty('theSender5', "nodee-rspecforMax", "ID of a resource")
     158defProperty('theReceiver', "nodef-rspecforMax", "ID of a resource")
     159}}}
     160
     161=== 2.2 Specify the location where Flow Statistics will be stored ===
     162
     163{{{
     164defProperty('pathfile', "/tmp/flowstats.out", "Path to file")
     165}}}
     166
     167=== 2.3 Define the Application created in Step 1) in OEDL ===
     168
     169
     170{{{
     171defApplication('ofstats') do |app|
     172  app.description = 'Simple Definition for the of-collect application'
     173  # Define the path to the binary executable for this application
     174  app.binary_path = '/usr/local/bin/learn_ofcollect.rb'
     175  app.defProperty('target', 'Address to output file', '-f', {:type => :string})
     176  app.defProperty("interval","Interval",'-i', {:type => :string})
     177  app.defMeasurement('wrapper_ofthroughput') do |m|
     178    m.defMetric(':srcaddr', :string)
     179    m.defMetric('throughput',:int64)
     180  end
     181end
     182}}}
     183
     184=== 2.4 Create Node Group with Application ===
     185
     186
     187{{{
     188defGroup('Source3', property.source1) do |node|
     189  node.addApplication("ofstats") do |app|
     190    app.setProperty('target', property.pathfile)
     191    app.setProperty('interval', property.intervalcol)
     192    app.measure('wrapper_ofthroughput', :samples => 1)
     193  end
     194end
     195}}}
     196
     197=== 2.5 Define parameters for graphs ===
     198
     199{{{
     200defGraph 'Throughput' do |g|
     201  g.ms('wrapper_ofthroughput').select(:oml_ts_client, :throughput, :srcaddr)
     202  g.caption "Throughput of Flows"
     203  g.type 'line_chart3'
     204  g.mapping :x_axis => :oml_ts_client, :y_axis => :throughput, :group_by => :srcaddr
     205  g.xaxis :legend => 'oml_ts'
     206  g.yaxis :legend => 'Throughput', :ticks => {:format => 's'}
     207end
     208
     209}}}
     210
     211
     212
     213= [wiki:GENIFIRE/Labwiki/Execute Next: Run Experiment] =