《Tanenbaum計算機網絡》課后習題

計算機網絡第五版第一章,第五章,第六章的習題解答。編號是按照中文版圖書來的,題目是復制的英文版圖書。答案經過本人驗證,比較可靠。

第一章:引言

(1) Imagine that you have trained your St. Bernard, Bernie, to carry a box of three 8mm tapes instead of a flask of brandy. (When your disk fills up, you consider that an emergency.) These tapes each contain 7 gigabytes. The dog can travel to your side, wherever you may be, at 18 km/hour. For what range of distances does Bernie have a higher data rate than a transmission line whose data rate (excluding overhead) is 150 Mbps?

Sol.

7 * 1024 * 8 * 3 / (d / 5) = 150
d = 5734.4m

Wrong!

1 kbps = 1000 bit/s
1024 should be 1000
d = 5600m

(2) An alternative to a LAN is simply a big timesharing system with terminals for all users. Give two advantages of a client-server system using a LAN.

Sol.

(1) 可以更好地利用網絡資源,timesharing system容易造成資源浪費
(2) 構建簡單,客戶機和服務機上各運行一個進程即可

(3) The performance of a client-server system is influenced by two network factors: the bandwidth of the network (how many bits/sec it can transport) and the latency (how many seconds it takes for the first bit to get from the client to the server). Give an example of a network that exhibits high bandwidth and high latency. Then give an example of one with low bandwidth and low latency.

Sol.

(1). 下載大型文件,建立連接需要很久,一旦建立下載很快
(2). 語音通話,不能有高延遲

A transcontinental fiber link might have many gigabits/sec of bandwidth, but the latency will also be high due to the speed of light propagation over thousands of kilometers. In contrast, a 56-kbps modem calling a computer in the same building has low bandwidth and low latency.

(4) Besides bandwidth and latency, what other parameter is needed to give a good characterization of the quality of service offered by a network used for digitized voice traffic?

Sol.

(1) 丟包率
(2) 安全性
(3) 斷點傳輸
(4) 對語音通話而言,統一的傳輸時間也很重要

(5) A factor in the delay of a store-and-forward packet-switching system is how long it takes to store and forward a packet through a switch. If switching time is 10 μsec, is this likely to be a major factor in the response of a client-server system where the client is in New York and the server is in California? Assume the propagation speed in copper and fiber to be 2/3 the speed of light in vacuum.

Sol.

2000km / 200000km/s = 10ms

It won't be a major factor.

(6) A client-server system uses a satellite network, with the satellite at a height of 40,000 km. What is the best-case delay in response to a request?

Sol.

40,000 * 2 / 300000 = 267ms

(7) In the future, when everyone has a home terminal connected to a computer network, instant public referendums on important pending legislation will become possible. Ultimately, existing legislatures
could be eliminated, to let the will of the people be expressed directly. The positive aspects of such a
direct democracy are fairly obvious; discuss some of the negative aspects.

Sol.

安全性存在問題

(8) A collection of five routers is to be connected in a point-to-point subnet. Between each pair of routers,
the designers may put a high-speed line, a medium-speed line, a low-speed line, or no line. If it takes 100 ms of computer time to generate and inspect each topology, how long will it take to inspect all of them?

Sol.

4 ^ (4 + 3 + 2 + 1) * 100ms = more than one day

(9) A disadvantage of a broadcast subnet is the capacity wasted when multiple hosts attempt to access the channel at the same time. As a simplistic example, suppose that time is divided into discrete slots, with each of the n hosts attempting to use the channel with probability p during each slot. What fraction of the slots are wasted due to collisions?

Sol.

P = 1 - n * p * (1 - p) ^ (n - 1) - p ^ n

(10) What are two reasons for using layered protocols?

Sol.

(1) 使得層與層之間不會影響,一層內的協議更新不會使得整個網絡連接發生變化
(2) 把大的任務分細,明確各層提供的服務

(11) The president of the Specialty Paint Corp. gets the idea to work with a local beer brewer to produce an
invisible beer can (as an anti-litter measure). The president tells her legal department to look into it, and they in turn ask engineering for help. As a result, the chief engineer calls his counterpart at the other company to discuss the technical aspects of the project. The engineers then report back to their respective legal departments, which then confer by telephone to arrange the legal aspects. Finally, the two corporate presidents discuss the financial side of the deal. Is this an example of a multilayer protocol in the sense of the OSI model?

Sol.

除了第一層(最底層,這里是engineer),高層之間不能有直接通信。

(12) What is the principal difference between connectionless communication and connection-oriented communication?

Sol.

面向連接的服務是先建立連接再通信。無連接服務是在傳輸時候帶上目標地址,然后交由網絡去通信。

