IP addresses and subnet masks

Alan Case

Lifetime Supporting Member
Join Date
Apr 2002
Location
Wagga Wagga
Posts
1,268
Hi.
My understanding of a class C address for example 192.168.210.10 was that it could only communicate with devices on the 192.168.210.X range when a subnet mask of 255.255.255.0 was used. Changing the 3rd octet of the mask did not allow a 192.168.210.x device to talk to a device on the 192.168.211.x network.
A class B network device ie 172.16.x.x device could talk to all approx 65k devices on these 2 networks if you use a 255.255.0 subnet.

Now I am being told that there is classless addressing and you can manipulate the subnet on a class C to allow a 192.168.210.x device to talk to a 192.168.211.x device.

The above relates to PLC, drive, remote io etc devices.

Regards Alan Case
 
Changing to netmask 255.255.0.0 (netmask 16) should make it possible on the same network, 192.168.210.x to 192.168.211.x

Is there a gateway between?

Address: 192.168.210.10
Netmask: 255.255.0.0 = 16
Wildcard: 0.0.255.255
=>
Network: 192.168.0.0/16 (Class C)]
Broadcast: 192.168.255.255
HostMin: 192.168.0.1
HostMax: 192.168.255.254
Hosts/Net: 65534
 
Last edited:
On the subnet mask the bits set to 0 are the bits that can vary to define the internal IPs range

For example with a subnet mask = 255.255.254.0 in your case all 512 IPs between 192.168.210.0 to 192.168.211.255 will be on the same subnet and can communicate each other directly.

But you can't use all the 512, some are reserved :
- 192.168.210.0 that defines the subnet itself
- 192.168.211.255 the broadcast IP
- The IP of the router/gateway which can be any IP within the range.
 
Forget all about class when using private networks. The class system doesn't really apply here, because all private network devices allow you to subnet to any degree,

I'll simplify the following explanations to make it easier.

Most times it is easier to see what is happening by converting the decimal numbers into binary "octets", 8 bits per number, which gives a 32 bit binary address.

For any two devices to communicate with each other, without any magic boxes between, there are two "rules"....

.. they must be in the same "network number"
.. they must have a different "host number"

The Class System

This defines which of the bits in the IP address are the network number (NetID), and which bits are the host number (HostID). The class system does not use subnets or subnet masking.

Class A

The first binary bit of the first octet is a 0.
The next 7 bits are the "network number" (NetID), and the remaining 24 bits are the "host number" (HostID).
Allows for a small number of logical networks (2^7) = 128, each with (2^24)-2 = 16,777,214 hosts.

Class B

The first 2 binary bits of the first octet are 10
The next 14 bits are the NetID, and the remaining 16 bits are the HostID.
Allows for more logical networks (2^14) = 16384, but a reduced number of hosts on each network (2^16)-2 = 65,534.

Class C

The first 3 binary bits of the first octet are 110
The next 21 bits are the NetID, and the remaining 8 bits are the HostID.
Allows for more the most logical networks (2^21) = 2,097,152, but a much reduced number of hosts on each network (2^8)-2 = 254

Summary....
Code:
Class A : 0nnnnnnn-hhhhhhhh-hhhhhhhh-hhhhhhhh
Class B : 10nnnnnn-nnnnnnnn-hhhhhhhh-hhhhhhhh
Class C : 110nnnnn-nnnnnnnn-nnnnnnnn-hhhhhhhh
where n = netID, and h = hostID

It should be fairly clear from the above that the class system can be very wasteful of IP addresses.

For example as your organisation grows, and expands around the globe, you will need to network your IP devices, computers, printers etc. via the internet. You might initially request 100 IP addresses, and you will be assigned a Class C address, allowing you up to 254 devices.

As your organisation grows further, you realise that 254 IP addresses is not going to be enough, so you re-apply for, say 1,000. The issuing authority has no choice but to give you a Class B address range, allowing for 65,534 unique hosts, far more than you need, but you have to have them regardless. And no-one else can use the 64,534 "unused" addreses either, so they are "wasted" from the available pool on the internet.

The situation becomes even worse when you move up from a Class B to a Class A, millions of addresses are "wasted" until you use them.

My next post will describe how "Subnetting" works on private networks.......
 
