wiki:Old/Documentation/OTG/ScriptsRepository/OtgAppDef
	#
	# Create an application representation from scratch
	#
	require 'handler/appDefinition'
	
 	a = AppDefinition.create('test:app:otg')
 	a.name = "otg"
 	a.version(1, 1, 2)
 	a.shortDescription = "Programmable traffic generator"
 	a.description = <<TEXT
 	OTG is a configurable traffic generator. It contains generators
 	producing various forms of packet streams and port for sending
 	these packets via various transports, such as TCP and UDP.
 	TEXT
 	
 	# addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil)
 	a.addProperty('protocol', 'Protocol to use [udp|tcp]', nil, String, false)
 	a.addProperty('generator', "Generator to use [cbr|expoo]'; nil, String, false)
 	#UDP/TCP
 	a.addProperty("port",  "Local port to bind to [int]", nil, Integer, false)
 	a.addProperty("dsthostname", "Name of destination host [string]", nil, String, false)
 	a.addProperty("dstport", "Destination port to send to", nil, String, false)
 	a.addProperty("broadcast", "broadcast on/off", nil, String, false)
 	
 	# RAW
 	a.addProperty("txdev","the device to tranmsit packets", nil, String, false)
 	a.addProperty("dstmacaddr", "MAC address of the destination", nil, String, false)               
 	
 	# CBR Generator
 	a.addProperty("size", "Size of packet [bytes]", nil, Integer, false)
 	a.addProperty("interval", "Internval between consecutive packets [msec]", nil, Integer, false)
 	a.addProperty("rate", "Data rate of the flow [kbps]", nil, Integer, false)
 	
 	# Exponential On/Off traffic generator
 	a.addProperty("ontime", "average burst length in milliseconds", nil, Integer, false)
 	a.addProperty("offtime", "average idle time in milliseconds", nil, Integer, false)
 	
 	a.addMeasurement("senderport", nil, [
 	    ['pkt_seqno', 'long'],
 	    ['pkt_size', 'long'],
 	    ['gen_timestamp', Float],
 	    ['tx_timestamp', 'long']
 	])
 	
 	#a.aptName = 'orbit-otg'
 	
 	a.path = "/usr/bin/otg"
 	
 	
	if $0 == __FILE__
	  require 'stringio'
 	  require 'rexml/document'
 	  include REXML
 	   
 	  sio = StringIO.new()
 	  a.to_xml.write(sio, 2)
 	  sio.rewind
 	  puts sio.read
 	 
 	  sio.rewind
 	  doc = Document.new(sio)
 	  t = AppDefinition.from_xml(doc.root)
 	 
 	  puts
 	  puts "-------------------------"
 	  puts
 	  t.to_xml.write($stdout, 2)
 	  	end

Last modified 18 years ago Last modified on Aug 13, 2006, 3:02:52 AM
Note: See TracWiki for help on using the wiki.