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

233 lines
19 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}{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}