计网-ch03-题目与解释

复习题

6.请描述应用程序开发者为什么更倾向于选择在UDP上运行应用程序而不是TCP。
ANS:
应用程序开发者可能不想其应用程序使用TCP的拥塞控制,因为这会在出现拥塞时降低应用程序的传输速率。通常,IP电话和IP视频会议应用程序的设计者选择让他们的应用程序运行在UDP上,因为他们想要避免TCP的拥塞控制。还有,一些应用不需要TCP提供的可靠数据传输。

选路和转发的区别
ANS:
路由是根据路由表查找到达目标网络的最佳路由表项,转发是根据最佳路由中的出口及下一跳IP转发数据包的过程。因此,路由选择是转发的基础,数据转发是路由的结果。

7.假定主机C上的一个进程有一个端口号6789的UDP套接字。假定主机A和主机B都用目的端口号6789向主机C发送一个UDP报文段。这两台主机的这些报文段在主机C上都被描述为相同的套接字吗?如果是这样的话,主机C上的进程是怎样区分源于两台不同主机的两个报文段的?
ANS:
是为相同的套接字,For each received segment, at the socket interface, the operating system will provide the process with the IP addresses to determine the origins of the individual segments.

8. 假定在主机C的端口80上运行一个Web服务器。假定这个Web服务器使用持久连接,并且正在接受来自两台不同主机A和B的请求。被发送的所有请求都通过位于主机C的相同套接字吗?如果它们通过不同的套接字来传递,这两个套接字都具有端口80吗?讨论和解释之。
ANS:
Web服务器是使用TCP连接,Web服务器对于不同的连接采用的是不同的套接字,因此A和B发出的请求通过的是在主机C不同的套接字上的,TCP连接的套接字是个四元组,由(源IP,源端口号,目标IP,目标端口号)组成,主机A和主机B都是向主机C 80端口上的Web服务器发出TCP连接请求,这两个套接字的目标端口号都是80,目标IP都是主机C的IP地址,因此这两个套接字中都具有端口号80。

9.在rdt协议中,为什么要引入序号
ANS:
序号是为了解决冗余分组问题。在rdt2.0协议中,由于假设信道中可能发生比特差错,发送方根据接收方反馈信息的肯定确认(ACK)或否定确认(NAK)来确定分组是否被正确的接收,若分组没有被正确的接收,即收到NAK反馈则重传该分组,但是ACK与NAK本身会发生差错,而通常情况下处理受损ACK或NAK的方法是,当发送方收到含糊不清的ACK或NAK时,只需重发当前数据分组即可。这就是冗余分组,发送方无法事先知道接收到的分组是新的还是又一次重传。因此,在数据分组中添加一新字段,即序号,让发送方对其数据分组编号,于是,接收方只需检查序号即可确定收到的分组是否是一次重传。

10.在rdt协议中,为什么需要引入定时器
ANS:
在数据传送的过程中可能会发生丢包的情况,解决丢包的方法有很多种,而rdt3.0中采用的是让发送方负责检测和恢复丢包。假定发送方传输一个数据分组,或则该分组或接收方对该分组的ACK发生了丢失。这两种情况下,发送方都收不到应当到来的接收方的响应。如果发送方愿意等待足够长的时间以确定分组已丢失,则只需重传该数据分组即可。因此在rdt3.0中引入了定时器来确定发送方应该等待的时间,一旦超过了该定时器的时间,则发送方认为产生了丢包现象,再重发该分组。

