229 lines
16 KiB
TeX
229 lines
16 KiB
TeX
|
\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: 01010101,01110000,01001100. 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 checksum,for 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 state,where 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 cases,you 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 ACK,what 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}
|