My last post described the Class system for IP addressing, this one will outline the Class-less system, using Sub-Nets....

Clearly the Class system is inflexible, and gives rise to huge jumps in the numbers of devices you can allow to communicate with.

On private networks, therefore, the technology of subnetting was introduced.

Instead of the beginning of the IP addresses designating the split between the NetID and the HostID, this is done with the Subnet Mask.

A subnet mask is another 32-bit binary number, where a "1" defines which portion of the IP Address is the NetID, and a "0" defines which portion of the IP address is the HostID.

An example....

Code:
IPAddress   : 192.168.001.123 : 11000000-10101000-00000001-01111011
Subnet Mask : 255.255.255.000 : 11111111-11111111-11111111-00000000
In the above address, 192.168.1.xxx is the Network Number (NetID), and xxx.xxx.xxx.123 is the host number (HostID) on that logical network.

The same rules as for Class apply....

for two devices to successfully communicate with each other, without any "magic" boxes between them, they needs to be on the same NetID, and have different HostIDs.

With a Subnet mask of 255.255.255.0, we are effectively saying it is a Class C address, with the subtle difference that we can use all 24 bits to specify our NetID, instead of 21. That gives us whole lot more network numbers to play with !!

The scenario I exampled above, where a network has to "grow" beyond a Class "boundary" doesn't hinder us in any way, we can simply drop a "1" in the subnet mask, to double the nember of HostIDs we can use...

e.g.

Code:
255.255.255.0 : 11111111-11111111-11111111-00000000
255.255.254.0 : 11111111-11111111-11111110-00000000
The first allows for 254 hosts on the network (2^8)-2
The second allows for 510 : (2^9)-2

NB : It is customary, but in no way mandatory, to have leading 1's, and trailing 0's in the subnet mask, and when this is the case a network address can be specified like 192.168.1.123/24 where the /24 denotes how many leading 1's are in the subnet mask. I have seen networks with "odd" masking arrangements like 11111111-11111000-11110000-00000000, which gives rise to "blocks" of the address ranges that are compatible, rather than a single range.

Conversion of IP Addresses and Subnet Masks to binary from decimal will reveal all, and there are many IP Calculators on the internet to make the job of subnetting much easier.

The NIC hardware does the necessary filtering of whether messages are accepted or not using simple AND logic on the IP and Subnet, to ascertain whether the 2 "rules" are true, or not, as the case may be.
 
Hi.
My understanding of a class C address for example 192.168.210.10 was that it could only communicate with devices on the 192.168.210.X range when a subnet mask of 255.255.255.0 was used. Changing the 3rd octet of the mask did not allow a 192.168.210.x device to talk to a device on the 192.168.211.x network.
A class B network device ie 172.16.x.x device could talk to all approx 65k devices on these 2 networks if you use a 255.255.0 subnet.

Now I am being told that there is classless addressing and you can manipulate the subnet on a class C to allow a 192.168.210.x device to talk to a 192.168.211.x device.

The above relates to PLC, drive, remote io etc devices.

Regards Alan Case

There are older legacy devices out there that do enforce the Class based subnets, but pretty much anything you've bought in the past 10 years should support the classless subnetting.

You are correct that, in theory, changing the subnet like you described will allow for device A to talk to device B. HOWEVER, Device B won't be able to respond unless its subnet is also changed. That may sound obvious to an IT guy, but I've seen many people stumble over it before they really understand what is going on.

One other thing to keep in mind is that when considering PLC/remote IO, the programming software will probably put limits on what IP/Subnet mask your IO can have, to ensure they can talk to the PLC..
 
>>NB : It is customary, but in no way mandatory, to have leading 1's, and trailing 0's in the subnet mask,

How does this post, in any way, validate this statement?
 
Can you provide a reference for this please?

I can't provide an actual reference, none of the references I've ever read on subnetting even mention it. I just thought I'd mention it in case anyone comes across such a situation and believes it to be an error, it could just as easily be deliberate.

Suffice to say I have seen this strategy used, it was on a large manufacturing plant, and the company's IT department created and maintained all of the networking. As is the case of many corporate IT departments, they kept everything close to their chests, and would only divulge the minimum information to get projects working.

I couldn't see the point of it at the time, but it most certainly worked, simply because the NIC does a logical AND of the IP address with the subnet mask to work out the NetID.