14. 是非判断题
a. 主机A通过一条TCP连接向主机B发送一个大文件。假设主机B没有数据发往主机A。因为主机B不能随数据捎带确认信息,所以主机B将不向主机A发送确认。
b. 在连接的整个过程中,TCP的RcvWindow的长度不会变化
c. 假设主机A通过一条TCP连接向主机B发送一个大文件。主机A发送的未被确认的字节数不会超过接收缓存的大小
d. 假设主机A通过一条TCP连接向主机B发送一个大文件。如果对于这次连接的一个报文段序列号为m,则对于后继报文段的序列号必然为m+1
e. TCP报文段在它的首部中有一个RcvWindow字段
f. 假定在一条TCP连接中最后的SampleRTT等于1s,那么对于这一连接的TimeoutInterVal的当前值必定 1s
g. 假定主机A通过一条TCP连接向主机B发送一个序号为38的4字节报文段。这个报文段的确认号必定是42
ANS:
a.错误;TCP连接中,如果主机B没有数据要发往主机,它就不能随数据捎带确认信息,但是,TCP要求B必须发送确认,因此B将向A发送非捎带的确认信息。
b.错误;TCP在全双工连接中,连接双方的发送方各自保留一个接收窗口以提供流量控制。接收窗口是动态的,在连接的整个生命周期中是不断变化的。
c. 正确。
d.错误;顺序号的设定是以传送的字节流为单位,而不是以报文段为单位。一个报文段的顺序号
是该报文段中数据段的第一个字节在字节流中的编号
e.正确
f.错误;超时时间是EstimatedRTT 和SampleRTT的函数,不能由一个SampleRTT值决定。
g.错误;某些情况下(比如该报文段发送超时)接收方会发送一个重复的ACK,即确认号仍然是 38。

15. 假设主机A通过一条TCP连接向主机B连续发送两个TCP报文段。第一个报文段的序号为90,第二个报文段的序号为110.
a. 第一个报文段中有多少数据
b. 假设第一个报文段丢失而第二个报文段到达主机B,那么在主机B发往主机A的捎带确认报文中,确认号应该是多少?
ANS:
a.因为TCP把数据看成一个无结构的但是有序的字节流。因此TCP的序号是建立在传送的字节流上的。因此在第一个报文段序号为90,第二个报文段序号为110的情况下,我们可推出第一个报文段中的数据大小为110-90=20 Bytes,即第一个报文段中有20个字节数据
b. 若第一个报文段丢失,则发送方会在一定时间后没有收到接收方的反馈确认包,因此接收方会发送一个重复的ACK,确认号为90。

16. 考虑3.5节中讨论的Telnet的例子。在键入字符C数秒之后,用户又键入字符R。那么在用户键入字符R之后,总共发送了多少个报文段?这些报文段中的序号和确认号字段应该填入什么?
ANS:
3 个报文段.
第一个报文段: seq = 43, ack =80;
第二个报文段: seq = 80, ack = 44;
第三个报文段: seq = 44, ack = 81

习题

3.UDP和TCP使用反码来计算检验和。假设有下面3个8比特字节:0101 0101,0111 0000,0100 1100.这些8比特字节和的反码是多少(注意到尽管UDP和TCP使用16比特的字来计算检验和,但对于这个问题,应考虑8比特和。)写出所有工作过程。UDP为什么要用该和的反码。即为什么不直接使用该和呢?使用该和反码方案,接收方如何检验出差错?1比特的差错将可能检测不出来吗?2比特的差错呢?
ANS:
0101 0101 + 0111 0000 = 1100 0101
1100 0101 + 0100 1100 = 0001 0001
二进制反码为:1110 1110
检测错误,接收方添加四个字(原来的三个单词和校验和)。如果和包含一个0,接收方知道存在一个错误。1比特的差错可以被检测出来,但2比特的差错无法检测(例如,如果第一个单词最后的数字转换为0,第二个词的最后数字转换为1)。

18.考虑一个GBN协议,其发送方窗口长度为3,序号范围为1024.假设在时刻t,接收方期待的下一个有序分组的序号是k.假设其中的介质不会对报文重新排序。请回答以下问题:
a. 在t时刻,发送窗口内的报文序号可能是多少?论证你的回答
b. 在t时刻,在当前发送方收到的所有报文中,ACK字段的可能值是多少?论证你的回答
ANS:
a. Here we have a window size of N=3. Suppose the receiver has received packet k-1, and has ACKed that and all other preceeding packets. If all of these ACK’s have been received by sender, then sender’s window is [k, k+N-1]. Suppose next that none of the ACKs have been received at the sender. In this second case, the sender’s window contains k-1 and the N packets up to and including k-1. The sender’s window is thus [k-N,k-1]. By these arguments, the senders window is of size 3 and begins somewhere in the range [k-N,k].
b. If the receiver is waiting for packet k, then it has received (and ACKed) packet k-1 and the N-1 packets before that. If none of those N ACKs have been yet received by the sender, then ACK messages with values of [k-N,k-1] may still be propagating back.
Because the sender has sent packets [k-N, k-1], it must be the case that the sender has already received an ACK for k-N-1. Once the receiver has sent an ACK for k-N-1 it will never send an ACK that is less that k-N-1. Thus the range of in-flight ACK values can range from k-N-1 ~ k-1.

