0% found this document useful (0 votes)
137 views6 pages

Homework3 Solutions

The document contains a homework assignment with 3 questions about internet protocols: 1) Analyzing sample socket API code for a UDP server. 2) Describing an HTTP request and response, including cache policies and page load times using persistent vs non-persistent connections. 3) Explaining DNS queries to different name server types and how DNS handles message loss.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views6 pages

Homework3 Solutions

The document contains a homework assignment with 3 questions about internet protocols: 1) Analyzing sample socket API code for a UDP server. 2) Describing an HTTP request and response, including cache policies and page load times using persistent vs non-persistent connections. 3) Explaining DNS queries to different name server types and how DNS handles message loss.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

IK2218 Protocols and Principles of the Internet

EP2120 Internetworking
Homework 3

Solutions due: 17:00, October 10, 2022


Review due: 17:00, October 12, 2022

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, ...);
while (true) {
recvfrom(s, ...);
if (fork() == 0) {
ProcessRequest(...);
sendto(s, ...);
exit();
}
}

(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. Give an explanation (5 p)
why the designer of this particular application still may have decided to use it.

Solution:
(a) It is a server (since it calls bind, and receives data before it sends). There are
no calls to listen() or accept(), which are mandatory for a TCP server. Hence,
it is a UDP server.

(b) Connection-less, concurrent communication. (The concurrency comes from the


fact that a child process is created through fork() for each message received.)
(c) Presumably it takes a considerable amount of time to process each message.
By creating a new process for each received message, the server does not need
to wait for one message to be processed before it can deal with the the next.
Hence, it seems that the application has requirements on how long time it may
take to process a message from a client.
Grading notes: the answer should demonstrate an understanding of the rea-
sons for chosing a concurrent design, namely that there is a need to process
several messages concurrently. If the solution does not indicate such an un-
derstanding, zero points should be given.)

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 /feathers/swordfish.html HTTP/1.1


Host: www.duck.org
Connection: keep-alive
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

Page 1 of 5
(a) Which web document does the browser request? Answer by giving the URL. The (5 p)
answer should be a complete and correct URL.
(b) Describe the TCP connection policy that the client requests. (2 p)
(c) The server gives the following response: (3 p)

HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sun, 20 Sep 2020 12:34:56 GMT
Server: Apache/2.2.3 (Red Hat)
Content-Length: 286
Cache-control: public, max-age=600
Keep-Alive: timeout=8, max=120
Content-Type: text/html; charset=utf-8

more data...
Describe the TCP connection policy with which the server responds.
(d) Is the returned object cacheable? If so, describe how it may be cached. (5 p)
(e) Assume that the web object that the client fetches is an HTML file that references (15 p)
four other web objects (which do not, in turn, use any further web objects).
The browser can use two different strategies to speed up loading the page: 1) mul-
tiple non-persistent connections in parallel, and 2) a single persistent connection
with pipelining. For each of the two cases, find the time it takes from that the user
clicks on the link until the web page can be presented on the screen. That is, the
total time it takes to fetch all objects that are needed for the page.
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 down a TCP connection (it takes place in the background).
(f) Page load time is important on the web, but it is not the only thing that matters. (5 p)
Not considering page load time performance, give two advantages of persistent
connections over non-persistent connections.

Solution:
(a) http://www.duck.org/feathers/swordfish.html The answer needs to be exactly
like this for full score, with two exceptions: no deduction in points for answer-
ing with https instead of http, or for including port 80 in the URL.
(b) The client requests a persistent connection – that the TCP connection should
be kept open so that it can be reused for several HTTP request/response
transactions.
(c) The server agrees to a persistent connections, which may be used for 120
requests at the most, and with a connection lifetime of 8 seconds. The exact
meaning of the timeout parameter is that it is the minimum amount of time
that an idle connection has to remain open. However, that level of detail is not
required in the answer. It is sufficient that the answer demonstrates a basic
understanding that the timeout parameter controls connection lifetime.
(d) Yes, the object is cacheable, both by browsers and proxies (that is what “pub-
lic” means). The object may be cached for 600 seconds at the most. Both
aspects – where and for how long – need to be considered for full score.
(e) 1) 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.

Page 2 of 5
2) 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.
(f) • Each connection uses system resources (memory, CPU, etc). So an ad-
vantage with the persistent connection strategy is that it uses less system
resources.
• TCP congestion control is more effective with long-lived TCP connections
than with short-lived connections.
• A long-lived connection has time to grow a larger transmission window,
so transfers over persistent connections are more efficient.
A solution should mention two advantages. These are probably the main ad-
vantages, but there could be other. However, a claimed advantage has to be
relevant and significant in order to render any points.

3. 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 @193.0.14.129 www.kth.se


dig @213.108.25.4 www.kth.se
dig @130.235.20.5 www.kth.se
dig @130.237.72.200 www.kth.se
(a) Explain the results: Describe the responses from the four DNS servers. What do (20 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) DNS uses UDP, not TCP. Unlike TCP, UDP does not guarantee delivery of data. (5 p)
What happens if a DNS message (query or response) is lost? Is it a problem, and
if so, how is it handled?

Solution:
(a) 1. The first query (193.0.14.129) is to a root server, and gives the TLD
servers for the “se” top-level domain.
2. The second query (213.108.25.4) is to a TLD server for the “se” top-
level domain. The response contains the (authoritative) name servers for
“kth.se”.
3. The third query (130.235.20.5) is to an authoritative server for “kth.se”,
and gives the IP address of the web server.
4. The fourth query (130.237.72.200) is to a resolver, and gives the IP addess
of the web server. You can tell that it is a resolver since it is the only
nameserver of the four that offers recursion (“ra” flag is set). This one

Page 3 of 5
turns out to be a bit tricky though – if you access it from outside KTH,
the answer will be empty, and the recursion flag will not be set, since
the resolver’s service is not open outside KTH. The last part is an extra
difficulty that was not intentional. No points should be deducted for not
answering this correctly. However, two extra points can be awarded to
students that manage to figure this out.
(b) The DNS client has a timer. If it does not receive a response before the timer
expires, the client retransmits the query.

4. DHCP (15 p)
Consider the following scenario, where a DHCP client arrives and requests an IP address
from the DCHP server.

In the simplest case, four DHCP messages will be exchanged according to the figure
below. Name these four DHCP messages (message type) and fill in the missing fields
in each message. You can assume that the subnet to which the DHCP client arrives
is a /24 network and that all addresses below 223.1.2.10 are occupied. Based on that,
you can let the DHCP server hand out a suitable IP address. You also have to select
reasonable transaction IDs.

Solution:

Page 4 of 5
5. IPv6 Autoconfiguration (10 p)
In IPv6 stateless autoconfiguration, the client can create an IP address based on the
client’s MAC address, instead of requesting the IP address from a DHCP server. Discuss
advantages and problems with using an IPv6 address generated from the MAC address,
and explain how IPv6 privacy extensions address the problems.

Solution: A MAC-derived IPv6 address is a straight-forward way to generate a


unique IP address automatically and L3/L2 address translation can be done locally
by the sender (no ARP needed). The problem is that the MAC address reveals
information about the interface card, such as identity and vendor of the interface
card so that e.g. potential bugs could be exploited. IPv6 privacy extensions solve
this problem by using a randomly assigned interface ID instead and this number
can change over time (temporal address).

Page 5 of 5

You might also like