SchoolWork-LaTeX/计算机网络/平时作业/Chapter_3_HW.tex

229 lines
16 KiB
TeX
Raw Normal View History

2024-09-02 17:47:53 +08:00
\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}