(13) Two networks each provide reliable connection-oriented service. One of them offers a reliable byte stream and the other offers a reliable message stream. Are these identical? If so, why is the distinction made? If not, give an example of how they differ.

Sol.

message的話每條信息有確定邊界,而byte stream則沒有確定邊界。

(14) What does ''negotiation'' mean when discussing network protocols? Give an example.

Sol.

協商就是建立一個雙方接受的通信規則。

(15) Which of the OSI layers handles each of the following:
a. (a) Dividing the transmitted bit stream into frames.
b. (b) Determining which route through the subnet to use.

Sol.

Transmission Layer and Network Layer

Wrong!

Data link layer and Network layer

這里很重要,數據是在data link層被劃分為幀(frame)的

(16) If the unit exchanged at the data link level is called a frame and the unit exchanged at the network level
is called a packet, do frames encapsulate packets or do packets encapsulate frames? Explain your
answer.

Sol.

高層的應該被封到低層里去。

(17) A system has an n-layer protocol hierarchy. Applications generate messages of length M bytes. At each
of the layers, an h-byte header is added. What fraction of the network bandwidth is filled with headers?

Sol.

hn / (M + hn)

(18) List two ways in which the OSI reference model and the TCP/IP reference model are the same. Now list
two ways in which they differ.

Sol.

OSI:
Application
Representation
Session
Transmission
Network
Data link
Physical

TCP/IP:
Application: HTTP, SMTP, RTP, DNS
Transmission: TCP, UDP
internet: IP (Internet Protocal), ICMP
Link: DSL, SONET, 802.11, Ethernet

(19) What is the main difference between TCP and UDP?

Sol.

TCP is connection oriented, reliable, fast.
UDP is connectionless oriented, unreliable, slow.

(20) When a file is transferred between two computers, two acknowledgement strategies are possible. In the first one, the file is chopped up into packets, which are individually acknowledged by the receiver, but the file transfer as a whole is not acknowledged. In the second one, the packets are not acknowledged
individually, but the entire file is acknowledged when it arrives. Discuss these two approaches.

Sol.

If the network is reliable, use the second one.

(21) How long was a bit on the original 802.3 standard in meters? Use a transmission speed of 10 Mbps and
assume the propagation speed in coax is 2/3 the speed of light in vacuum.

Sol.

802.3是以太網,這里計算出來是20米

(22) An image is 1024 x 768 pixels with 3 bytes/pixel. Assume the image is uncompressed. How long does it
take to transmit it over a 56-kbps modem channel? Over a 1-Mbps cable modem? Over a 10-Mbps Ethernet? Over 100-Mbps Ethernet?

Sol.

337s, 19s, 1.9s, 0.19s

(23) Ethernet and wireless networks have some similarities and some differences. One property of Ethernet is that only one frame at a time can be transmitted on an Ethernet. Does 802.11 share this property with Ethernet? Discuss your answer.

Sol.

Wireless networks also transmit one frame at a time, but determining when one can send is more difficult. Ethernet is a broadcast bus so the sender can just listen to see if there is any traffic before sending. Due to range issues with wireless, a sender cannot be sure that there are not other transmissions just because it cannot "hear" other transmissions. Wireless senders use either a central base station or use methods discussed in Chapter 4 to avoid collisions.

(24) Wireless networks are easy to install, which makes them inexpensive since installation costs usually far overshadow equipment costs. Nevertheless, they also have some disadvantages. Name two of them.

Sol.

無法控制范圍,容易被人利用。任何人可以接收到傳送中的包。
此外,傳輸更慢。

(25) List two advantages and two disadvantages of having international standards for network protocols.

Sol.

好處:統一的標準使得兼容性更好,成本降低。
壞處:不好的標準可能很難被淘汰,比如OSI比TCP/IP先進但沒有被采用。

第五章:網絡層

(1) Give two example computer applications for which connection-oriented service is appropriate. Now give two examples for which connectionless service is best.

Sol.

面向連接服務:SSH,文件傳輸

無連接服務:視頻通話,游戲在線對戰,需要快速應答的服務一般需要無連接服務。

(2) Are there any circumstances when connection-oriented service will (or at least should) deliver packets out of order? Explain.

Sol.

接收端將無法正確接收數據,比如視頻傳輸,順序一錯視頻就亂了。

Wrong!

Circumstance是情況的意思,在terminal中ctrl-c應該被最先傳送,而不是排在隊尾。

(3) Datagram subnets route each packet as a separate unit, independent of all others. Virtual-circuit subnets do not have to do this, since each data packet follows a predetermined route. Does this observation mean that virtual-circuit subnets do not need the capability to route isolated packets from an arbitrary source to an arbitrary destination? Explain your answer.

