Skip to content
Snippets Groups Projects
Commit f2724697 authored by Simon Crowle's avatar Simon Crowle
Browse files

Merge remote-tracking branch 'origin/integration' into integration

parents 60da1860 d38b9473
No related branches found
No related tags found
No related merge requests found
......@@ -43,3 +43,8 @@ This table is written in shorthand
| response | cpuUsage | ~#clients |
| SF | avg_response_time | ~#requests and ~quality |
| SF | peak_repsonse_time | ~#requests and ~quality |
### Scenario 2 - Two Dash Servers
# line protocol
# Method to create a full InfluxDB request statement (based on partial statement from client)
import uuid
from random import random, randint
def _generateClientRequest(cReq, id, time):
# Tags first
result = 'sid="' + str(id) + '",' + cReq
# Fields
# No additional fields here yet
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
return 'request,' + result
# Method to create a full InfluxDB response statement
def _generateServerResponse(reqID, quality, time, cpuUsage, qualityDifference):
# Tags first
result = ' '
# Fields
result += 'quality=' + str(quality) + ','
result += 'cpuUsage=' + str(cpuUsage) + ','
result += 'qualityDifference=' + str(qualityDifference) + ','
result += 'requestID="' + str(reqID) + '",'
result += 'index="' + str(uuid.uuid4()) + '"'
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
# print('response'+result)
return 'response' + result
def _generateNetworkReport(sum_of_client_quality, time):
# Measurement
result = 'net_port_io'
# Tags
result += ',port_id=enps03 '
# Fields
result += 'RX_BYTES_PORT_M=' + str(sum_of_client_quality * 32) + ","
result += 'TX_BYTES_PORT_M=' + str(sum_of_client_quality * 1024)
# Timestamp
result += ' ' + str(_getNSTime(time))
# Measurement
# print('network'+result)
return result
def _generateMpegDashReport(resource, quality, time):
# Measurement
result = 'mpegdash_service '
# Tags
#None
# Fields
requests = randint(10, 30)
avg_response_time = 50 + randint(0, 100) + randint(0, 10 * quality)
peak_response_time = avg_response_time + randint(30, 60) + randint(5, 10) * quality
result += 'cont_nav=\"' + str(resource) + "\","
result += 'cont_rep=' + str(quality) + ','
result += 'requests=' + str(requests) + ','
result += 'avg_response_time=' + str(avg_response_time) + ','
result += 'peak_response_time=' + str(peak_response_time)
# Timestamp
result += ' ' + str(_getNSTime(time))
#print(result)
return result
def _generateServerConfig(ID, location, cpu, mem, storage, time):
# metric
result = 'host_resource'
# Tags
result += ',slide_id=' + quote_wrap(ID)
result += ',location=' + quote_wrap(location)
result += ' '
# Fields
result += 'cpu=' + str(cpu)
result += ',memory=' + quote_wrap(mem)
result += ',storage=' + quote_wrap(storage)
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _generateVMConfig(state, cpu, mem, storage, time):
# metric
result = 'vm_res_alloc'
# Tags
result += ',vm_state=' + quote_wrap(state)
result += ' '
# Fields
result += 'cpu=' + str(cpu)
result += ',memory=' + quote_wrap(mem)
result += ',storage=' + quote_wrap(storage)
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _configure_port(port_id, state, rate, time):
# metric
result = 'net_port_config '
# Fields
result += 'port_id=' + quote_wrap('enps' + port_id)
result += 'port_state=' + quote_wrap(state)
result += 'tx_constraint=' + quote_wrap(rate)
result += ' '
# Time
result += ' ' + str(_getNSTime(time))
print(result)
return result
def _configure_service_function(state, max_connected_clients):
# measurement
result = 'mpegdash_service_config'
# tags
result += ',running='+quote_wrap(state)
result += ' '
# fields
result += 'max_connected_clients='+max_connected_clients
return result
def quote_wrap(str):
return "\"" + str + "\""
# InfluxDB likes to have time-stamps in nanoseconds
def _getNSTime(time):
# Convert to nano-seconds
return 1000000 * time
File added
......@@ -32,7 +32,7 @@ import datetime
import uuid
import urllib.parse
import urllib.request
import LineProtocolGenerator as lp
# DemoConfig is a configuration class used to set up the simulation
class DemoConfig(object):
......@@ -134,7 +134,7 @@ class DemoServer(object):
ids = ['A', 'B', 'C']
locations = ['locA', 'locB', 'locC']
for i, id in enumerate(ids):
server_conf_block.append(self._generateServerConfig(id,locations[i],8,'100G','1T',self._selectDelay(len(ids))))
server_conf_block.append(lp._generateServerConfig(id,locations[i],8,'100G','1T', self._selectDelay(len(ids))))
self._sendInfluxDataBlock(server_conf_block)
def configure_VMs(self):
print("Configuring VM nodes")
......@@ -144,6 +144,14 @@ class DemoServer(object):
self._sendInfluxDataBlock(VM_conf_block)
def configure_ports(self):
print("Configuring Servers")
server_conf_block = []
for i in range(0,10):
server_conf_block.append(lp._configure_port())
self._sendInfluxDataBlock(server_conf_block)
def shutdown_VMs(self):
print("Shutting down VM nodes")
VM_conf_block = []
......@@ -153,7 +161,7 @@ class DemoServer(object):
def _generateVMS(self,state, amount, datablock):
for i in range(0, amount):
datablock.append(self._generateVMConfig(state, 1, '100G', '1T', self._selectDelay(amount)))
datablock.append(lp._generateVMConfig(state, 1, '100G', '1T', self._selectDelay(amount)))
def iterateService( self ):
# The simulation will run through 'X' iterations of the simulation
......@@ -187,7 +195,7 @@ class DemoServer(object):
if ( cReq != None ):
clientsRequesting.append( client )
requestBlock.append( self._generateClientRequest(cReq) )
requestBlock.append( lp._generateClientRequest(cReq, self.id, self.currentTime) )
......@@ -202,20 +210,22 @@ class DemoServer(object):
# Generate some quality and delays based on the number of clients requesting for this iteration
qualitySelect = self._selectQuality( client.getQuality(), clientReqCount )
delaySelect = self._selectDelay( clientReqCount )
delaySelect = self._selectDelay( clientReqCount ) + self.currentTime
qualityDifference = client.getQuality() - qualitySelect
totalDifference+=qualityDifference
# print('totalDifference = ' + str(totalDifference) +'\n')
# print('totalDifference = ' + str(totalDifference) +'\n')
sumOfclientQuality+=client.getQuality()
#print('sumOfclientQuality = ' + str(sumOfclientQuality) + '\n')
# print('sumOfclientQuality = ' + str(sumOfclientQuality) + '\n')
percentageDifference=int((totalDifference*100)/sumOfclientQuality)
# print('percentageOfQualityDifference = ' + str(percentageDifference) + '%')
# print('percentageOfQualityDifference = ' + str(percentageDifference) + '%')
responseBlock.append( self._generateServerResponse( client.getLastRequestID(), qualitySelect, delaySelect, cpuUsagePercentage, percentageDifference ) )
SFBlock.append( self._generateMpegDashReport('https://netflix.com/scream',qualitySelect,delaySelect))
responseBlock.append(lp._generateServerResponse(client.getLastRequestID(), qualitySelect,
delaySelect, cpuUsagePercentage,
percentageDifference))
SFBlock.append(lp._generateMpegDashReport('https://netflix.com/scream', qualitySelect, delaySelect))
networkBlock.append(self._generateNetworkReport(sumOfclientQuality,delaySelect))
networkBlock.append(lp._generateNetworkReport(sumOfclientQuality, delaySelect))
# Iterate the service simulation
self.simIterations -= 1
self.currentTime += 1000 # advance 1 second
......@@ -226,7 +236,7 @@ class DemoServer(object):
self._sendInfluxDataBlock( responseBlock )
self._sendInfluxDataBlock( networkBlock )
self._sendInfluxDataBlock( SFBlock )
#print("Sending influx data blocks")
print("Sending influx data blocks")
return self.simIterations
......@@ -300,114 +310,6 @@ class DemoServer(object):
return result
# Method to create a full InfluxDB request statement (based on partial statement from client)
def _generateClientRequest( self, cReq ):
# Tags first
result = 'sid="' + str(self.id) + '",' + cReq
# Fields
# No additional fields here yet
# Timestamp
result += ' ' + str( self._getNSTime() )
# Measurement
return 'request,' + result
# Method to create a full InfluxDB response statement
def _generateServerResponse( self, reqID, quality, delay, cpuUsage, qualityDifference ):
# Tags first
result = ' '
# Fields
result += 'quality=' + str( quality ) + ','
result += 'cpuUsage=' + str(cpuUsage) + ','
result += 'qualityDifference=' + str(qualityDifference) +','
result += 'requestID="' + str( reqID ) + '",'
result += 'index="' + str( uuid.uuid4() ) + '"'
# Timestamp
result += ' ' + str( self._getNSTime(delay) )
# Measurement
#print('response'+result)
return 'response' + result
def _generateNetworkReport(self, sum_of_client_quality, delay):
# Tags
result = ',port_id=enps03 '
# Fields
result += 'RX_BYTES_PORT_M='+str(sum_of_client_quality*32)+","
result += 'TX_BYTES_PORT_M='+str(sum_of_client_quality*1024)
# Timestamp
result += ' ' + str( self._getNSTime(delay) )
# Measurement
#print('network'+result)
return 'net_port_io' + result
def _generateMpegDashReport(self, resource, quality, delay):
# Tags
result = ' '
# Fields
requests = randint(10,30)
avg_response_time = 50+randint(0,100)+randint(0,10*quality)
peak_response_time = avg_response_time + randint(30,60) + randint(5,10)*quality
result += 'cont_nav=\"'+str(resource)+"\","
result += 'cont_rep='+str(quality)+','
result += 'requests='+str(requests)+','
result += 'avg_response_time='+str(avg_response_time)+','
result += 'peak_response_time='+str(peak_response_time)
# Timestamp
result += ' ' + str( self._getNSTime(delay) )
# Measurement
#print('mpegdash_service'+result)
return 'mpegdash_service' + result
def _generateServerConfig(self, ID, location, cpu, mem, storage, delay):
# metric
result = 'host_resource'
# Tags
result += ',slide_id='+self.quote_wrap(ID)
result += ',location='+self.quote_wrap(location)
result += ' '
# Fields
result += 'cpu='+str(cpu)
result += ',memory='+self.quote_wrap(mem)
result += ',storage=' + self.quote_wrap(storage)
#Time
result += ' ' + str( self._getNSTime(delay) )
print(result)
return result
def _generateVMConfig(self, state, cpu, mem, storage, delay):
# metric
result = 'vm_res_alloc'
# Tags
result += ',vm_state='+self.quote_wrap(state)
result += ' '
# Fields
result += 'cpu='+str(cpu)
result += ',memory='+self.quote_wrap(mem)
result += ',storage=' + self.quote_wrap(storage)
#Time
result += ' ' + str( self._getNSTime(delay) )
print(result)
return result
def quote_wrap(self,str):
return "\""+str+"\""
# InfluxDB likes to have time-stamps in nanoseconds
def _getNSTime( self, offset = 0 ):
# Convert to nano-seconds
return 1000000 * ( self.currentTime + offset )
def _createDB( self ):
self._sendInfluxQuery( 'CREATE DATABASE '+ self.influxDB )
......
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