The NIC doesn't check that the subnet mask consists only of leading ones and trailing zeroes, it just goes ahead and does the AND regardless of what the bits actually are.

I've not gone into the logic of it much, perhaps I need to write a spreadsheet to see what happens, but as stated it does create blocks of non-contiguous IP address ranges, and possibly a way of further subnetting a subnet ???

Taking it to the extreme, if you had a subnet mask of, say, 255.255.0.1, then the least significant bit of the IP address becomes part of the NetID, so you have split your networks into 2 sub-types, in this case Even and Odd, but you block out using bit 0 in the HostID, which means you can only have even-numbered HostID's.... absolute madness !!

EDIT : If anyone is wondering, I did not dream this up, and am not on any medication. However the subnet mask is formed, providing the two "rules" I quoted are observed, then it all gets sorted out, albeit with some strange results in most peoples minds
 
Last edited:
Wow, I never seen anything like that. There are something called "wildcard mask" but the function of that is very different.

I also wouldn't assume that IT know what they are doing.
 
I also wouldn't assume that IT know what they are doing.

I never did, it was their baby, their time used, their headache when things didn't go as planned. We just took the numbers they gave us and punched them in.

I've done a fair bit of digging, and all references I've found use the /nn suffix to denote the "boundary" between NetID and HostID, so they're never going to admit that there could ever be a "/16/4/2/18" (yikes !!) suffix, denoting a subnet mask of 11111111-11111111-00001100-00000000.

I suppose my quoted example is such a rarity that no-one has ever considered it to be a valid means of subnetting, but just remember, it's only a logical AND away from defining the NetID, and those stray 1's in the 0's will "kill" blocks of potential HostID's.
 
I have found a reference to what I have talked about.

This is from an early RFC from 1985, and in that era the Network Number and Subnet were considered to be separate entities, but the principles are the same.

The highlighted text describes my example.

2018-02-05_195036.jpg
 
Last edited:
Interesting stuff - your research goes back farther than mine. Microsoft doesn't seem to agree:

https://technet.microsoft.com/en-us/library/cc958832.aspx

Network Prefix Length Representation of Subnet Masks
Because the network ID bits must always be chosen in a contiguous fashion from the high order bits, a shorthand way of expressing a subnet mask is to denote the number of bits that define the network ID as a network prefix using the network prefix notation: /<# of bits>. Table 1.15 lists the default subnet masks using the network prefix notation for the subnet mask.

Nor the following RFCs:

https://tools.ietf.org/html/rfc1878
See table

http://www.ietf.org/rfc/rfc1518.txt

http://ipset.netfilter.org/iptables.man.html
The mask can be either a network mask or a plain number, specifying the number of 1's at the left side of the network mask.

Good info, though. Thanks for the reference.

Good discussion on the topic: https://superuser.com/questions/979915/are-subnets-always-contiguous-1s
 
Last edited:
As I said, I came across it many many years ago, and if IT had already built their unstable ivory tower on an obsolete RFC then that was their legacy.....

I knew it was a strange thing to do when I saw it, as it effectively chopped chunks of HostIDs from the allowable range, but I just figured they had their reasons.

It was the same IT department that allocated IP addresses for programming machines, and I estimated I would have up to 5 systems engineers on-site. I asked for a block of 16, they gave me 5, and allocated the next ones to another system integrator.... go figure !!
 

Similar Topics

I am trying to create a network setup that would take many devices that are working together and have them appear as one device or IP on a network...
Replies
3
Views
2,277
Hello to all, Is it possible to export Codesys symbols to .txt, .csv or .xml in a similar manner like exporting symbol table in STEP 7? For...
Replies
0
Views
124
Hi guys, so I'm using BOOTP/DHCP tool in my virtual machine for setting up an IP addresses for basically everything. My only issue is always with...
Replies
3
Views
358
Hi. I'm doing an upgrade of an old 1400e to a new panel view plus 7 standard using ftv studio v 12,which will be communicating to a slc 5/04 via...
Replies
15
Views
2,610
Trying to find the proper documentation to explain the CC-Link Parameters for Mitsubishi remote I/O. The system I am modifying uses several...
Replies
0
Views
345
Back
Top Bottom