Sol.

并不是如此,虛電路網絡對不同方向的數據包需要建立不同的虛電路,因此也要具備這樣的能力。

補充:在建立虛電路的時候需要把setup package從任意端傳輸到任意接收方。

(4) Give three examples of protocol parameters that might be negotiated when a connection is set up.

Sol.

IP協議,協商IP包的最大跳數,是否可以分段,還有出錯時的處理方式。

(5) Consider the following design problem concerning implementation of virtual-circuit service. If virtual circuits are used internal to the subnet, each data packet must have a 3-byte header and each router must tie up 8 bytes of storage for circuit identification. If datagrams are used internally, 15-byte headers are needed but no router table space is required. Transmission capacity costs 1 cent per 106 bytes, per hop. Very fast router memory can be purchased for 1 cent per byte and is depreciated over two years, assuming a 40-hour business week. The statistically average session runs for 1000 sec, in which time 200 packets are transmitted. The mean packet requires four hops. Which implementation is cheaper, and by how much?

Sol.

Virtual Circuits: 200 * 3 * 4 / 10 ^ 6 + 1000 * 8 * 5 / 2 / 52 / 40 / 3600
Datagrams: 15 * 4 * 200 / 10 ^ 6

(6) Assuming that all routers and hosts are working properly and that all software in both is free of all errors, is there any chance, however small, that a packet will be delivered to the wrong destination?

Sol.

有可能,當有ip沖突或者傳輸過程中發生ip地址變更的情況。

Wrong!

答案是錯誤可能出在低層上,比如物理層

(7) Give a simple heuristic for finding two paths through a network from a given source to a given destination that can survive the loss of any communication line (assuming two such paths exist). The routers are considered reliable enough, so it is not necessary to worry about the possibility of router crashes.

Sol.

先找出一條最短路徑,再把這條路徑刪除,找出另一條最短路徑。只要兩條路徑沒有公共部分即可。

(8) Consider the subnet of Fig.5-12(a). Distance vector routing is used, and the following vectors have just come in to router C: from B: (5, 0, 8, 12, 6, 2); from D: (16, 12, 6, 0, 9, 10); and from E: (7, 6, 3, 9, 0, 4). The measured delays to B, D, and E, are 6, 3, and 5, respectively. What is C's new routing table? Give both the outgoing line to use and the expected delay.

Sol.

這題是距離矢量算法。

  C 到 A 11 經過 B
  A 11 B
  B 6  B
  C 0  -
  D 3  D
  E 5  E
  F 8  B

(9) If delays are recorded as 8-bit numbers in a 50-router network, and delay vectors are exchanged twice a second, how much bandwidth per (full-duplex) line is chewed up by the distributed routing algorithm? Assume that each router has three lines to other routers.

Sol.

每個路由器需要維護一張400bit的表,因此傳輸0.5s一次會浪費單個方向800bps的帶寬

(10) In Fig. 5-14 the Boolean OR of the two sets of ACF bits are 111 in every row. Is this just an accident here, or does it hold for all subnets under all circumstances?

Sol.

這題講的是鏈路狀態路由算法。

這個永遠是對的,ACK標志標志表示來自哪里,它可能由兩條路線過來,而發送標志表示要發送往哪里。

(11) For hierarchical routing with 4800 routers, what region and cluster sizes should be chosen to minimize the size of the routing table for a three-layer hierarchy? A good starting place is the hypothesis that a solution with k clusters of k regions of k routers is close to optimal, which means that k is about the cube root of 4800 (around 16). Use trial and error to check out combinations where all three parameters are in the general vicinity of 16.

Sol.

這題講的是層次路由。

層次可以分許多層,和網絡中路由器的數量規模有關。

16 15 20

(12) In the text it was stated that when a mobile host is not at home, packets sent to its home LAN are intercepted by its home agent on that LAN. For an IP network on an 802.3 LAN, how does the home agent accomplish this interception?

Sol.

家鄉代理擁有主機的IP地址即可截獲,有什么問題嗎?

Conceivably it might go into promiscuous mode, reading all frames dropped onto the LAN, but this is very inefficient. Instead, what is normally done is that the home agent tricks the router into thinking it is the mobile host by re- sponding to ARP requests. When the router gets an IP packet destined for the mobile host, it broadcasts an ARP query asking for the 802.3 MAC-level ad- dress of the machine with that IP address. When the mobile host is not around, the home agent responds to the ARP, so the router associates the mobile user’s IP address with the home agent’s 802.3 MAC-level address.

上面是標準答案,實際上就是在ARP廣播時相應家鄉代理自己的MAC地址,實際上就是擁有了主機的IP地址嘛。

