提交所有LaTeX文件。

This commit is contained in:
2024-09-02 17:47:53 +08:00
parent 10e6004666
commit b2fb901612
131 changed files with 17921 additions and 0 deletions

View File

@@ -0,0 +1,164 @@
\documentclass[全部作业]{subfiles}
\input{mysubpreamble}
\begin{document}
\chapter{计算机网络概述}
\begin{enumerate}
\cnitem[3]{Consider an application that transmits data at a steady rate (for example, the
sender generates an N-bit unit of data every k time units, where k is small and fixed).
Also, when such an application starts, it will continue running for a relatively long
period of time. Answer the following questions, briefly justifying your answer:}
\begin{enumerate}
\item Would a packet-switched network or a circuit-switched network be more
appropriate for this application? Why?
电路交换网络更合适,一方面,该应用以稳定的速率传输数据,因此只需要分配固定的频宽或时隙等即可方便实现电路交换的多路复用,而不需要分组交换;另一方面,该应用开始后会持续运行相当长的一段时间,因此不需要分组交换来应对突发情况,此时使用电路交换,不需要分片,也不需要处理,能达到更高的传输效率。
\item Suppose that a packet-switched network is used and the only traffic in this network
comes from such applications as described above. Furthermore, assume that the sum
of the application data rates is less than the capacities of each and every link. Is some
form of congestion control needed? Why?
不需要拥塞控制注意到“such applications”是复数说明可能存在多个这样的应用但由于应用传输速率小于每条连接的传输能力而拥塞控制是用于在应用传输速率大于连接的传输能力时降低应用传输速率的所以这时不需要拥塞控制。
\end{enumerate}
\cnitem[5]{This elementary problem begins to explore propagation delay and transmission
delay, two central concepts in data networking. Consider two hosts, A and B,
connected by a single link of rate $R$ bps. Suppose that the two hosts are separated by
$m$ meters, and suppose the propagation speed along the link is $s$ meters/sec. Host A is
to send a packet of size $L$ bits to Host B.}
\begin{enumerate}
\item Express the propagation delay, $d_{prop}$, in terms of $m$ and $s$.
$$
d_{prop}=\frac{m}{s}\ \mathrm{second}
$$
\item Determine the transmission time of the packet, $d_{trans}$, in terms of $L$ and $R$.
$$
d_{trans}=\frac{L}{R}\ \mathrm{second}
$$
\item Ignoring processing and queuing delays, obtain an expression for the end-to-end
delay.
$$
d_{end\_to\_end}=d_{prop}+d_{trans}=(\frac{m}{s}+\frac{L}{R})\ \mathrm{second}
$$
\item Suppose Host A begins to transmit the packet at time $t = 0$. At time $t = d_{trans}$,
where is the last bit of the packet?
最后一个bit刚刚被Host A发出但Host B还未收到。
\item Suppose $d_{prop}$ is greater than $d_{trans}$. At time $t = d_{trans}$, where is the first bit of the
packet?
第一个bit仍然在传播过程中未被Host B收到。
\item Suppose $d_{prop}$ is less than $d_{trans}$. At time $t = d_{trans}$, where is the first bit of the packet?
第一个bit已经被Host B收到了。
\item Suppose $s = 2.5 \cdot 10^{8}$,$L=100 \mathrm{bits}$,and $R=28 \mathrm{kbps}$. Find the distance $m$ so that $d_{prop}$ equals $d_{trans}$.
\begin{proof}[解]
\begin{zhongwen}
$$
\begin{aligned}
d_{prop}&=d_{trans} \\
\frac{m}{s}&=\frac{L}{R} \\
\frac{m}{2.5\cdot 10^{8}}&=\frac{100}{28\cdot 10^{3}} \\
m = 2.5\cdot 10^{8}\times \frac{100}{28\cdot 10^{3}} &= \frac{6250000}{7} \approx 892857.142857143 \quad (\mathrm{meters})\\
\end{aligned}
$$
\end{zhongwen}
\end{proof}
\end{enumerate}
\cnitem[10]{Consider the queuing delay in a router buffer (preceding an outbound link).
Suppose all packets are $L$ bits, the transmission rate is $R$ bps, and that N packets
simultaneously arrive at the buffer every $LN/R$ seconds. Find the average queuing
delay of a packet. (Hint: The queuing delay for the first packet is zero; for the second
packet $L/R$; for the third packet $2L/R$. The $N$th packet has already been transmitted
when the second batch of packets arrives.)}
\begin{proof}[解]
\begin{zhongwen}
$$
\begin{aligned}
&第i个包的排队延迟为(i-1)\frac{L}{R}每一批共N个包且各批之间互不影响 \\
&\therefore 一个包的平均排队延迟为: \\
&\frac{1}{N}\sum_{i=1}^{N}(i-1)\frac{L}{R}=\frac{L}{NR}\sum_{i=1}^{N}(i-1)=\frac{L}{NR}\frac{N(N-1)}{2}=\frac{L(N-1)}{2R} \\
\end{aligned}
$$
\end{zhongwen}
\end{proof}
\cnitem[12]{Consider a packet of length $L$ which begins at end system A and travels over one
link to a packet switch, and travels from the packet switch over a second link to a
destination end system. These two links are connected by one packet switch. Let $d_i$,
$s_i$, and $R_i$ denote the length, propagation speed, and the transmission rate of link $i$, for $i
= 1, 2$. The packet switch delays each packet by $d_{proc}$. Assuming no queuing delays, in
terms of $d_i$, $s_i$, and $R_i,(i = 1,2)$, and $L$, what is the total end-to-end delay for the packet?}
$$
d_{end\_to\_end} = d_{proc} + d_{prop}+d_{trans} = d_{proc}+\sum_{i=1}^{2}\frac{d_i}{s_i}+ \sum_{i=1}^{2}\frac{L}{R_i}
$$
Suppose now the packet is 1,000 bytes, the propagation speed on both links is
$2.5\cdot 10^{8}$ m/s, the transmission rates of all both links are 1 Mbps, the packet length is
1,000 bytes, the packet switch processing delay is 1 msec, the length of the first link is
4,000 km, and the length of the last link is 1,000 km. For these values, what is the
end-to-end delay?
$$
\begin{aligned}
d_{end\_to\_end} &= d_{proc} + d_{prop}+d_{trans} = d_{proc}+\sum_{i=1}^{2}\frac{d_i}{s_i}+ \sum_{i=1}^{2}\frac{L}{R_i} \\
&=1 \cdot 10^{-3}\mathrm{s} + \frac{4000 \cdot 10^{3} \mathrm{m}}{2.5\cdot 10^{8} \mathrm{m/s}}+\frac{1000\cdot 10^{3}\mathrm{m}}{2.5\cdot 10^{8}\mathrm{m/s}} + 2\times \frac{1000 \times 8\ \mathrm{bits}}{1\cdot 10^{6}\mathrm{bits/s}} \\
&=(1\cdot 10^{-3}+\frac{4000\cdot 10^{3}}{2.5\cdot 10^{8}}+\frac{1000\cdot 10^{3}}{2.5\cdot 10^{8}}+2\times \frac{1000\times 8}{1\cdot 10^{6}})\times 10^{3} \quad \mathrm{ms} \\
&= 37 \quad \mathrm{ms} \\
\end{aligned}
$$
\cnitem[17]{Consider the throughput example corresponding to Figure 1.16(b). Now
suppose that there are $M$ client-server pairs rather than 10. Denote $R_s$, $R_c$, and
$R$ for the rates of the server links, client links, and network link. Assume all other
links have abundant capacity and that there is no other traffic in the network besides
the traffic generated by the M client-server pairs. Derive a general expression for
throughput in terms of $R_s$, $R_c$, $R$, and $M$.}
\begin{figure}[h]
\centering
\includegraphics{imgs/2023-10-14-21-43-15.png}
\caption{Figure 1.16(b)}
\end{figure}
吞吐量为:
$$
\min \left\{ R_s,R_c,\frac{R}{M} \right\}
$$
\pagebreak[1]
\cnitem[25]{Consider sending a large file of $F$ bits from Host A to Host B. There are two links
(and one switch) between A and B, and the links are uncongested (that is, no
queuing delays). Host A segments the file into segments of $S$ bits each and adds 40
bits of header to each segment, forming packets of $L = 40 + S$ bits. Each link has a
transmission rate of $R$ bps. Find the value of $S$ that minimizes the delay of moving the
file from Host A to Host B. Disregard propagation delay.}
\begin{proof}[解]
\begin{zhongwen}
$$
设d_{all}(F,S,R)表示将文件从主机A发送到主机B的全部延迟即需要求解
$$ $$
\mathop{\arg\min}_{S}
\quad d_{all}(F,S,R)
$$ $$
\begin{aligned}
d_{all}(F,S,R) &= \frac{\left\lceil \frac{F}{S} \right\rceil \times (40+S)}{R} + \frac{(40+S)}{R}\\
&=\left(\left\lceil \frac{F}{S} \right\rceil + 1\right) \times \frac{40+S}{R} \\
&=\frac{1}{R}\left( 40\left\lceil \frac{F}{S} \right\rceil +S\left\lceil \frac{F}{S} \right\rceil +40+S \right) \\
\end{aligned}
$$ $$
一般情况下, S\ll F所以\left\lceil \frac{F}{S} \right\rceil \approx \frac{F}{S},所以
$$ $$
\begin{aligned}
d_{all}(F,S,R)&\approx \frac{1}{R}\left(40 \times \frac{F}{S}+S\times \frac{F}{S}+40+S\right)\\
&=\frac{1}{R}\left(S+\frac{40F}{S}+F+40\right) \\
&\geqslant \frac{1}{R}\left(2\sqrt{40F}+F+40\right) \\
&当且仅当S=\sqrt{40F}时,此不等式的等号成立 \\
\end{aligned}
$$ $$
\therefore S取\sqrt{40F}将文件从主机A发送到主机B的全部延迟最小。
$$
\end{zhongwen}
\end{proof}
\end{enumerate}
\end{document}

