Introduction to IP Addressing and Binary
Introduction to IP Addressing and Binary
They show up all over the place on our computers every computer on a TCAP IP
network must have a uniqueIP address.
IP addresses are distinct in that it's going to be for values separated by three
dots.
That's it.
Just ones and zeros on and offs pulses of electricity or light whatever it might
be.
So I got to go game out and I'm going to represent zeros with little white beads.
And what we need to do in this episode is understand how we can take ones and zeros
and convert them into something like this.
So to do that the first thing you need to appreciate is that there really are no
dots dots don't exist in IP addresses.
Now if you take a look at this phone number would you actually dial an open
parenthesis and a close parenthesis and a dash as part of your dialing process on a
phone.
Of course not.
The reason those are there on a phone number is because human beings need to be
able to use telephones and they're used as separators.
We're going to break them up into four groups of eight so we're just going to
separate these with my hand and there's no particular reason for separating them
into four groups of eight other than it was chosen arbitrarily as a good way to do
this.
So I'm going to just kind of artificially separate them a little bit so we can see
it a little bit better.
If you have eight ones and zeros you could have all zeros.
Or we can have a whole bunch of combinations in between like this is one possible
combination between all zeros and all ones.
So the whole idea behind dotted decimal notation is that instead of us having to
say things like my IP address is 0 0 0 1 0 0 1 0 0 1 0 0 1 0.
The dotted decimal notation is nothing more than a shortcut a shorthand that we use
to represent 32 ones and zeros in a row.
Now in the IP world we start with zeros so it's 0 to 255 and that's where IP
addresses come from.
It's simply taking eight ones and zeros and converting it into a value that goes
between 0 and 255.
The secret to converting from binary to Dahdah decimal is to take a piece of paper
and remember one number.
Remember 128.
If you can remember that number you can convert this very very easily and you're
going to have to do this on the network plus by the way.
So if you could remember the number 128 you take a piece of paper and then the
upper left hand corner you write in 128 and then you take half of that then half
than half and half and half and half and half.
So if you take a look we've got one two three four five six seven eight locations.
Got it.
All right.
So once you've got this little cheat sheet let's go ahead and pick a value.
But on your piece of paper you could just write ones and zeros directly underneath
each of these letters 0 1 0 1 ok 1 1 0 0 0 1 0 1.
OK.
Now what you have to do at this point is simply take a look and wherever you have a
one you add those values together.
Now we don't add any of these because these are all zeros plus four is one hundred
ninety six.
We don't add the two because that's a zero plus one is one hundred ninety seven.
That's great but let's do it a few more times to make sure you get the idea.
Now again you could just write ones and zeroes on the piece of paper to do this for
yourself.
But let's go through the process and remember if it has a zero underneath that we
don't add it.
So 0 0 0 0 1 1 1 0 equals 14 as an octet.
Fantastic.
And again I'm just going to pick an arbitrary value so this time I'm going to do 1
0 1 0 1 0 1 0 and again you can write ones and zeroes underneath your piece of
paper to do the exact same thing I'm doing with my gobies.
So here we go.
First we'll get rid of the zeros so we're going to add 128 plus 32 and that's 160
plus 8 equals 168.
So 1 0 1 0 1 0 1 0 equals 170.
Fantastic.
After you look at these for a while you start to notice certain things for example
that these were all zeros like that.
You should be able to recognize some of these binary values and instantly be able
to convert it into an octet.
If you have just the one followed by seven zeros that's going to be 128.
If you have seven zeros with just the one that's one that's all you need to do to
take any binary value and convert it into an octet.
So now what I'm going to do is I'm going to give you an octet value and I need to
be able to convert it into binary.
Don't worry we still use the exact same tool just remember 128.
OK so I've got my little piece of paper with the 128 all the way down to the 1
again.
Let's start off with a pick an arbitrary value here between 0 and 255.
Let's do 171.
You start with your initial value 171 and you start on the left and you march over
to the right.
So we'll put a one bead there and we subtract 100 in 28 from one hundred and
seventy one and we get the remainder of 43.
So how many 16s are there and 11 hole that's bigger than 11 so there is zero.
How many tools are there and 3 1 and then that leaves a value of 1 and how many
ones are in one one.
Fantastic.
Let's try it again this time I'm going to pick another arbitrary value.
You guys get the right place and this time we're going to use the value to 24.
So we start with 2:24 how many 1:28 are there and 2:24.
So we go ahead and take the 32 how many 32 are there and 32.
There's exactly one and not were done.
So all we have to do is throw zeros in for the rest because we don't have the
remainder left to deal with so 2:24 equals 1 1 1 0 0 0 0 0.
Perfect.
And after we do the subtraction we have exactly 15 so that's moved down to the
eights.
Fantastic.
It's really important that you know how to convert binary to octets and octets to
binary not just for the network plus but for the real networking world.
Now keep in mind I've shown you how to do it by hand but in reality will use things
like Windows calculator there's apps that you can put on your phone that allow you
to do this conversion very very quickly and easily.
I'm a computer and I've got this IP packet that I want to send to another computer
on my broadcast domain.
I'm running.
I don't know say gigabit ethernet so I need to put MAC addresses and make an
Ethernet frame to put this IP packet inside of.
So to do that I'm going to have to get the MAC address of the other computer so
that I can go ahead make an Ethernet frame out of the whole shebang and send it out
so that that computer can get it now to do that I've got a problem.
And the problem is if this is me over here and I want to send it to this guy I may
know his IP address because I've got an IP packet but I don't know his MAC address.
All right.
I've gone ahead and thrown some IP addresses on each one of the computers to help
understand how ARP actually works.
And keep in mind what we're concentrating on is that I've got a IP packet over here
on my computer and I want to get it to this guy.
Please tell 192 168 15:23 So he's going to send this out now.
It's a broadcast but only one computer the purple computer is going to respond
because that's his IP address and he's going to say oh that's me and here's my MAC
address.
So by doing that when my computer gets that response he can then go ahead and put
the right MAC address.
Send out the ether net frame and send the data to that particular computer.
Now if you think about this for a little bit it would mean that every time I wanted
to talk to any computer on my network I would have to keep RPM and that would seem
to be inefficient.
Would it be a great idea if individual computers kept a list of all the different
IP addresses on their network as well as the MAC address.
Well they do and you can actually do an ARP command within windows to see the cache
of what your computer has kept track of.
Now when I run this you'll see that it's kept a bunch of IP addresses for computers
within my local area network.
I want you to ignore the static ones for right now let's just concentrate on the
dynamic ones.
These are stored within your computer and it'll keep these for a few minutes.
So if you do an ARP minus A on your computer you may not see as much so you might
find yourself having to you know go out to web browser or pinging other computers
or something to actually have ARP minus A show you anything.
Anyway the important thing for network plus is that if you want to see your ARP
cache you have to use the ARP space minus A command.
Art or address resolution protocol is simply what your computer uses when it has
the IP address and it needs to know the Mac.
Make sure you know ARP minus A for the network plus
ARP is what a computer uses when it knows the IP address, but needs the MAC address
Subnet Masks
Now if you take a look at this network first of all I got one two three four
computers on this network and they're all plugged together into the switch in the
center.
Now this router also has an IP address because routers always have an IP address.
That's part of one local area network but it also has another IP address which I
don't have on here right now.
Now here's the issue, now we know about ARP from the previous episode but the
challenge we have is how do we arp.
For example if this computer right here wants to talk to this computer right here
he would normally just broadcast out in arp get the IP address and everything would
be great.
However what does this computer right here what's to talk to somebody way out on
the Internet.
In that case he's still going to have to ARP but he's going to have to ARP to get
to his default gateway to his router.
So what we need is something built into every network that identifies it as its own
local area network and also a mechanism that allows an individual computer to
determine hey if I'm talking to this ip address this is a local call.
However if it's a long distance call go ahead and talk through your default gateway
through your router to get out to the Internet.
And that's where your subnet mask really comes into play.
Now to help get us all wrapped around on this concept I've got something laid out
right here I'd like you to take a look at.
Now what we're looking at down here is what we're going to call my network ID the
network ID is the part of the network numbering system that has to be identical for
every computer on this particular network.
Now on my network which I've decided to set up this way all the computers are going
to be 232 25 208.
The idea behind this is that when I'm setting up these network IDs no computer can
have just a zero as part of its numbering system because it's reserved for what we
call the network ID so I could have a computer in this network ID that's called a
232 7:35 dot 14 but no computer could be called 2:32 25 to 0 8 0.
Now the part over here that changes for every individual computer is going to be
called the host ID.
So what I'm going to do is I'm going to put a little skewer here to kind of
separate it and that's where this guy called the subnet mask comes into play a
subnet mask is a string of ones followed by a certain number of zeros.
The numbers have to stay the same anywhere there's a zero you can change the
values.
So in this particular case our subnet mask is going to be 255 255 255 0 I need to
warn you about something for a minute.
It's just for us human beings when we type in 255 255 255 0 in our computers he
instantaneously changes it into what it really is 24 ones followed by eight zeros.
Now in this particular example the way we've gotten it set up is that the first
three numbers are identical.
So what I've done here is I've replaced the third set of ones with all zeros so and
good.
Now as you're looking at this stuff there's one thing you need to keep in mind we
always use these terms to find files and zeros.
But we know that the computer just uses all ones and zeros.
So what is commonly done is that we simply say this is a whack 16 subnet that
little slashes what I call a whack and that is common terminology so you want to
get used to it.
The cool part now is that when we change the subject mass to something like this we
could literally if we wanted to say only the first two numbers have to be the same.
You can use any other 2 numbers that you want to use that doesn't matter because
they're all going to work.
So with a whack 16 subnet that means only the first two digits have to be the same
for all the computers.
So our network ID could be anything from I guess 232 . 25 dot 1.1 to 32 dot twenty
five dot 255 that 254.
I mean think how many different computers we could have on this little tiny
network.
So usually the subnet mask gets smaller for really huge networks and it gets longer
like a whacked 24 2 5 5 2 5 5 5 5 0 for smaller networks.
In fact we know these things ahead of time for example if we use a whacked 24
subnet mask to remember 2 5 5 2 5 5 2 5 0 we get exactly 254 hosts.
So that means the smallest network at least based on what we know so far we could
make would have up to 254 hosts.
OK.
So this really makes things a big deal when it comes to making these subnets.
Right.
At what we call the dots where it's only two high fives and zeros.
We've got other episodes coming up where we're going to make it a little bit more
interesting.
So basically in order to make our network work all of the computers within this one
broadcast domain within this one network ID are all going to have to have the same
subnet mask and wherever there's a 2:55 in the subnet mask they're going to have to
have the exact numbers.
So what I want to do right now is take a moment and walk you through a Mac a
Windows system in a Linux box to see where these numbers exist on your computer.
The host uses the subnet mask to know if the destination is on the local network or
a remote network
Each host knows the default gateway so that it can forward traffic to remote
networks