How IP Addresses Work | Network Fundamentals Part 4

welcome back in a recent video we

discussed how addresses are important

devices need them so they know where to

send their data IP addressing is a good

example of this not only does it include

the address of the device but the

address of the network that the device

is in that means with one simple address

we can find a device on our local

network or on the other side of the

world IP addresses come in two different

flavors these are called ipv4 and ipv6

and they look quite different ipv6 is

newer but ipv4 is still more common so

we're going to focus our attention

entirely on ipv4 for now firstly this is

what an IP address looks like it's four

numbers separated by dots each of these

numbers is called an octet as each

number is an 8-bit value we break it up

into four separate octet to make it

easier for us humans oh and if you're

having trouble remembering one octet is

think of an octopus an octopus is eight

tentacles and octet has eight bits eight

bits means that these numbers can range

from 0 to 255 that means that an IP

address starts at 0 0 0 0 and ends at

255 dot 255 dot 255 dot 255 we call a

range of addresses the IP space straight

away you can see that knowing how binary

works is important for IP addressing if

you don't know a binary or if you need a

refresher I have a video to help I'll

add it to the description IP addresses

are actually two addresses in one the IP

address is the address of the device but

it's also the address of the network

that the device is in two addresses in

one how is this possible let's take a

look at this sample IP address here 172

dot 16 dot 0 dot 1 the first part 1 7 2

dot 16 refers to the network the second

part 0.1 is the host address

don't worry I'll get to explaining how

we know the difference between the two

soon all the hosts here that start with

1:7 2.16 are in the same network if we

add more hosts and the IP addresses

start with 1:7 2.17 then this is a

different network

if hosts in different IP networks need

to communicate then then we'll need to

be a router between them

you're probably wondering is it always

the first half of the address that

represents the network short answer no

how then do we know which part of the IP

addresses the network and which part is

the host the answer to this question

strangely has changed over time so let's

start back at the beginning and we'll

work along from there when the Internet

Protocol was first created the first

octet always represented the network and

the following three octet

were used for hosts the largest value

that we can get out of a single octet is

255 that means that there was only room

for 255 different networks on the other

hand three octets meant that there could

be over 16 million hosts IPS in each

network this sounds a little unbalanced

but in the beginning the internet was

not international and there were only a

few organizations using it but as the

internet started to grow it became

obvious that this wouldn't work for very

long 255 networks just wasn't enough so

back in 1981 a new method was introduced

this broke the entire IP space into five

classes that's Class A through to E

Class A B and C were used to address

devices Class D is for multicast and

we'll touch on that a little in the next

video Class E is reserved for special

purposes so Class A B and C are the ones

we need to think about right now there

are a small number of Class A networks

but each network supports a large number

of hosts Class A works a bit like the

old method the first octet is the

network and the remaining three octet

are for hosts however the first bit of

the network is always 0 that leaves

seven bits for us to allocate to our

networks that means there are 128 Class

A networks with more than 16 million

host IPS per Network the Class A address

base then is 0.000 through to one 27000

there is a small catch with this though

networks starting with 0 and 127 are

reserved so the usable class a space is

really 1.000 to 120 6.000

Class B networks are used for a medium

number of hosts the first two octets are

used for the network and the second two

are used for host addresses the first

two bits of the network are always 1 0

which leaves 14 bits or 16384 possible

networks each network can have over

65,000 hosts the total Class B IP space

is from 1 28000 to 191 to 5500 Class C

are small networks but there are a lot

of them the first 3 octets are just for

the network the first three bits are

always 1 1 0 leaving 21 Network bits or

a little over 2 million networks with

only 1 octet left though we can have

only 256 hosts ip's per Class C Network

the address space ranges from 190 to 0 0

0 2 223 255 255 0

so to summarize Class A uses 1 octet - 1

bit for networks Class B uses two octets

- 2 bits and finally Class C uses 3

octet - 3 bits addresses outside of this

our classes D and E which are reserved

for special uses if you're the kind of

person that likes the math we can show

this as an equation the number of

networks is 2 to the power of n and is

the number of network bits so Class B

has 14 network bits to the power of 14

years 16384 the same is true for hosts

B has 16 bits four hosts two to the

power of 16 is about 65,000 ready for

some practice take a look at these IP

addresses which classes are they in time

to look at an example if device 170 2.16

dot zero dot one wants to send a packet

to 172 1602 it starts by looking at the

first few bits of the destination IP

address as the first two bits are 1 0 it