(13) Looking at the subnet of Fig. 5-6, how many packets are generated by a broadcast from B, using a. (a)reverse path forwarding? b. (b)the sink tree?

Sol.

reverse path forwarding,路由器接收到廣播包時,檢查是否是自己給廣播源發包的路徑,是的話說明是從最優路徑發過來的,這時給所有其他節點發包,最后算下來發了21次

sink tree是匯集樹,是由B到所有節點最短路徑的集合,這樣發的話發14個包,每個樹枝必會到一個節點,而且不會重復。

(14) Suppose that node B in Fig. 5-20 has just rebooted and has no routing information in
its tables. It suddenly needs a route to H. It sends out broadcasts with TTL set to 1, 2,
3, and so on. How many rounds does it take to find a route?

Sol.

這題考查自組織網絡路由,就是路由器本身也在移動的情況。TTL分別設置為1,2,3是為了使搜索半徑不斷增大。由于B和H距離為3,因此TTL設置為3的時候可以發現,因此3輪可以發現路由。

(15) As a possible congestion control mechanism in a subnet using virtual circuits internally,
a router could refrain from acknowledging a received packet until (1) it knows its last transmission along the virtual circuit was received successfully and (2) it has a free buffer. For simplicity, assume that the routers use a stop-and-wait protocol and that each virtual circuit has one buffer dedicated to it for each direction of traffic. If it takes T sec to transmit a packet (data or acknowledgement) and there are n routers on the path, what is the rate at which packets are delivered to the destination host? Assume that transmission errors are rare and that the host-router connection is infinitely fast.

Sol.

講的是擁塞控制,這個方法不好,需要前一個包完全確認了才能傳輸下一個包。

The protocol is terrible. Let time be slotted in units of T sec. In slot 1 the source router sends the first packet. At the start of slot 2, the second router has received the packet but cannot acknowledge it yet. At the start of slot 3, the third router has received the packet, but it cannot acknowledge it either, so all the routers behind it are still hanging. The first acknowledgement can only be sent when the destination host takes the packet from the destination router. Now the acknowledgement begins propagating back. It takes two full transits of the network, 2(n ? 1)T sec, before the source router can send the second packet. Thus, the throughput is one packet every 2(n ? 1)T sec.

(17) Describe two major differences between the ECN and the RED method.

Sol.

這兩種是擁塞控制算法。

ECN (Explicit Congestion Notification, 顯式擁塞通知),路由器在它轉發的數據包上打上標記,發出信號,接收方注意到擁塞時,發送應答包的同時告知發送方,讓發送方降低傳送速率。

RED (Random Early Detection, 隨機早期檢測), 路由器維護一個運行隊列長度的平均值,當超過閾值的時候就開始隨機丟棄數據包,快速發送方發現丟包就開始降低發送速率。

主要區別是一個顯式通知,一個隱式通知,一個是緩存區開始不夠了才通知,另一個是提前預知。

(18) An ATM network uses a token bucket scheme for traffic shaping. A new token is put into the bucket every 5 μsec. Each token is good for one cell, which contains 48 bytes of data. What is the maximum sustainable data rate?

Sol.

With a token every 5 μsec, 200,000 cells/sec can be sent. Each packet holds 48 data bytes or 384 bits. The net data rate is then 76.8 Mbps.

(19) A computer on a 6-Mbps network is regulated by a token bucket. The token bucket is filled at a rate of 1 Mbps. It is initially filled to capacity with 8 megabits. How long can the computer transmit at the full 6 Mbps?

Sol.

8 / (6 - 1) = 1.6s

(21) The CPU in a router can process 2 million packets/sec. The load offered to it is 1.5 million packets/sec. If a route from source to destination contains 10 routers, how much time is spent being queued and serviced by the CPUs?

Sol.

這題用到排隊論,服務速率為2,到達速率為1.5,那么服務時間為 1/2million / (1 - 1.5 / 2) = 2us。 10個routers就是20us.

(22) Consider the user of differentiated services with expedited forwarding. Is there a guarantee that expedited packets experience a shorter delay than regular packets? Why or why not?

Sol.

不保證,過多包被標記為加速的,那么可能反而變慢了。

(23) Suppose that host A is connected to a router R 1, R 1 is connected to another router, R 2, and R 2 is connected to host B. Suppose that a TCP message that contains 900 bytes of data and 20 bytes of TCP header is passed to the IP code at host A for delivery to B. Show the Total length, Identification, DF, MF, and Fragment offset fields of the IP header in each packet transmitted over the three links. Assume that link A-R1 can support a maximum frame size of 1024 bytes including a 14-byte frame header, link R1-R2 can support a maximum frame size of 512 bytes, including an 8-byte frame header, and link R2-B can support a maximum frame size of 512 bytes including a 12- byte frame header.

