The goal of this lab assignment to allow you to explore computer networking by measuring bandwidth and latency using off-the-shelf tools and with your own custom Python code. Additionally, you will play an educational game to review the topics discussed this week.
For this assignment, record your work in a Jupyter Notebook and upload it to the form below by 11:59 PM Friday, March 29.
To help you get started, we have provided you with a starter notebook, which you can download and then use to record your answers. To utilize the starter notebook, download it to wherever you are running Jupyter Notebook and then use the Jupyter Notebook interface to open the downloaded file.
The starter notebook is already formatted for all the various sections you need to fill out. Just look for the red instructions that indicates were you need to write text or the cyan comments that indicate where you need to write code.
For the first activity, you are to measure the speed of various networking technologies by using the SpeedTest website. You are to use the following three connection types:
Wired connection from your laptop or a lab machine
Wireless connection from your laptop
Cellular connection from your phone (make sure you are using 4G/LTE and not WiFi)
To test the speed of each connection, simply go to the website on the
appropriate device: www.speedtest.net and hit the Go
button. This will
measure your Ping, Download, and Upload speeds to generate a
result such as:
Run the SpeedTest on each connection type a few times to get a representative sample and then complete the table below:
After completing the table above with your speed tests, analyze the results by answering the following questions:
Which connection type had the best latency? Explain.
Which connection type had the best bandwidth? Explain.
What difference (if any) did you notice between download and upload speeds? Discuss why this could be.
Overall, which connection type was the best? Explain.
For the second activity, you are to write two functions that you can
utilize to perform your own bandwidth and latency measurements.
The first is measure_bandwidth
, which uses requests to download data
from a web server, while the second is measure_latency
which uses a
low-level socket to connect to a remote server. For timing, we will use
Python's time module:
current_time = time.time()
The first function you need to complete is measure_bandwidth
:
def measure_bandwidth(url):
''' Measure bandwidth by doing the following:
1. Record start time.
2. Download data specified by url.
3. Record end time.
4. Compute bandwidth:
bandwidth = (Amount of Data / Elapsed Time) / 2**20
'''
return 0
This function measures bandwidth by downloading the specified url
using
the requests module and then computing the elapsed time using the time
module to record the start and stop times. Since we wish for the
measurements to be in terms of megabytes per second (MBps), we divide our
bandwidth by 2^20
.
Once you have completed this function, you are to write a for
loop that
measures the bandwidth of downloading each of the apps in the
URLS
dictionary:
URLS = {
'Discord': 'https://downloads.slack-edge.com/releases_x64/SlackSetup.exe',
'Slack' : 'https://dl.discordapp.net/apps/win/0.0.305/DiscordSetup.exe',
'Firefox': 'https://download-installer.cdn.mozilla.net/pub/firefox/releases/66.0/linux-x86_64/en-US/firefox-66.0.tar.bz2'
}
Your for
loop should emit output that looks like this:
Downloaded Discord with bandwidth of 5.10 MBps
Downloaded Slack with bandwidth of 40.35 MBps
Downloaded Firefox with bandwidth of 12.94 MBps
Record time using time.time()
.
Use requests.get
to download data.
To get the number of bytes we download we get check the length of the response objects content attribute.
Note, we do not need to save anything to disk.
The second function you need to complete is measure_latency
:
def measure_latency(domain):
''' Measure latency by doing the following:
1. Create streaming internet socket.
2. Record start time.
3. Connect to specified domain at port 80.
4. Record end time.
5. Compute latency:
latency = Elapsed Time * 1000
'''
This function measures latency by connecting to the specified domain
using the socket module and then computing the elapsed time using the
time module to record the start and stop times. Since we wish for the
measurements to be in terms of milliseconds (ms) we multiply our latency by
1000
.
Once you have completed this function, you are to write a for
loop that
measures the latency of connecting to each of the servers in the DOMAINS
list:
DOMAINS = [
'facebook.com',
'cnn.com',
'google.com',
'nd.edu',
'amazon.co.uk',
'baidu.com',
'europa.eu',
'yahoo.co.jp',
]
Your for
loop should emit output that looks like this:
Connection to facebook.com has latency of 11.63 ms
Connection to cnn.com has latency of 9.15 ms
Connection to google.com has latency of 13.30 ms
Connection to nd.edu has latency of 29.24 ms
Connection to amazon.co.uk has latency of 126.67 ms
Connection to baidu.com has latency of 203.80 ms
Connection to europa.eu has latency of 117.01 ms
Connection to yahoo.co.jp has latency of 166.58 ms
After writing the measure_bandwidth
and measure_latency
functions above
and testing them, answer the following questions:
Which applications had the best bandwidth? How do these bandwidth measurements compare to the ones you had in Activity 1? What explains the differences?
Which domains had the best latency? Which ones had the worst latency? What explains these differences?
For the last activity, you are play the following educational game created by the Office of Digital Learning as an experiment:
Once you have completed the game, please fill out the following survey.
Once you have completed your lab, submit your Jupyter Notebook using the form: