Cracking the coding interview--Q17.4
来源:互联网 发布:linux ant打包 编辑:程序博客网 时间:2024/06/07 18:38
题目
原文:
What is a network / subnet mask? Explain how host A sends a message / packet to host B when: (a) both are on same network and (b) both are on different networks.Explain which layer makes the routing decision and how.
译文:
网络/子网掩码是什么?解释主机A是如何发送消息/包给主机B的当:(a) A,B在同一网络上。 (b) A,B在不同网络上。解释哪一层做出路由决定,是怎么做的?
解答
掩码是一个用于识别网络/子网地址的位模式。IP地址由两部分组成:网络地址和主机地址。
IP地址被分为不同的类,这些类标识了它的网络地址。
例如:IP地址:152.213.011.002,它属于B类地址。那么:
网络掩码:11111111.11111111.00000000.00000000IP 地址:10011000.11010101.00001011.00000010
对网络掩码和IP地址做与操作,我们得到以下网络地址和主机地址:
网络地址:10011000.11010101.00000000.00000000 (152.213.0.0)主机地址:00001011.00000010
同样地,网络管理员可以用子网掩码将任何网络划分成子网。要做到这一点, 我们可以进一步将主机地址划分成更多子网。
例如,如果要将上述网络划分成18个子网(至少需要5位二进制位25 > 18), 我们可以将主机地址的前5位用于标识子网地址。
子网掩码:11111111.11111111.11111000.00000000 (255.255.248.0)IP 地址:10011000.11010101.00001011.00000010
对子网掩码和IP地址做与操作,我们得到以下的子网地址:
10011000.11010101.00001000.00000000 (152.213.8.0)
例如:2014.03阿里实习生笔试:假如主机的ip地址是192.168.5.121,而子网掩码为255.255.255.248,则主机的网络号部分(包括子网号部分)是192.168.5.120
主机A是如何发送消息/包给主机B
当两台主机在同一网络上时,通过主机地址的二进制位识别其它主机。
当两台主机不在同一网络时,路由器通过网络掩码来识别网络并路由数据包。 每台主机可以通过网络主机地址来识别。
网络层负责进行路由决策。路由表存储路径信息及其对应的开销, 路由算法使用路由表来决定路由这些数据包的路径。
路由一般分为静态路由和动态路由。划分依据是: 路由表是固定的还是会根据当前网络状况而改变。
---EOF---
- Cracking the coding interview--Q17.4
- Cracking the coding interview--Q17
- Cracking the coding interview--Q17.1
- Cracking the coding interview--Q17.2
- Cracking the coding interview--Q17.3
- Cracking the coding interview--Q17.5
- Cracking the Coding Interview
- 《Cracking the coding interview》
- Cracking The Coding Interview
- Cracking the coding interview
- Cracking the coding interview
- Cracking the coding interview--Q12.4
- Cracking the Coding Interview Chap1 Q1.4
- Cracking the coding interview--Q1.4
- Cracking the coding interview--Q2.4
- Cracking the coding interview--Q3.4
- Cracking the coding interview--Q1.4
- Cracking the coding interview--Q2.4
- 将vim搭建为一个编辑方便的类C/C++ IDE环境
- 初学unity第二篇
- CSDN博文精选:最受欢迎的系列专栏博客推荐
- 网站seo优化常见问题和解决方法
- 黑马程序员10_动态代理
- Cracking the coding interview--Q17.4
- vos2009系统配置(4)
- CString,Char*,string 互相转换
- codeforce 189A 完全背包之必须装满问题
- 范数的定义
- 怎样面对搜索引擎算法调整
- 设计模式之单例模式 (一)
- oracle知识点
- JVM详解之Java垃圾回收机制详解和调优