Sol.

Link A-R1 :
Length: 900 + 20 (TCP) + 20 (IP) = 940 Bytes, ID:X , DF:0 , MF:0 , Fragment offset:0
Link R1-R2:
(1) Length = 500; ID = x; DF = 0; MF = 1; Offset = 0 (2) Length = 460; ID = x; DF = 0; MF = 0; Offset = 60
Link R2-B:
(1) Length = 500; ID = x; DF = 0; MF = 1; Offset = 0 (2) Length = 460; ID = x; DF = 0; MF = 0; Offset = 60
不用去考慮數據鏈路層的成幀部分,IP協議不關心。

(24) A router is blasting out IP packets whose total length (data plus header) is 1024 bytes. Assuming that packets live for 10 sec, what is the maximum line speed the router can operate at without danger of cycling through the IP datagram ID number space?

Sol.

IP包的ID字段擁有16位,因此65536個不同編號

65536 * 1024 * 8 / 10 = 54 Gbps

(25) An IP datagram using the Strict source routing option has to be fragmented. Do you think the option is copied into each fragment, or is it sufficient to just put it in the first fragment? Explain your answer.

Sol.

Strict Source Routing 嚴格源路由,是IPv4頭的可選項,表明該包必須經過指定路由。

必須要在每個fragment都要包括。

(26) Suppose that instead of using 16 bits for the network part of a class B address originally, 20 bits had been used. How many class B networks would there have been?

Sol.

B類地址,前綴10定死,因此18bits可以用,所以有2^18個B類網絡。

(28) A network on the Internet has a subnet mask of 255.255.240.0. What is the maximum number of hosts it can handle?

Sol.

4096

(29) 為什么以太網地址不能特定于一個網絡,而IP地址卻可以?

Sol.

Each Ethernet adapter sold in stores comes hardwired with an Ethernet (MAC) address in it. When burning the address into the card, the manufac- turer has no idea where in the world the card will be used, making the address useless for routing. In contrast, IP addresses are either assigned either stati- cally or dynamically by an ISP or company, which knows exactly how to get to the host getting the IP address.

(30) A large number of consecutive IP address are available starting at 198.16.0.0. Suppose that four organizations, A, B, C, and D, request 4000, 2000, 4000, and 8000 addresses, respectively, and in that order. For each of these, give the first IP address assigned, the last IP address assigned, and the mask in the w.x.y.z/s notation.

Sol.

A: 198.16.0.0 – 198.16.15.255 written as 198.16.0.0/20 
B: 198.16.16.0 – 198.23.15.255 written as 198.16.16.0/21 
C: 198.16.32.0 – 198.47.15.255 written as 198.16.32.0/20 
D: 198.16.64.0 – 198.95.15.255 written as 198.16.64.0/19

(31) A router has just received the following new IP addresses: 57.6.96.0/21, 57.6.104.0/21, 57.6.112.0/21, and 57.6.120.0/21. If all of them use the same outgoing line, can they be aggregated? If so, to what? If not, why not?

Sol.

可以聚合成57.6.96.0/19, 這個時候會有57.6.120.0/21沒有被聚合,但是有最大匹配原則所以不要緊。

(32) The set of IP addresses from 29.18.0.0 to 19.18.128.255 has been aggregated to 29.18.0.0/17. However, there is a gap of 1024 unassigned addresses from 29.18.60.0 to 29.18.63.255 that are now suddenly assigned to a host using a different outgoing
line. Is it now necessary to split up the aggregate address into its constituent blocks, add the new block to the table, and then see if any reaggregation is possible? If not, what can be done instead?

Sol.

不需要,因為有最長匹配,所以單獨聚合即可。

(34) Many companies have a policy of having two (or more) routers connecting the company to the Internet to provide some redundancy in case one of them goes down. Is this policy still possible with NAT? Explain your answer.

Sol.

After NAT is installed, it is crucial that all the packets pertaining to a single connection pass in and out of the company via the same router, since that is where the mapping is kept. If each router has its own IP address and all traffic belonging to a given connection can be sent to the same router, the mapping can be done correctly and multihoming with NAT can be made to work.

所以是可以的,只要網絡中的每個主機發給特定router即可。

(36) Describe a way to reassemble IP fragments at the destination.

Sol.

In the general case, the problem is nontrivial. Fragments may arrive out of order and some may be missing. On a retransmission, the datagram may be fragmented in different-sized chunks. Furthermore, the total size is not known until the last fragment arrives. Probably the only way to handle reassembly is to buffer all the pieces until the last fragment arrives and the size is known. Then build a buffer of the right size, and put the fragments into the buffer, maintaining a bit map with 1 bit per 8 bytes to keep track of which bytes are present in the buffer. When all the bits in the bit map are 1, the datagram is complete.

所以就是等尾巴來,就可以確定總長度,然后等所有分段都來就可以重組了。

(37) Most IP datagram reassembly algorithms have a timer to avoid having a lost fragment tie up reassembly buffers forever. Suppose that a datagram is fragmented into four fragments. The first three fragments arrive, but the last one is delayed. Eventually, the timer goes off and the three fragments in the receiver's memory are discarded. A little later, the last fragment stumbles in. What should be done with it?

Sol.

前三段已經被discard了,那么第四段再來會被當成新的,過一段時間一樣被扔。

(38) In both IP and ATM, the checksum covers only the header and not the data. Why do you suppose this design was chosen?

Sol.

其他部分的checksum可以交給上層協議,而且開銷太大,此外頭的錯誤非常嚴重。

(39) A person who lives in Boston travels to Minneapolis, taking her portable computer with her. To her surprise, the LAN at her destination in Minneapolis is a wireless IP LAN, so she does not have to plug in. Is it still necessary to go through the entire business with home agents and foreign agents to make e-mail and other traffic arrive correctly?

Sol.

當然需要,無線網是數據鏈路層和物理層的事情,和IP層無關,還是要利用家鄉代理。

(41) The Protocol field used in the IPv4 header is not present in the fixed IPv6 header. Why not?

Sol.

因為在IPv6頭中有一個字段叫下一個頭,會說明該字段要交給哪一種上層協議處理。

(42) When the IPv6 protocol is introduced, does the ARP protocol have to be changed? If so, are the changes conceptual or technical?

Sol.

不需要做任何改變,只是IP地址需要更長的空間而已。

第六章:傳輸層

(1) In our example transport primitives of Fig.6-2, LISTEN is a blocking call. Is this strictly necessary? If not, explain how a nonblocking primitive could be used. What advantage would this have over the scheme described in the text?

Sol.

The LISTEN call could indicate a willingness to establish new connections but not block. When an attempt to connect was made, the caller could be given a signal. It would then execute, say, OK or REJECT to accept or reject the con- nection. In our original scheme, this flexibility is lacking.

(2) 像bittorrent這種點對點應用如何區分哪個是connect哪個listen呢?

Sol.

可以競爭,也可以隨機,也可以由上層協議控制。

(3) 假設網絡層是百分百正確的那么三次握手協議會有什么樣的變化?

Sol.

第三次握手就沒有必要了,主機2收到主機1的請求時,直接就確立連接,返回給1確認信息后,1也確立連接。

(7) Suppose that the clock-driven scheme for generating initial sequence numbers isused with a 15-bit wide clock counter. The clock ticks once every 100 msec, and the maximum packet lifetime is 60 sec. How often need resynchronization take place
a. (a)in the worst case?
b. (b)when the data consumes 240 sequence numbers/min?

Sol.

首先,現在的規定是這樣的,通信的時候初始段的序號等于始終序號,因此在x秒的時候同步的信號序號為x,注意,建立連接之后,序號就和時間無關了?。。?!

第二,在時間x時,不允許發送x+T(T是lifetime)序號的段,這是為什么呢?因為你這個段會生存T秒,而在隨后的T秒內如果要建立一個連接,可能會和你現在發的這個段序號一樣的懂嗎?

(a) 題目是這樣的,假設在70秒的時候,你建立了一個連接,這個時候你發出去的信號序號為70。注意,之后你要發送的序號是71,然后你一直忍著不發(這就是最壞的情況),然后時間繞了一圈回來了,時間變成了11秒,此時你再想發71,對不起,規則不允許,因為在11秒的時候,不允許發71。這就是最壞情況了,所以必須重新同步一次。答案是3276.8-60=3216.8

(b) 這個時候變成追及問題,最后計算出來結果是5361.3

總結,你發送速率與時鐘速率越接近,需要同步的間隔就越長。但是如果一上來超過時鐘速率就直接GG。

因為這種方法不好所以后來創造了三次握手,兩邊的初始序列號都是隨機值,就不需要那么麻煩的時鐘什么的啦。只要雙方確認了,后面都好辦。

(9) Imagine that a two-way handshake rather than a three-way handshake were used to
set up connections. In other words, the third message was not required. Are deadlocks
now possible? Give an example or show that none exist.

Sol.

有可能出問題,主機2的確認被延遲了,那么可能會建立起一個重復的連接。

(11) Consider the problem of recovering from host crashes (i.e.,Fig.6-18). If the interval
between writing and sending an acknowledgement, or vice versa, can be made relatively small, what are the two best sender-receiver strategies for minimizing the chance of a protocol failure?

