Skip to content
Snippets Groups Projects
Commit 9a3a1d24 authored by Rowan Powell's avatar Rowan Powell
Browse files

New simulation and intraVM testing

parent 52a51fef
No related branches found
No related tags found
No related merge requests found
......@@ -44,9 +44,6 @@ Vagrant.configure("2") do |config|
# open TICK Kapacitor port
config.vm.network "forwarded_port", guest: 9092, host: 9092
# open local Telegraf port
config.vm.network "forwarded_port", guest: 8186, host: 8186
# install the TICK stack
config.vm.provision :shell, :path => 'scripts/influx/install-tick-stack-vm.sh'
......
#!/bin/bash
#/////////////////////////////////////////////////////////////////////////
#//
#// (c) University of Southampton IT Innovation Centre, 2018
#//
#// Copyright in this software belongs to University of Southampton
#// IT Innovation Centre of Gamma House, Enterprise Road,
#// Chilworth Science Park, Southampton, SO16 7NS, UK.
#//
#// This software may not be used, sold, licensed, transferred, copied
#// or reproduced in whole or in part in any manner or form or in or
#// on any media by any person other than in accordance with the terms
#// of the Licence Agreement supplied with the software, or otherwise
#// without the prior written consent of the copyright owners.
#//
#// This software is distributed WITHOUT ANY WARRANTY, without even the
#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#// PURPOSE, except where stated in the Licence Agreement supplied with
#// the software.
#//
#// Created By : Simon Crowle
#// Created Date : 03/11/2018
#// Created for Project : FLAME
#//
#/////////////////////////////////////////////////////////////////////////
echo Starting Telegraf services...
systemctl start telegraf
\ No newline at end of file
......@@ -28,7 +28,7 @@ echo Starting TICK stack services...
systemctl start influxdb
systemctl start kapacitor
systemctl start telegraf
#systemctl start telegraf
systemctl start chronograf
# test influx
......
File added
File added
import LineProtocolGenerator as lp
import time
import urllib.parse
import urllib.request
from random import random, randint
# Simulator for services
class sim:
def __init__(self, influx_url):
# requests per second for different quality levels
self.quality_request_rate = {"locA": [10, 20, 10], "locB": [5, 30, 5]}
self.influx_db = 'testDB'
self.influx_url = influx_url
# Teardown DB from previous sim and bring it back up
self._deleteDB()
self._createDB()
def run(self, simulation_length_seconds):
start_time = time.time()
current_time = int(time.time())
surrogate_services = [{'location': 'locA', 'cpu': 2, 'sfc': 'scenario1_template',
'sfc_i': 'Scenario1_Template_I1', 'sf_package': 'MS_STREAMING', 'sf_i': 'MS_STREAMING_1',
'mem': '8GB', 'storage': '1TB'},
{'location': 'locB', 'cpu': 4, 'sfc': 'scenario1_template',
'sfc_i': 'Scenario1_Template_I1', 'sf_package': 'MS_STREAMING', 'sf_i': 'MS_STREAMING_2',
'mem': '8GB', 'storage': '1TB'}
]
# Simulate surrogate services being asserted
for service in surrogate_services:
self._sendInfluxData(lp.generate_vm_config('starting', service['cpu'], service['mem'], service['storage'], current_time))
for service in surrogate_services:
self._sendInfluxData(lp.generate_vm_config('running', service['cpu'], service['mem'], service['storage'], current_time))
# Run simulation
for i in range(simulation_length_seconds):
for service in surrogate_services:
# Scale CPU usage on number of requests, quality and cpu allocation
cpu_usage = self.quality_request_rate[service['location']][0]
cpu_usage += self.quality_request_rate[service['location']][1]*2
cpu_usage += self.quality_request_rate[service['location']][2]*4
cpu_usage = cpu_usage/service['cpu']
cpu_usage = cpu_usage/100 # Transform into %
self._sendInfluxData(lp.generate_cpu_report(service['location'], service['sfc'], service['sfc_i'],
service['sf_package'], service['sf_i'],
cpu_usage, cpu_usage, current_time))
# Scale SENT/REC bytes on requests and quality
bytes = self.quality_request_rate[service['location']][0]
bytes += self.quality_request_rate[service['location']][1]*2
bytes += self.quality_request_rate[service['location']][2]*4
bytes_sent = 1024*bytes
bytes_rec = 32*bytes
self._sendInfluxData(lp.generate_network_report(bytes_rec, bytes_sent, current_time))
# Scale MPEG Dash on requests, quality, cpu usage
avg_response_time = randint(0, 5 * self.quality_request_rate[service['location']][0])
avg_response_time += randint(0, 10 * self.quality_request_rate[service['location']][1])
avg_response_time += randint(0, 15 * self.quality_request_rate[service['location']][2])
avg_response_time *= cpu_usage
peak_response_time = avg_response_time + randint(30, 60)
requests = sum(self.quality_request_rate[service['location']])
self._sendInfluxData(lp.generate_mpegdash_report('https://Netflix.com/scream', requests,
avg_response_time, peak_response_time, current_time))
# Add a second to the clock
current_time += 1000
end_time = time.time()
print("Simulation Finished. Start time {0}. End time {1}. Total time {2}".format(start_time,end_time,end_time-start_time))
def _createDB(self):
self._sendInfluxQuery('CREATE DATABASE ' + self.influx_db)
def _deleteDB(self):
self._sendInfluxQuery('DROP DATABASE ' + self.influx_db)
def _sendInfluxQuery(self, query):
query = urllib.parse.urlencode({'q': query})
query = query.encode('ascii')
req = urllib.request.Request(self.influx_url + '/query ', query)
urllib.request.urlopen(req)
def _sendInfluxData(self, data):
data = data.encode()
header = {'Content-Type': 'application/octet-stream'}
req = urllib.request.Request(self.influx_url + '/write?db=' + self.influx_db, data, header)
urllib.request.urlopen(req)
simulator = sim('http://localhost:8186')
simulator.run(180)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment