Home > other >  Don't understand determine whether in the same network segment algorithm
Don't understand determine whether in the same network segment algorithm

Time:01-26

Just learning network, I see two PC communication, the Internet is set to A and B, A to contact B, know B IP but don't know the MAC address, if they are in the same network segment, can send ARP request, is not the same network segment is sent to the gateway, and judge whether the same network segment method is A IP address and A bitwise and mask, it is concluded that the network number. Then the IP address of the B and A bitwise mask and the results considered B network number, if two network number is the same, is A and B in the same network segment, different is not in the same network segment,

So if it is the following configuration:
A: 192.168.0.1/16
B: 192.168.1.1/24

From A to b, as follows:

192.168.0.1 & amp; 255.255.0.0 - & gt; 192.168.0.0
192.168.1.1 & amp; 255.255.0.0 - & gt; 192.168.0.0

According to the above algorithm is the same network segment, but from B:

192.168.1.1 & amp; 255.255.255.0 - & gt; 192.168.1.0
192.168.0.1 & amp; 255.255.255.0 - & gt; 192.168.0.0

According to the above algorithm, it is not the same network segment,

So the question is as follows:
1. Don't know B mask, use the IP address of the B and calculate their own mask, the result indicates that the first n bits of B and A first n bits of the same (n is A number 1 in the mask of),
That A and B in A network segment? From B is not the same network segment?
2. Whether in the same network segment is decided to PC to send ARP or sent to A gateway, that here A just send ARP, B to gateway?




  • Related