Sol.

If the AW or WA time is small, the events AC(W) and WC(A) are unlikely events. The sender should retransmit in state S1; the receiver’s order does not matter.

(13) Discuss the advantages and disadvantages of credits versus sliding window protocols.

Sol.

滑動窗口協議用于流量控制。

The sliding window is simpler, having only one set of parameters (the win- dow edges) to manage. Furthermore, the problem of a window being increased and then decreased, with the segments arriving in the wrong order, does not occur. However, the credit scheme is more flexible, allowing a dynamic management of the buffering, separate from the acknowledgements.

(14) 擁塞控制的公平性方面的策略,加法遞增乘法遞減(AIMD).

(15) Why does UDP exist? Would it not have been enough to just let user processes send
raw IP packets?

Sol.

無法確認端口。

(17) A client sends a 128-byte request to a server located 100 km away over a 1-gigabit optical fiber. What is the efficiency of the line during the remote procedure call?

Sol.

發送包需要128*8/1G=1.024us, 在路上的時間100km/200000 = 50us, 然后一來一回100us,因此利用率約為1%。
所以說這個時候的制約不是帶寬而是距離。

(19) Both UDP and TCP use port numbers to identify the destination entity when delivering a message. Give two reasons for why these protocols invented a new abstract ID (port numbers), instead of using process IDs, which already existed when these protocols were designed.

Sol.

進程id動態變化,不易管理,端口號可以被進程綁定,而且一些知名服務需要用固定端口號。

Here are three reasons. First, process IDs are OS-specific. Using process IDs would have made these protocols OS-dependent. Second, a single process may establish multiple channels of communications. A single process ID (per process) as the destination identifier cannot be used to distinguish between these channels. Third, having processes listen on well-known ports is easy, but well-known process IDs are impossible.

(20) 何時選用基于UDP的RPC,合適使用基于TCP的RPC。

Sol.

RPC是遠程過程調用,可以建立客戶端-服務器應用。如果請求不是冪等的(冪等是如同計數器加一這種命令,執行次數不同會產生不同結果),那就可以考慮使用UDP。同時,如果傳遞的數據包并不大,可以考慮使用UDP。

(22) 最小TCP MTU的總長度是多少?包括TCP和IP的開銷,但是不包括數據鏈路層的開銷。

Sol.

MTU是最大傳輸單元,最小的TCP MTU可以設置,如果一臺主機不設置的話默認是536+20=556字節的TCP段。Internet要求每臺主機至少能夠處理556字節的段。

(23) RTP is used to transmit CD-quality audio, which makes a pair of 16-bit samples 44,100 times/sec, one sample for each of the stereo channels. How many packets per second must RTP transmit?

Sol.

Each sample occupies 4 bytes. This gives a total of 256 samples per packet. There are 44,100 samples/sec, so with 256 samples/packet, it takes 44100/256 or 172 packets to transmit one second’s worth of music.

按照標準答案的理解,RTP的一個packet只能傳輸1024字節,不清楚這個規定是在哪里。

(25) Would it be possible to place the RTP code in the operating system kernel, along with the UDP code? Explain your answer.

Sol.

應該要分開,RTP是基于UDP的協議,其他應用程序也要調用UDP,因此最好可以把兩段代碼分開。

錯了!

Sure. The caller would have to provide all the needed information, but there is no reason RTP could not be in the kernel, just as UDP is.

(26) 主機1的端口p和主機2的端口q之間可能存在多個TCP連接嗎?

Sol.

不可能,一對端口之間只能有一個TCP連接。一個進程可以有多個TCP連接。

(27) ACK標志位有什么用?

Sol.

ACK標志位用來表示ACK字段是否有意義。其實在連接已經建立起來之后ACK標志位已經沒有意義了,因為ACK是必須的。而在連接建立的過程中,這是非常重要的。

(28) 為什么TCP段的有效載荷是65495字節?

Sol.

因為TCP長度為16位標示,所以最多65535字節,然后去掉TCP頭20字節,去掉IP頭20字節。剩下65495字節。

(30) Consider the effect of using slow start on a line with a 10-msec round-trip time and no congestion. The receive window is 24 KB and the maximum segment size is 2 KB. How
long does it take before the first full window can be sent?

Sol.

慢速啟動是TCP協議中擁塞控制的一個算法,略看。The first bursts contain 2K, 4K, 8K, and 16K bytes, respectively. The next one is 24 KB and occurs after 40 msec.

(31) Suppose that the TCP congestion window is set to 18 KB and a timeout occurs. How big
will the window be if the next four transmission bursts are all successful? Assume that
the maximum segment size is 1 KB.

