ts = time.time() # expID = "exp" + str(exp_id) expID = str(int(ts)) clientID = client + "_" + expID ## Run baseline DASH client simple_dash(video, clientID, closest_srv_ip) ## Get Intrazone Candidate Servers cand1 = get_candidates(cache_agent, srvs_closest_zone, cache_agents, 2) ## Get Interzone Candidate Servers cand2 = get_candidates(cache_agent, srvs_closest_region, cache_agents, 2) ## Save candidate servers for the experiment candidatesFile = "./data/" + clientID + "_intra_CANDS.json" with open(candidatesFile, 'w') as outfile: json.dump(cand1, outfile, sort_keys = True, indent = 4, ensure_ascii = False) candidatesFile = "./data/" + clientID + "_inter_CANDS.json" with open(candidatesFile, 'w') as outfile: json.dump(cand2, outfile, sort_keys = True, indent = 4, ensure_ascii = False) ## Run Intra-zone server selection algorithms intra_clientID = clientID + "_intra" qas_dash_agent(intra_clientID, cache_agent, cand1, cache_agents, port, video) cqas_dash_agent(intra_clientID, cache_agent, cand1, cache_agents, port, video) ## Run Inter-zone server selection algorithms inter_clientID = clientID + "_inter" qas_dash_agent(inter_clientID, cache_agent, cand2, cache_agents, port, video) cqas_dash_agent(inter_clientID, cache_agent, cand2, cache_agents, port, video)
expID = 'exp5' clientID = client + "_" + expID ## The first candidate server is the closest server srvs_closest_region.remove(cache_agent) candidates = {} candidates[cache_agent] = cache_agents[cache_agent] ## The second candidate server is randomly selected from the same zone second_srv = random.choice(srvs_closest_region) candidates[second_srv] = cache_agents[second_srv] ## Save candidate servers for the experiment candidatesFile = "./data/" + clientID + "_CANDS.json" with open(candidatesFile, 'w') as outfile: json.dump(candidates, outfile, sort_keys=True, indent=4, ensure_ascii=False) ## Run QAS_DASH client qas_dash_agent(clientID, cache_agent, candidates, cache_agents, port, video) ## Wait 20 minutes between two types of clients time.sleep(600) ## Run CQAS_DASH client cqas_dash_agent(clientID, cache_agent, candidates, cache_agents, port, video)
## Run baseline DASH client simple_dash(video, clientID, closest_srv_ip) ## Get Intrazone Candidate Servers cand1 = get_candidates(cache_agent, srvs_closest_zone, cache_agents, 2) ## Get Interzone Candidate Servers cand2 = get_candidates(cache_agent, srvs_closest_region, cache_agents, 2) ## Save candidate servers for the experiment candidatesFile = "./data/" + clientID + "_intra_CANDS.json" with open(candidatesFile, 'w') as outfile: json.dump(cand1, outfile, sort_keys=True, indent=4, ensure_ascii=False) candidatesFile = "./data/" + clientID + "_inter_CANDS.json" with open(candidatesFile, 'w') as outfile: json.dump(cand2, outfile, sort_keys=True, indent=4, ensure_ascii=False) ## Run Intra-zone server selection algorithms intra_clientID = clientID + "_intra" qas_dash_agent(intra_clientID, cache_agent, cand1, cache_agents, port, video) cqas_dash_agent(intra_clientID, cache_agent, cand1, cache_agents, port, video) ## Run Inter-zone server selection algorithms inter_clientID = clientID + "_inter" qas_dash_agent(inter_clientID, cache_agent, cand2, cache_agents, port, video) cqas_dash_agent(inter_clientID, cache_agent, cand2, cache_agents, port, video)
# print "Failed to write file ", pingFile cache_agent = attach_cache_agent(cache_agent_rtts) print "=============== Cache Agent for Client: ", client, " is ", cache_agent, " ======================" expNum = 1 for i in range(1, expNum + 1): expID = 'exp' + str(i) candidate_srvs = random.sample(set(cache_agents.keys()), 2) candidates = {} for s in candidate_srvs: candidates[s] = cache_agents[s] clientID = client + "_" + expID ## Save candidate servers for the experiment candidatesFile = "./data/" + clientID + "_QAS_CANDS.json" #try: # cFile = open(candidatesFile, 'w') # json.dump(candidates, cFile, sort_keys = True, indent = 4, ensure_ascii = False) #except IOError: # print "Failed to write file ", candidatesFile with open(candidatesFile, 'w') as outfile: json.dump(candidates, outfile, sort_keys = True, indent = 4, ensure_ascii = False) print "Selected candidate servers for ", clientID, " are :" for srv in candidate_srvs: print srv qas_dash_agent(clientID, cache_agent, candidates, cache_agents, port, video) waitRandom(10, 1000)