knows that this is a Class B address it

can then assume that the first 2 octet

are the network and the last two are the

host it sees that the destination

network is 172 dot 16 which is the same

as its own as they're in the same

network it can send traffic directly to

the destination

now what if it wants to send a packet to

172 dot 17.0 to 1 it does the same thing

and it determines that the destination

is on the 170 2.17 network this is

different to its own network so it can't

send traffic directly it needs to send

traffic to a router first take the

practice session from before a step

further tell me which part of each

address is the host address

as the internet started to grow we

started using up IP addresses faster and

faster and we started running low on IP

addresses again so in 1993 yet another

new method was introduced it is called

classless inter-domain routing or cider

previously we could identify IP address

class by looking at the first few bits

knowing the class we then knew which

parts of the IP were for the network and

which parts were for the hosts but now

we throw all that away and we introduce

something new the subnet mask the subnet

mask is also made up of four octet s--

this lines up with the IP address bit

for bit the bits set to one tell us

which part of the IP address is the

network the zero bits are used for hosts

it's important to notice that all the

ones go on the left and all the zeros go

on the right we never mix up the ones

and zeros in a subnet mask take a Class

A address for an example we know eight

bits are used in the network so the

subnet mask would look like this eight

one bits for the network the remaining

24 bits set to zero for hosts a Class B

address follows the same rules sixteen

bits for the network set to 1 and the

host bits set to zero and finally Class

C well you get the idea by now is this

making sense so far the subnet mask

tells us which part of the IP is for the

network and which party's for the hosts

but this hasn't really addressed our

original problem yet has it

so far we've just seen a different way

to show Class A B and C addresses so far

we haven't seen anything on how to save

IP addresses the real power of cider is

the ability to break a large network

into small ones we call this subnetting

let's say that you have the classful

network of 170 to 1600 this would have

the subnet mask

of 255 255 0 0 this allows for about

65,000 hosts that's a lot of hosts that

might be fine if we have one massive

office but what if we have several

smaller offices do we want to allocate

65,000 IPS to each office that seems

like overkill to me so instead what we

can do is we can break the Class B

Network using our subnet mask we may

decide to use 255 255 255 dot 0 instead

now our large office network has been

broken into 256 different subnets why

256 well our subnet mask is now using an

additional 8 bits for the network the

largest 8-bit value is 256 now we can

allocate 256 host IPS per network which

is far more reasonable when we have a

few small offices if we want to

communicate between our subnets just

like before we will need a router let me

take a moment to make sure that I'm

clear on this devices in the same subnet

must be in the same IP network if not

they will not be able to communicate

likewise if devices in the same subnet

are separated by a router they will also

not be able to communicate I'd like to

challenge you to think this through for

yourself take the 172 dot 1600 network

with a subnet mask 255 255 0 0 if we

broke that network up by using the

subnet mask of 255 255 to 40.0 how many

subnets do we have how many host IPS per

subnet are there if you're taking notes

you've probably noticed that's a pain to

write down the subnet masks all the time

to make things simple we have what's

known as cider notation take 1 7 2 dot

16 dot one dot 0 / 24 as an example

the slash 24 is the subnet mask written

inside a notation this means that the

first 24 bits of the subnet mask are

turned on it's that easy

we will be using side of notation more

and more from here on so try to get more

comfortable with it see if you

understand by testing yourself with this

example we have to slash 24 networks

these are joined together by a small

slash 30 network a device in network a

is unable to communicate with a device

in network B why are they unable to

communicate classful is an older method

of networking and subnetting is newer so

why are we even talking about classful

networking hasn't it been replaced yes

it has been replaced but for one if

you're doing an exam you may still find

exam questions that refer to class for

addressing we also have some remnants of

classes in everyday networking think of

when you set an IP address in Windows

for example if you configure an IP of

10.8 62 windows will automatically give

you the subnet to 55000

it's assuming classful networking and

what we're mostly classless now a lot of

people tend to think of subnetting are

starting with a classful network and

breaking it up from there which is not

always strictly true sometimes we may

have a few small networks and we decide

to join them together this is called

super netting for example it may have

one nine two one six eight zero zero

slash 24 and one nine two one six eight

one zero slash 24 if we want we can join

these into a single network

slash twenty-three in my opinion we

shouldn't really worry about class all

networks in the real world use

subnetting all the way but what do you

think tell me if you agree or disagree

in the comments I would love to hear

your opinion join me the next video and

we'll dive deeper into IP addressing