iperflexer.iperfparser.IperfParser

class iperflexer.iperfparser.IperfParser(expected_interval=1, interval_tolerance=0.1, units='Mbits', threads=1, maximum=1000000000)[source]

The Iperf Parser extracts bandwidth and other information from the output

IperfParser Constructor

Param:
  • expected_interval: the seconds between sample reports
  • interval_tolerance: upper bound of difference between actual and expected
  • units: desired output units (must match iperf output case - e.g. MBytes)
  • threads: (number of threads) needed for coroutine and pipe
  • maximum: the max value (after conversion) allowed (if exceeded converts to 0)
__init__(expected_interval=1, interval_tolerance=0.1, units='Mbits', threads=1, maximum=1000000000)[source]

IperfParser Constructor

Param:
  • expected_interval: the seconds between sample reports
  • interval_tolerance: upper bound of difference between actual and expected
  • units: desired output units (must match iperf output case - e.g. MBytes)
  • threads: (number of threads) needed for coroutine and pipe
  • maximum: the max value (after conversion) allowed (if exceeded converts to 0)

Methods

__init__([expected_interval, ...]) IperfParser Constructor
bandwidth(match)
param:
filename(basename) Changes the extension of the basename to .csv
pipe(*args, **kwargs)
reset() Resets the attributes set during parsing
search(line)
param:
valid(match)
param:

Attributes

bandwidths Traverses self.interval’s keys in sorted order and generates their bandwidths.
IperfParser.conversion
IperfParser.intervals
logger
return:A logging object.
regex A dictionary holding the regular expressions for the 2 formats
bandwidth(match)[source]
Param:
  • match: A parsed match group dictionary
Return type:

float

Returns:

the bandwidth in the self.units

filename(basename)[source]

Changes the extension of the basename to .csv

Param:
  • basename: a the raw-iperf filename (without path)
Returns:

the filename with the extension changed to .csv

reset()[source]

Resets the attributes set during parsing

search(line)[source]
Param:
  • line: a string of iperf output
Returns:

match dict or None

transfer(match)[source]
Param:
  • match: A parsed match group dictionary
Return type:

float

Returns:

the transfer in the self.units

traverse(intervals)[source]

traverses the intervals, infilling missing intervals

Param:
  • intervals: default dict of interval:value
Yield:

next value for the interval

valid(match)[source]
Param:
  • match: a groupdict containing parsed iperf fields
Returns:

True if the end-start interval is valid (within tolerance)

bandwidths[source]

Traverses self.interval’s keys in sorted order and generates their bandwidths.

Yield:self.interval’s values in the sorted order of the intervals
logger
Returns:A logging object.
regex[source]

A dictionary holding the regular expressions for the 2 formats

Returns:format:regex dictionary
transfer_units[source]

a hack to handle the fact that only the bandwidth units are being specified

transfers[source]

generator of transfer values

Yield:converted transfer interval values