所谓广播地址指同时向网上所有的主机发送报文,也就是说,不管物理网络特性如何,internet网支持广播传输。如136.78.255.255就是B类地址中的一个广播地址,你将信息送到此地址,就是将信息送给网络号为136.78的所有主机。
广播地址(Broadcast Address):这是一个特殊地址,当数据包可以寻址到该地址时,可以帮助所有设备打开和处理信息。例如,MAC 地址,格式为 1xFFFFFFFF 是一种广播地址;IP 地址255.255.255.255是通用广播地址。任何设备都将打开寻址到广播地址的信息,并将它们传送到下一个工作站。
很多局域网都定义了一个特殊的保留地址, 称为广播地址. 当信息头中目的地址域的内容为广播地址时, 该帧被局域网上所有计算机接收. 这个过程称为广播.
专门用于同时向网络中所有工作站进行发送的一个地址。在使用TCP/IP 协议的网络中,主机标识段hostid 为全1 的IP 地址为广播地址,广播的分组传送给hostid 段所涉及的所有计算机。例如,对于10.1.1.0 (255.255.255.0 )网段,其广播地址为10.1.1.255 (255 即为2 进制的11111111 ),当发出一个目的地址为10.1.1.255 的分组(封包)时,它将被分发给该网段上的所有计算机。
广播地址主要有两类 广播地址应用于网络内的所有主机
1)有限广播
它不被路由但会被送到相同物理网络段上的所有主机
IP地址的网络字段和主机字段全为1就是地址255.255.255.255
2)直接广播
网络广播会被路由,并会发送到专门网络上的每台主机
IP地址的网络字段定义这个网络,主机字段通常全为1,如 192.168.10.255
四种I P广播地址: 受限的广播受限的广播地址是255.255.255.255。该地址用于主机配置过程中IP数据报的目的地址,此时,主机可能还不知道它所在 网络的网络掩码,甚至连它的IP地址也不知道。在任何情况下, 路由器都不转发目的地址为受限的广播地址的数据报,这样的数据报仅出现在本地网络中。
指向网络的广播指向子网的广播
指向子网的广播地址为主机号为全1且有特定子网号的地址。作为子网直接广播地址的IP地址需要了解子网的掩码。例如,如果路由器收到发往128.1.2.255的数据报,当B类网络128.1的子网掩码为255.255.255.0时,该地址就是指向子网的广播地址;但如果该子网的掩码为255.255.254.0,该地址就不是指向子网的广播地址。
指向所有子网的广播
指向所有子网的广播也需要了解目的网络的子网掩码,以便与指向网络的广播地址区分开。指向所有子网的广播地址的子网号及主机号为全1。例如,如果目的子网掩码为255.255.255.0,那么IP地址128.1.255.255是一个指向所有子网的广播地址。然而,如果网络没有划分子网,这就是一个指向网络的广播。
子网掩码与广播地址
合法的广播地址就是主机的网络地址加上最大的主机号。网络地址通过机器的ip地址与子网掩码按位与得出,我们以ip地址为10.78.202.175 ,子网掩码为255.255.255.0。
为例来分析一下上面的几个概念
首先将这两个东西换算成二进制代码
ip地址:00001010.01001110.11001010.10101111
子网掩码:11111111.11111111.11111111.00000000
按位与之后得出网络地址:00001010.01001110.11001010.00000000
十进制表示就是10.78.202.0
这个网络地址理论上可以有256台主机,但是除去网络地址
0和广播地址255之后,实际上只能有254台主机
那么我们可以知道175就是你这台机器的主机号,
广播地址就是最大的主机号,也就是10.78.202.255。
有没有255.255.255.255可能成为一个合法的广播地址呢?
答案是不可能因为0.0.0.0不是一个合法子网掩码。
比如192.168.1.10这个IP,它的掩码应该是255.255.255.0 因为是个C类地址
将IP地址与掩码地址做与运算,得到的就是网络地址,255的部分不变 0的部分与后就变成了0,所以是192.168.1.0 而广播地址就是网络地址中的0部分变成255就是了,192.168.1.255 而网关就是你这台IP的机器要去访问其他所属的网络地址比如192.168.2.0这个网段必须交给的地址,注意网关的地址应该是和你的PC地址同一网段,一般是192.168.1.254或者192.168.1.1
已知 IP地址为:202.112.14.137
子网掩码:255.255.255.224
要求计算出这台主机所在的网络地址和广播地址是?
解:
第一步,确定网络位和主机位。
首先,把IP地址(202.112.14.137) 转换为二进制,
那么就是:11001010.01110000.00001110.10001001
然后,把子网掩码(255.255.255.224)也转换为二进制,即:
11111111.11111111.11111111.11100000
那么,它的网络位应该是蓝色部分:
11001010.01110000.00001110.10001001
它发生了借位。它的主机位应该是后五位,即红色部分。
到了这一步,已经很明白地看出,它的网络地址就是:
11001010.01110000.00001110.10000000
把主机位(后五位)全部清零,就得出了上面的网络地址。
换算为十进制就是:202.112.14.128
它的广播地址就是:把主机位的全0变为全1,即:
11001010.01110000.00001110.10011111
换算为十进制就是:202.112.14.159
多练习几次,牢记了十进制和二进制的换算规则,这题就不会难倒你了
1.172.16.10.33/27 中的/27也就是说子网掩码是255.255.255.224 即27个全1
2.从子网掩码255.255.255.252得出其网络位为30位,所以只有剩下的2位为主机位,主机位全零的为网络地址,主机位全1的为广播地址,剩余的主机号码为主机地址范围
3.公有地址(Public address)由Inter NIC(Internet Network Information Center 因特网信息中心)负责。这些IP地址分配给注册并向Inter NIC提出申请的组织机构。通过它直接访问因特网。
私有地址(Private address)属于非注册地址,专门为组织机构内部使用。私网IP地址是不可能直接用来跟WAN通信的,要么利用帧来进行通信(例如FR帧中继,HDLC,PPP)要么需要路由的NAT功能把私网地址转换成一个公网IP地址
以下列出留用的内部私有地址
A类 10.0.0.0--10.255.255.255
B类 172.16.0.0--172.31.255.255
C类 192.168.0.0--192.168.255.255
再根据CCNA中会出现的题目给大家举个例子:
首先,我们看一个考试中常见的题型:一个主机的IP地址是202.112.14.137,掩码是255.255.255.224,要求计算这个主机所在网络的网络地址和广播地址。
常规办法是把这个主机地址和子网掩码都换算成二进制数,两者进行逻辑与运算后即可得到网络地址。其实大家只要仔细想想,可以得到另一个方法:255.255.255.224的掩码所容纳的IP地址有256-224=32个(包括网络地址和广播地址),那么具有这种掩码的网络地址一定是32的倍数。而网络地址是子网IP地址的开始,广播地址是结束,可使用的主机地址在这个范围内,因此略小于137而又是32的倍数的只有128,所以得出网络地址是202.112.14.128。而广播地址就是下一个网络的网络地址减1。而下一个32的倍数是160,因此可以得到广播地址为202.112.14.159。
CCNA考试中,还有一种题型,要你根据每个网络的主机数量进行子网地址的规划和计算子网掩码。这也可按上述原则进行计算。比如一个子网有10台主机,那么对于这个子网需要的IP地址是:
10+1+1+1=13
注意:加的第一个1是指这个网络连接时所需的网关地址,接着的两个1分别是指网络地址和广播地址。因为13小于16(16等于2的4次方),所以主机位为4位。而
256-16=240
所以该子网掩码为255.255.255.240。
如果一个子网有14台主机,不少人常犯的错误是:依然分配具有16个地址空间的子网,而忘记了给网关分配地址。这样就错误了,因为:
14+1+1+1=17
17大于16,所以我们只能分配具有32个地址(32等于2的5次方)空间的子网。这时子网掩码为:255.255.255.224。
例1:下面例子IP地址为192·168·100·5 子网掩码是255·255·255·0。算出网络地址、广播地址、地址范围、主机数。
(一)分步骤计算
1) 将IP地址和子网掩码换算为二进制,子网掩码连续全1的是网络地址,后面的是主机地址。 虚线前为网络地址,虚线后为主机地址
2)IP地址和子网掩码进行与运算,结果是网络地址
3) 将上面的网络地址中的网络地址部分不变,主机地址变为全1,结果就是广播地址。
4) 地址范围就是含在本网段内的所有主机
网络地址+1即为第一个主机地址,广播地址-1即为最后一个主机地址,由此可以看出
地址范围是: 网络地址+1 至 广播地址-1
本例的网络范围是:192·168·100·1 至 192·168·100·254
也就是说下面的地址都是一个网段的。
192·168·100·1、192·168·100·2 。。。 192·168·100·20 。。。 192·168·100·111 。。。 192·168·100·254
5) 主机的数量
主机的数量=2二进制的主机位数-2
减2是因为主机不包括网络地址和广播地址。本例二进制的主机位数是8位。
主机的数量=28-2=254
(二)总体计算
我们把上边的例子合起来计算一下过程如下:
例2: IP地址为128·36·199·3 子网掩码是255·255·240·0。算出网络地址、广播地址、地址范围、主机数。
1) 将IP地址和子网掩码换算为二进制,子网掩码连续全1的是网络地址,后面的是主机地址, 虚线前为网络地址,虚线后为主机地址
2)IP地址和子网掩码进行与运算,结果是网络地址
3)将运算结果中的网络地址不变,主机地址变为1,结果就是广播地址。
4) 地址范围就是含在本网段内的所有主机
网络地址+1即为第一个主机地址,广播地址-1即为最后一个主机地址,由此可以看出
地址范围是: 网络地址+1 至 广播地址-1
本例的网络范围是:128·36·192·1 至 128·36·207·254
5) 主机的数量
主机的数量=2二进制位数的主机-2
主机的数量=212-2=4094
减2是因为主机不包括网络地址和广播地址。