wiki:Old/OtherApps/ScriptsRepository

Version 1 (modified by Surya Satyavolu, 19 years ago) ( diff )

Orbit > Other Applications > Iperf Scripts

Application Definition Schema

The application definition schema for the Iperf application is as follows

<?xml version="1.0" encoding="UTF-8"?>
<orbit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<application id="orbit_winlab_iperf">
		<name>iperf</name>
		<id>iperf</id>
		<version major="0" minor="1" revision="0"/>
		<organization>
			<name>WINLAB, Rutgers University</name>
			<url>http://www.winlab.rutgers.edu/</url>
		</organization>
		<shortDescription>Traffic Generator</shortDescription>
		<description>Receive network traffic on the specified interface
                    </description>
		<url>http://apps.orbit-lab.org/otr</url>
		<measurement-points>
			<measurement-point id="receiverport">
				<metric id="flow_no" type="int">
					<description>id of the flow</description>
				</metric>
				<metric id="throughput" type="float">
					<description> Flow Throughput</description>
				</metric>
				<metric id="jitter" type="float">
					<description>Flow jitter</description>
				</metric>
				<metric id="packet_loss" type="float"/>
				<description>Flow Packet loss</description>
			</measurement-point>
		</measurement-points>
		<issueTrackingUrl>http://apps.orbit-lab.org/issues/winlab/iperf
                     </issueTrackingUrl>
		<repository>
			<development>scm:cvs:pserver:anoncvs@cvs.orbit-lab.org:/trafficgenerator/iperf</development>
			<binary>apt:repository.orbit-lab.org/orbit/binary:???</binary>
		</repository>
		<mailingLists/>
		<developers>
			<developer>
				<name>John Doe</name>
				<id>jdoe</id>
				<email>jdoe@winlab.rutgers.edu</email>
				<organization>
					<name>WINLAB, Rutgers University</name>
				</organization>
			</developer>
		</developers>
		<dependencies>
			<dependency>
				<id>libmac</id>
				<version>&gt;= 0.4</version>
				<url>apt:repository.orbit-lab.org/debian/binary:libmac
                                        </url>
			</dependency>
		</dependencies>
	</application>
</orbit>

Application definition script for Iperf sender and Receiver

Iperf Sender

#
# Create an application representation from scratch
#
require 'appDefinition'

a = AppDefinition.create('test:app:iperfs')
a.name = "iperfs"
a.version(0, 0, 1)
a.shortDescription = "Iperf traffic generator"
a.description = <<TEXT
Iperf is a traffic generator for TCP and UDP traffic. 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('udp', 'Use UDP, otherwise TCP by default', nil, String, false)
a.addProperty('client', 'Run as client', nil, String, false)
a.addProperty('port', 'Sender port number', nil, Integer, false)
a.addProperty('window', 'TCP Send Window Size', nil, Integer, false)
a.addProperty('len', "Payload length (bytes)", nil, Integer, false)
a.addProperty('bandwidth', "Offered load for UDP", nil, Integer, false)
a.addProperty('time', "Duration of traffic generation(secs)", nil, Integer, false)
a.addProperty('parallel', "Number of parallel flows", nil, Integer, false)

a.addMeasurement("senderport", nil, [
    ['stream_no', 'int'],
    ['pkt_seqno', 'long'],
    ['pkt_size', 'long'],
    ['gen_timestamp', 'long'],
    ['tx_timestamp', 'long']
 ])

a.path = "/usr/local/bin/iperf"

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

Iperf Receiver

#
# Create an application representation from scratch
#
require 'appDefinition'

