# Assignment 2 - Jessica Werner (2563327), Varada Sudharshana Kumar (7029511), Jan-Robin Aumann (2576766)
## Question 1
### (a)
Objects can either be sent via a persistent or non-persistent HTTP connection.
For the former, the server doesn't close the TCP connection to the requesting host after sending a response but instead keeps it open such that future requests and their responses are sent via that same TCP connection.
This saves on both response time and ressources: One RTT is saved by not having to create a TCP connection before requesting an object; we also save on both local and server side ressources by having only one open TCP connection instead of one per requested object.
For the latter we incur an additional RTT per object as compared to a persistent connection as well as additional open TCP connections for the benefits of being able to load multiple objects in parallel which can be beneficial (this concern was supposed to be addressed in HTTP/2 but adoption is slow, leading to HTTP/3 and QUIC which use UDP instead).
### (b)
In HTTP, a server answers requests without prior knowledge of client. This means it can keep no state to correlate separate requests (at least not as per standard).
This "problem" can be "solved" with ... Coooooookies!
Cookies are pieces of data sent between the server (who generated it in the first place) and a willing client to identify a given client for the sake of keeping state (often called a session).
### \(c\)
The Cache is (often) both closer to client than the actual application server and connected at a greater link speed. It can for example be as close as being in the same network and instead of being connected at the speed of the internet provider it is instead connected at local network speeds (10G/1G).
A cached page (or other assets like fonts/images/...) is great but the webserver can not serve a customized document that's specific to the user.
### (d)
```shell=telnet
telnet example.com 80
Trying 93.184.216.34...
Connected to example.com.
Escape character is '^]'.
GET / HTTP/1.1
host: example.com
HTTP/1.1 200 OK
Age: 475364
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Wed, 04 May 2022 15:28:29 GMT
Etag: "3147526947+ident"
Expires: Wed, 11 May 2022 15:28:29 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (bsa/EB11)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1256
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: -apple-system,
system-ui,
BlinkMacSystemFont,
"Segoe UI",
"Open Sans",
"Helvetica Neue",
Helvetica,
Arial,
sans-serif;
}
div {
width: 600px;
margin: 5em auto;
padding: 2em;
background-color: #fdfdff;
border-radius: 0.5em;
box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
}
a:link, a:visited {
color: #38488f;
text-decoration: none;
}
@media (max-width: 700px) {
div {
margin: 0 auto;
width: auto;
}
}
</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.</p>
<p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>
GET / HTTP/1.1
host: example.com
If-Modified-Since: Wed, 04 May 2022 15:28:30 GMT
HTTP/1.1 304 Not Modified
Age: 475393
Cache-Control: max-age=604800
Date: Wed, 04 May 2022 15:28:58 GMT
Etag: "3147526947+ident"
Expires: Wed, 11 May 2022 15:28:58 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (bsa/EB11)
Vary: Accept-Encoding
X-Cache: HIT
```
## Question 2
### (a)
While a (authoratative) nameserver is responsible for a certain set of domain names and responds to DNS requests for that set of domain names, a resolver only issues those requests to nameservers in order to get the IP address for a given domain name.
Of those resolvers, there are three different types:
* The stub resolver (typically) running on your local machine sends dns requests to the locally configured resolver on the behalf of any software running on the system (e.g. web browser).
* The forwarding resolver, typically found on the local router, acts as a proxy forwarding requests it receives on to a recursive resolver that has been configured and relays the received answer back to the stub resolver that queried it.
* The recursive resolver located at your ISP or DNS provider (Cloudflare, Google, ...) receives queries either from a forwarding or stub resolver. It then retrieves the information recursively by first querying a root server, then a top level domain server, a second level domain server and finally (one of) the authoratative nameserver(s) for that domain, returning that answer to the querying resolver.
### (b)
First the Client sends a recursive request to the local DNS server.
It in turn sends an iterative request to the root DNS server to find the tl-dns server for the .com tld.
Once it has that information it will use it to again iteratively query the tl-dns server for the authoratative nameserver of yahoo.com.
Lastly it iteratively queries dns.yahoo.com for the mail.yahoo.com address, returning the response to the client.
### \(c\)
Most implementations retry sending the packet a few times after a given timeout has been reached.
If there is still no result, a different nameserver can be tried.
## Question 3
### (a)
* A record
An A record maps a given domain name to an IPv4 address.
* AAAA record
An AAAA record maps a given domain name to an IPv6 address.
* CNAME record
A CNAME record is used to alias two domain names together. For example, if `www.example.com` and `example.com` point to the same application, you only need an A record for the latter and a CNAME record for the former aliasing it the the latter. That way you only have to maintain/update one A record if the IP address changes.
* NS rcord
A NS record is used to map a DNS Zone either to a list of authoratative nameservers or chains together DNS Zones to a zone tree.
* MX record
A MX record maps a given domain name to a list of email delivery agents.
### (b)
Often a given domain will have multiple A records pointing to different IP adresses for load balancing.
IPv6 adoption is fairly low (most domains don't have an AAAA record, instead returning their nameservers in the authority section).
MX records often contain five or more servers for redundancy to make sure mail arrives even in bigger outage scenarios.
Some people don't bother using a CNAME record to alias their domain and their domain with the www. prefix, like the LSF at `lsf.uni-saarland.de` ehhhh excuse me `www.lsf.uni-saarland.de` (most browsers will actually fill in the www. for you).
### \(c\)
The response time on the first run is 40ms, but any subsequent run is 0 msec because the results have been cached.
```shell=zsh
❯ dig stackoverflow.com a
; <<>> DiG 9.18.1 <<>> stackoverflow.com a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4556
;; flags: qr rd ad; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;stackoverflow.com. IN A
;; ANSWER SECTION:
stackoverflow.com. 0 IN A 151.101.129.69
stackoverflow.com. 0 IN A 151.101.193.69
stackoverflow.com. 0 IN A 151.101.65.69
stackoverflow.com. 0 IN A 151.101.1.69
;; Query time: 40 msec
;; SERVER: 172.17.64.1#53(172.17.64.1) (UDP)
;; WHEN: Thu May 05 18:57:40 CEST 2022
;; MSG SIZE rcvd: 116
❯ dig stackoverflow.com a
; <<>> DiG 9.18.1 <<>> stackoverflow.com a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7034
;; flags: qr rd ad; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;stackoverflow.com. IN A
;; ANSWER SECTION:
stackoverflow.com. 0 IN A 151.101.129.69
stackoverflow.com. 0 IN A 151.101.193.69
stackoverflow.com. 0 IN A 151.101.65.69
stackoverflow.com. 0 IN A 151.101.1.69
;; Query time: 0 msec
;; SERVER: 172.17.64.1#53(172.17.64.1) (UDP)
;; WHEN: Thu May 05 18:57:45 CEST 2022
;; MSG SIZE rcvd: 116
❯ dig stackoverflow.com a
; <<>> DiG 9.18.1 <<>> stackoverflow.com a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9324
;; flags: qr rd ad; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;stackoverflow.com. IN A
;; ANSWER SECTION:
stackoverflow.com. 0 IN A 151.101.129.69
stackoverflow.com. 0 IN A 151.101.193.69
stackoverflow.com. 0 IN A 151.101.65.69
stackoverflow.com. 0 IN A 151.101.1.69
;; Query time: 0 msec
;; SERVER: 172.17.64.1#53(172.17.64.1) (UDP)
;; WHEN: Thu May 05 18:57:45 CEST 2022
;; MSG SIZE rcvd: 116
❯ dig stackoverflow.com a
; <<>> DiG 9.18.1 <<>> stackoverflow.com a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29285
;; flags: qr rd ad; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;stackoverflow.com. IN A
;; ANSWER SECTION:
stackoverflow.com. 0 IN A 151.101.129.69
stackoverflow.com. 0 IN A 151.101.193.69
stackoverflow.com. 0 IN A 151.101.65.69
stackoverflow.com. 0 IN A 151.101.1.69
;; Query time: 0 msec
;; SERVER: 172.17.64.1#53(172.17.64.1) (UDP)
;; WHEN: Thu May 05 18:57:46 CEST 2022
;; MSG SIZE rcvd: 116
```