# Network layer (Part III)

Networking and Communications

Oct 24, 2013 (4 years and 11 months ago)

140 views

Network layer (Part III)

Basics of
Subnetting

:
Classical IP

Network

sometimes

need

to

divide

networks,

especially

large

ones,

into

smaller

networks
.

These

smaller

divisions

are

called

subnetworks

and

provide

flexibility
.

Most

of

the

time

subnetworks

are

simply

referred

to

as

subnets

Basics of
Subnetting

:
Classical IP

Similar

to

the

host

number

portion

of

Class

A,

Class

B,

and

Class

C

subnet

are

assigned

locally,

usually

by

the

network

.

Also,

like

other

IP

,

each

subnet

is

unique
.

Basics of
Subnetting

:
Subnetwork

Subnet

include

the

Class

A,

Class

B,

or

Class

C

network

portion,

plus

a

subnet

field

and

a

host

field
.

The

subnet

field

and

the

host

field

are

created

from

the

original

host

portion

for

the

entire

network
.

The

ability

to

decide

how

to

divide

the

original

host

portion

into

the

new

subnet

and

host

fields

provides

flexibility

for

the

network

.

To

create

a

subnet

a

network

borrows

bits

from

the

original

host

portion

and

designates

them

as

the

subnet

field
.

Figure 1

Basics of
Subnetting

:
Subnetwork

Internally,

networks

may

be

divided

into

smaller

networks

called

sunetworks,

or

simply

sub
-
nets
.

By

providing

a

third

level

of

subnets

provide

extra

flexibility

for

the

network

.

For

example,

a

class

“B”

network

provided

by

the

interNIC,

can

be

broken

up

into

many

networks
.

In

this

example,

131
.
108
.
1
.
0
,

131
.
108
.
2
.
0

and

131
.
108
.
3
.
0

are

all

subnets

within

the

network

131
.
108
.
0
.
0

Figures

1

and

2

illustrate

the

hierarchical

nature

of

subnet

.

Figure 2

Basics of
Subnetting

:
Subnetwork

To

create

a

subnet

a

network

borrows

bits

from

the

host

field

and

designates

them

as

the

subnet

field
.

The

minimum

number

of

bits

that

can

be

borrowed

is

2
.

If

you

were

to

borrow

only

1

bit,

to

create

a

subnet,

then

you

would

only

have

a

network

number

-

the

.
0

network

-

and

the

number

-

the

.
1

network
.

maximum

number

of

bits

that

can

be

borrowed

can

be

any

number

that

leaves

at

least

2

bits

remaining,

for

the

host

number
.

In

this

example

of

a

Class

C

IP

bits

from

the

host

field

for

the

subnet

field

have

been

borrowed
.

Basics of
Subnetting

:
Purpose for
subnetting

A

primary

reason

for

using

subnets

is

to

reduce

the

size

of

a

domain
.

are

sent

to

all

hosts

on

a

network

or

subnetwork
.

When

traffic

begins

to

consume

too

much

of

the

available

bandwidth,

network

may

choose

to

reduce

the

size

of

the

domain
.

Basics of
Subnetting

:

The

subnet

(formal

term
:

extended

network

prefix),

tells

the

network

devices

which

part

of

an

is

the

network

field

and

which

part

is

the

host

field
.

A

subnet

is

32

bits

long

and

has

4

octets,

just

like

an

IP

.

Basics of
Subnetting

:

To

determine

the

subnet

for

a

particular

subnetwork

IP

follow

these

steps
.

(
1
)

Express

the

subnetwork

IP

in

binary

form
.

(
2
)

Replace

the

network

and

subnet

portion

of

the

with

all

1
s
.

(
3
)

Replace

the

host

portion

of

the

with

all

0
s
.

(
4
)

As

the

last

step

convert

the

binary

expression

back

to

dotted
-
decimal

notation
.

Note
:

The

extended

network

prefix

includes

the

class

A,

B,

or

C

network

number,

plus

the

subnet

field

(or

subnet

number)

that

is

being

used

to

extend

the

routing

information

(which

is

otherwise

just

the

network

number)
.

Basics of
Subnetting

:
Boolean
operations: AND, OR, and NOT

The

term

"operations"

in

mathematics

refers

to

rules

that

define

how

one

number

combines

with

other

numbers
.

Decimal

number

operations

include

subtraction,

multiplication,

and

division
.

There

are

related,

but

different,

operations

for

working

with

binary

numbers
.

The

basic

Boolean

operations

are

AND,

OR,

and

NOT
.

AND

is

like

multiplication

OR

is

like

NOT

changes

1

to

0
,

and

0

to

1