19.假定有两个网络实体A和B。B有一些数据报文要通过下列规则传给A:当A从其上一层得到一个请求时,就从B接收下一个数据(D)报文。A必须通过A到B信道向B发送一个请求(R)报文。仅当B收到一个R报文后,它才会通过B到A信道向A发送数据(D)报文。A应当将每份D报文的拷贝交付给上层。R报文可能会在A到B的信道中丢失(但不会损坏);D报文一旦发出总是能够正确交付。两个信道的时延未知且是变化的。
请设计一个协议(画出FSM),它能够综合适当的机制,以补偿A到B信道中可能出现的丢包,实现在A实体中向上层传递的报文。只采用绝对必要的机制。
ANS:
Because the A-to-B channel can lose request messages, A will need to timeout and retransmit its request messages (to be able to recover from loss). Because the channel delays are variable and unknown, it is possible that A will send duplicate requests (i.e., resend a request message that has already been received by B). To be able to detect duplicate request messages, the protocol will use sequence numbers. A 1-bit sequence number will suffice for a stop-and-wait type of request/response protocol.
A (the requestor) has 4 states:

  • “Wait for Request 0 from above.” Here the requestor is waiting for a call from above to request a unit of data. When it receives a request from above, it sends a request message, R0, to B, starts a timer and makes a transition to the “Wait for D0” state. When in the “Wait for Request 0 from above” state, A ignores anything it receives from B.

  • “Wait for D0”. Here the requestor is waiting for a D0 data message from B. A timer is always running in this state. If the timer expires, A sends another R0 message, restarts the timer and remains in this state. If a D0 message is received from B, A stops the time and transits to the“Wait for Request 1 from above” state. If A receives a D1 data message while in this state, it is ignored.

  • “Wait for Request 1 from above.” Here the requestor is again waiting for a call from above to request a unit of data. When it receives a request from above, it sends a request message, R1, to B, starts a timer and makes a transition to the “Wait for D1” state. When in the “Wait for Request 1 from above” state, A ignores anything it receives from B.

  • “Wait for D1”. Here the requestor is waiting for a D1 data message from B. A timer is always running in this state. If the timer expires, A sends another R1 message, restarts the timer and remains in this state. If a D1 message is received from B, A stops the timer and transits to the “Wait for Request 0 from above” state. If A receives a D0 data message while in this state, it is ignored.

The data supplier (B) has only two states:

  • “Send D0.” In this state, B continues to respond to received R0 messages by sending D0, and then remaining in this state. If B receives a R1 message, then it knows its D0 message has been received correctly. It thus discards this D0 data (since it has been received at the other side) and then transits to the “Send D1” state, where it will use D1 to send the next requested piece of data.

  • “Send D1.” In this state, B continues to respond to received R1 messages by sending D1, and then remaining in this state. If B receives a R1 message, then it knows its D1 message has been received correctly and thus transits to the “Send D1” state.

21. 判断下面的问题,并简要地证实你的回答:
a.在SR协议中,发送方可能会收到落在其当前窗口之外的分组ACK.
b.在GBN协议中,发送方可能会受到落在其当前窗口之外的分组的ACK
c. 当发送方和接收方窗口长度都为1时,比特交替协议与SR协议相同
d. 当发送方和接收方窗口长度都为1时,比特交替协议与GBN协议相同
ANS:
a. 正确 ;Suppose the sender has a window size of 3 and sends packets 1, 2, 3 at t0 . At

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值