It's likely that the subnet masks are throwing you off. As long as you keep in mind that the below rules no longer apply, you should be fine.
Ultimately classful addressing came down to the most significant (or "leading") bits in the address. Nothing more, nothing less.
- Class A: Most significant bits starts with
0
- Class B: Most significant bits start with
10
- Class C: Most significant bits start with
110
The "classes" came from the way they split up the address space for use between "host" and "network". Keep in mind that back then (way way back, from the days of ARPANET), subnet masks did not exist, and the network was intended to be inferred from the address itself. So, with the above in mind, this is what they came up with (this is intended to be binary representation - each N
or H
represents a single bit in the 32-bit address):
- Class A:
NNNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH
(less networks, more hosts)
- Class B:
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH
(more networks, less hosts)
- Class C:
NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH
(even more networks, even less hosts)
Here the N
is representative of the network portion of the address, and the H
is representative of the host portion of the address, or as they called it back in the day, the "rest field."
Combining that with what was said earlier about the most-significant bits, we have the following:
- Class A: 0.0.0.0 - 127.255.255.255
- Class B: 128.0.0.0 - 191.255.255.255
- Class C: 192.0.0.0 - 223.255.255.255
Converting those ranges to binary may make this more clear:
Class A
0.0.0.0
-----------
[0]0000000.00000000.00000000.00000000
127.255.255.255
-----------
[0]1111111.11111111.11111111.11111111
^
most significant bit = 0
Class B
128.0.0.0
-----------
[10]000000.00000000.00000000.00000000
191.255.255.255
-----------
[10]111111.11111111.11111111.11111111
^
most significant bits = 10
Class C
192.0.0.0
-----------
[110]00000.00000000.00000000.00000000
223.255.255.255
-----------
[110]11111.11111111.11111111.11111111
^
most significant bits = 110
Every single address within those ranges will share a common leading bit(s). The moral of the story is, if you can remember what the leading bits are supposed to be (0 for class A, 10 for class B, 110 for class C) it's extremely simple to determine what "class" an address would have otherwise belonged in. Or, if decimal is easier:
- Class A: First octet in address is between 0 and 127, inclusive
- Class B: First octet in address is between 128 and 191, inclusive
- Class C: First octet in address is between 192 and 223, inclusive
The easiest way to mess someone up on "classful addressing" either on a test, or exam, or whatever, is to use misdirection by way of a subnet mask. Again, remember that the subnet mask does not apply for determining the class of an address. This is easy to forget because as others have said, classless addressing and routing have been around for over two decades now, and the subnet mask and CIDR notation have become ubiquitous in the industry.
First of all that You have route from PC0 to PC1 doesn't mean that You have route from PC1 to PC0.
Thats are Zinin’s 3 routing principles:
- "Every router makes its decision alone, based on the
information it has in its own routing table.“
- "The fact that one router has certain information in
its routing table does not mean that other routers have the same
information.“
- "Routing information about a path from one network to
another does not provide routing information about the reverse, or
return path."
That means all routers must have full routing table to all networks - R1 to networks beyond R3 and R3 to all networks beyond R2.
Besides R3 probably don't have any information about networks at the other site of R2. You can check it showing R3 routing table - show ip route
Best Answer
The purpose of the Subnet Mask is to determine whether the host you are trying to speak to is on your network or on a foreign network.
If the other host is on your network, the sending host is going to send the data directly to the other host.
If the other host is on a foreign network, the sending host is going to send the data to its default gateway.
In your example:
PC1 is configured as a
/24
, which means it thinks everything in this range is on the local network:192.168.1.0 - 192.168.1.255
. This range includes PC2's IP address, and therefore PC1 considers PC2 to be on its local network.PC2 is configured as a
/16
, which means it thinks everything in this range is on the local network:192.168.0.0 - 192.168.255.255
. This range includes PC1's IP address, and therefore PC2 considers PC1 to be on its local network.Since they both think the other is on the local network, they both follow the rules to communicate with another host on the local network. The fact that their masks are not identical ends up being irrelevant.
That said, as Xavier Nicollet pointed out in the comments... just because it works, doesn't mean it's a good idea. This should be avoided when possible.
Disclaimer: The Youtube video links above are my own creation, I am providing them to the reader to show additional context about hosts communicating on the same networks and foreign networks