Basics of
Subnetting

:
Performing the
AND function

The

lowest

numbered

in

an

IP

network

is

the

network

(the

network

number

plus

0

in

the

entire

host

field)
.

This

also

applies

to

a

subnet
:

the

lowest

numbered

is

the

of

the

subnet
.

Basics of
Subnetting

:
Boolean
operations: AND, OR, and NOT

In

order

to

route

a

data

packet,

the

router

must

first

determine

the

destination

network/subnet

by

performing

a

logical

AND

using

the

destination

host's

IP

and

the

subnet

.

The

result

will

be

the

network/subnet

.

In

the

Figure,

the

router

has

a

packet

for

host

131
.
108
.
2
.
2

-

it

uses

the

AND

operation

to

learn

that

this

packet

should

be

routed

to

subnet

131
.
108
.
2
.
0
.

Creating a Subnet

:

Range of bits
needed to create subnets

To

create

subnets,

you

must

extend

the

routing

portion

of

the

.

The

Internet

knows

your

network

as

a

whole,

identified

by

the

Class

A,

B,

or

C

which

defines

8
,

16
,

or

24

routing

bits

(the

network

number)
.

The

subnet

field

will

become

routing

bits,

so

that

the

routers

within

your

organization

can

recognize

different

locations,

or

subnets,

within

the

whole

network

Creating a Subnet

:

Range of bits
needed to create subnets

Question
:

In

the

131
.
108
.
0
.
0
,

which

are

the

routing

bits?

:

131
.
108

-

That's

the

16

bit

Class

B

network

number
.

Question
:

What

are

the

other

two

octets

(
16

bits)

of

the

131
.
108
.
0
.
0

used

for?

:

Well,

as

far

as

the

Internet

knows,

that's

just

a

16

bit

host

field,

because

that's

what

a

Class

B

is

-

a

16

bit

network

number

and

a

16

bit

host

number
.

Creating a Subnet

:

Range of bits
needed to create subnets

Question
:

What

part

of

the

131
.
108
.
0
.
0

is

the

subnet

field?

:

When

you

decide

to

create

subnets,

you

must

divide

the

original

host

field

(
16

bits

in

the

case

of

Class

B)

into

two

parts

-

the

subnet

field

and

the

host

field
.

This

is

sometimes

referred

to

as

"borrowing"

some

of

the

original

host

bits

to

create

the

subnet

field
.

The

other

networks

in

the

Internet

won't

care

-

they

look

at

the

the

same

-

all

they

really

see

is

the

Class

A,

B,

or

C

network

number,

and

send

the

packet

on

to

its

destination
.

The

minimum

number

of

bits

that

you

can

borrow

is

2
,

regardless

of

whether

you're

working

with

a

Class

A,

B,

or

C

network
1

because

at

least

2

bits

must

remain

for

host

numbers
2
,

the

maximum

varies

by

class
.

Creating a Subnet

:

Range of bits
needed to create subnets

Creating a Subnet

:

Range of bits
needed to create subnets

The

subnet

field

always

follows

immediately

after

the

network

number
.

That

is,

the

borrowed

bits

must

be

the

first

n

bits

of

the

default

host

field,

where

n

is

the

desired

size

of

the

new

subnet

field
.

The

subnet

is

the

tool

used

by

the

router

to

determine

which

bits

are

routing

bits

and

which

bits

are

host

bits

Creating a Subnet

:

Range of bits
needed to create subnets

Previous

standards

did

not

allow

for

the

use

of

subnets

obtained

by

borrowing

1

bit

