Why use a subnet mask?

The subnet mask can be isolated from the network and host addresses in the IP address, so why separate it? Because the two hosts to communicate, we must first determine whether the segment in the same network, i.e. the network address are the same. If so, then the packet can be sent directly to the target host, otherwise you will need a gateway router forwards the packet to the destination. It can be appreciated that a simple: To Host A result of calculation And the host communication and B, A and B are each IP address and subnet mask of the host A, appreciable:

1, if the results are identical, the two hosts are in the same network segment, so that A can find B's MAC address by broadcasting ARP, B A MAC address can also be found to implement normal communication.

2, if a different result, ARP broadcast will end at the local gateway, this time A will send packets B of the first distributed to local gateway, then to query the routing table based on the IP address of the host B, and then continue to pass data packets forwarding, delivery to the final destination B.

Computer gateway (Gateway) is exported to other segments, that is, the IP address of the router interface. IP address of the router interface used can be any one of the network segment address, but usually use the first available address of the network segment or the last available address, which is to avoid as much as possible and this site in a segment host address conflict.

Guess you like

Origin www.cnblogs.com/zlnb/p/11946200.html