Computer Network Homework 1

本文解答了《Computer Networks》和《Data and Computer Communication》中的多个练习题,涉及数据传输速率、延迟计算、广播子网效率、协议层级开销等问题。

Computer Networks》:chapter 1 problems 1, 6, 10, 20, 27, 28.

 

1.    Imagine that you have trained your St. Bernard, Bernie, to carry a box ofthree 8-mm tapes instead of a flask of brandy. (When your disk fills up, youconsider that an emergency.) These tapes each contain 7 gigabytes. The dog cantravel to your side, wherever you may be, at 18 km/hour. For what range ofdistances does Bernie have a higher data rate than a transmission line whosedata rate (excluding overhead) is 150 Mbps? How does your answer change if (i)Bernie’s speed is doubled; (ii) each tape capacity is doubled; (iii) the datarate of the transmission line is doubled.

Answer:

(1)  3*7gigabytes = 21gigabytes = 168 gigabits

18km/hour = 0.005m/s

x/0.005 = 200x

So: 168gigabits/200x > 150/1024 Gbps

x > 5.73 (or x > 5.6 if you suggest that 150Mbps =150/1000 Gbps)

(2)  (i)  168gigabits/100x >150/1024 x > 11.46

       (ii)  2*168gigabits/200x>150/1024x > 11.46

       (iii) 168gigaits/200x > 300/1024 x > 2.87

 

2. A client-server system uses a satellite network,with the satellite at a height of 40,000 km. What is the best-case delay inresponse to a request?

Answer: Total Distance:40,000km * 4 = 160,000km

            C = 300,000km/s Sov = 533msec


3.A disadvantage of a broadcast subnet isthe capacity wasted when multiple hosts attempt to access the channel at thesame time. As a simplistic example, suppose that time is divided into discreteslots, with each of the n hosts attempting to use the channel with probability pduring each slot. What fraction of the slots are wasted due to collisions?

 

Answer: Every channel has three statuses.Free, used but not congestion, congestion. The probability of free is (1-p)^n,and the probability of used but not congestion equals np(1-p)^(n-1). So theanswer is 1-np(1-p)^(n-1)-(1-p)^n.

 

4.A system has an n-layer protocolhierarchy. Applications generate messages of length M bytes. At each 
of thelayers, an h-byte header is added. What fraction of the network bandwidth isfilled with headers?

Answer: According to “each of the layers,an h-byte header is added”. We can draw the conclusion that the answer is h*n/(M+h*n).

 

5.How long was a bit on the original802.3 standard in meters? Use a transmission speed of 10 Mbps and 
assume thepropagation speed in coax is 2/3 the speed of light in vacuum.

Answer: 200m/μsec  In 10Mbps, it will cost 0.1μsec fornetwork to transmit a single bit. C*2/3 = 2*10^8m/s

So the answer is 2*10^8*0.1μsec=20m

 

6.An image is 1024 x 768 pixels with 3bytes/pixel. Assume the image is uncompressed. How long does it 
take totransmit it over a 56-kbps modem channel? Over a 1-Mbps cable modem? Over a10-Mbps Ethernet? Over 100-Mbps Ethernet?

Answer: The size of image: 1024*768*3 =18874368bits

            For 56-kbps: 18874368 / 56000 = 337.042s

            For1M-kbps: 18874368 / 1000000 = 18.874s

            For 10M-kbps: 18874368 / 10000000= 1.8874s

            For 100M-kbps: 18874368 / 100000000 = 0.189s

 

《Data and computer communication》:chapter 2problems  2, 3, 4

2.2 a.

The Frenchand Chinese prime ministers need to come to an agreement by telephone, butneither speaks the other’s language. Further, neither has on hand a translatorthat can translate to the language of the other. However, both prime ministershave English translators on their staffs. Draw a diagram similar to Figure 2.12to depict the situation, and describe the interaction and each level.


b. Now supposethat the Chinese prime minister’s translator can translate only into Japaneseand that the French prime minister has a German translator available. Atranslator between German and Japanese is available in Germany. Draw a newdiagram that reflects this arrangement and describe the hypothetical phone con-versation.


2.3  List the major disadvantages with thelayered approach to protocols.

Answer: Layered protocols willcause delay or some ranges of distortion in the messages which will be transmitted.

2.4  Two blue armies are each poised onopposite hills preparing to attack a single red army in the valley. The redarmy can defeat either of the blue armies separately but will fail to defeatboth blue armies if they attack simultaneously. The blue armies com- municatevia an unreliable communications system (a foot soldier). The commander withone of the blue armies would like to attack at noon. His problem is this: If hesends a message to the other blue army, ordering the attack, he cannot be sureit will get through. He could ask for acknowledgment, but that might not getthrough. Is 
there a protocol that the two blue armies can use to avoid defeat?

Answer: No. Blue armies willnever ensure whether the information has been transmitted safely.

### ImportError: cannot import name 'NetworkTopology' from 'my_network' 在 Python 中,`ImportError: cannot import name 'NetworkTopology' from 'my_network'` 表示尝试从模块 `my_network` 中导入名为 `NetworkTopology` 的对象时失败。以下是可能导致此错误的原因及解决方法: #### 1. 模块中不存在目标名称 如果模块 `my_network` 中未定义 `NetworkTopology`,则会引发该错误。需要检查模块文件 `my_network.py` 是否包含 `NetworkTopology` 的定义[^1]。 ```python # my_network.py class NetworkTopology: def __init__(self): pass ``` #### 2. 文件路径问题 Python 解释器无法找到 `my_network` 模块。这可能是由于当前工作目录或 `PYTHONPATH` 环境变量未正确配置。确保模块所在的目录位于解释器的搜索路径中[^2]。 可以通过以下代码检查模块搜索路径: ```python import sys print(sys.path) ``` 若模块不在路径中,可以临时添加路径: ```python import sys sys.path.append('/path/to/module') ``` #### 3. 循环导入问题 如果两个模块相互导入,可能会导致循环依赖问题,从而引发 `ImportError`。例如: ```python # module_a.py from module_b import B class A: pass # module_b.py from module_a import A class B: pass ``` 这种情况下,应重构代码以避免循环依赖,或将部分导入移至函数内部[^3]。 ```python # module_a.py class A: pass # module_b.py class B: pass from module_a import A ``` #### 4. 拼写错误 检查是否拼写错误了模块名或对象名。例如,`NetworkTopology` 可能被误写为 `NetworkToplogy` 或其他形式[^4]。 #### 5. 条件导入或延迟导入 如果 `NetworkTopology` 是通过条件语句或其他逻辑动态导入的,可能会导致导入失败。建议直接在模块顶层进行明确的导入[^5]。 ```python # 不推荐 if some_condition: from my_network import NetworkTopology # 推荐 from my_network import NetworkTopology ``` #### 6. 版本兼容性问题 如果使用的是第三方库,可能是因为版本不兼容导致的导入错误。检查库的文档,确保安装的是正确的版本[^6]。 ```bash pip install my_network==1.0.0 ``` --- ### 示例代码 以下是一个完整的示例,展示如何正确导入并使用 `NetworkTopology`: ```python try: from my_network import NetworkTopology except ImportError as e: print(f"Import failed: {e}") else: topology = NetworkTopology() print("Import and initialization successful!") ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值