### Get client name and attache to the closest cache agent client_name = getMyName() ## Denote the server info # cdn_host = 'cmu-agens.azureedge.net' # cdn_host = 'aws.cmu-agens.com' cdn_host = 'rs-cdn.cmu-agens.com' video_name = 'BBB' ### Get the server to start streaming for i in range(10): ## Testing rtt based server selection selected_srv_addr = cdn_host + '/videos/' client_ID, CDN_SQS, uniq_srvs = dash_client(selected_srv_addr, video_name) all_srv_trace_data = {} for srv in uniq_srvs: ## ping all servers mnRTT = getMnRTT(srv) print mnRTT ## Traceroute all srvs cdnHops = get_hop_by_host(srv) print cdnHops traceData = {'RTT' : mnRTT, 'Hops' : cdnHops, 'TS' : time.time()} all_srv_trace_data[srv] = traceData.copy() writeJson("TR_" + client_ID, all_srv_trace_data)
if selected_method == "Adapt1": print "[Adapt1]: Use Adaptive CDN selection methods to select among Azure CDN and CloudFront!" adapt_cdn = {} adapt_cdn['Azure'] = cdns['Azure'].copy() adapt_cdn['CloudFront'] = cdns['CloudFront'].copy() updated_adapt_cdn = adaptive_client(adapt_cdn, video_name, selected_method) cdns['Azure'] = updated_adapt_cdn['Azure'].copy() cdns['CloudFront'] = updated_adapt_cdn['CloudFront'].copy() elif selected_method == "Adapt2": print "[Adapt2]: Use Adaptive CDN selection methods to select among Azure CDN and Rackspace!" adapt_cdn = {} adapt_cdn['Azure'] = cdns['Azure'].copy() adapt_cdn['Rackspace'] = cdns['Rackspace'].copy() updated_adapt_cdn = adaptive_client(adapt_cdn, video_name, selected_method) cdns['Azure'] = updated_adapt_cdn['Azure'].copy() cdns['Rackspace'] = updated_adapt_cdn['Rackspace'].copy() elif selected_method in cdns.keys(): print "Use " + selected_method + " CDN to stream video!" selected_url = cdns[selected_method]['url'] sqs = dash_client(selected_url, video_name, selected_method) cdns[selected_method]['QoE'] = sqs else: print "[Error] Selected method is not available: ", selected_method print "Updated CDN SQS: ", cdns try: with open(latest_config_file, 'w') as outfile: json.dump(cdns, outfile, sort_keys = True, indent = 4, ensure_ascii=False) except: os.remove(latest_config_file)
import os import logging import shutil import time from datetime import datetime from dash_client import * from test_utils import * from client_utils import * ### Get client name and attache to the closest cache agent client_name = getMyName() ## Denote the server info # srv_addr = 'www.cmu-agens.tk.global.prod.fastly.net/videos/' # srv_addr = '23.251.129.31' srv_addr = 'cache-01.cloudapp.net/videos/' # srv_addr = 'az833905.vo.msecnd.net/videos/' video_name = 'BBB' ### Get the server to start streaming for i in range(1): cur_ts = time.time() ## Testing rtt based server selection # waitRandom(1, 100) dash_client(srv_addr, video_name) #time_elapsed = time.time() - cur_ts #if time_elapsed < 600: # time.sleep(600 - time_elapsed)
if selected_method == "Adapt1": print "[Adapt1]: Use Adaptive CDN selection methods to select among Azure CDN and CloudFront!" adapt_cdn = {} adapt_cdn['Azure'] = cdns['Azure'].copy() adapt_cdn['CloudFront'] = cdns['CloudFront'].copy() updated_adapt_cdn = adaptive_client(adapt_cdn, video_name, selected_method) cdns['Azure'] = updated_adapt_cdn['Azure'].copy() cdns['CloudFront'] = updated_adapt_cdn['CloudFront'].copy() elif selected_method == "Adapt2": print "[Adapt2]: Use Adaptive CDN selection methods to select among Azure CDN and Rackspace!" adapt_cdn = {} adapt_cdn['Azure'] = cdns['Azure'].copy() adapt_cdn['Rackspace'] = cdns['Rackspace'].copy() updated_adapt_cdn = adaptive_client(adapt_cdn, video_name, selected_method) cdns['Azure'] = updated_adapt_cdn['Azure'].copy() cdns['Rackspace'] = updated_adapt_cdn['Rackspace'].copy() elif selected_method in cdns.keys(): print "Use " + selected_method + " CDN to stream video!" selected_url = cdns[selected_method]['url'] sqs = dash_client(selected_url, video_name, selected_method) cdns[selected_method]['QoE'] = sqs else: print "[Error] Selected method is not available: ", selected_method print "Updated CDN SQS: ", cdns try: with open(latest_config_file, 'w') as outfile: json.dump(cdns, outfile, sort_keys=True, indent=4, ensure_ascii=False) except: os.remove(latest_config_file)
# test_cdn_client.py # Chen Wang, Oct. 23, 2015 # [email protected] from utils.client_utils import * from dash_client import * from utils.test_utils import * ### Get client name and attache to the closest cache agent client_name = getMyName() if len(sys.argv) > 1: cdn_host = sys.argv[1] else: cdn_host = 'az.cmu-agens.com' if len(sys.argv) > 2: video_name = sys.argv[2] else: video_name = 'BBB' ## Denote the server info srv_addr = cdn_host + '/videos' ### Get the server to start streaming dash_client(srv_addr, video_name) if os.path.exists(os.getcwd() + "/tmp/"): shutil.rmtree(os.getcwd() + "/tmp/")