The objective of this assignment is to become familiar with Networking teminology, the process of analyzing networks by calculating delays and throughput, and the available networking tools.
This assignment focuses on material from K&R Chapter 1.
You may also find the following resources useful:
Kurose & Ross, Ch 1. P16 (page 73)
Kurose & Ross, Ch 1. P18 (page 73)
Kurose & Ross, Ch 1. P25 (page 75)
Kurose & Ross, Ch 1. P28 (page 75)
For this assignment, you will need access to a UNIX command line. They are available on Linux and Mac OS X. If you use Windows, you will have to connect to csgateway.clarku.edu using PuTTY, and you may do so from your own computer.
All the commands to be used in this assignment are denoted like
command to run. It is understood that an ENTER key
should be pressed when you finish typing a command. You will not be
reminded again to hit the ENTER key.
ssh user@csgateway.clarku.edu and make sure you
replace user with your actual CS account
login name.The nc program interfaces TCP or UDP sockets with
the terminal, so you can craft requests and observe responses at the
application protocol level (e.g. HTTP). It has many uses; we will
explain a few specific uses later. View the man page (man nc) for
useful help, or google "netcat".
cURL is a command line tool to make HTTP requests to a web server without using a web browser. It is higher level than nc, in that it guarantees that you will be making a well-formed HTTP request.
All commands you used and the output produced for the following tasks should be saved in an document named username-hw02.doc, or if you want to use NotePad++ on Windows or Text Editor on Linux, save it as a text document named username-hw02.txt. Do the task in the UNIX command line prompt, and copy and paste the command you used and its output into the document. Each command will produce multiple lines of output. Answer all questions in the homework document as well.
When you enter a URL in the browser, it starts by looking up the
hostname part of the URL and finding its IP address. This only
needs to be done once every few hours, as the hostname-to-address
mapping seldom changes. An IP address is a group of four numbers
with periods between them, e.g. 123.45.67.89.
Use the host command, find out the IP address of the
following hosts or web sites.
After the IP address of a host is determined, you can make
connection to that computer if you know how to talk a common
protocol. At the command prompt, once you enter the
command nc -v -n ip-address port you
will immediately begin talking to the host until
the command prompt appears again. Perform the following
tasks using nc and the IP addresses for the same hosts
you figured out in the last part.
Connect to csgateway.clarku.edu port 22 using the IP address you can figure out using the same technique as in Required Task 1. Port 22 is the port used by the SSH service. Upon connection, it will tell you the version of SSH csgateway is running. Just hit ENTER, and SSH should tell you "Protocol mismatch" and then you will see the bash prompt again. What is the version of the SSH service?
Connect to csgateway.clarku.edu port 25. You can try a few commands on port 25 (eg. HELO yourname), but you probably won't get any response. What protocol is running on this port? (You can't do much useful here without authenticating)
Connect to www.cs.clarku.edu port 80. This is the port used by the HTTP service. Once connected, it will not show any prompt this time. Repeat the connection as necessary for the following requests. For each request, explain the resulting HTTP response and what happens.
/~jmagee/test.html./~jmagee/test.txt./~jmagee/nosuchfile.html./~jmagee/privatefile.html.In practice, you can give nc DNS name of the host
instead if you remove the -n flag from the command. It
will perform the DNS lookup for you. We may also omit the
-v option, which will suppress the "Connection to
... succeeded!" message, nor will it show you "Connection refused"
when there is a problem.
We will now use curl to make HTTP requests for us.
This simplifies a lot of typing. The command curl
-i http://hostname/path will connect
to hostname at port 80 and make the request
for path on the host, using HTTP/1.1, a more
recent version of HTTP than the HTTP/1.0 we used in last part.
Visit the following URLs, first with a web browser, then
with curl.
Except for the file extension, the content of the two URLs are identical. The web browser renders hello.html as HTML, but hello.txt as text with visible HTML markup.
When using curl with the -i option, you also see the HTTP response
headers before the content of the files are transmitted. Which of
these headers might help the web browser decide how to present the
URL, as HTML or as plain text?
curl to make a request for the Coca Cola page object with the URL https://graph.facebook.com/cocacola .
How many "likes" does Coca Cola have? How could you write a program to find this automatically (very high level pseudocode, assume your program can use curl).
Note: They seem to have updated the API since last time, requiring some authentication token. If you find a way around this please post on the facebook group. If you cannot do it with curl, use the Facebook API Explorer to see what you can access.
Submit your username-hw02.doc or username-hw02.pdf or username-hw02.txt file with the command outputs and the answers to these questions on Moodle by the due date and time.
Refer to the grading criteria file: hw02.criteria.
Cooperation is recommended in understanding programming concepts and system features. But the actual solution of the assignments including all programming must be your individual work. For example, copying without attribution any part of someone else's program is plagiarism, even if you have modified the code. The University takes acts of cheating and plagiarism very seriously.