Sol.

也是擁塞控制的算法,TCP維護一個擁塞窗口,略看。The next transmission will be 1 maximum segment size. Then 2, 4, and 8. So after four successes, it will be 8 KB.

(33) A TCP machine is sending full windows of 65,535 bytes over a 1-Gbps channel that has
a 10-msec one-way delay. What is the maximum throughput achievable? What is the line efficiency?

Sol.

One window can be sent every 20 msec. This gives 50 windows/sec, for a maximum data rate of about 3.3 million bytes/sec. The line efficiency is then 26.4 Mbps/1000 Mbps or 2.6 percent.

因此有延遲的網絡傳輸效率和窗口大小,延遲有很大關系。

(34) What is the fastest line speed at which a host can blast out 1500-byte TCP payloads with a 120-sec maximum packet lifetime without having the sequence numbers wrap around? Take TCP, IP, and Ethernet overhead into consideration. Assume that Ethernet frames may be sent continuously.

Sol.

TCP中每個Byte會占用一個序號,而TCP的sequence number是32位的,所以可以每120s發送2^32Bytes信息,然而1500B信息需要1500+20+20+26(以太網)的段幀來發送因此需要的帶寬為2 ^ 32 * 8 * 1566 / 1500 / 120 = 299Mbps。

The goal is to send 2^32 bytes in 120 sec or 35,791,394 payload bytes/sec. This is 23,860 1500-byte frames/sec. The TCP overhead is 20 bytes. The IP overhead is 20 bytes. The Ethernet overhead is 26 bytes. This means that for 1500 bytes of payload, 1566 bytes must be sent. If we are to send 23,860 frames of 1566 bytes every second, we need a line of 299 Mbps. With any- thing faster than this we run the risk of two different TCP segments having the same sequence number at the same time.

(35) 為什么那么多人在為了ipv4的局限性做努力,而對TCP的局限性卻沒有人這樣做。

Sol.

根本原因是IP協議運行在所有路由器上。

IP is a network level protocol while TCP is an end-to-end transport level protocol. Any change in the protocol specification of IP must be incorporated on all routers in the Internet. On the other hand, TCP can works fine as long as the two end points are running compatible versions. Thus, it is possible to have many different versions of TCP running at the same time on different hosts, but not this is not the case with IP.

(36) In a network that has a maximum TPDU size of 128 bytes, a maximum TPDU lifetime of 30 sec, and an 8-bit sequence number, what is the maximum data rate per connection?

Sol.

TPDU:Transport Protocol Data Unit 協議數據單元。

2 ^ 8 * 128 * 8 / 30 = 8.7kbps

(37) Suppose that you are measuring the time to receive a TPDU. When an interrupt occurs,
you read out the system clock in milliseconds. When the TPDU is fully processed, you read out the clock again. You measure 0 msec 270,000 times and 1 msec 730,000 times. How long does it take to receive a TPDU?

Sol.

27次是0ms,73次是1ms,那么平均是730us。

(38) A CPU executes instructions at the rate of 1000 MIPS. Data can be copied 64 bits at a time, with each word copied costing 10 instructions. If an coming packet has to be copied four times, can this system handle a 1-Gbps line? For simplicity, assume that all instructions, even those instructions that read or write memory, run at the full 1000- MIPS rate.

Sol.

1000M * 64 /10 / 4 = 1.6 Gbps > 1Gbps 可以.

(41) For a 1-Gbps network operating over 4000 km, the delay is the limiting factor, not the bandwidth. Consider a MAN with the average source and destination 20 km apart. At what data rate does the round-trip delay due to the speed of light equal the transmission delay for a 1-KB packet?

Sol.

20 * 2 / 200000 = 200us延遲 發送1KB要200us的話,帶寬至少要1024 * 8 * 1 / 200u = 40 Mbps

(43) What is the bandwidth-delay product for a 50-Mbps channel on a geostationary satellite? If the packets are all 1500 bytes (including overhead), how big should the window be in packets?

Sol.

The round-trip delay is about 540 msec, so with a 50-Mbps channel the bandwidth-product delay is 27 megabits or 3,375,000 bytes. With packets of 1500 bytes, it takes 2250 packets to fill the pipe, so the window should be at least 2250 packets.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,460評論 6 538
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,067評論 3 423
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事?!?“怎么了?”我有些...
    開封第一講書人閱讀 177,467評論 0 382
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,468評論 1 316
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,184評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,582評論 1 325
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,616評論 3 444
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,794評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,343評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,096評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,291評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,863評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,513評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,941評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,190評論 1 291
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,026評論 3 396
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,253評論 2 375

推薦閱讀更多精彩內容