a = AppDefinition.create('test:app:iperfr')
a.name = "iperfr"
a.version(0, 0, 1)
a.shortDescription = "Iperf traffic generator"
a.description = <<TEXT
Iperf is a traffic generator for TCP and UDP traffic. 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('udp', 'Use UDP, otherwise TCP by default', nil, String, false)
a.addProperty('server', 'Client/Server', nil, String, false)
a.addProperty('port', 'Receiver port number', nil, Integer, false)
a.addProperty('window', 'TCP Receiver Window Size', nil, Integer, false)
a.addProperty('time', "Duration for traffic generation(seconds)", nil, Integer, false)
a.addProperty('len', "Payload Length(bytes)", nil, Integer, false)
a.addProperty('interval', "Interval between reports (sec)", nil, Integer, false)

a.addMeasurement("receiverport", nil, [
  ['flow_no', 'int', 'id of the flow'],
  ['throughput', Float, 'Flow Throughput'],
  ['jitter', Float,'Average Jitter'],
  ['packet_loss',Float,'Packet loss']
 ])
a.path = "/usr/local/bin/iperf"

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

Sample prototype definitions script for Iperf UDP and TCP (sender and Receiver)

Iperf UDP Sender

#
# Define a prototype
#
require 'prototype'
require 'filter'
require 'appDefinition'

p = Prototype.create("test:proto:iperfudpsender")
p.name = "Iperf UDP Sender"
p.description = "Nodes which send a stream of packets"
p.defProperty('use_udp', 'Protocol to use')
p.defProperty('client', 'Host to send packets to')
p.defProperty('sender_rate', 'Number of bits per second', 100000)
p.defProperty('len', 'Size of packets')
p.defProperty('time', 'Experiment duration (sec)', 10)

iperfs = p.addApplication(:iperfs, "test:app:iperfs")
iperfs.bindProperty('udp','use_udp')
iperfs.bindProperty('client')
iperfs.bindProperty('bandwidth','sender_rate')
iperfs.bindProperty('len')
iperfs.bindProperty('time')

iperfs.addMeasurement('senderport',  Filter::TIME, 
  {Filter::SAMPLE_SIZE => 1},
  [
    ['stream_no'],
    ['pkt_seqno'],
    ['pkt_size', Filter::SUM],
    ['gen_timestamp'],
    ['tx_timestamp']
  ]
)
if $0 == __FILE__
  p.to_xml.write($stdout, 2)
  puts
end

Iperf UDP Receiver

#
# Define a prototype
#

require 'prototype'
require 'filter'
require 'appDefinition'

p = Prototype.create("test:proto:iperfudpreceiver")
p.name = "Iperf UDP Receiver"
p.description = "Nodes which receive packets"
p.defProperty('use_udp', 'Protocol to use')
p.defProperty('server', 'Client/Server')
p.defProperty('time', 'Duration of experiment (seconds)', 10)
p.defProperty('len', 'Payload length', 512)
p.defProperty('report_interval', 'Interval between bandwidth reports', 1)

iperfr = p.addApplication('iperfr', "test:app:iperfr")
iperfr.bindProperty('udp')
iperfr.bindProperty('server')
iperfr.bindProperty('time')
iperfr.bindProperty('len')
iperfr.bindProperty('interval','report_interval')

iperfr.addMeasurement('receiverport',  Filter::TIME, 
  {Filter::SAMPLE_SIZE => 1},
  [
    ['flow_no'],
    ['throughput'],
    ['jitter'],      
    ['packet_loss']
  ]
)
if $0 == __FILE__
  p.to_xml.write($stdout, 2)
  puts
end

Iperf TCP Sender

#
# Define a prototype
#
require 'prototype'
require 'filter'
require 'appDefinition'

p = Prototype.create("test:proto:iperftcpsender")
p.name = "Iperf TCP Sender"
p.description = "Nodes which send a stream of packets"
p.defProperty('client', 'Host to send packets to')
#p.defProperty('port', 'Port to send packets to')
p.defProperty('len', 'Size of packets')
p.defProperty('window', 'TCP window Size (bytes)', 64000)
p.defProperty('time', 'Experiment duration (sec)', 10)

