234 lines
14 KiB
TeX
234 lines
14 KiB
TeX
|
\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 we’ll 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}
|