A little networking
Upload via Moodle as: networking.pdf or .md or .txt
Goals
- Learn some basic networking vocabulary
- Use
ncas a client and a server - Use python's built-in HTTP server
- Use
curlas an HTTP client
Rubric
The questions
Keep your answers short, write them up, and submit them as described at the top of this page. Really truly, short and simple is sufficient!
Vocabulary. For each of the following terms, give a short definition of no more than 12 words.
- client
- server
- protocol
- TCP connection
- port
- well-known port
Common clients, servers, and protocols.
- List three clients that you use regularly (for different services).
- For each of those clients, name one protocol it supports.
- Name one server (the software, not the domain name) that supports the HTTP and HTTPS protocols. (Such servers are typically called "web servers".)
Simple client/server example. The daytime protocol is about as simple as internet protocols get. (1) The client establishes a TCP connection with the daytime server; (2) the server sends a string representing the current date and time back to the client; and (3) the server closes the connection.
Try it, like so.
- Either install
ncon your own computer or login to mantis, wherencis already installed. - Pick an IP address from this list of daytime servers.
- Execute the command
nc IP_OF_DAYTIME_SERVER DAYTIME_PORT(where you need to fill in the two command-line arguments in question).
Answer these questions.
- What is the well-known port for the daytime protocol?
- In the exercise described above, what software acts as the client?
- Either install
Using nc as both client and server.
- On whichever computer you're working with
nc(your own or mantis), open two terminals. - In one terminal, pick a port number between 8000 and 65000, and
execute
nc -l -p YOUR_PORT. Note for macOS: The syntax on macOS is different:nc -l YOUR_PORT(oh Apple, sometimes you're so annoying!). - In the other terminal, execute
nc localhost YOUR_PORT. - Type something in each terminal and hit Enter.
- When you're done playing around, hit Ctrl-C in both terminals.
Questions:
- What does the
-lstand for in the firstnccommand? - Which of the two
nccommands is acting as the server, and which is acting as the client, and how can you tell? - What IP address does
localhostcorrespond to? - If you replace "localhost" with that IP address in the exercise above, does it still work?
- On whichever computer you're working with
Talking to a web server, part 1
- Execute
curl https://jeffondich.com/. What do you see? (a summary is sufficient) - Execute
curl -v https://jeffondich.com/. You get some more stuff in addition to what you saw before. Summarize the new stuff. - In the previous question, you saw a "200" in the output. What is the role of that 200?
- Execute
curl -v http://jeffondich.com/. What do you get now, and why? - Execute
curl -v https://jeffondich.com/blahblahblah. What do you get now, and why?
- Execute
Talking to a web server, part 2
- Execute
nc cs208.jeffondich.com 80. What do you see? - Now (assuming the previous command is still running), type the following:
GET / HTTP/1.1 Host: cs208.jeffondich.com
NOTE: you need that blank line after the "Host" line.
What do you see now?
- What do you see if you do the same thing, but this time you do
/moose.htmlinstead of just/in theGETline? - What does a browser do differently from curl to make sure you see a picture of a moose? (Though "curl is text-only" is one answer, I'm looking for a different answer, about a step that Firefox or Chrome or Safari would take that curl does not when visiting this web page.)
- Execute
That's enough for now...
...but I encourage you to keep playing with this kind of thing. It's fun, and you can learn a lot!