Monday, December 23, 2019

How to determine the round trip time between two geo coordinates?

I am solving a problem as follows:

Write a fully working program that takes two inputs:

a) The geographic coordinates to a customer somewhere on Earth. Give this location a name.

b) The geographic coordinates to two edge caches somewhere on Earth. Give each location a name.

The output is simple:

Provide name of the location that the customer would likely get a better experience from.

Extra1: What is the expected round trip time from the customer to that cache?

Extra2: What is the maximum expected bandwidth from the customer to that edge cache, given a bandwidth delay product of 10MB?

I have currently written a python program to calculate the Round trip time between my computer and two servers with URL Google.com and Facebook.com, which works well.

import time import requests bandWidthDelayProduct = 10 def calc_time(url): t1 = time.time() r = requests.get(url) t2 = time.time() diff = t2-t1 return diff def calc_bw(rtt): return bandWidthDelayProduct/rtt def better_experience(cacheLoc1, cacheLoc2): roundTripTime1 = calc_time(cacheLoc1) roundTripTime2 =calc_time(cacheLoc2) if(roundTripTime1 > roundTripTime2): print("The customer gets better experience from: " + cacheLoc2) print("The max BW from the customer to that end cache is: "+ str(calc_bw(roundTripTime2))) elif(roundTripTime1 < roundTripTime2): print("The customer gets better experience from: " + cacheLoc1) print("The max BW from the customer to that end cache is: "+ str(calc_bw(roundTripTime1))) else: print("The customer gets better experience both locations") print("The max BW from the customer to that end cache is: ", str(calc_bw(roundTripTime1))) customerLocation = 0 cacheLoccation1 = "http://www.google.com" cacheLocation2 = "http://www.facebook.com" better_experience(cacheLoccation1, cacheLoccation1) 

But my question is how to perform the same computation between 2 Geo Coordinates i.e, the customer and the edge cache. I am very new into CDN(content delivery network). If you can show how I can how I can do it, it would be very helpful. Please go easy on me.

Thank you so much.



No comments:

Post a Comment