IT Lessons Learn

Exploring the Digital World in an Easy to Understand Way.


IPv4 Subnetting Series Part 1: Beginner’s Binary Bonanza

I talked briefly about subnetting IPV4 in this other post https://itlessonslearn.com/2023/03/01/a-brief-introduction-to-network-ipv4-addresses/.  This post focuses on how to subnet IPV4 and more or less assumes the reader has not do subnetting before. This will be a bit of a retread.  In the useful links below, I’ve included a link to an online calculator that can do this for you automatically if you want to take easier route.  The first step in understanding subnetting is that binary machines view all data as a series of 1’s or TRUE and 0’s FALSE.     A bit is the smallest unit of data storage for computers and our current machines store many bits.   Binary machines manipulate bits and do something based on the results. The binary number system functions as powers of 2 and generally will start at the right most bit and work its way down.   For example, 245 as binary looks like 11110101 and the right most binary which happens to be set is equal to 1 in decimal. The left most bit is also 1 but its place value in decimal is 128. Binary is a zero-based number system.  So, in a binary, the number places 1-8 are actually 0-7 and so on.

In the tables below, there is a few collections of what happens to bits when ran thru the relevant bitwise operation. For readability, the set bits (which are equal to 1) are listed as true and the cleared bits (which are equal to 0) are listed as false.

AND Operation  (All bits must be true to set output bit to true)
TRUETRUETRUE
FALSETRUEFALSE
FALSEFALSEFALSE
TRUEFALSEFALSE
This table lists what happens to a pair of bits when the bitwise AND operation is applied to a series of bits.
OR Operation (Only one bit out of any in a series of bits needs to be true to set output true)
TRUETRUETRUE
FALSETRUETRUE
FALSEFALSEFALSE
TRUEFALSETRUE
This table lists what happens to a pair of bits when the bitwise OR operation is applied to series of bits.
XOR Operation   (Either bit BUT NOT BOTH need to be true to set output as true)
TRUETRUEFALSE
FALSETRUETRUE
FALSEFALSEFALSE
TRUEFALSETRUE
This table lists what happens to a pair of bits when the bitwise XOR operation is applied to a series of bits.
NOT Operation (Flip input bit)
TRUEFALSE
FALSETRUE
This table lists what happens to bits when the bitwise NOT operation applied to said bits.

How a left most significant byte (8 bits) looks like.

1286432168421
0 or 10 or 10 or 10 or 10 or 10 or 10 or 10 or 1
Table representative of converting decimal to binary

Going between binary and decimal is as easy as taking the power of 2 out a number.  I’ll break down the number 204 to binary as an example.  We already know that it can be stored in 8 bits.

204
-128
76
Mathematics!

Don’t forgot to set bit 7 to 1.

1286432168421
1       
Binary and Decimal cross reference table

Next, let’s half our 128 to 64 (bit 6) and see if it’s not too large to take out 76.

76
-64
12
Mathematical

It’s not. Yay!

Don’t forgot to set bit 6 to 1.

1286432168421
11      
Progress!

Let’s keep going.  32 is too large. Half of 32 is 16 and that’s still too large for our needs.   This means we set bits 5 and 4 to 0 also.

1286432168421
1100    
Setting the bits for 32 and 16 to 0 due to both being larging that 12.

Next, let’s see if 8 can be taking out of 12. It can and leaves us with 4 which happens to be a power of 2. Don’t forget to set bit 4 to true.

12
-8
4
More math
1286432168421
11001   
Positive Progress

With 4 being all that’s left, we can just set bit 3 to true while setting bits 2 and 1 to false. It would look like this table below.

1286432168421
11001100
Price of Progress

One quick plug into Bing and we got a screenshot of the binary value for 204.  Note that the 0b at the beginning is being used to indicate that the 11001100 number is binary rather than decimal.

There are tools to do things like this but said tools may not be allowed if one is taking a proctored test. The useful links include the tool used for the above screenshot. For that reason, it’s useful to know how to do it manually if the need arises.

One thing that can be useful is a spreadsheet application such as Excel or Apache OpenOffice – Official Download if Excel is unavailable. The function in Excell is called ‘DEC2BIN’ and it takes a decimal number either from a cell or a hardcoded specific decimal number and outputs the equivalent in binary. One will need to be a little careful in mentally filling out blanks or just specify how many places that are desired in the output number. The table below shows some simple Excel formulates to get started.

=DEC2BIN(A2)Convert the number in cell A2 to binary
=DEC2BIN(25,8)Convert 25 to binary and used 8 numerical places to store it.
=BIN2DEC(cell)Convert the passed number expressed in binary to decimal.
Some Useful Spreadsheet Routines for going between binary and decimal. Using the equal sign tells the software that the cell is a formula rather than simply words.
Example Excel Use.

This concludes the post. My plan for posting is once a week on Mondays but that did not happen this week. My apologies. Next post will break down the IPv4 Addressing format, what’s a network mask and why subnetting is useful in large networks. If I can get it to work, I’ll upload a Packet Tracer set do demonstrate the difference between a network that’s subnetted and one that’s not.

Useful links:

Decimal to Binary Converter (rapidtables.com) – use an online tool.

Cisco Packet Tracer – Networking Simulation Tool (netacad.com) – get starting learning about networks for FREE.

IP Subnet Calculator – use an existing tool.



Leave a comment

About Me

I’m a Network Engineer A.S. Graduate and enjoy learning how to do something new with computers. I also enjoy video gaming. This blog plans to focus primarily on IT related things such as how to do something or learning about a technology. Video Gaming Posts likely may crop up from time to time. Thank you for visiting!

Newsletter