iperfs = p.addApplication(:iperfs, "test:app:iperfs")
iperfs.bindProperty('client')
iperfs.bindProperty('len')
iperfs.bindProperty('time')
iperfs.bindProperty('window')

iperfs.addMeasurement('senderport',  Filter::TIME, 
  {Filter::SAMPLE_SIZE => 1},
  [
    ['stream_no'],
    ['pkt_seqno'],
    ['pkt_size', Filter::SUM],
    ['gen_timestamp'],
    ['tx_timestamp']
  ]
)
#
if $0 == __FILE__
  p.to_xml.write($stdout, 2)
  puts
end

Iperf TCP Receiver

#
# Define a prototype
#

require 'prototype'
require 'filter'
require 'appDefinition'

p = Prototype.create("test:proto:iperftcpreceiver")
p.name = "Iperf TCP Receiver"
p.description = "Nodes which receive packets"
p.defProperty('server', 'Client/Server')
p.defProperty('time', 'Duration of experiment (seconds)', 10)
p.defProperty('window', 'Receiver Window Size', 64000)
p.defProperty('report_interval', 'Interval beween reports', 1)


iperfr = p.addApplication('iperfr', "test:app:iperfr")
iperfr.bindProperty('server')
iperfr.bindProperty('time')
iperfr.bindProperty('window')
iperfr.bindProperty('interval', 'report_interval')

iperfr.addMeasurement('receiverport',  Filter::TIME,
  {Filter::SAMPLE_SIZE => 1},
    [
      ['flow_no'],
      ['throughput'],
    ] )

if $0 == __FILE__
  p.to_xml.write($stdout, 2)
  puts
end

Experiment script for Iperf

############# Tutorial1 ##################################
# This script defines the experiment
# that has one sender and one receiver using Iperf
# Sender, Receiver - 802.11a channel 36
# UDP flow at 1 Mbps
# Receiver reports throughput, packet loss and jitter 
############################################################

require 'net/http'
require 'uri'

Experiment.name = "tutorial-iperf"
Experiment.project = "orbit:tutorial"

###########################################
# Sender definition and configuration
###########################################
defNodes('sender',[1,1]) {|node|
  node.image = nil  # assume the right image to be on disk
  # use prototype "iperfudpsender" 
  # and set it's property "destinationHost" to 
  # the receiver node
  # and bind the remaining properties to the 
  # experiment property space
  node.prototype("test:proto:iperfudpsender", {
    'client' => '192.168.1.2',
    'use_udp' => nil,         #UDP client - nil argument means use UDP, For TCP, we dont use this option
    'time' => 60,             #Duration of traffic gen
    'sender_rate' => 1000000, #Sender rate = 1 Mbps
    'len' => 1024             #Payload length (bytes)
  })
  node.net.w0.ip = "%192.168.%x.%y"
  node.net.w0.mode = "master"
  node.net.w0.type = 'a'
  node.net.w0.essid = "helloworld"
}
###########################################
# Receiver definition and configuration
###########################################
defNodes('receiver', [1,2]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:iperfudpreceiver" , {
  'server' => nil,         # Server
  'use_udp' => nil,        # Use UDP nil means no argument required
  'len' => 1024,           # Payload length (bytes)
  'time' => 60,            # Duration = 60 seconds
  'report_interval' => 1   # Report interval = 1 sec
  })
  node.net.w0.ip = "%192.168.%x.%y"
  node.net.w0.mode = "managed"
  node.net.w0.type = 'a'
  node.net.w0.essid = "helloworld"	
}
###########################################
#  When nodeAgents have reported "OK" to 
# the nodeHandler start the application
###########################################
whenAllInstalled {|node|
  NodeSet['receiver'].startApplications
  NodeSet['sender'].startApplications

###########################################
# Run for 60 seconds
###########################################
wait 60

###########################################
# Shutdown nodes
###########################################
 Experiment.done
}

Note: See TracWiki for help on using the wiki.