(with

only

1

subnet

bit,

the

subnet

field

can

only

have

two

values
:

subnet

0

is

part

of

the

network

and

subnet

1

would

be

part

of

the

network

although

many

devices

can

now

support

subnets

obtained

by

borrowing

1

bit,

it

is

still

common

practice

to

avoid

doing

this

to

insure

compatibility

with

legacy

devices
;

for

our

purposes

here,

you

will

always

borrow

at

least

2

bits
.

Similarly,

a

1

bit

host

field

would

allow

only

for

host

0
,

which

is

part

of

the

network

and

host

1
,

which

is

part

of

the

leaving

0

valid

host

.

Creating a Subnet

:
Determining

Subnet

use

the

same

format

as

IP

.

They

are

32

bits

long

and

are

divided

into

four

octets,

written

in

dotted

decimal

format
.

Subnet

contain

all

1
s

in

the

network

bit

positions

(determined

by

the

class)

as

well

as

the

desired

subnet

bit

positions,

and

contain

all

0
s

in

the

remaining

bit

positions,

designating

them

as

the

host

portion

of

an

.

Creating a Subnet

:
Determining

By

default,

if

you

borrow

no

bits,

the

subnet

for

a

Class

B

network

would

be

255
.
255
.
0
.
0
,

which

is

the

dotted

decimal

equivalent

of

1
s

in

the

16

bits

corresponding

to

the

Class

B

network

number
.

If

8

bits

were

to

be

borrowed

for

the

subnet

field,

the

subnet

would

include

8

1

bits,

and

would

become

255
.
255
.
255
.
0
.

Creating a Subnet

:
Determining

For

example,

if

the

subnet

255
.
255
.
255
.
0

were

associated

with

the

Class

B

130
.
5
.
2
.
144

(
8

bits

borrowed

for

subnetting
),

the

router

would

know

to

route

this

packet

to

subnet

130
.
5
.
2
.
0

rather

than

to

just

network

130
.
5
.
0
.
0

Creating a Subnet

:
Determining

Another

example

is

the

Class

C

197
.
15
.
22
.
131
,

with

a

subnet

of

255
.
255
.
255
.
224
.

With

a

value

of

224

in

the

final

octet

(
11100000

in

binary),

the

24

bit

Class

C

network

portion

has

been

extended

by

3

bits,

to

make

the

total

27

bits
.

The

131

in

the

last

octet

now

presents

the

third

usable

host

in

the

subnet

197
.
15
.
22
.
128
.

The

routers

in

the

Internet

(that

don't

know

the

subnet

will

only

worry

routing

to

the

Class

C

network

197
.
15
.
22
.
0
,

while

the

routers

inside

that

network,

knowing

the

subnet

will

be

looking

at

27

bits

to

make

a

routing

decision
.

Creating a Subnet

:
Computing subnet

Whenever

you

borrow

bits

from

the

host

field,

it

is

important

to

note

the

number

of

subnets

that

are

being

created

each

time

you

borrow

one

more

bit
.

You

have

learned

that

you

cannot

borrow

only

1

bit
;

the

fewest

you

may

borrow

is

2

bits
.

Creating a Subnet

:
Computing subnet

Borrowing

2

bits

creates

four

possible

subnets

(
2
2
)

(but

you

must

always

remember

that

there

are

two

reserved/unusable

subnets)
.

Each

time

you

borrow

another

bit

from

the

host

field,

the

number

of

subnets

created

increases

by

a

power

of

2
.

Creating a Subnet

:
Computing subnet

The

eight

possible

subnets

that

are

created

by

borrowing

3

bits

is

equal

to

2
3

(
2

x

2

x

2
)
.

The

sixteen

possible

subnets

created

by

borrowing

4

bits

is

equal

to

2
4

(
2

x

2

x

2

x

2
)
.

From

these

examples,

it

is

easy

to

see

that

each

time

you

borrow

another

bit

from

the

host

field,

the

number

of

possible

subnets

doubles
.

Creating a Subnet

:
Computing subnet

Question:
How many bits are being borrowed (how long is the
subnet field) for a Class B network using a subnet mask of
255.255.240.0?

The first two octets of the mask (255.255) correspond with
the 16 bits in a Class B network number. Remember that the subnet
field is represented by all the additional "1" bits past that. The
number 240 decimal is 11110000 in binary, and you can see that
you are using 4 bits for the subnet field.

Question:
How many possible subnets are there with a 4 bit subnet
field?

-

0000
-

then
the largest 4 bit number
-

1111 (15). So the possible subnets are 0
-
15, or sixteen subnets. However, you know you cannot use subnet

0
(it's part of the network address), and you cannot use subnet 15
you fourteen usable subnets (1
-
14).

Creating a Subnet

:
Computing hosts
per
subnetwork

Each

time

you

borrow

1

bit

from

a

host

field,

there

is

1

less

bit

remaining

in

the

field

that

can

be

used

for

host

numbers
.

Specifically,

each

time

you

borrow

another

bit

from

the

host

field,

the

number

of

host

that

you

can

assign

decreases

by

a

power

of

2

(gets

cut

in

half)
.

Creating a Subnet

:
Computing hosts
per
subnetwork

To

help

you

understand

how

this

works,

use

a

Class

C

network

as

an

example
.

If

there

is

no

subnet

all

8

bits

in

the

last

octet

are

used

for

the

host

field
.

Therefore,

there

are

256

(
2
8
)

possible

available

to

assign

to

hosts

(
254

usable

after

you

subtract

the

2

you

know

you

can't

use)
.

Now,

imagine

that

this

Class

C

network

is

divided

into

subnets
.

If

you

borrow

2

bits

from

the

default

8

bit

host

field,

the

host

field

decreases

in

size

to

6

bits
.

If

you

write

out

all

of

the

possible

combinations

of

0
s

and

1
s

that

could

occur

in

the

remaining

6

bits,

you

would

discover

that

the

total

number

of

possible

hosts

that

could

be

assigned

in

each

subnet

would

be

reduced

to

64

(
2
6
)
.

The

number

of

usable

host

numbers

would

be

reduced

to

62
.

Creating a Subnet

:
Computing hosts
per
subnetwork

In

the

same

Class

C

network,

if

you

borrow

3

bits,

the

size

of

the

host

field

decreases

to

5

bits

and

the

total

number

of

hosts

that

you

could

assign

to

each

subnet

would

be

reduced

to

32

(
2
5
)
.

The

number

of

usable

host

numbers

would

be

reduced

to

30
.

Creating a Subnet

:
Computing hosts
per
subnetwork

The

number

of

possible

host

that

can

be

assigned

to

a

subnet

is

related

to

the

number

of

subnets

that

have

been

created
.

In

a

Class

C

network,

for

example,

if

a

subnet

of

255
.
255
.
255
.
224

has

been

applied,

then

3

bits

(
224

=

11100000
)

would

have

been

borrowed

from

the

host

field
.

The

useable

subnets

created

are

6

(
8

minus

2
),

each

having

30

(
32

minus

2
)

useable

host

Creating a Subnet

:
Computing hosts
per
subnetwork

Exercise:

Divide the last octet into two parts: a subnet field and a host field. If there
are 32 possible host addresses that can be assigned to each subnet, then
their IP addresses would fall within the range of numbers (but remember
the 2 unusable host addresses in each subnet!).

In a Class C network 199.5.12.0 with subnet mask 255.255.255.224, to
which subnet would host 199.5.12.97 belong? (hint: 97 = 01100001
binary)

A.
subnet 0?

B.
subnet 1?

C.
subnet 2?

D.
subnet 3?

E.
subnet 4?

F.
none of the above?

Creating a Subnet

:
Boolean AND
operation

As

you

have

learned,

the

lowest

numbered

in

an

IP

network

is

the

network

(the

network

number

plus

0

in

the

entire

host

field)
.

This

also

applies

to

a

subnet
;

the

lowest

numbered

is

the

of

the

subnet

Creating a Subnet

:
Boolean AND
operation

In

order

to

route

a

data

packet,

the

router

must

first

determine

the

destination

network/subnet

.

To

accomplish

this

the

router

performs

a

logical

AND

using

the

destination

host's

IP

and

the

subnet

for

that

network
.

Imagine

that

you

have

a

Class

B

network

with

the

network

number

172
.
16
.
0
.
0
.

After

assessing

the

needs

of

your

network,

you

decide

to

borrow

8

bits

in

order

to

create

subnets
.

As

you

learned

earlier,

when

you

borrow

8

bits

with

a

Class

B

network,

the

subnet

is

255
.
255
.
255
.
0

Creating a Subnet

:
Boolean AND
operation

Someone

outside

the

network

sends

data

to

the

IP

172
.
16
.
2
.
120
.

In

order

to

determine

where

to

deliver

the

data,

the

router

ANDs

this

with

the

subnet

.

When

the

two

numbers

are

ANDed
,

the

host

portion

of

the

result

will

always

be

0
.

What

is

left

is

the

network

number,

including

the

subnet
.

Thus,

the

data

is

sent

to

subnet

172
.
16
.
2
.
0
,

and

only

the

final

router

notices

that

the

packet

should

be

delivered

to

host

120

in

that

subnet
.

Creating a Subnet

:
Boolean AND
operation

Now,

imagine

that

you

have

the

same

network,

172
.
16
.
0
.
0
.

This

time,

however,

you

decide

to

borrow

only

7

bits

for

the

subnet

field
.

The

binary

subnet

for

this

would

be

11111111
.
11111111
.
11111110
.
00000000
.

What

would

this

be

in

dotted

decimal

notation?

Creating a Subnet

:
Boolean AND
operation

Again,

someone

outside

the

network

sends

data

to

host

172
.
16
.
2
.
120
.

In

order

to

determine

where

to

send

the

data,

the

router

again

ANDs

this

with

the

subnet

.

As

before,

when

the

two

numbers

are

ANDed
,

the

host

portion

of

the

result

is

0
.

So

what

is

different

in

this

second

example?

Everything

looks

the

same

-

at

least

in

decimal
.

The

difference

is

in

the

number

of

subnets

available,

and

the

number

of

hosts

that

can

be

in

each

subnet
.

You

can

only

see

this

by

comparing

the

two

different

subnet

.

Creating a Subnet

:
Boolean AND
operation

With 7 bits in the subnet field, there can be
only 126 subnets.

How many hosts can there be in each subnet?

How long is the host field?

With 9 bits for host numbers, there can be 510
hosts in each of those 126 subnets.

Creating a Subnet

:
Boolean AND
operation

The

two

graphics

on

this

page

include

something

you'll

learn

more

later

-

an

alternate

way

to

express

the

subnet

.

You

learned

that

the

1
s

of

the

represent

the

routing

bits

-

the

network

plus

the

subnet
.

255
.
255
.
255
.
0

indicates

there

are

24

total

routing

bits
.

This

is

sometimes

indicated

by

following

an

IP

with

"/
24
",

as

in

131
.
108
.
3
.
1

/
24

-

this

says

the

same

thing

as

the

longer

subnet

.

Creating a Subnet

:
IP configuration
on a network diagram

When

you

configure

routers,

you

must

connect

each

interface

to

a

different

network

segment
.

Then

each

of

these

segments

will

become

a

separate

subnet
.

You

must

select

an

from

each

different

subnet

to

assign

to

the

interface

of

the

router

that

connects

to

that

subnet
.

Each

segment

of

a

network

-

the

actual

wires

and

-

must

have

different

network/subnet

numbers
.

The

Figure

shows

what

a

network

diagram

might

look

like

using

a

subnetted

Class

B

network
.

Creating a Subnet

:
Host/subnet
schemes

One

of

the

decisions

that

you

must

make

whenever

you

create

subnets

is

to

determine

the

optimal

number

of

subnets

and

hosts

(Note
:

The

number

of

subnets

required

in

turn

determines

the

number

of

hosts

available
.

For

example,

if

you

borrow

3

bits

with

a

Class

C

network,

only

5

bits

remain

for

hosts)
.

Creating a Subnet

:
Host/subnet
schemes

You

have

learned

that

you

cannot

use

the

first

and

last

subnet
.

You

also

cannot

use

the

first

and

last

within

each

subnet

-

one

is

the

of

that

subnet,

and

the

other

is

part

of

the

network

.

When

you

create

subnets,

you

lose

quite

a

few

potential

.

For

this

reason,

network

must

pay

close

attention

to

the

percentage

of

that

they

lose

by

creating

subnets
.

Creating a Subnet

:
Host/subnet
schemes

Example
:

If

you

borrow

2

bits

with

a

Class

C

network,

you

create

4

subnets,

each

with

64

hosts
.

Only

2

of

the

subnets

are

usable

and

only

62

hosts

are

usable

per

subnet,

leaving

124

usable

hosts

out

of

254

that

were

possible

before

you

chose

to

use

subnets
.

This

means

you

are

losing

51
%

of

your

.

Creating a Subnet

:
Host/subnet
schemes

Imagine,

this

time,

that

you

borrow

3

bits
.

You

now

have

8

subnets,

of

which

only

6

are

usable,

with

30

usable

hosts

per

subnet
.

This

gives

you

a

total

of

180

usable

hosts,

down

from

254
,

but

now

you

are

losing

only

29
%

of

your

.

Whenever

you

create

subnets,

you

need

to

take

into

consideration

future

network

growth

and

the

percentage

of

that

you

would

lose

by

creating

subnets
.

Creating a Subnet

:

There

are

certain

in

each

class

of

IP

that

are

not

assigned
.

These

are

called

private

.

Private

might

be

used

by

hosts

that

use

network

translation

(
NAT
),

or

a

proxy

server
,

to

connect

to

a

public

network
;

or

by

hosts

that

do

not

connect

to

the

Internet

at

all
.

Creating a Subnet

:

Many

applications

require

connectivity

within

only

one

network

and

do

not

need

external

connectivity
.

In

large

networks,

TCP/IP

is

often

used,

even

when

network

layer

connectivity

outside

the

network

isn’t

needed
.

Banks

are

good

examples
.

They

may

use

TCP/IP

to

connect

to

automatic

teller

machines

(ATMs)
.

These

machines

do

no

connect

to

the

public

network,

so

private

are

ideal

for

them
.

Private

can

also

be

used

on

a

network

where

there

are

not

enough

public

available
.

Creating a Subnet

:

The

private

can

be

used

together

with

a

network

translation

(NAT)

server
.

Either

a

NAT

server

or

a

proxy

server

to

provide

connectivity

to

all

hosts

in

a

network

that

has

relatively

few

public

available
.

By

agreement,

any

traffic

with

a

destination

within

one

of

the

private

ranges

will

NOT

be

routed

on

the

Internet
.