SchoolWork-LaTeX/计算机网络/平时作业/Chapter_2_HW.tex
423A35C7 5906ac1efc 重构目录层次
0-课程笔记
1-平时作业
2-实验报告
3-期末大作业
2024-09-02 18:32:58 +08:00

194 lines
9.1 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

\documentclass[全部作业]{subfiles}
\input{mysubpreamble}
\setcounter{chapter}{1}
\begin{document}
\chapter{应用层}
\begin{enumerate}
\cnitem[2] Consider an HTTP client that wants to retrieve a Web document at a given URL.
The IP address of the HTTP server is initially unknown. What transport and
application-layer protocols besides HTTP are needed in this scenario?
\begin{zhongwen}
首先客户端需要根据URL中的域名找到IP地址这需要DNS协议这是应用层协议而DNS协议是基于UDP协议的这是传输层协议。之后的HTTP协议如果不是HTTP3.0则是基于TCP协议的这是传输层协议如果是HTTP3.0则是基于UDP协议的这是传输层协议
总结如果是HTTP3.0则还需要应用层协议DNS传输层协议UDP
如果不是HTTP3.0则还需要应用层协议DNS传输层协议UDP、TCP。
\end{zhongwen}
\cnitem[8] Suppose within your Web browser you click on a link to obtain a Web page. The
IP address for the associated URL is not cached in your local host, so a DNS lookup is
necessary to obtain the IP address. Suppose that $n$ DNS servers are visited before your
host receives the IP address from DNS; the successive visits incur an RTT of
RTT$_1$, $\cdots$, RTT$_n$. Further suppose that the Web page associated with the link contains
exactly one object, consisting of a small amount of HTML text. Let RTT$_0$ denote the
RTT between the local host and the server containing the object. Assuming zero
transmission time of the object, how much time elapses from when the client clicks on
the link until the client receives the object?
\begin{zhongwen}
首先需要查询DNS由于DNS基于UDP因此需要$\sum_{i=1}^{n}RTT_i$的时间完成DNS查询。之后的网页应该是通过HTTP协议传输假定这里使用的不是HTTP 3.0那么这里是基于TCP协议的HTTP协议因此需要$RTT_0$的时间建立TCP连接之后请求和响应还需要一个$RTT_0$的时间。
因此总的时间为:
$$
\sum_{i=1}^{n}RTT_{i} + 2RTT_0
$$
\end{zhongwen}
\cnitem[9] Referring to Problem P8, suppose the HTML file references three very small
objects on the same server. Neglecting transmission times, how much time elapses
with
\begin{enumerate}
\item Non-persistent HTTP with parallel connections?
\begin{zhongwen}
每次请求和响应都需要开启一个新的TCP连接但这些连接可以同时进行因此需要的时间为
$$
\sum_{i=1}^{n}RTT_{i}+2RTT_0+2RTT_0=\sum_{i=1}^{n}RTT_i+4RTT_0
$$
\end{zhongwen}
\item Non-persistent HTTP with no parallel TCP connections?
\begin{zhongwen}
每次请求和响应都需要开启一个新的TCP连接而且这些连接不能同时进行因此需要的时间为
$$
\sum_{i=1}^{n}RTT_{i}+2RTT_0+3\times 2RTT_0=\sum_{i=1}^{n}RTT_i+8RTT_0
$$
\end{zhongwen}
\item Persistent HTTP?
\begin{zhongwen}
只开启一个TCP连接并且在这个TCP连接中HTTP请求互相不阻塞也就是说不需要等到前一个HTTP请求收到响应后再发送后一个HTTP请求由于忽略传输时间因此可以认为这三个请求同时发出同时得到响应。但这三个请求还是会依赖于HTML文件的响应因此在DNS查询后需要建立一次TCP连接之后在这个连接上进行两批HTTP的请求和响应因此总的时间为
$$
\sum_{i=1}^{n}RTT_{i}+RTT_0+2RTT_0=\sum_{i=1}^{n}RTT_{i}+3RTT_0
$$
\end{zhongwen}
\end{enumerate}
\cnitem[11] What is the difference between \textit{MAIL FROM}: in SMTP and \textit{From}: in the mail
message itself?
\begin{zhongwen}
SMTP中的\textit{MAIL FROM}表示发信的SMTP服务器的地址与发信的用户名而邮件信息中的\textit{From}是用户自己填写的内容。
也就是说一封邮件可能经过很多次转发而SMTP中的\textit{MAIL FROM}就是每次转发时直接发信的服务器和用户名,而邮件信息中的\textit{From}是写信的人。
当然,由于\textit{From}是可以由用户自己编辑的,所以用户也可以填写一个虚假的发信的邮箱地址,而用户就无法在\textit{MAIL FROM}上造假了除非用户用自己的SMTP服务器
\end{zhongwen}
\cnitem[15] Consider accessing your e-mail with POP3.
\begin{enumerate}
\item Suppose you have configured your POP mail client to operate in the
\textit{download-and-keep} mode. Complete the following transaction:
% 这种需要分栏的情况可以用minipage也可以用multicol具体哪个更好呢
\begin{minipage}[H]{0.3\linewidth}
\begin{minted}{text}
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: blah blah ...
S: ..........blah
S: .
?
?
\end{minted}
\end{minipage}
{\Huge$\longrightarrow$}
\begin{minipage}[H]{0.3\linewidth}
\begin{minted}{text}
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: blah blah ...
S: ..........blah
S: .
C: retr 2
S: blah blah ...
S: ..........blah
S: .
C: quit
S: +OK POP3 server signing off
\end{minted}
\end{minipage}
\item Suppose you have configured your POP mail client to operate in the
\textit{download-and-delete} mode. Complete the following transaction:
\begin{minipage}[H]{0.3\linewidth}
\begin{minted}{text}
S: ..........blah
S: .
?
?
\end{minted}
\end{minipage}
{\Huge$\longrightarrow$}
\begin{minipage}[H]{0.3\linewidth}
\begin{minted}{text}
S: ..........blah
S: .
C: dele 1
C: retr 2
S: blah blah ...
S: ..........blah
S: .
C: dele 2
C: quit
S: +OK POP3 server signing off
\end{minted}
\end{minipage}
\item Suppose you have configured your POP mail client to operate in the
\textit{download-and-keep} mode. Using your transcript in part (b), suppose you retrieve
messages 1 and 2, exit POP, and then five minutes later you again access POP to
retrieve new e-mail. Suppose that in the five-minute interval no new messages have
been sent to you. Provide a transcript of this second POP session.
\begin{minted}{text}
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: blah blah ...
S: ..........blah
S: .
C: retr 2
S: blah blah ...
S: ..........blah
S: .
C: quit
S: +OK POP3 server signing off
\end{minted}
\end{enumerate}
\item Consider query flooding, as discussed in Section 2.6. Suppose that each peer is
connected to at most $N$ neighbors in the overlay network. Also suppose that the
node-count field is initially set to $K$. Suppose Alice makes a query. Find an upper
bound on the number of query messages that are sent into the overlay network.
\begin{zhongwen}
每个节点最多向$N$个邻居节点发送查询信息但是不应向给自己发送查询信息的服务器发送查询信息因此除了Alice外每个邻居最多向$N-1$个邻居节点发送查询信息。而Alice因为是查询的发起者所以最多向$N$个邻居节点发送查询信息。
因此设Alice发起的查询为第$0$次查询,邻居发送给邻居的邻居为第$1$次查询,依此类推。设$a_i$ $(i\in \mathbb{N})$表示第$i$次查询时新收到查询的邻居数,则$a_{i+1}=a_i\times (N-1)$,且$a_0=N$。这样的查询最多执行$K$轮,那么最多发送的查询信息数也就是所有收到查询的邻居数的总和,因此只需要将每次查询时新收到查询的邻居数求和即可。
因此最多发送的查询信息数为:
$$
\underbrace{a_0+a_1+a_2+ \cdots}_{K个}=\underbrace{N+N(N-1)+N(N-1)^{2}+ \cdots }_{K个}
$$
可以看到$\{ a_n \}_{n=1}^{\infty}$构成等比数列,所求的值为它的前$K$项求和,因此上式可化为:
$$
\frac{N(1-(N-1)^{K})}{1-(N-1)}=\frac{N(1-(N-1)^{K})}{2-N}
$$
\end{zhongwen}
\end{enumerate}
\end{document}