Thursday, February 18, 2021

Subnetting - Introduction to Subnetting

 

Concept derived from Udemy class - introduction to subnetting

How to do subnetting
- Understanding subnetting basic
- IPv4 addressing
- Numbering systems

Before Subneting
IP Address
- Network Identifier
- Host Identifier

After subnetting
IP address
- Network Identifier
- Host Identifier
  - Subnet Identifier
  - Host Identifier


Binary basic

Numbering system
- Decimal

- Binary (Base2)
  - Base10


1. Decimal numbers include
- 0 to 9
- Noted as Decimal or Dec
Decimal numbers
1 to any number does not matter
0, 5 10, 12345 999934343434

All numbers are decimal numbers.


Binary numbers
- Binary number include
-> 1 and 0
- Binary numbers are always 1 and 0
For example
0, 1, 10, 110, 110011 ......

Please note: 1 in binary does not mean 1 in decimal.
- Every binary number has a corresponding decimal value and vice-versa.

Binary number        Decimal Equivalent
------------        ------------------
1            1
10            2
1010            10
1111            15

Converting from binary to decimal

Each position for a binary number has a value
There are 8 positions and from right to left the power of 2 to 0 to 7
so we have

-    -    -    -    -    -    -    -    
2^7    2^6    2^5    2^4    2^3    2^2    2^1    2^0
128    64    32    16    8    4    2    1


Now, start from right to convert 1010
It takes 4 positions from right side

                1    0    1    0
---    --    --    --    --    --    --    --
128    64    32    16    8    4    2    1
---------------------------------------------------------
                8    0    2    0
so we add which position value is 1, not the 0.
so, we have 8+0+0+2 = 10

1010 in binary is equal to 10 in decimal.
Note: If you have more binary number, you keep adding 2^x.
so you will have 2^8, 2^9 and so on.


Terminology
-----------

Bits
Bytes
Octets

Bits
- Smallest number you can represent
- In binary bits are 1s and 0s.
- Bits are infact electrical signals such as on or off.

Bytes
- Bytes are group of 8 bits. 11111111

Octets
- Octets are grouping of 8 bits.
- For eg, 11111111.11111111.00000000.00000000 (NetMask)


How many different numbers?
- Lets tryUsing 2 bits (2^2 =4)

- There are 4 different binary numbers with two bits.
-> 00    (i.e. decimal 0)
-> 01    (i.e. decimal 1)
-> 10    (i.e. decimal 2)
-> 11    (i.e. decimal 3)

So, we have combinaton of 1s and 0s produces 4 different binary number.

-> Now try with 3 bits (2^3 - two to the power 3 = 8)
   2^4 = 16 bits
-> There are eight different binary numbers with three bits:
-> 000    (i.e. decimal 0)
-> 001    (i.e. decimal 1)
-> 010    (i.e. decimal 2)
-> 011    (i.e. decimal 3)
-> 100    (i.e. decimal 4)
-> 101    (i.e. decimal 5)
-> 110    (i.e. decimal 6)
-> 111    (i.e. decimal 7)

Now, converting from Decimal to a Binary
----------------------------------------

Now, take the decimal number and use the substraction. Lets pick a number 185

can we substract 185 from 128? lets try
 185
-128
----
 057
now, the next number is 64, can we substract 64, no, so we use 0,
next number is 32, can we substract, yes, so
 57
-32
---
 25
now, next number is 16, can we substract, yes
 25-16=9
how about 8, yes we can
9-8=1
now, can we substract 1 from 1, yes
1-1=0
so we have

so, we can simplyfy this way, whereever you can substract, you use 1 and wherever you can't
use 0, so you get the answer


1    0    1    1    1    0    0    1
---    ---    ---    ---    ---    ---    ---    ---
128    64    32    16    8    4    2    1

Decimal number 185, can you substract 128 from 185? Yes


---    ---    ---    ---    ---    ---    ---    ---
128    64    32    16    8    4    2    1

so, the binary number of 185 is = 10111001

if you want to convert do dec, do the math


128    64    32    16    8    4    2    1
---    ---    ---    ---    ---    ---    ---    ---
1    0    1    1    1    0    0    1
----------------------------------------------------------
128 +   0  +     32 +     16 +    8 +    0  +     0  +     1
128+32+16+8+1=185


Note: Subnet is build on binary system


        1    0    0    1    0    1
128    64    32    16    8    4    2    1
---------------------------------------------------------
32+4+1=37

1. 10101010=128+42= 170
2. 10001101=141
3. 10010111=151
4. 01010101=85
5. 100101=37
6. 01111101
125-64= 61-32=29-16=13-8=5-4=1-1=0  [128 is missing so we add 0]
01111101
7. 63=00111111
63-32=31-16=15-8=7-4=3-2=1-1=0    [Missing values are 0, since we are missing for 128 and 64]
8. 48=110000 => 00110000
48-32=16-16=0

9. 250 = how?
11111010
10. 3608= 111000011000 how?

-----------------------------------------------

Numbering systems - Binary math

In binary, everything is 1s and 0s.

Binary addition
Note: in binary 1+1 is not equal to 2. It is either 0 or 1.

Lets add
  1    1    1
+        1
-----------------

we add from right side 1+1, so value does not fit or we can't do it, we add 0
and 1 goes to 2s position
so it becames like this
  1    1    1
+    1    
-----------------
    0    0
same thing happens and the 1 moves to 3rd position

  1    1    1
+ 1        
-----------------
  0    0    0
again 0, so I moves to new position - 4th
so we add 0 to 4th position and add 1
so, the result is 0+1=1

  0     1    1    1
+ 1        
--------------------------
  1    0    0    0

Now, lets convert this binary number into decimal

0    0    0    0    1    0    0    0
---    ---    ---    ---    ---    ---    ---    ---
128    64    32    16    8    4    2    1
2^7    2^6    2^5    2^4    2^3    2^3    2^1    2^0
------------------------------------------------------------
0 +    0 +    0 +    0 +    8 +     0 +    0 +    0
--------------------------------------------------------
=8

NOW, lets add another value
    1    0    1
+            1
--------------------------
            0
here, 1+1=0, because we can't add there,
next step
    1    0    1
+        1    1
--------------------------
        1    0
0+1=1, here we can add 0 and 1 which becomes 1
so, we have no more value to add, so the final result is

    1    0    1
+        1    1
--------------------------
    1    1    0

110
convert this binary number to decimal
we have only 3 numbers, we its

1    1    0
2^2  +  2^1 +     2^0
4 +    2  +    1
---------------------
4 +    2 +    0 =6    





No comments:

Post a Comment

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...