>> Let's take a look at how subnet masks are used.
>>让我们看看子网掩码是如何使用的。
We'll also explore why both physical MAC addressesand logical IP addresses are always needed for communication.
我们还将探讨为什么通信总是需要物理MAC地址和逻辑IP地址。
Let's do all of that with a couple of stories.
让我们用几个故事来做这些。
In story number one, host A with IP address 10.10.1.1 wants to communicatewith host B whose IP address is 10.10.1.2.
在故事1中,IP地址为10.10.1.1的主机A想与IP地址为10.10.1.2的主机B通信。
The source of the traffic will take its IP address in subnet maskand perform a boolean and operation.
通信流的源将在子网掩码中获取其IP地址并执行布尔值和操作。
All 32 bits of the IP address are lined up with the 32 bits of the subnet mask.
IP地址的所有32位与子网掩码的32位对齐。
In this case, the subnet mask of the source 10.10.1.1 is 255.255.255.0 in base 10.
在这个例子中,这个子网掩码是属于源10.10.1.1的,它是255.255.255.0以基数10.
In binary, it looks like 24 ones followed by 8 zeros.
在二进制中,它看起来像是24个1后面跟着8个0。
This means that the first 24 of the 32 bits are network bitsand are shared by every device on this network.
这意味着32位中的前24位是网络位,并由网络上的每个设备共享。
The last eight bits are host bits and are unique in entirety to each host on this network.
最后8位是主机位,对这个网络上的每个主机都是完全唯一的。
Each of the four base 10 numbers is known as an octetbecause each number is represented by eight bits in binary.
以10为底的的四个数字被称为一个八位字节,因为每个号码是由八位二进制表示。
Subnet masks can span multiple octets and need not be contained to a multiple of eight bits.
子网掩码可以跨越多个八位元,不需要包含八个位元的倍数。
For example, instead of 255.255.255.0, the mask could have been 255.255.255.192where the first 26 bits are network bits and the last six bits are host bits.
例如,掩码不是255.255.255.0,而是255.255.255.192,其中前26位是网络位,后6位是主机位。
When the host logically ends each of the 32 columns bringing down a 1 if both bitsin the column are ones and bringing down a zero if the two bits in a column are not both ones,what results is what we call a network identifier.
当主机在逻辑上结束32列中的每一列时,如果列中的两个位都是1,就会得到1,如果列中的两个位都不是1,就会得到0,结果就是我们所说的网络标识符。
In this case, the source's network identifier is 10.10.1.0.
在本例中,源的网络标识符是10.10.1.0。
No matter how many host bits are in an IP address, if they are all zerosthat represents a network ID and cannot be assigned to a host.
无论IP地址中有多少主机位,如果它们都是表示网络ID且不能分配给主机的零。
In this case, there are eight host bits and they can't all be zeros because the IP addresswith all host bits set to zero represents the network ID.
在这种情况下,有8个主机位,它们不可能都是0,因为所有主机位都设置为0的IP地址表示网络ID。
In fact, they can't be all ones either because when all host bits are set to onethat represents a network broadcast address and, like a network ID, cannot be assigned to hosts.
事实上,它们也不可能都是1,因为当所有主机位被设置为表示网络广播地址的位时,就像网络ID一样,不能分配给主机。
This network's broadcast address with all host bits set to one would be 10.10.1.255.
这个网络的广播地址的所有主机位设置为1将是10.10.1.255。
Any pattern besides all zeros and all ones for the host bits, that's legal and validto be assigned to devices on the network.
除了主机位的所有0和所有1之外,任何模式都可以合法且有效地分配给网络上的设备。
Now the source needs to determine if the destination is on the same networkor a different one by performing a second boolean and operation.
现在,源需要通过执行第二个布尔值和操作来确定目标是在同一个网络上还是在另一个网络上。
The source takes the destination IP address and logically ends itwith the sources own subnet mask.
源获取目的IP地址,并用源自身的子网掩码来逻辑地结束它。
The destination's subnet mask is unknown and it is never transmitted.
目标的子网掩码是未知的,它永远不会被传输。
The destination's IP address is either known by the source or resolvedfrom its name using a protocol we'll explore in a future module called DNS, domain name system.
目标的IP地址要么由源知道,要么使用我们将在以后的DNS模块(域名系统)中讨论的协议从其名称解析。
The source doesn't actually need the destination's mask because if they areon the same network their subnet masks will be the same anyway.
源实际上并不需要目的地的掩码,因为如果它们在同一个网络上,那么它们的子网掩码无论如何将是相同的。
After logically ANDing the destination IP address of 10.10.1.2 with the source maskof 255.255.255.0, the resultant network ID matches the network ID of the source 10.10.1.0.
在逻辑上将目标IP地址10.10.1.2与源掩码255.255.255.0进行匹配之后,得到的网络ID与源网络ID 10.10.1.0匹配。
This lets the source know that the destination is on the same networkand traffic can be delivered directly.
这让源知道目的地在同一个网络上,并且可以直接交付流量。
转载于:https://www.cnblogs.com/sec875/articles/10344635.html
