IK2218 Protocols and Principles of the Internet
EP2120 Internetworking
Homework 3
Solutions due: 17:00, October 8, 2021
Review due: 17:00, October 13, 2021
i
1. Socket API (15 p)
The pseudo-code sample below (with most details omitted) describes an application
that uses the socket interface (API) for communication
s = socket(...);
bind(s, ...);
listen(s, ...);
while (true) {
t = accept(s, ...);
recv(t, ...);
ProcessRequest(...);
send(t, ...);
close(t);
}
(a) Is the sample code for a client or server? Does it use TCP or UDP? Explain your (5 p)
answer.
(b) The textbook gives two examples of communication using the socket interface: (5 p)
1) connection-oriented, concurrent communication, and 2) connectionless, iterative
communication. Characterize the communication in the sample code using the
same terminology.
(c) In practice, this kind of communication is not frequently used. What is the main (5 p)
limitation?
Solution:
(a) It is a TCP server. It does not initiate the communication itself; instead, it
waits to be contacted. Hence, it is a server. Only a TCP server uses listen()
and accept().
(b) Connection-oriented, iterative communication.
(c) c) The server can only deal with one client request at a time. (How severe
that limitation would be depends on the complexity of the request processing,
represented by the ProcessRequest() function.)
2. Web (35 p)
Suppose that you are using your web browser and click on a link on a web page, which
causes the following HTTP request to be sent:
GET /swordfish HTTP/1.1
Host: www.feathers.org
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5)
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
(a) Which web document does the browser request? Answer by giving the URL. The (3 p)
answer should be a complete and correct URL.
(b) Which version of HTTP is the browser using? What kind of connection is re- (3 p)
quested, persistent or non-persistent? (Note that the textbook does not cover
header fields related to persistence, so you may want to consult other resources,
on the Internet for example.)
Page 1 of 4
(c) The server gives the following response: (3 p)
HTTP/1.1 302 Found
Date: Fri, 13 Sep 2019 12:34:56 GMT
Server: Apache/2.2.3 (Red Hat)
Location: https://www.feathers.org/swordfish
Content-Length: 286
Connection: close
Content-Type: text/html; charset=iso-8859-1
more data...
Describe the TCP connection policy with which the server responds.
(d) The server seems to give a positive response (“302 Found”), but this is not the (6 p)
normal response for a successful request. Answer the following three questions:
1. Why does the server give this response?
2. What is the browser supposed to do?
3. Why do you think the server has been configured to respond in this way?
(e) Assume that you instead receive a “200 OK” response with an HTML object (20 p)
that contains three other objects (it could be a web page with three images, for
instance). How long time does it take from that you click on the link until the entire
document has been received, for the four cases below? Explain your solutions.
1. Non-persistent HTTP.
2. Non-persistent HTTP. The client can use multiple TCP connections in parallel,
as many as needed.
3. Persistent HTTP without HTTP pipelining.
4. Persistent HTTP with HTTP pipelining.
The round-trip time between client and server is RTT. Assumed that all objects
are very small, and the connection is fast, so transmission time is negligible, and
so is processing time on the server. Moreover, you need not consider the time it
takes to close a TCP connection (it takes place in the background).
Solution:
(a) http:/www.feathers.org/swordfish The answer needs to be exactly like this for
full score, with two exceptions: no deduction in points for answering with https
instead of http, or for including port 80 in the URL.
(b) HTTP version 1.1. The browser is requesting a persistent connection.
(c) The server accepts a non-persistent connection.
(d) 1. This response is a normal response when a page is moved.
2. The client is redirected to the new location, as specified by the “Location”
header, so the client should send another request for the new object.
3. In this case, the client is redirected from a non-encrypted connection
to an encrypted connection, i.e., from a URL with “http:” to a URL
with “https:”, so the server has been configured to enforce encrypted
communication.
(e) The transaction involves fetching the main HTML object, and then the three
objects it contains.
1. 1. 8 × RTT. First one TCP SYN/ACK and one HTTP request/response
for the main HTML object. Then, for each contained object, one TCP
SYN/ACK and one HTTP request/response.
Page 2 of 4
2. 4 × RTT. First one TCP SYN/ACK plus one HTTP request/response
for the main HTML object. Then the contained objects are fetched in
parallel, each with a TCP SYN/ACK and an HTTP request/response.
3. 5 × RT T One TCP SYN/ACK and then one HTTP request/response for
each object.
4. 3 × RT T . First one TCP SYN/ACK plus one HTTP request/response
for the main HTML object. Then the client uses HTTP pipelining and
sends requests for the contained objects back-to-back, without waiting
for responses in between. The responses are returned back-to-back.
Grading suggestions: The main thing here is to demonstrate an understanding
of how TCP SYN/ACK and HTTP request/response are combined. In which
order are they performed, and what can be done in parallel? Incomplete or
missing explanations render deduction in points.
3. Email (25 p)
Internet email consists of several components that have different functions. Consider
the case when Alice wants to send an email to Bob. The email will be transferred in
three steps, through an outgoing and an incoming mail server, before Bob reads the
mail.
(a) What is the purpose of the outgoing mail server? Discuss what would happen if (10 p)
it were removed, so that Alice’s user agent directly connects to the incoming mail
server. What would be the limitations (if any)?
(b) What is the purpose of the incoming mail server? Discuss what would happen if (10 p)
it were removed, so that the outgoing mail server connects directly to Bob’s user
agent. What would be the limitations (if any)?
(c) List the three transfer steps, and explain for each step what application-layer (5 p)
protocol(s) it uses.
Solution:
(a) If the outgoing mail server is removed, Alice’s UA needs to contact the incom-
ing mail server directly in order to send the mail. The incoming mail server
may not be able to receive the mail – it could be busy or otherwise unavailable
– and then Alice’s UA cannot send the mail, and has to wait until the incom-
ing mail server becomes available. Hence, the outgoing mail server offloads
Alice’s UA by queuing messages waiting to be sent. (An outgoing mail server
is also important for controlling the sending of mail from an organization. It
can control what clients are allowed to send mail as a way to prevent abuse,
spam for instance. This is not a required part of the solutions so there is no
reduction in points for not mentioning it.)
(b) The incoming mail server stores Bob’s mail, and Bob can access the mail
whenever he wants. If the server is removed, Bob has to be online in order to
receive mail. (It also means that Bob will store all mail on his computer, so
he cannot access his mail from another computer. (No reduction in points for
not mentioning this.)
(c) 1. From Alice to outgoing mail server: SMTP
2. From outgoing mail server to incoming mail server: SMTP
3. From incoming mail server to Bob: IMAP or POP (HTTP is also a valid
answer here, if Bob uses webmail)
Page 3 of 4
4. DNS (25 p)
You use the “dig” lookup tool to get the IP address of KTH’s web server “www.kth.se”.
You want to try different name servers, so you specify the DNS server as an argument to
dig (the server’s IP address prepended with ‘@’). You run the following three commands:
dig @192.36.135.107 www.kth.se
dig @192.36.148.17 www.kth.se
dig @130.237.72.250 www.kth.se
(a) Explain the results: Describe the responses from the three DNS servers. What do (15 p)
the responses say?
We distinguish between four kinds of name servers: root, TLD, authoritative, and
local. You can deduce just from studying the responses what kind of DNS server
it is (the flags are useful here, among other things). For each of the four cases,
describe the kind of name server that is responding to your query. Explain what
the response contains. Also, for each name server, explain whether or not the
answer contains the IP address you are looking for. You only need to discuss the
responses at a general level – you should not discuss or describe the details of the
messages, the different fields, their contents, etc. However, you probably need to
study the responses carefully in order to be able to explain them.
(b) Organizations often have multiple name servers for their domains. What is the (5 p)
purpose of having multiple name servers? How are they kept synchronized?
(c) It is sometimes useful to have more than one name in DNS for the same computer. (5 p)
Is it possible for a computer to have two names under different top-level domains?
For example, one name in the “com.” TLD and one in “se.”. If so, give an example
when this might be useful.
Solution:
(a) The first response (192.36.135.107) is from a TLD server for the “se” top-level
domain. The response contains the (authoritative) name servers for “kth.se”.
The second response is from a root server, and gives the TLD servers for the
“se” top-level domain. The last answer is from an authoritative server for
“kth.se”, and gives the IP address of the web server.
(b) Having multiple name servers is for redundancy. When an organization has
multiple name servers, there is one primary server and several secondary
servers. The zone file is updated on the primary server, and then the updates
are transferred automatically to the secondaries through “zone transfers”.
(c) It is perfectly legal to have names in different top-level domains. A web server
for the “feathers” company could have the names “www.feathers.com” and
“www.feathers.se”. When it gets a request to the name in the “se” domain,
it responds with a page in Swedish, otherwise in English. (Remember that
an HTTP request contains the host name in the “Host:” header field, so the
server can examine the header to see what host name was used.)
Page 4 of 4