def bw_monitor_stop(): print "now in bw stop" global bw_monitors for (h, p) in bw_monitors: print "now adding", "bw_" + str(h) framework.addLogfile("bw_" + str(h)) p.send_signal(2) # SIGINT timeOffset = None for line in open("bw_" + str(h), "r"): parts = line.split(";") if len(parts) < 5: break time = float(parts[0]) if timeOffset is None: timeOffset = time intf = parts[1] try: bwOut = float(parts[2]) / 1000 # kbyte bwIn = float(parts[3]) / 1000 # kbyte framework.record("bwm-ng-kbyte-in-" + intf, bwIn, time - timeOffset) framework.record("bwm-ng-kbyte-out-" + intf, bwOut, time - timeOffset) except ValueError: print "Cant parse bwm values for row", line
def runCbrExperiment(h1, h2, schedName, schedName2): direction_server_receiver = 0 direction_server_sender = 1 direction_client_receiver = 1 direction_client_sender = 0 os.system("chmod +x cbr_server") os.system("chmod +x cbr_client") h1.cmd('./cbr_server 8080 {{cbr_bitrate}} {{cbr_duration}} ' + str(direction_server_receiver) + ' &> server.out &') h2.cmd('./cbr_client 10.0.0.1 8080 {{cbr_bitrate}} {{cbr_duration}} ' + str(direction_client_sender) + ' &> client.out') time.sleep(2) framework.addLogfile('server.out') framework.addLogfile('client.out') i = 0 with open('server.out') as serverLog: for line in serverLog: # just lines of time spans (in ms) it took to read what was expected in one second (1000 ms) if line[-1] != "" and line != "finished": framework.record("cbr_for_1s", int(line[:-1]), offset=i) error = math.pow(1000 - int(line[:-1]), 2) framework.record("cbr_error", error, offset=i) i = i + 1
def runFctExperiment(h1, h2, schedName, schedName2): print "run with", schedName, schedName2 h1.cmd( 'python -u server.py 8080 {{fct_number_of_requests}} {{fct_request_size}} send server.log ' + schedName2 + ' {{fctTest_waitForSubflowEstablishment}} &> server.out &') h2.cmd( 'python -u client.py 10.0.0.1 8080 {{fct_number_of_requests}} {{fct_request_size}} send client.log ' + schedName + ' {{fctTest_waitForSubflowEstablishment}} &> client.out') framework.addLogfile('server.out') framework.addLogfile('client.out') #framework.addLogfile('server.log') in general, we do not have a server.log framework.addLogfile('client.log') # store results in framework minTimestamp = None with open('client.log') as clientLog: for line in clientLog: parts = line.split("\t") if len(parts) != 3: continue if parts[0] == "flow_begin": continue if minTimestamp is None: minTimestamp = float(parts[0]) framework.record("AppLayerRTT", float(parts[2]), offset=float(parts[0]) - minTimestamp)
def runIperfExperiment(source, destination): destination.cmd('iperf -s -i 1 -y C > server.log &') source.cmd('iperf -c ' + str(destination.IP()) + ' -t 10 > client.log') framework.addLogfile("server.log") framework.addLogfile("client.log") server = open('server.log', 'r') bwsamples = [] minTimestamp = None for line in server: # 20160622002425,10.0.0.2,5001,10.0.0.1,39345,4,0.0-1.0,14280,114240 matchObj = re.match(r'(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)', line, re.M) if matchObj: timestamp = float(matchObj.group(1)) bwsample = float( matchObj.group(9)) / 1000.0 / 1000.0 # bits per second -> MBit bwsamples.append(bwsample) if minTimestamp is None: minTimestamp = timestamp framework.record("iperf_mbit_over_time", bwsample, timestamp - minTimestamp) framework.record("iperf_mbit_avg", sum(bwsamples) / len(bwsamples), offset=5)
def collectTotalSendData(): ifconfigResult = subprocess.check_output("ifconfig", shell=True) framework.log("ifconfig result", ifconfigResult) for line in ifconfigResult.split("\n"): matchObj = re.match(r'(.*) Link (.*)', line, re.M) if matchObj: currentInt = matchObj.group(1) else: matchObj = re.match(r'(.*)RX bytes:(.*)\((.*) TX bytes:(.*)\((.*)', line, re.M) if matchObj: framework.record("tx_" + str(currentInt), int(matchObj.group(4))) framework.record("rx_" + str(currentInt), int(matchObj.group(2)))
def parseProgMpOutput(): currentIdForSk = {} minTimestamp = None for line in open("dmesg.log", "r"): result = parseProgMpOutputLine(line) if result is not None: (timestamp, meta_sk, key, value) = result if key == "sbfId": currentIdForSk[meta_sk] = value if minTimestamp is None: minTimestamp = timestamp if key != "sbfId": if meta_sk in currentIdForSk: usedKey = key + "_" + str( currentIdForSk[meta_sk]) + "_" + str(meta_sk) framework.record(usedKey, value, offset=float(timestamp) * 100.0 - float(minTimestamp) * 100.0) else: framework.warn("ProgMP Parser", "Key " + str(key) + " not found as meta_sk")
### CFG int test_parameter [ms] "write description here..." ### CFG string str_param "write description here..." ### ENV float float_param "write description here..." import framework from time import sleep # test 2 if __name__ == '__main__': framework.start() framework.record("a", framework.param('a')) sleep(2) framework.record("b", framework.param('b')) framework.stop()
1. Inform the framework about the beginning of the experiment """ framework.start() """ 2. Configure the experiment according to the given environment and configuration parameters. """ print "myParameter has the value", framework.param('myParameter') print "myParameter has the value", {{myParameter}} """ 3. Store measurement results during the experiment. You might even store multiple values for the same metric key. """ framework.record("targetMetric", 1) """ Each measurement record contains a time offset. Override this offset if required (e.g., for time-based analysis) """ framework.record("targetMetric", 1, offset=5) """ 4. Store additional logs and warnings during the experiment. Note that the standard output is also recorded, e.g., prints. """ framework.log("key", "value") framework.warn("key", "value") # create dummy logfile