View File

@@ -0,0 +1,194 @@
\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}

View File

@@ -0,0 +1,229 @@
\documentclass[全部作业]{subfiles}
\input{mysubpreamble}
% \definecolor{shadecolor}{RGB}{255,255,255}
\setcounter{chapter}{2}
\begin{document}
\chapter{传输层}
\begin{enumerate}
\begin{shaded}
\cnitem[14] True or false?
\end{shaded}
\begin{enumerate}
\questionandanswer[]{Suppose Host A is sending a large file to Host B over a TCP connection. If the sequence number for a segment of this connection is m, then the sequence number for the subsequent segment will necessarily be $m+1$.}{
错误,下一次连接的序列号应为$m$加上这次发送的数据部分的字节数。
}
\questionandanswer[]{Host A is sending Host B a large file over a TCP connection. Assume Host B has no data to send Host A. Host B will not send acknowledgments to Host A because Host B cannot piggyback the acknowledgments on data.}{
错误即使没有数据要发送也要发送ACK报文否则就违背了可靠传输协议的原则。
}
\questionandanswer[]{Suppose that the last SampleRTT in a TCP connection is equal to 1 sec. The current value of Timeout Interval for the connection will necessarily be $\geqslant $ l sec.}{
正确,
$$
sRTT = 0.875sRTT + 0.125SampleRTT
$$
$$
DevRTT = 0.75DevRTT + 0.25\left\vert SampleRTT - sRTT \right\vert
$$
$$
Timeout = sRTT + 4 DevRTT
$$
若在某一时刻,假设$sRTT$$DevRTT$都非常接近0而最后一个$SampleRTT$为1秒则在下一时刻可以计算得到
$$
sRTT = 0.125\quad DevRTT = 0.25\quad Timeout = 0.125 + 4 \times 0.25 = 1.125
$$
$sRTT$增加或者$DevRTT$增加都会使Timeout增加因此$Timeout \geqslant 1.125$,所以$Timeout \geqslant 1$正确。
}
\questionandanswer[]{Suppose Host A is sending Host B a large file over a TCP connection. The number of unacknowledged bytes that A sends cannot exceed the size of the receive buffer.}{
正确。
}
\questionandanswer[]{The size of the TCP RcvWindow never changes throughout the duration of the connection.}{
错误TCP RcvWindow会根据接收端的接收能力变化。
}
\questionandanswer[]{The TCP segment has a field in its header for Rcvwindow.}{
正确。
}
\questionandanswer[]{Suppose Host A sends one segment with sequence number 38 and 4 bytes of data over a TCP connection to Host B. In this same segment the acknowledgment number is necessarily 42.}{
错误确认序号为下一个希望对方发送给自己的段序号而发送序号为自己发送给对方的段序号即前者为B维护的序号后者为A维护的序号这两者互不影响。
}
\end{enumerate}
\questionandanswer[2]{UDP and TCP use 1s complement for their checksums. Suppose you have the following three 8-bit bytes: 010101010111000001001100. What is the 1s
complement of the sum of these 8-bit bytes?(Note that although UDP and TCP use
16-bit words in computing the checksumfor this problem you are being asked to
consider 8-bit sums.) Show all work. }{
\begin{center}
\begin{tabular}{rr}
$ $ & $\ 0\ 1\ 0\ 1\ 0\ 1\ 0\ 1$ \\
$ $ & $\ 0\ 1\ 1\ 1\ 0\ 0\ 0\ 0$ \\
$+$ & $\ 0\ 1\ 0\ 0\ 1\ 1\ 0\ 0$ \\
\hline
直接求和 & $\ 1\ 0\ 0\ 0\ 1\ 0\ 0\ 0\ 1$ \\
进位加到末尾 & $\ 0\ 0\ 0\ 1\ 0\ 0\ 1\ 0$ \\
取反 & $\ 1\ 1\ 1\ 0\ 1\ 1\ 0\ 1$
\end{tabular}
\end{center}
所以8位校验和是11101101。
}
\questionandanswer[-]{Why is it that UDP takes the 1s complement of
the sum; that is, why not just use the sum? }{
使用反码后接收端校验时只需要把整个报文一起进行回卷求和再取反若结果为全1则通过校验而不需要先把报文中的校验和字段置为0再进行求和回卷取反。
}
\questionandanswer[-]{With the 1s complement scheme, how does the receiver detect errors?}{
接收端对整个报文和发送方进行相同的操作包括校验和本身即将报文分割成16位的字若报文为奇数个字节即分割到最后不足16位则将最后一个字节在末尾增加0补充到16位之后将这些16位的字求和将超过16位的高位部分即进位加到低16位的部分再进行取反此时结果如果为全1则说明校验正确否则说明校验错误。
}
\questionandanswer[-]{Is it possible that a 1-bit error will go undetected? How
about a 2-bit error?}{
1位的错误必定会被发现因为1位的错误会导致最终的校验结果中的其中一位的1变为0而2位的错误可能不被发现。
}
\questionandanswer[5]{Consider our motivation for correcting protocol rdt2.1. Show that the receiver, shown in the following figure, when operating with the sender shown in Figure 3.11, can lead the sender and receiver to enter into a deadlock statewhere each is waiting for an event that will never occur.
\noindent\includegraphics[width=0.9\linewidth]{imgs/2023-12-08-20-44-19.png}
\includegraphics[width=0.9\linewidth]{imgs/2023-12-08-20-46-36.png}
}{
首先rdt2考虑的是具有比特差错信道上的可靠数据传输也就是不会丢包。那么考虑如下情况发送端发送了序号0的包接收端接收校验正确返回ACK并转换状态但ACK出错发送端校验错误后重新发送序号0的包此时接收端已经处于等待序号1的包的状态它接收到序号0的包会返回NAK发送端收到NAK又会重发序号0的包这样就会导致死锁发送端一直发送序号0的包接收端一直返回NAK。
}
\questionandanswer[22]{Consider the GBN and SR protocols. Suppose the sequence number space is of
size k. What is the largest allowable sender window that will avoid the occurrence of
problems such as that in Figure 3.27 for each of these protocols?
\noindent\includegraphics[width=1\linewidth]{imgs/2023-12-08-21-18-23.png}
}{
对于GBN协议最大的发送端窗口大小为$2^{k}-1$对于SR协议最大的发送端窗口大小为$2^{k-1}$
}
\begin{shaded}
\cnitem[24]{P24.Consider transferring an enormous file of $L$ bytes from Host A to Host B. P24 MSS 为 536 字节)
}
\end{shaded}
\begin{enumerate}
\questionandanswer[]{What is the maximum value of $L$ such that TCP sequence numbers are not exhausted? Recall that the TCP sequence number field has 4 bytes.\label{a}}{
由于TCP协议的序号有4个字节那么序号范围就是$0\sim 2^{4\times 8}-1$因此如果需要TCP的序号不耗尽L最大取$2^{4\times 8} = 4294967296 = 4 \mathrm{Gi}$\\
1Gi=1024Mi=1048576Ki=1073741824
}
\questionandanswer[]{For the $L$ you obtain in (\ref{a}) , find how long it takes to transmit the file. Assume that a total of 66 bytes of transport, network, and data-link header are added to each segment before the resulting packet is sent out over a 10 Mbps link. Ignore flow control and congestion control so A can pump out the segments back to back and continuously.}{
一共要分$\displaystyle \frac{L}{MSS}=\frac{2^{32}}{536}$个段,每段的长度为$536+66 = 602$ (bytes),于是需要传输的数据的总长度为 ($\displaystyle \frac{2^{32}}{536}\times 602$) bytes。
所以传输文件需要的时间为
$$
\frac{\left( \frac{2^{32}}{536}\times 602 \right) \mathrm{bytes}}{10 \mathrm{Mbps}}=\frac{\left( \frac{2^{32}}{536}\times 602 \times 8\right) \mathrm{bit}}{(10\times 2^{20})\mathrm{bit}/\mathrm{s}} = \frac{1232896}{335} \approx 3680.28656716418\approx 61.338 分钟
$$
}
\end{enumerate}
\begin{shaded}
\cnitem[32]{Consider Figure 3.58.
\noindent\includegraphics[width=0.9\linewidth]{imgs/2023-12-09-09-01-01.png}
Assuming TCP \textbf{Reno} is the protocol experiencing the behavior shown above, answer the following questions. In all casesyou should provide a short discussion justifying your answer.
}
\end{shaded}
\begin{enumerate}
\questionandanswer[]{What is the value of Threshold \textit{ssthresh} at the 18th transmission round?
}{
第16轮时的拥塞窗口为42第17轮拥塞窗口和\textit{ssthresh}都变为42的一半即21第18轮\textit{ssthresh}未改变因此还是21。
}
\questionandanswer[]{What is the value of Threshold \textit{ssthresh} at the 24th transmission round?
}{
第22轮时的拥塞窗口为26第23轮\textit{ssthresh}变为26的一半即13第24轮\textit{ssthresh}未改变因此还是13。
}
\questionandanswer[]{Identify the intervals of time when TCP slow start is operating.
}{
即图中拥塞窗口大小指数增长的部分即第1到6轮、第23到26轮。
}
\questionandanswer[]{Assuming a packet loss is detected after the 26th round by the receipt of a triple duplicate ACKwhat will be the values of the congestion window size and of Threshold \textit{ssthresh}?
}{
第26轮原先的拥塞窗口大小为8\textit{ssthresh}为13收到三个重复ACK后后拥塞窗口大小变为8的一半即4\textit{ssthresh}也变为8的一半即4。
}
\questionandanswer[]{After the 16th transmission round,is segment loss detected by a triple duplicate ACK or by a timeout?
}{
第17轮的拥塞窗口变为第16轮的一半这说明发送端收到了三个重复的ACK。
}
\questionandanswer[]{After the 22nd transmission round, is segment loss detected by a triple duplicate ACK or by a timeout?
}{
第23轮的拥塞窗口变为1这说明发送端通过超时检测到了丢包。
}
\questionandanswer[]{Identify the intervals of time when TCP congestion avoidance is operating.
}{
即图中拥塞窗口大小线性增长的部分即第6到16轮、第17到第22轮。
}
\questionandanswer[]{What is the initial value of Threshold \textit{ssthresh} at the first transmission round?
}{
在第7轮时由慢启动状态转换到拥塞避免状态此时的拥塞窗口大小为32这说明第1轮初始的\textit{ssthresh}为32.
}
\questionandanswer[]{During what transmission round is the 70th segment sent?
}{
每一轮的拥塞窗口大小为这一轮发的段的数量,将它们按顺序列出来:
$$
1,2,4,8,16,32,33, \cdots \cdots
$$
则可以注意到前6轮发的段的数量为$1+2+4+8+16+32 = 63$前7轮发的段的数量为$1+2+4+8+16+32+33 = 96$,而$63<70<96$因此第70个段在第7轮发出。
}
\questionandanswer[]{Suppose TCP \textbf{Tahoe} is used (instead of TCP \textbf{Reno}), and assume that triple duplicate ACKs are received at the 16th round. What are the \textit{ssthresh} and the congestion window size at the 19th round?
}{
第16轮原先的拥塞窗口为42若使用TCP \textbf{Tahoe}则收到三个重复的ACK后第17轮的\textit{ssthresh}变为42的一半即21拥塞窗口大小变为1。因此第19轮的\textit{ssthresh}为21拥塞窗口大小为4。
}
\questionandanswer[]{Again suppose TCP \textbf{Tahoe} is used, and there is a timeout event at 22nd round.How many packets have been sent out from 17th round till 22nd round, inclusive?
}{
第17轮到第22轮的拥塞窗口大小依次为$1,2,4,8,16,21$每一轮的拥塞窗口大小为这一轮发的段的数量第22轮的超时事件只会影响第22轮以后的发的包的数量而不会影响第22轮发的包的数量因此从第17轮包括到22轮包括发的包的数量为
$$
1+2+4+8+16+21 = 52
$$
}
\end{enumerate}
\begin{shaded}
\item[] 【2010统考真题】主机甲和主机乙之间已建立一个TCP连接TCP最大段长为1000B。若主机甲的当前拥塞窗口为4000B在主机甲向主机乙连续发送两个最大段后成功收到主机乙发送的第一个段的确认段确认段中通告的接收窗口大小为2000B则此时主机甲还可以向主机乙发送的最大字节数是(B).
% \tabcolsep=2em
% \resizebox{\textwidth}{\linewidth}{
\noindent\begin{tabular*}{0.9\linewidth}{@{}@{\extracolsep{\fill}}llll@{}}
A. 1000 & B. 2000 & C. 3000 & D. 4000 \\
\end{tabular*}
\end{shaded}
\begin{zhongwen}
主机甲接收到主机乙发送的第一个段的确认段后发现接收窗口小于当前拥塞窗口因此窗口暂停滑动直到2000B接收窗口大小以前的数据都已确认而原先的发送窗口大小为4000B发送了两个最大段即2000B因此还可以发2000B的字节数。
所以此题选B。
\end{zhongwen}
\begin{shaded}
\item[] 【2020统考真题】若主机甲与主机乙建立TCP连接时发送的SYN段中的序号为1000,在断开连接时甲发送给乙的FIN段中的序号为5001则在无任何重传的情况下甲向乙已经发送的应用层数据的字节数为(C).
\noindent\begin{tabular*}{0.9\linewidth}{@{}@{\extracolsep{\fill}}llll@{}}
A. 4002 & B. 4001 & C. 4000 & D. 3999 \\
\end{tabular*}
\end{shaded}
\begin{zhongwen}
由题意可知是主机甲主动发起连接并且主机甲主动断开连接。主机甲发送的SYN段不应携带应用层数据之后主机乙向主机甲发送ACK+SYN主机甲再发送ACK段时可以携带应用层数据此时这个携带数据的ACK的序号为1001。而甲发送给乙的FIN段序号为5001也不应携带应用层数据所以携带应用层数据的字节序号为1001到5000因此发送的应用层数据的字节数为 $5000-1001+1=4000$
所以此题选C。
\end{zhongwen}
\begin{shaded}
\item[] 【2021统考真题】设主机甲通过TCP向主机乙发送数据部分过程如下图所示。甲在$t_0$时刻发送一个序号seq=501、封装200B数据的段,在$t_1$时刻收到乙发送的序号seq=601、确认序号ack\_seq=501、接收窗口rcvwnd= 500B的段则甲在未收到新的确认段之前可以继续向乙发送的数据序号范围是(A).
\begin{center}
\includegraphics[width=0.5\linewidth]{imgs/2023-12-09-10-33-30.png}
\end{center}
\noindent\begin{tabular*}{0.9\linewidth}{@{}@{\extracolsep{\fill}}llll@{}}
A. $501\sim 1000$ & B. $601\sim 1100$ & C. $701\sim 1000$ & D. $801\sim 1100$ \\
\end{tabular*}
\end{shaded}
\begin{zhongwen}
此题中,主机甲初始的发送窗口大小未知,那么只能根据甲在$t_1$时刻收到乙发送的段来判断此段中确认序号为501所以甲需要重发序号为501的段接收窗口为500B则说明甲在收到新的确认段之前最多只能发送500B的应用层数据因此甲可以继续向乙发送的数据序号范围是$501\sim 1000$
所以此题选A。
\end{zhongwen}
\end{enumerate}
\end{document}

View File

@@ -0,0 +1,234 @@
\documentclass[全部作业]{subfiles}
\input{mysubpreamble}
% \definecolor{shadecolor}{RGB}{255,255,255}
\setcounter{chapter}{3}
\setlist[1]{label=\arabic{enumi},listparindent=\parindent}
% 失败无法不使用临时文件将字符串转为token list
% \ExplSyntaxOn
% % \cs_set:Nn \myexpand:n {#1}
% % \debug_on:n {all}
% \RenewEnviron{zhongwen}{
% % \seq_new:N \temp
% % \tl_new:N \temp
% \tl_set:NV \temp {\BODY} % 看来LaTeX3也有字符串当作序列的概念
% \regex_replace_all:nnN{[^\x00-\xff]+}{\\textit\{\0\}}{\temp}
% % 应该可以使用\ifwindows和\iflinux来判断临时文件目录从而把临时文件放到临时文件目录里的
% % \immediate\openout0=\jobname.zhongwen
% % \immediate\write0{\temp}
% % \immediate\closeout0
% % \ExplSyntaxOff
% % % \input{\jobname.zhongwen}
% % \temp\csname \temp \endcsname
% % \exp_args:NV \myexpand:n {\temp}
% % \tl_use:N \temp
% % \temp
% % \exp_args_generate:n
% % \str_map_tokens:Nn
% \tlrep
% \tl_set:NV \l_tmpa_tl \temp
% \tl_use:N \l_tmpa_tl
% % \text_expand:n \temp
% % \ExplSyntaxOn
% % 好像没法删除临时文件,编译时会提示 rm: cannot remove '第十周作业.zhongwen': No such file or directory 但不影响编译,那还不如不删除了,少执行一个命令还能再快一点
% % \DeleteFile{\jobname.zhongwen}
% }
% \ExplSyntaxOff
\begin{document}
\chapter{网络层}
\begin{enumerate}
% \item[R13.]
\Rquestionandanswer[13]{Suppose Host A sends Host B a TCP segment encapsulated in an IP datagram.
When Host B receives the datagram, how does the network layer in Host B know it
should pass the segment (that is, the payload of the datagram) to TCP rather than to
UDP or to something else?}{
在IP协议的头部有一个字段指示了高层协议的类型主机B的网络层根据这个字段的值决定它应该把这个IP报文负载的段传递给哪个高层协议。
}
\Rquestionandanswer[16]{Suppose an application generates chunks of 40 bytes of data every 20 msec, and
each chunk gets encapsulated in a TCP segment and then an IP datagram. What
percentage of each datagram will be overhead, and what percentage will be
application data?}{
假设TCP层和IP层均没有额外的选项字段那么TCP的头部为20字节IP的头部为20字节应用层总长度也就是每个chunk为40字节那么每个报文的头部占比为$\frac{20+20}{20+20+40}\times 100\%=50\%$,应用层占比为$\frac{40}{20+20+40}\times 100\%=50\%$
}
\Rquestionandanswer[20]{Suppose you purchase a wireless router and connect it to your cable modem.
Also suppose that your ISP dynamically assigns your connected device (that is, your
wireless router) one IP address. Also suppose that you have five PCs at home that use
802.11 to wirelessly connect to your wireless router. How are IP addresses assigned to
the five PCs? Does the wireless router use NAT? Why or why not?}{
在没有进行特别设置的情况下五台个人电脑的IP地址由无线路由器提供并且是局域网IP地址但为了使局域网中的电脑能访问互联网路由器需要使用NAT网络地址转换将局域网内其他设备的IP和端口映射到路由器的IP和端口从而使局域网中的其他设备都能访问互联网。
}
\Rquestionandanswer[22]{Compare and contrast link-state and distance-vector routing algorithms.}{
\noindent\begin{tabular}{c|p{0.5\linewidth-5em}|p{0.5\linewidth-5em}}
\toprule
比较项目 & 链路状态(Link-State)算法 & 距离矢量(Distance-Vector)算法 \\
\hline
原理 & 每个节点与所有其他节点广播交流,只告知与其直接相连链路的费用。 & 每个节点只与邻居互相交流,得到邻居的新费用,并告知邻居自己的当前最低费用。\\
\hline
报文复杂性 & 知道网络每条链路的费用,需发送$\mathrm{O}(nE)$个报文;当一条链路的费用变化时,必须通知所有节点。 & 迭代时,在两个直接相连邻居之间交换报文;收敛时间受许多因素影响;当链路费用改变时,只有该链路相连的节点的最低费用路径发生改变时,才传播已改变的链路费用。\\
\hline
收敛速度 & 需要$\mathrm{O}(nE)$个报文和$\mathrm{O}(n^{2})$的搜寻。 & 收敛较慢。可能会遇到选路回环,或计数到无穷的问题。 \\
\hline
健壮性 & 当一台路由器发生故障、操作错误或受到破坏时,路由器向其连接的一条链路广播不正确费用。路由计算基本独立(仅计算自己的转发表),有一定健壮性。 & 当一台路由器发生故障、操作错误或受到破坏时,一个节点可向任意或所有目的节点发布其不正确的最低费用路径。一个节点的计算值会传递给它的邻居,并间接地传递给邻居的邻居。一个不正确的计算值会扩散到整个网络。\\
\bottomrule
\end{tabular}
}
\Rquestionandanswer[24]{Why are different inter-AS and intra-AS protocols used in the Internet?}{
\noindent
策略:\\
自治系统之间:管理员想要控制网络流量如何流动以及其他流量是否能通过它的网络。\\
自治系统内部:单个管理员,因此不需要这些决策。
\noindent
规模:\\
层次化的路由减少了路由表的大小,减少了更新路由表的流量。
\noindent
性能:\\
自治系统内部:能够专注于性能。\\
自治系统之间:策略可能比性能更重要。
}
\Rquestionandanswer[25]{Consider Figure 4.33. Starting with the original table in D, suppose that D
receives from A the following advertisement:
\noindent\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccc}
\toprule
Destination Subnet & Next Router & Number of Hops to Destination \\
\midrule
z & C & 10 \\
w & --- & 1 \\
x & --- & 1 \\
\dots & \dots & \dots \\
\bottomrule
\end{tabular*}
\includegraphics[width=1\linewidth]{imgs/2023-12-23-15-47-18.png}
Will the table in D change? If so how?
}{
D的路由表不会改变。
首先可以看出A向D提供了A分别到z,w,x的下一跳和总跳数那么之后D会查看自己的路由表。D原先记录的到z的总跳数是7但如果经过A再到z那就会是$1+10=11$比原先的跳数还多因此不会更新z这一行D原先记录的到w的总跳数是2从A收到的信息来看经过A再到w的跳数就是$1+1=2$和原来一样因此也不会更新w这一行D原先记录的到x的跳数是1已经最少了不需要更新。
所以D收到的A的前三行信息都不会导致D更新第三行以下的信息也没给出因此可以认为D的路由表不会改变。
}
\Pquestionandanswer[11]{Consider a datagram network using 8-bit host addresses. Suppose a router uses longest prefix matching and has the following forwarding table:
\noindent\begin{tabularx}{\linewidth}{ZZ}
\toprule
Prefix Match & Interface \\
\midrule
1 & 0 \\
11 & 1 \\
111 & 2 \\
otherwise & 3 \\
\bottomrule
\end{tabularx}\\
For each of the four interfaces, give the associated range of destination host addresses and the number of addresses in the range.
}{
\noindent\begin{tabularx}{\linewidth}{ZZZ}
\toprule
接口 & 目的主机地址关联范围 & 目的主机地址数 \\
\midrule
0 & 1000 0000 - 1011 1111 & $2^{6}=64$\\
1 & 1100 0000 - 1101 1111 & $2^{5}=32$\\
2 & 1110 0000 - 1111 1111 & $2^{5}=32$\\
3 & 0000 0000 - 0111 1111 & $2^{7}=128$\\
\bottomrule
\end{tabularx}
检查一下,目的主机地址数总和为$64+32+32+128 = 256 = 2^{8}$,正确。
}
\Pquestionandanswer[13]{Consider a subnet with prefix 101.101.101.64/26. Give an example of one IP
address (of form xxx.xxx.xxx.xxx) that can be assigned to this network.}{
直接把表示网络号的IP地址加一即可即 101.101.101.65。
}
\Pquestionandanswer[-]{Suppose an
ISP owns the block of addresses of the form 101.101.128/17. Suppose it wants to
create four subnets from this block, with each block having the same number of IP
addresses. What are the prefixes (of form a.b.c.d/x) for the four subnets?}{
由于子网掩码为$17=8+8+1$所以IP地址的前两个部分以及第三个部分的第一位表示网络号因此IP地址第三个部分还有$2^{8-1}=128$个数字可以使用要分成4个子网$128\div 4=32$$17+2=19$
$128+0\times 32=128$, $128+1\times 32=160$, $128+2\times 32 = 192$, $128+3\times 32 = 224$
所以四个子网的前缀为
\begin{center}
101.101.128.0/19\\
101.101.160.0/19\\
101.101.192.0/19\\
101.101.224.0/19\\
\end{center}
}
\Pquestionandanswer[14]{Consider a datagram network using 8-bit host addresses. Suppose a router uses
longest prefix matching and has the following forwarding table:
\noindent\begin{tabularx}{\linewidth}{ZZ}
\toprule
Prefix Match & Interface \\
\midrule
00 & 0 \\
01 & 1 \\
10 & 2 \\
11 & 3 \\
\bottomrule
\end{tabularx}
For each of the four interfaces, give the associated range of destination host addresses and the number of addresses in the range.
}{
\noindent\begin{tabularx}{\linewidth}{ZZZ}
\toprule
接口 & 目的主机地址关联范围 & 目的主机地址数 \\
\midrule
0 & 0000 0000 - 0011 1111 & $2^{6}=64$\\
1 & 0100 0000 - 0111 1111 & $2^{6}=64$\\
2 & 1000 0000 - 1011 1111 & $2^{6}=64$\\
3 & 1100 0000 - 1111 1111 & $2^{6}=64$\\
\bottomrule
\end{tabularx}
}
\Pquestionandanswer[18]{In this problem well explore the impact of NATs on P2P applications. Suppose a
peer with username Arnold discovers through querying that a peer with username
Bernard has a file it wants to download. Also suppose that Bernard and Arnold are
both behind a NAT. Try to devise a technique that will allow Arnold to establish a
TCP connection with Bernard without application-specific NAT configuration. If you
have difficulty devising such a technique, discuss why.}{
由于Arnold和Bernard都在NAT后面因此他们都只能发现对方所在子网的路由器的IP地址公网IP而TCP连接是端到端的因此如果没有对NAT进行特别配置那么只能采用TCP打洞方式TCP打洞具体过程比较复杂这里就简单描述一下大致是通过一个具有公网IP的服务器对TCP三次握手的报文进行中继使每一方与对方的路由器进行通信但对于上层来说就好像是双方形成了TCP连接而且TCP打洞还不一定能成功例如对于对称NAT就无法成功详细过程就不再叙述了可以查找相关资料。
}
\Pquestionandanswer[20]{Consider the network fragment shown below. $x$ has only two attached neighbors,
$w$ and $y$. $w$ has a minimum-cost path to destination $u$ (not shown) of 5, and $y$ has a
minimum-cost path to $u$ of 6. The complete paths from $w$ and $y$ to $u$ (and between $w$
and $y$) are not shown. All link costs in the network have strictly positive integer
values.
\begin{center}
\includegraphics[width=0.3\linewidth]{imgs/2023-12-23-18-56-31.png}
\end{center}
}{}
\begin{enumerate}
\Pquestionandanswer[-]{
\item Give $x$\!\!s distance vector for destinations $w$, $y$, and $u$.
}{
\begin{tabularx}{\linewidth}{ZZZ}
\toprule
终点 & 下一跳 & 花费/代价/损失 \\
\midrule
$w$ & --- & 2 \\
$y$ & $w$ & 4 \\
$u$ & $w$ & 7 \\
\bottomrule
\end{tabularx}
}
\Pquestionandanswer[-]{
\item Give a link-cost change for either $c(x,w)$ or $c(x,y)$ such that $x$ will inform its
neighbors of a new minimum-cost path to $u$ as a result of executing the
distance-vector algorithm.
}{
$c(x,w) = 10$,则$x$$u$的最小代价的距离更新为11且下一跳更新为$y$,此时$x$会通知$w$$y$它的距离矢量发生了变化。
}
\Pquestionandanswer[-]{
\item Give a link-cost change for either $c(x,w)$ or $c(x,y)$ such that $x$ will \textit{not} inform its
neighbors of a new minimum-cost path to u as a result of executing the
distance-vector algorithm.
}{
$c(x,y)=6$,则$x$$u$的最小代价仍然是7下一跳仍然是$w$,此时$x$不会通知它的邻居。
}
\end{enumerate}
\end{enumerate}
\end{document}

View File

@@ -0,0 +1,233 @@
\documentclass[全部作业]{subfiles}
\input{mysubpreamble}
% \definecolor{shadecolor}{RGB}{255,255,255}
\setcounter{chapter}{4}
\setlist[1]{label=\arabic{enumi},listparindent=\parindent}
\begin{document}
\chapter{数据链路层}
\begin{enumerate}
\Rquestionandanswer[1]{What are some of the possible services that a link-layer protocol can offer to the
network layer? Which of these link-layer services have corresponding services in IP?
In TCP?}{
数据链路层可以提供流量控制,差错检测和纠正,共享广播信道-多路访问链路层编址。其中流量控制、差错检测在IP和TCP中都有相应的服务链路层编址在IP有类似的IP地址。
}
\Rquestionandanswer[2]{If all the links in the Internet were to provide reliable delivery service, would the
TCP reliable delivery service be redundant? Why or why not?}{
如果在因特网中的所有链路都能提供可靠收发服务TCP的可靠收发服务也不是多余的。这样虽然能保证到达的包没有差错但是IP层可能把数据包转发到错误的地方导致丢包或者各个数据包通过不同的链路到达目的导致数据包乱序TCP的可靠收发服务需要解决丢包和乱序的问题。
}
\Rquestionandanswer[9]{Why is an ARP query sent within a broadcast frame? Why is an ARP response
sent within a frame with a specific destination MAC address?}{
ARP查询使用广播帧是因为发送端此时还不知道接收端的MAC地址无法单播所以只能使用广播帧而ARP响应帧理论上使用广播MAC地址也行只要查询方能收到就行但其他没有发送ARP查询帧的主机收到ARP响应帧也会丢弃因此还不如不使用广播帧其他主机收到目的MAC不是自己的帧就提早丢弃了。
}
\Rquestionandanswer[10]{Suppose nodes A, B, and C each attach to the same broadcast LAN (through
their adapters). If A sends thousands of IP datagrams to B with each encapsulating
frame addressed to the MAC address of B, will C's adapter process these frames? If
so, will C's adapter pass the IP datagrams in these frames to the network layer C?
How would your answers change if A sends frames with the MAC broadcast address?}{
C的适配器会将这些帧首部的目的MAC地址和C的MAC地址比较发现不相同就把这些帧丢弃了所以C的适配器会处理这些帧但是将这些帧丢弃了所以不会将IP数据传递给C的网络层。但是如果A发送的帧使用了MAC广播地址那么C的适配器会处理这些帧并且将帧里的IP数据包传递给C的网络层网络层还是有可能丢弃报文的
}
\Rquestionandanswer[11]{In CSMA/CD, after the fifth collision, what is the probability that a node
chooses K = 4? The result K = 4 corresponds to a delay of how many seconds on a 10
Mbps Ethernet?}{
第五次冲突后,$K$的取值范围为$[0,2^{5}-1]$,即$K$等可能地从$[0,31]$中选取一个整数,因此$P(K=4)=\dfrac{1}{32}$
$K=4$就意味着延迟$4\times 512 \operatorname{bit}$的传输时间,因此在 10 Mbps 的以太网中,延时为
$$
\text{Delay}=\frac{4\times 512 \text{bit}}{10 \text{Mbps}}=\frac{2048 \text{bit}}{10 \times 10^{6} \text{bit/s}}= 0.0002048\ \text{}
$$
}
\Rquestionandanswer[13]{Suppose a 10 Mbps adapter sends into a channel an infinite stream of 1s using
Manchester encoding. The signal emerging from the adapter has how many transitions
per second?}{
曼彻斯特编码在每位信号的中间都有一个跳变由于数据全1所以在每位信号的开始处还需要归零因此一位信号有2个跳变。而在10 Mbps 的适配器上每秒能传输$10\times 10^{6}$位信号,所以每秒的跳变数为$20 \times 10^{6}$
}
\Pquestionandanswer[1]{Suppose the information content of a packet is the bit pattern 1010 1010 1010
1011 and an even parity scheme is being used. What would the value of the field
containing the parity bits be for the case of a two-dimensional parity scheme? Your
answer should be such that a minimum-length checksum field is used.}{
由于需要二维奇偶校验和长度最小并且此数据包的长度为16个字节$\sqrt{16}=4$所以应当一行4个字节共4行。校验过程可以画出二维表格如下
\begin{center}
\begin{tabular}{ccccl}
$1$ & $0$ & $1$ & $0$ \vline & $0$ \\
$1$ & $0$ & $1$ & $0$ \vline & $0$ \\
$1$ & $0$ & $1$ & $0$ \vline & $0$ \\
$1$ & $0$ & $1$ & $1$ \vline & $1$ \\
\hline
$0$ & $0$ & $0$ & $1$ \vline & $1$ \\
\end{tabular}
\end{center}
于是带校验的数据为 10100 10100 10100 10111 00011。
}
\Pquestionandanswer[15]{Suppose nodes A and B are on the same 10 Mbps Ethernet bus, and the
propagation delay between the two nodes is 225 bit times. Suppose node A begins
transmitting a frame and, before it finishes, node B begins transmitting a frame. Can A
finish transmitting before it detects that B has transmitted? Why or why not? If the
answer is yes, then A incorrectly believes that its frame was successfully transmitted
without a collision. \textit{Hint:} Suppose at time t = 0 bit times, A begins transmitting a
frame. In the worst case, A transmits a minimum-sized frame of 512 + 64 bit times. So
A would finish transmitting the frame at t = 512 + 64 bit times. Thus, the answer is no,
if B's signal reaches A before bit time t = 512 + 64 bits. In the worst case, when does
B's signal reach A?}{
题目中已经给出了提示在最差的情况下A传输的帧为8个字节的前同步码加上64个字节的有效帧的部分数据字段长度最小为46字节也就是$64+512=576$位。A的信号到达B需要225个比特时间在最差的情况下在A发出的帧到达B的一瞬间B发出了自己的帧此时B的信号再到达A又需要225个比特时间因此在第$2\times 225=450$个比特时间B的信号到达A$450<576$因此A不会在检测到B传输之前结束传输。
}
\Pquestionandanswer[16]{Suppose two nodes, A and B, are attached to opposite ends of an 900 m cable,
and that they each have one frame of 1,000 bits (including all headers and preambles)
to send to each other. Both nodes attempt to transmit at time $t$ = 0. Suppose there are
four repeaters between A and B, each inserting a 20-bit delay. Assume the
transmission rate is 10 Mbps, and CSMA/CD with backoff intervals of multiples of
512 bits is used. After the first collision, A draws $K$ = 0 and B draws $K$ = 1 in the
exponential backoff protocol. Ignore the jam signal and the 96-bit time delay.}{}
\begin{enumerate}
\Pquestionandanswer[-]{\item
What is the one-way propagation delay (including repeater delays) between A and
B in seconds? Assume that the signal propagation speed is $2\times 10^{8}$ m/sec.}{
这里说的包括中继器的延时是要把每个中继器20比特时间的延时也算进去但这不是传输延时的范畴了不过既然说了那就这样算吧。
信号传播速度是$2\times 18^{8}$ m/secAB之间使用900 m的电缆连接。因此在不考虑中继器的情况下传播延时为
$$
\frac{900 \text{m}}{2\times 10^{8} \text{m/sec}}=4.5 \times 10^{-6}\ \text{}
$$
每个中继器有20比特时间的延时传输率为10 Mbps因此每个中继器的延时为
$$
\frac{20 \text{bit}}{10 \text{Mbps}}=\frac{20 \text{bit}}{10\times 10^{6} \text{bit/s}}=2\times 10^{-6}\ \text{}
$$
所以在考虑中继器的情况下总的传播延时为
$$
4.5\times 10^{-6}+ 4\times 2\times 10^{-6}=12.5\times 10^{-6}\ \text{}
$$
}
\Pquestionandanswer[-]{\item
At what time (in seconds) is A's packet completely delivered at B?}{
这里为什么用的是“packet”“packet”不应该是指网络层的协议数据单元吗这题不是关注数据链路层吗而且题目中也说了传输了一帧frame
首先将上一小题计算的传播延时转化为比特时间数据传输率为10 Mbps所以
$$
10 \text{Mbps} \times (12.5\times 10^{-6}) \text{sec}=(10\times 10^{6}) \text{bit/s} \times (12.5\times 10^{-6}) \text{sec}=125 \text{bit比特时间}
$$
A和B都在$t=0$时刻发出帧,在$t=125$时刻A和B都检测到了冲突忽略48比特的拥塞信号直接停止发送。A在指数退避中选择了$K=0$因此会立刻重新准备发送此时信道忙A继续侦听。B在指数退避中选择了$K=1$因此会在512比特时间后重新发送帧。
$t=125+125=250$时刻B发送的帧已经全部到达了A此时信道空闲忽略96比特的侦听时间A立刻重新发送帧。
$t=250+125=375$时刻B开始接受帧。
$t=125+512+737$时刻B准备重发帧但信道忙B正在接收帧因此不会发送。
$t=375+1000=1375$时刻B完整接收了帧。
再将比特时间转化为秒
$$
\frac{1375 \text{bit}}{10\times 10^{6} \text{bit/s}}=137.5\times 10^{-6}\ \text{}
$$
所以在$137.5\times 10^{-6}$A的帧完全到达B。
% 上一小题已经算出了传播延时这里只需要计算传输延时。传输率为10 Mbps 一帧为1000 bits所以传输延时为
% $$
% t_{\text{transmission}}=\frac{1000 \text{bit}}{10 \text{Mbps}}=\frac{1000 \text{bit}}{10\times 10^{6} \text{bit/s}}=10\times 10^{-6}\ \text{秒}
% $$
% 因此总延时(不考虑排队延时和处理延时)为
% $$
% t_{\text{all}}=t_{\text{propagation}}+t_{\text{transmission}}=12.5\times 10^{-6}+1\times 100^{-6}=112.5 \times 10^{-6}\ \text{秒}
% $$
% 由于A在$t=0$时刻发出帧,所以在$t=112.5\times 10^{-6}$时刻A的帧完全到达B。
}
\Pquestionandanswer[-]{\item
Now suppose that only A has a packet to send and that the repeaters are replaced
with switches. Suppose that each switch has a 20-bit processing delay in addition to a
store-and-forward delay. At what time, in seconds, is A's packet delivered at B?}{
只有A发送包因此不考虑冲突以及排队延时。这时就不便于使用比特时间来计算了因此还是使用秒为单位来计算。
传播延时只需要整体考虑A到B之间的线缆即可
$$
t_{\text{propagation}} = \frac{900 \text{m}}{2\times 10^{8} \text{m/sec}}=4.5 \times 10^{-6}\ \text{}
$$
4个交换机每个交换机的处理延时为20个比特时间应该是处理的这段时间里能传输20比特的数据的意思吧那么根据数据传输率为10 Mbps可以计算出处理延时
$$
t_{\text{processing}}=4\times \frac{20 \text{bit}}{10\times 10^{6} \text{bit/s}}=8\times 10^{-6}\ \text{}
$$
由于每个交换机都采用存储转发方式所以传输延时为4个交换机把链路分成了5段
$$
t_{\text{transmission}}=5\times \frac{1000 \text{bit}}{10\times 10^{6}\text{bit/s}}=500\times 10^{-6}\ \text{}
$$
所以总延时为
$$
\begin{aligned}
t_{\text{all}} & = t_{\text{propagation}}+t_{\text{processing}}+t_{\text{transmission}} \\
& = 4.5\times 10^{-6}+8\times 10^{-6}+500\times 10^{-6} \\
& = 512.5\times 10^{-6}\ \text{} \\
\end{aligned}
$$
所以在$512.5\times 10^{-6}$A的帧完全到达B。
}
\end{enumerate}
\Pquestionandanswer[17]{Suppose nodes A and B are on the same 10 Mbps Ethernet bus, and the
propagation delay between the two nodes is 225 bit times. Suppose A and B send
frames at the same time, the frames collide, and then A and B choose different values
of K in the CSMA/CD algorithm. Assuming no other nodes are active, can the
retransmissions from A and B collide? For our purposes, it suffices to work out the
following example. Suppose A and B begin transmission at $t$ = 0 bit times. They both
detect collisions at $t$ = 225 bit times. They finish transmitting a jam signal at $t$ = 225 +
48 = 273 bit times. Suppose $K_A$ = 0 and $K_B$ = 1. At what time does B schedule its
retransmission? At what time does A begin transmission? (\textit{Note:} The nodes must wait
for an idle channel after returning to Step 2—see protocol.) At what time does A's
signal reach B? Does B refrain from transmitting at its scheduled time?}{
上一题不考虑48 bit的拥塞信号时间和96 bit的侦听时间这一题就要考虑了。
根据题意A和B都在$t=225$时刻检测到了冲突,在$t=225+48=273$时刻结束发送拥塞信号。之后在指数退避过程中A选择了$K=0$因此立刻进入侦听状态。由于B之前发送的帧还没有完全到达A因此这时A侦听到信道忙。
B的信号在225个比特时间后完全到达A因此在$t=273+225=498$时刻A侦听到信道开始空闲于是在96个比特时间后也就是$t=498+96=594$时刻A开始重新发送帧。
在225个比特时间后也就是$t=594+225 = 819$时刻A重新发送的帧开始到达B。
由于在指数退避过程中B选择了$K=1$因此在512个比特时间后也就是$t=273+512=785$时刻B进入侦听状态此时信道空闲但是在$t=819=785+34$时刻B开始接收A发送的帧此时信道开始忙$34<96$也就是在96个比特时间内信道开始忙了所以此时B不会发送帧。
因此A和B的重发帧不会冲突。
}
\Pquestionandanswer[19]{Consider three LANs interconnected by two routers, as shown in the figure
below.
\begin{center}
\includegraphics[width=0.5\linewidth]{imgs/2023-12-31-09-55-13.png}
\end{center}
}{}
\begin{enumerate}
\Pquestionandanswer[-]{
\item Redraw the diagram to include adapters.
\item Assign IP addresses to all of the interfaces. For Subnet 1 use addresses of the form
111.111.111.xxx; for Subnet 2 uses addresses of the form 122.122.122.xxx; and for
Subnet 3 use addresses of the form 133.133.133.xxx.
\item Assign MAC addresses to all of the adapters.
}{
% \includesvgpdf{5.19.1.drawio}
\noindent\includexopp{5.19.1}
}
\Pquestionandanswer[-]{
\item Consider sending an IP datagram from Host A to Host F. Suppose all of the ARP
tables are up to date. Enumerate all the steps, as done for the single-router example in
Section 5.4.2.
}{
第一跳主机A已知主机F的IP地址133.133.133.2于是封装了一个源IP为111.111.111.1目的IP为133.133.133.2的IP包之后A发现目的IP和本机IP不在一个子网于是A从自己的ARP表中查找网关路由器的IP111.111.111.11对应的MAC01:23:45:67:89:11将目的MAC为01:23:45:67:89:11源MAC为01:23:45:67:89:01放到数据链路层首部形成帧并发送出去。
第二跳路由器1的接口1收到该帧比较该帧首部的MAC和自己的MAC确认是发送给自己的后查看该帧内的IP层内容发现目的IP133.133.133.2和接口1、接口2都不在一个子网于是查看自己的路由表发现该子网的数据包应该发送给路由器2的接口1的IP122.122.122.21并且应该从接口2发出之后查看自己的ARP表找到此IP对应的MAC01:23:45:67:89:21将目的MAC为01:23:45:67:89:21源MAC为01:23:45:67:89:12接口2放到数据链路层首部形成帧从接口2发出。
第三跳路由器2的接口1收到帧比较该帧首部的MAC和自己的MAC确认是发送给自己的后查看该帧内的IP层内容发现目的IP133.133.133.2和接口2在同一个子网于是查看自己的ARP表找到此IP对应的MAC01:23:45:67:89:06将目的MAC为01:23:45:67:89:06源MAC为01:23:45:67:89:22接口2放到数据链路层首部形成帧从接口2发出。
最后主机F收到帧比较该帧首部的MAC和自己的MAC确认是发送给自己的后查看该帧内的IP层内容比较目的IP和自己的IP确认是发送给自己的后将IP层的数据解包后交给上层处理。
}
\Pquestionandanswer[-]{
\item Repeat (d), now assuming that the ARP table in the sending host is empty (and the
other tables are up to date).
}{
首先仍然是主机A已知主机F的IP地址133.133.133.2于是封装了一个源IP为111.111.111.1目的IP为133.133.133.2的IP包之后A发现目的IP和本机IP不在一个子网于是查找网关路由器的IP已经配置为111.111.111.11对应的MAC但ARP表为空无法找到此IP对应的MAC。于是A发送ARP查询广播将目的MAC设为广播地址全1源MAC为A的MAC01:23:45:67:89:01源IP为A的IP111.111.111.1目的IP设为111.111.111.11。路由器1的接口1收到该帧该帧为广播帧因此不需要和自己的MAC比较直接查看该帧封装的数据部分发现是ARP查询报文并且目的IP和自己的IP相同于是准备发送ARP响应报文。路由器1在自己的ARP表中查询该报文中的源111.111.111.1IP对应的MAC查找到为01:23:45:67:89:01于是将目的MAC设为01:23:45:67:89:01源MAC为路由器1接口1的MAC01:23:45:67:89:11源IP为路由器1接口1的IP111.111.111.11目的IP为111.111.111.1将该帧从接口1发送出去。
A收到该帧比较该帧首部的MAC和自己的MAC确认是发送给自己的后查看该帧内的IP层内容比较目的IP和自己的IP确认是发送给自己的后发现IP层内的数据为ARP响应报文并且此响应报文中的源IP111.111.111.11正好是自己刚才查询的IP于是将此帧的源IP和源MAC放入自己的ARP表中于是A就知道网关路由器的IP对应的MAC为01:23:45:67:89:11了之后的步骤就和上一小题相同了。
}
\end{enumerate}
\end{enumerate}
\end{document}

View File

@@ -0,0 +1,144 @@
\usepackage[margin=1in]{geometry}
\usepackage{environ} % 加了这个再\def\myitem就不报错了
\usepackage{extarrows}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{amssymb, amsfonts, amstext, amsmath, amsopn, amsthm}
\usepackage{extarrows}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\usepackage{ragged2e}
\usepackage[outputdir=./latex-output]{minted}
\usepackage{color}
\usepackage{hyperref}
\usepackage{mylatex}
\usepackage{subfiles}
\setlist[1]{label=P\arabic{enumi}.,listparindent=\parindent}
\setlist[2]{label=\alph{enumii}.,listparindent=\parindent}
\definecolor{shadecolor}{RGB}{204,232,207}
% 有\EnumitemId了
% 百分号要记得在判断语句的外面也用上
\def\getenum{%
\ifnum\EnumitemId=1%
enumi%
\else
\ifnum\EnumitemId=2%
enumii%
\else
\ifnum\EnumitemId=3%
enumiii%
\else%
enumiv%
\fi
\fi
\fi%
}
% \ifx\theenumiv\empty
% \ifx\theenumiii{}
% \ifx\theenumii{}
% 1
% \else
% 2
% \fi
% \else
% 3
% \fi
% \else
% 4
% \fi
% 可选参数合并到主.sty文件中了
% \def\myitemArg#1#2{
% \item \textbf{#1}
% \begin{enumerate}
% #2
% \end{enumerate}
% }
% \def\myitemOptArg[#1]#2#3{
% \setcounter{\getenum}{#1-1}
% \item \textbf{#2}
% \begin{enumerate}
% #3
% \end{enumerate}
% }
% \def\myitem{\futurelet\next\myitemAux}
% \def\myitemAux{\ifx\next[%
% \expandafter\myitemOptArg
% \else
% \expandafter\myitemArg
% \fi}
% \def\originitem{\csname\item \endcsname}
% \edef\item[#1]{
% \csname a\expandafter \endcsname \item
% % {\setcounter{\getenum}{#1-1}}
% % {\item}
% }
% \edef\item{\item}
% \edef\item{\originitem}
\newcommand{\cnitem}[1][]{
\IfBlankF{#1}{
\setcounter{\getenum}{#1-1}
}
\item
}
% 好像直接\AddEnumerateCounter就行
\newcommand{\questionandanswer}[3][]{%
\begin{shaded}%
\ifstrequal{#1}{-}{}{\cnitem[#1]} #2%
\end{shaded}%
\begin{zhongwen}%
#3%
\end{zhongwen}%
}
\ExplSyntaxOn
\cs_set:Nn \rawquestionandanswer:Nnnn {%
\begin{shaded}%
\ifstrequal{#2}{-}{}{\format_item:Nn #1{#2}} #3%
\end{shaded}%
\begin{zhongwen}%
#4%
\end{zhongwen}%
}
\cs_set:Nn \format_item:Nn {
\IfBlankTF{#2}{
\stepcounter{\getenum}
\item[#1{\csname the\getenum\endcsname}]
% 完美结合了LaTeX2e和LaTeX3
}{
\item[#1{#2}]
}
}
\cs_set:Nn \Rformat:n {R#1.}
\cs_set:Nn \Pformat:n {P#1.}
\newcommand{\Rquestionandanswer}[3][]{%
\rawquestionandanswer:Nnnn \Rformat:n {#1}{#2}{#3}
}
\newcommand{\Pquestionandanswer}[3][]{%
\rawquestionandanswer:Nnnn \Pformat:n {#1}{#2}{#3}
}
\ExplSyntaxOff
% 成功实现了,而且下划线也没问题!!!似乎是函数式程序设计,或者装饰器模式?
% 该命令用于控制 p{} 的情况
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % 使用过程中将p{4cm}换成P{4cm},小写改成大写即可!
% 该命令用于控制 X 的情况
\newcolumntype{Z}{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}X} % 使用过程中将Z 换成 X即可
% 可利用 RaggedLeft Centering替换RaggedRight实现靠右和居中 [代码对大小写敏感!!!!!!!!!!!!!!!!!!!!!!!!!!!!]
% 原文链接https://blog.csdn.net/wanjiac/article/details/107494424

View File

@@ -0,0 +1,6 @@
\usepackage{fancyhdr}
\usepackage{totpages}
\pagestyle{fancyplain}
\fancyhead{}
\fancyhead[C]{\mysignature}
\fancyfoot[C]{\thepage\quad\ref{TotPages}}

View File

@@ -0,0 +1,15 @@
\documentclass[a4paper]{ctexbook}
\input{mypreamble}
\title{\heiti\zihao{2} 《计算机网络》作业}
\author{\songti 岳锦鹏}
\newcommand{\mysignature}{10213903403 岳锦鹏}
\date{2023年10月6日 —— 2023年12月31日}
\begin{document}
\maketitle
\tableofcontents
\subfile{Chapter_1_HW}
\subfile{Chapter_2_HW}
\subfile{Chapter_3_HW}
\subfile{Chapter_4_HW}
\subfile{Chapter_5_HW}
\end{document}