Last Updated: 2021-04-25 Sun 23:30

CSCI 4061 HW13: HTTP Client

CODE DISTRIBUTION: hw13-code.zip

CHANGELOG: Empty

1 Rationale

Sockets in Unix allow communication with distant computers using familiar I/O techniques. This HW briefly covers basics of socket communication and a simple protocol for retrieving web pages.

1.1 Associated Reading

  • Stevens & Rago Ch 16 discusses Sockets for network communication.
  • Robbins & Robbins discusses some network programming but unfortunately uses dated system calls inappropriate for IPv6 so does not provide as much information.

1.2 Grading Policy

Credit for this HW is earned by taking the associate Quiz which is linked under Gradescope. The quiz will ask similar questions as those that are present in the QUESTIONS.txt file and those that complete all answers in QUESTIONS.txt should have no trouble with the quiz.

See the full policy in the syllabus.

2 Codepack

The codepack for the HW contains the following files:

File Description
QUESTIONS.txt Questions to answer
Makefile Makefile to build programs below
http_get.c Problem 1 program using sockets to be analyzed
http_get_ssl.c Problem 2 program using sockets to be analyzed

3 What to Understand

Ensure that you understand

  • System calls to create and set up sockets that are connected to other machines
  • System calls to read and write socket data
  • Basics of the HTTP protocol used by the client

4 Questions

Analyze the provided files and answer the questions given in QUESTIONS.txt.

                           _________________

                            HW 12 QUESTIONS
                           _________________


- Name: (FILL THIS in)
- NetID: (THE kauf0095 IN kauf0095@umn.edu)

Write your answers to the questions below directly in this text file.
HW quiz questions will be related to the questions in this file.


Problem 1 `http_get.c'
======================

  Examine the source code for `http_get.c' and use it to contact a few
  hosts and files such as those shown at the top of the source.  Answer
  the following questions.


A
~

  - What is the full name of the that protocol is being employed?
  - Which port does the server listen on in this protocol?


B
~

  Describe which system calls are used to find an internet address,
  create a socket, and connect the socket to the found address.


C
~

  In this protocol, which entity, SERVER or CLIENT, sends data first?
  (Though you don't have access to a server code, this should be obvious
  from the structure of the client code).


D
~

  Does the protocol work in plain text (human readable) or in binary
  format (harder for humans to read directly).  Show examples/evidence
  to support your answer.


E
~

  Many protocols use /headers/ which are meant to convey information
  between the communication programs about the state of the
  communication but are NOT data that a program user would be interested
  in.  Show a few headers which appear in communication and describe
  what you infer their meaning to be.


F
~

  Something folks using `http_get' will notice is that many sites report
  something along the following lines:
  ,----
  | HTTP/1.1 301 Moved Permanently
  `----
  This is a common response to redirect requests to new locations of
  sites that have re-arranged.  It is also used to indicate a PROTOCOL
  CHANGE, that standard HTTP is not to be used any more. One will notice
  this when doing

  ,----
  | > http_get www-users.cs.umn.edu /~kauffman/congrads.txt
  `----

  Look for clues in the returned headers as to the new location of the
  page and the new and more complex protocol required to get its
  contents. Report your findings below.


Problem 2 `http_get_ssl.c'
==========================

  Examine the source code for `http_get_ssl.c' and use it to contact
  some of the same hosts that you did with `http_get.c'.  Answer the
  following questions.


A
~

  Determine what additional measures `http_get_ssl.c' employs to use a
  secure protocol for communication with a server.  Show the code block
  that accomplishes this (though no explanation is required).


B
~

  Aside from the code block that is added above to enable secure
  communication, are there any other large changes between `http_get.c'
  and `http_get_ssl.c' to implement the secure communication version?

Author: Chris Kauffman (kauffman@umn.edu)
Date: 2021-04-25 Sun 23:30