def main(): url = os.getenv("TARGET_URL") tg = TrafficGenerator(url) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete( tg.run() )
def initialize_config(config_file): config = read_config(config_file) sumo = sumo_config(config['simulation']['gui'], \ config['simulation']['max_steps']) traffic_generator = TrafficGenerator(int(config['simulation']['nb_cars_generated']), \ int(config['simulation']['max_steps'])) return config, sumo, traffic_generator
def setUpClass(cls): gov_uk_url = os.getenv("GOV_UK_URL", "https://www.gov.uk.glasswall-icap.com") file_drop_url = os.getenv( "FILE_DROP_URL", "https://glasswall-file-drop.azurewebsites.net") num_files = int(os.getenv("NUM_FILES", 10)) tg = TrafficGenerator(gov_uk_url) asyncio.get_event_loop().run_until_complete( tg.run(num_files=num_files)) cls.file_drop = FileDrop(file_drop_url)
def setUpClass(cls): gov_uk_url = os.getenv("GOV_UK_URL", "https://www.gov.uk.glasswall-icap.com") file_drop_url = os.getenv("FILE_DROP_URL", "https://glasswall-file-drop.azurewebsites.net") num_files = int(os.getenv("NUM_FILES", 1)) elastic_host = os.getenv("ELASTIC_HOST", "localhost") elastic_port = os.getenv("ELASTIC_PORT", "9200") elastic_username = os.getenv("ELASTIC_USER") elastic_password = os.getenv("ELASTIC_PASSWORD") cls.index_name = os.getenv("INDEX_NAME", "tg_test_results") tg = TrafficGenerator(gov_uk_url) asyncio.get_event_loop().run_until_complete(tg.run(num_files=num_files)) cls.file_drop = FileDrop(file_drop_url) cls.ship_test_results_to_elastic = os.getenv("SHIP_TO_ELASTIC", "0") if cls.ship_test_results_to_elastic == "1": cls.es = ElasticService(elastic_host, elastic_port, elastic_username, elastic_password) cls.es.create_index(cls.index_name)
def main(): # *** INITIALIZATION PHASE *** ## set constant variables traffic_distribution_per_cos = [COS0, COS1, COS2] ## import data & preprocessing geant_traffic_data = import_csv(TRAFFIC_FILE) throughput = preprocess_data(geant_traffic_data) ## setup a traffic generator tg = TrafficGenerator(throughput, traffic_distribution_per_cos) ## initialize variables for plots estimated_tot_throughput = np.array([]) estimated_cos0_percent = np.array([]) estimated_cos1_percent = np.array([]) estimated_cos2_percent = np.array([]) # *** EXECUTION PHASE *** x = 1 for t in range(len(throughput)): traffic_t = tg.traffic[t] oom_t = morris_algo(traffic_t) sample_t = vitter_algo(traffic_t, SLOTS) estimated_results_t = estimate_throughput_and_cos(sample_t, oom_t) #! TROUBLESHOOTING PURPOSE #print("{} --> ESTIMATED = {}K || REAL = {}K || OOM RATIO (real/est) = {} || SAMPLING RATIO (slots/real) {} || COS DISTRO {}".format(t,estimated_throughput_t[0]//10**3, throughput[t]//10**3, #get_digits(len(traffic_t))/oom_t, SLOTS/len(traffic_t), "{}|{}|{}".format(int(100*estimated_throughput_t[1]/estimated_throughput_t[0]),int(100*estimated_throughput_t[2]/estimated_throughput_t[0]),int(100*estimated_throughput_t[3]/estimated_throughput_t[0])))) # SAVE DATA FOR PLOTS estimated_tot_throughput = np.append(estimated_tot_throughput, estimated_results_t[0]) estimated_cos0_percent = np.append(estimated_cos0_percent, estimated_results_t[1]) estimated_cos1_percent = np.append(estimated_cos1_percent, estimated_results_t[2]) estimated_cos2_percent = np.append(estimated_cos2_percent, estimated_results_t[3]) # PROGRESS BAR if t == (x * int(len(throughput) / 100)): print("EXECUTION PROGRESS IS @ {}%: {}".format(x, x * '=' + '>')) x += 1 # *** PLOT RESULTS PHASE *** ## THROUGHPUT fig = plt.figure(1, figsize=(10, 10)) fig.suptitle('Big Data Network Analyzer (BDNA)', fontsize=16) plt.xlabel('Time [s]') plt.ylabel('Throughput [bit/s]') plt.title( 'TOTAL THROUGHPUT ESTIMATION - MEMORY = {}% OF INTERFACE CAPACITY'. format(PERCENTAGE)) xdata = np.arange(SECONDS_OF_TRAFFIC) plt.plot(xdata, estimated_tot_throughput, 'rx') plt.plot(xdata, throughput, 'b--', linewidth=2) plt.show() ## COS DISTRIBUTION fig = plt.figure(2, figsize=(10, 10)) fig.suptitle('Big Data Network Analyzer (BDNA)', fontsize=16) plt.xlabel('Time [s]') plt.ylabel('COS PERCENTAGE [%]') plt.title( 'COS DISTRIBUTION ESTIMATION - MEMORY = {}% OF INTERFACE CAPACITY'. format(PERCENTAGE)) xdata = np.arange(SECONDS_OF_TRAFFIC) # COS0 plt.plot(xdata, estimated_cos0_percent, 'bx') real_cos0_percent = np.array(SECONDS_OF_TRAFFIC * [COS0]) plt.plot(xdata, real_cos0_percent, 'r--', linewidth=2) # COS1 plt.plot(xdata, estimated_cos1_percent, 'yx') real_cos1_percent = np.array(SECONDS_OF_TRAFFIC * [COS1]) plt.plot(xdata, real_cos1_percent, 'r--', linewidth=2) # COS2 plt.plot(xdata, estimated_cos2_percent, 'gx') real_cos2_percent = np.array(SECONDS_OF_TRAFFIC * [COS2]) plt.plot(xdata, real_cos2_percent, 'r--', linewidth=2) plt.show()