Results 1 to 6 of 6

Thread: IPv4 and Binary Basics For Beginners

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Posts
    149

    Post IPv4 and Binary Basics For Beginners

    IPV4 stands for Internet Protocol version 4. It has a 32-bit address broken down into 4 octets of 8 bits each (8 x 4 = 32). These octets are represented using dotted decimal notation. An example would be 192.168.1.1 (192 is the first octet (8-bits), 168 is the second octet (8-bits) and so on). Each octet cannot be larger than 255. Each octet needs to be converted into binary. Binary is the way computers communicate with each other. Eight 0’s and/or 1’s are used to translate each octet. Each octet equals 8 bits, and we know that there are 4 octets in an IP address, so 8 bits times 4 octets equals 32-bits.

    IPV4 is divided into classes of addresses. Each class has unique properties:

    Class A. First octet ranges from 1 through 126. <127 is a reserved address>

    Class B. First octet ranges from 128 through 191.

    Class C. First octet ranges from 192 through 223.

    If we take a look at the first octet of 192.168.1.1; We can see that 192 fits into the Class C category. To find out in which category our IP address belongs to we should always look at the first octet. What do those octets in the IP address mean and does it really matter what class they belong to? Well, yes, it does matter what class they belong to. The Octets in the different classes identify either the Network portion or the Host portion of the address.

    N = Network, H = Host
    Class A. N.H.H.H
    Class B. N.N.H.H
    Class C. N.N.N.H

    Breaking down an IP address:
    Let’s open up our command prompt and ping www.yahoo.com. The IP address I got at the time of this ping is 68.142.226.41. What class does this IP address fit into? If you guessed Class A you are right. By taking a look at the first octet which is 68 we can see that it fits into the Class A category. We can break it down like this:
    68.142.226.41:

    68. = N (network part of the IP) 8 bits in the network portion
    142. = H (host part of the IP) 8 bits in the host portion
    226. = H (host part) 8 bits in the host portion
    41 = H (host part) 8 bits in the host portion

    4 x 8 = 32 bits total. Four octets times eight is always 32 bits.

    Typically it is much easier to use a Class C type because you would only need to change the Host portion of the IP address which would only be one in Class C. For example if our gateway or the main IP for the router is 192.168.1.1, all the IPs in that network should all have the same first three octets which are 192.168.1.0. All the computers can then be given a different IP like 192.168.1.50, 192.168.1.51 and so on by just changing the last octet and keeping the first three. In a class B you would have to keep the first two and change the last two. With a class A you would keep the first and change the last three octets. So in Yahoo’s IP, the first octet (68) is the Network portion of the IP. So 142.226.41 are the host portion of that one computer you pinged. As you can see it can get quite complex for very large networks.
    Earlier in this essay/tutorial I mentioned routers love binary. How can we turn all of these numbers into binary? Binary is all 0’s and 1’s. It is very simple. Take out a sheet a paper and from Right to Left write down a number 1. Now double that 1 and next to it (on the left) right a 2. Now double that 2. Next to that 2 write down a 4. Double that 4 and so on until you reach 128. It should look like this:

    Formula: 128 64 32 16 8 4 2 1

    If you add these 8 numbers you are going to get 255. To get the binary of an IP address you will have to take out each IP address and calculate it. You must take the first octet and try to calculate what numbers from the formula add up to the first octet and so on. If the first octet is 10 you would put a 1 under 8 and a 1 under 2. 8+2 equals 10. Then all you have to do is put a 0 under the rest of the formula numbers. Do it like this:

    128 64 32 16 8 4 2 1 = 255
    ________________________________________________
    192.| 1 1 0 0 0 0 0 0
    168.| 1 0 1 0 1 0 0 0 128+32+8=168
    1. | 0 0 0 0 0 0 0 1 1=1
    1 | 0 0 0 0 0 0 0 1 1=1


    So now if we take all of those zeros and ones we get this:
    11000000 10101000 00000001 00000001. Awesome now we know how to convert these IP addresses into binary. But lets keep this in mind for right now. 1+1 = 1, 1+0 = 0, and 0+1 = 0. Yeah that’s right, 1 plus 1 is 1 and 0 plus 1 is zero.

    All networks have a default mask (wont get much into that, you can simply google network mask, or default mask):

    Class A’s default mask: 255.0.0.0
    Class B’s default mask: 255.255.0.0
    Class C’s default mask: 255.255.255.0

    (To get the binary numbers for these masks is so easy. If the number is 255 all we have to do is right down eight 1’s. (11111111 = 255). If it is a zero we write down eight 0’s (00000000 = 0)).
    So to get the default mask of your of your computers IP address all you have to do is calculate your IP address into binary. Then you calculate the default mask into binary. Remember now, you must look at the first octet of your IP address and find out in what category it fits into. If it is a class B then your default mask would be 255.255.0.0. (that in binary would be: 11111111 11111111 00000000 00000000).

    Earlier I mentioned that 1 + 1 equals 1 and 0 + 1 or 1 +0 equals 0. This is the binary formula for calculating your default mask into binary, that’s what your router will be using to send and receive, all zero’s and one’s. We have already calculate 192.168.1.1 and we got 11000000 10101000 00000001 00000001 when we calculated it into binary. So lets take this number and add it too the default masks’s binary number. In our case the 192 falls into the Class C so the default mask is 255.255.255.0
    ( 11111111 11111111 11111111 00000000).
    We add them like this (remember 1 + 1 equals 1 and 0 + 1 or 1 + 0 equals 0):
    192.168.1.1 = 11000000 10101000 00000001 00000001

    255.255.255.0 = 11111111 11111111 11111111 00000000
    __________________________________
    Default mask = 11000000 10101000 00000001 00000001

    So the default mask of 192.168.1.1 in binary is 11000000 10101000 00000001 00000001, the funny part is that the number you get should equal the 192.168.1.1 in binary. How many bits are there in the network portion of 192.168.1.1? Three times eight is 24. There are 24 bits in the network portion of the 192.168.1.1. If you don’t know how I got that re-read this tutorial.

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    149
    The binary calculation got unaligned so i uploaded this picture of how it looked like in word. Its much more easier to read.

  3. #3
    They call me the Hunted foxyloxley's Avatar
    Join Date
    Nov 2003
    Location
    3rd Rock from Sun
    Posts
    2,534
    Terr's tut on subnet masks
    Use the two together, for a better picture of the whole shebang

    Earlier I mentioned that 1 + 1 equals 1 and 0 + 1 or 1 +0 equals 0. This is the binary formula for calculating your default mask into binary, that’s what your router will be using to send and receive, all zero’s and one’s. We have already calculate 192.168.1.1 and we got 11000000 10101000 00000001 00000001 when we calculated it into binary. So lets take this number and add it too the default masks’s binary number. In our case the 192 falls into the Class C so the default mask is 255.255.255.0
    ( 11111111 11111111 11111111 00000000).
    We add them like this (remember 1 + 1 equals 1 and 0 + 1 or 1 + 0 equals 0):
    192.168.1.1 = 11000000 10101000 00000001 00000001

    255.255.255.0 = 11111111 11111111 11111111 00000000
    __________________________________
    Default mask = 11000000 10101000 00000001 00000001
    just as an aside .........
    could you check the adding.

    the final set :
    0+0=0 ?

    the subnet SHOULD be 11000000 10101000 00000001 00000000
    so now I'm in my SIXTIES FFS
    WTAF, how did that happen, so no more alterations to the sig, it will remain as is now

    Beware of Geeks bearing GIF's
    come and waste the day :P at The Taz Zone

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    149
    OOppss, a mistake there, thanks for finding it foxyloxley. 1 + 0 is 0 of course

  5. #5
    Senior Member
    Join Date
    Feb 2005
    Posts
    149
    Another mistake, hopefully the last one, is that i mentioned that the default mask is the same as the IP address in binary. That is not true... sorry about that. I dont know what g0t into me when saying that.

  6. #6
    They call me the Hunted foxyloxley's Avatar
    Join Date
    Nov 2003
    Location
    3rd Rock from Sun
    Posts
    2,534
    One more and we shoot you
    so now I'm in my SIXTIES FFS
    WTAF, how did that happen, so no more alterations to the sig, it will remain as is now

    Beware of Geeks bearing GIF's
    come and waste the day :P at The Taz Zone

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •