ravinet / mahimahi

Web performance measurement toolkit
GNU General Public License v3.0
241 stars 129 forks source link

A script to generate mahimahi tracefiles #146

Open shaymargolis opened 3 years ago

shaymargolis commented 3 years ago

Hi everyone,

For a project I had to write a simple script to generate mahimahi tracefiles for simple links (for example, bandwidth change every few seconds). The main issue was to adapt to every possible bandwidth :)

Here is a quick example for the code (Creating link varying between 16 Mbit/s and 32 Mbit/s every 5 seconds):

import random

def main():
    length = 100
    change = 5

    trace = Trace([])

    for x in range(int(length/change)):
        trace += Trace.generate(random.random() * 16 + 16, change)

    print("Generated bandwidth average", trace.get_avg_bw())

    trace.to_file("custard_link.trace")

You can take a look here: https://gist.github.com/shaymargolis/af946c8bb481b7a91a5863f286d77a5f

Hope this helps anyone!

keithw commented 3 years ago

Looks interesting -- have you seen the mm-rate-to-events script (https://github.com/ravinet/mahimahi/blob/master/scripts/mm-rate-to-events) ? It sounds like this may do the same thing.