Download Subnetting Explained the Ballinger Way

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Real Networkers don’t
use Decimal! Part 1.
Binary & Interpreting IP Addresses
October 19, 2004
1
Understanding Binary




Computers, networks and network
addressing schemes use the binary number
system.
Number systems are based on “powers of”
the base number.
Binary is based on powers of 2.
The powers of 2 table is a powerful tool for
network designers.
2
Counting in Binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
3
Powers of 2
power
decimal
binary
0
1
1
1
2
10
2
4
100
3
8
1000
4
16
10000
5
32
100000
6
64
1000000
7
128
10000000
8
256
100000000
9
512
1000000000
10
1,024
10000000000
11
2,048
100000000000
12
4,096
1000000000000
13
8,192
10000000000000
14
16,384
100000000000000
15
32,768
1000000000000000
16
65,536
10000000000000000
2POWER Example
23 = 8 decimal
= 1000 binary
Notice 3 zeros.
4
Powers of 2, continued
power
decimal
binary
17
131,072
100000000000000000
18
262,144
1000000000000000000
19
524,288
10000000000000000000
20
1,048,576
100000000000000000000
21
2,097,152
1000000000000000000000
22
4,194,304
10000000000000000000000
23
8,388,608
100000000000000000000000
24
16,777,216
1000000000000000000000000
25
33,554,432
10000000000000000000000000
26
67,108,864
100000000000000000000000000
27
134,217,728
1000000000000000000000000000
28
268,435,456
10000000000000000000000000000
29
536,870,912
100000000000000000000000000000
30
1,073,741,824
1000000000000000000000000000000
31
2,147,483,648
10000000000000000000000000000000
32
4,294,967,296
100000000000000000000000000000000
32 0’s
5
Conversion from
Binary to Decimal


Decimal value is determined by the total value of
bits.
Each bit position value is some power of 2
position
2
1
4
7
4
value
8
3
6
4
8
power 31
1
0
7
3
7
4
1
8
2
4
5
3
6
8
7
0
9
1
2
2
6
8
4
3
5
4
5
6
1
3
4
2
1
7
7
2
8
6
7
1
0
8
8
6
4
3
3
5
5
4
4
3
2
1
6
7
7
7
2
1
6
8
3
8
8
6
0
8
4
1
9
4
3
0
4
2
0
9
7
1
5
2
1
0
4
8
5
7
6
5
2
4
2
8
8
2
6
2
1
4
4
1
3
1
0
7
2
6
5
5
3
6
3
2
7
6
8
1
6
3
8
4
8
1
9
2
4
0
9
6
2
0
4
8
1 5 2 1 6 3 1 8 4 2 1
0 1 5 2 4 2 6
2 2 6 8
4
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6
5
4
3
2
1
0
6
Conversion sample 1


1101101101
Add the value of each bit position containing a one.
position
2
1
4
7
4
value
8
3
6
4
8
power 31

1
1
0
7
3
7
4
1
8
2
4
5
3
6
8
7
0
9
1
2
2
6
8
4
3
5
4
5
6
1
3
4
2
1
7
7
2
8
6
7
1
0
8
8
6
4
3
3
5
5
4
4
3
2
1
6
7
7
7
2
1
6
8
3
8
8
6
0
8
4
1
9
4
3
0
4
2
0
9
7
1
5
2
1
0
4
8
5
7
6
5
2
4
2
8
8
2
6
2
1
4
4
1
3
1
0
7
2
6
5
5
3
6
3
2
7
6
8
1
6
3
8
4
8
1
9
2
4
0
9
6
2
0
4
8
1
0
1
1
0
1
1
0
1
1 5 2 1 6 3 1 8 4 2 1
0 1 5 2 4 2 6
2 2 6 8
4
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6
5
4
3
2
1
0
= 512 + 256 + 64 + 32 + 8 + 4 + 1 = 877
7
Conversion sample 2


11011011011101101101
Add the value of each bit position containing a one.
position
2
1
4
7
4
value
8
3
6
4
8
power 31

1
0
7
3
7
4
1
8
2
4
5
3
6
8
7
0
9
1
2
2
6
8
4
3
5
4
5
6
1
3
4
2
1
7
7
2
8
6
7
1
0
8
8
6
4
3
3
5
5
4
4
3
2
1
6
7
7
7
2
1
6
8
3
8
8
6
0
8
4
1
9
4
3
0
4
2
0
9
7
1
5
2
1
0
4
8
5
7
6
1
1
0
1
1
0
1
1
0
1
1
5
2
4
2
8
8
2
6
2
1
4
4
1
3
1
0
7
2
6
5
5
3
6
3
2
7
6
8
1
6
3
8
4
8
1
9
2
4
0
9
6
2
0
4
8
1 5 2 1 6 3 1 8 4 2 1
0 1 5 2 4 2 6
2 2 6 8
4
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
1
8
0
7
1
6
1
5
0
4
1
3
1
2
0
1
1
0
= 524288 + 262144 + 65536 + 32768 + 8192 + 4096
+ 1024 + 512 + 256 + 64 + 32 + 8 + 4 + 1 = 898,925
8
Key Points of IP addressing



32 bits addressing allows 4,294,967,295
possible addresses.
Not feasible to keep track of 4.3 trillion routes
to individual hosts.
Separating the address into Network Bits and
Host bits allows a single network address to
summarize information for many hosts.
00101100011110111010110001111011
Network Bits
Host bits
9
Identifying networks

A network address represents a way to connect
to many hosts.


One Class A network address connects 16,777,215 hosts
One Class C network connects 255 hosts.

Network addresses are identified by setting the host
bits to 0 in an IP Address.

11011110 00100001 00000100 00000000 is a
Class C network

11011110 00100001 00000100 00100100 is a
host on that network
10
Three types of IP addresses



Network Address:
Host bits all 0’s
Broadcast Address: Host bits all 1’s
Host Address:
at least one 0 & one 1

11011110 00100001 00000100 00000000 is a
network address.
All 0’s

11011110 00100001 00000100 11111111 is
the broadcast address for that network.
All 1’s

11011110 00100001 00000100 00100100 is a
host address on that network.
11
Address Ranges

32 bits on every device


Class A: 8 network bits, 24 host bits, starts 0…


00101100 01111011 10101100 01111011
Class B: 16 network bits, 16 host bits, starts 10…


10101100 01111011 10101100 01111011
10101100 01111011 10101100 01111011
Class C: 24 network bits, 8 host bits, starts 110…

11001100 01111011 10101100 01111011
Does this address identify a host or a network?
12
Address Ranges


Class D: Multicast, starts 1110…

11100110 01111011 10101100 01111011

224.0.0.5 and 224.0.0.6 are used by OSPF
Class E: Reserved, starts 1111…

11110100 01111011 10101100 01111011
Classes D & E are not important in CCNA1.
13
Address Ranges in Decimal
Class A
1.0.0.0 - 126.0.0.0 (127 is local loopback)
Class B
128.0.0.0 - 191.255.0.0
Class C
192.0.0.0 - 223.255.255.0
Class D
224.0.0.0 - 239.255.255.255
Class E
240.0.0.0 - 247.255.255.255
14
Special Address Ranges
Private
Class A
Private
Class B
Private
Class C
Local
Loopback
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
127.0.0.0 - 127.255.255.255
Automatic
Private IP 169.254.0.0 - 169.254.255.255
Addressing
15
Notation Scheme

IP: 32 bit binary number for all addresses.

10101100011110111010110001111011

Reading and writing 32 bits of binary is too hard!

Converting all 32 bits to Decimal is too tedious

Break 32 bits into 4 groups of 8 bits called octets

Dotted Decimal notation converts octets to decimal

A notation scheme is merely a way of representing
the bits in an address, it is for convenience –
networking is based on the bits not the notation!
16
Sample Address in bits

Without breaking it down into octets

10101100011110110010110001111000
1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0
2
1
4
7
4
8
3
6
4
8
1
0
7
3
7
4
1
8
2
4
5
3
6
8
7
0
9
1
2
2
6
8
4
3
5
4
5
6
1
3
4
2
1
7
7
2
8
6
7
1
0
8
8
6
4
3
3
5
5
4
4
3
2
1
6
7
7
7
2
1
6
8
3
8
8
6
0
8
4
1
9
4
3
0
4
2
0
9
7
1
5
2
1
0
4
8
5
7
6
5
2
4
2
8
8
2
6
2
1
4
4
1
3
1
0
7
2
6
5
5
3
6
3
2
7
6
8
1
6
3
8
4
8
1
9
2
4
0
9
6
2
0
4
8
1 5 2 1 6 3 1 8 4 2 1
0 1 5 2 4 2 6
2 2 6 8
4
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8
7
6
5
4
3
2
1
0
= 2,893,753,464 too hard to do correctly
17
Sample Address,
dotted decimal

Same address using octets

10101100.01111011.00101100.01111000
position 1 0 1 0 1 1 0 0
1 6 3 1 8 4 2 1
value 2 4 2 6
8
power 7 6 5 4 3 2 1 0



0
1
1
1
1
0
1
1
0
0
1
0
1
1
0
0
0
1
1
1
1
0
0
0
1 6 3 1 8 4 2 1
2 4 2 6
8
1 6 3 1 8 4 2 1
2 4 2 6
8
1 6 3 1 8 4 2 1
2 4 2 6
8
7
7
7
6
5
4
3
2
1
0
6
5
4
3
2
1
0
6
5
4
3
2
1
0
easy to add up each octet
128 + 32 + 8 +4 ● 64 + 32 + 16 + 8 + 2 + 1
● 32 + 8 + 4 ● 64 + 32 +16 +8
= 172.123.44.120 in dotted decimal notation
18
Sample Address
Network & Host Bits

Begins 10… so it is a Class B address with
the first 16 bits representing the network.

10101100.01111011.00101100.01111000

172.123.44.120 in dotted decimal.
This is the 00101100.01111000 host on the

10101100.01111011 network.
19
Subnetting begins!

In A, B, & C networks, boundary between
network and host bits always on an octet
boundary.



10101100.01111011.00101100.01111000
Subnetting: some host bits are converted to
subnet bits.

10101100.01111011.00101100.01111000

172.123.44.120
One octet may have both subnet & host bits.
20
How many subnets?




10101100 01111011 00100000 00000000 has
three subnet bits.
Represents just one subnet.
When 3 bits are used for subnetting, how many
possible subnets may be created? Lets list them.
Subnet #
Bits
Subnet #
Bits
0
000
4
100
1
001
5
101
2
010
6
110
3
011
7
111
8 subnets
Notice that when the bits are converted from
binary to decimal, you get the subnet number!
21
Possible subnets in Binary

3 bits are borrowed in a Class B network

SN# 0: 10101100
SN# 1: 10101100
SN# 2: 10101100
SN# 3: 10101100
SN# 4: 10101100
SN# 5: 10101100
SN# 6: 10101100
SN# 7: 10101100







01111011
01111011
01111011
01111011
01111011
01111011
01111011
01111011
000 00000
001 00000
010 00000
011 00000
100 00000
101 00000
110 00000
111 00000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
Subnet number is decimal of subnet bits
22
Possible subnets in
Dotted Decimal
3 bits are borrowed from a class B network








SN# 0: 172.123.0.0
SN# 1: 172.123.32.0
SN# 2: 172.123.64.0
SN# 3: 172.123.96.0
SN# 4: 172.123.128.0
SN# 5: 172.123.160.0
SN# 6: 172.123.192.0
SN# 7: 172.123.224.0
23
Some Addresses on a Subnet

10101100 01111011 00100000 00000001
(172.123.32.1)
and

10101100 01111011 00100010 00000000
(172.123.34.0)
are both hosts on the

10101100 01111011 00100000 00000000
(172.123.32.0 ) network.
What address type is
10101100 01111011 01100010 00000000 (172.123.98.0) ?
24
The Formula!


3 bits can provide for 8 possible subnets, 4 bits can
provide for 16 possible subnets.
What is the rule?
# of Possible Subnets = 2Number of subnet bits
borrowed
22 21 20 19 18 17 16 15 14 13 12 11 10 9
4
1
number 9
of 4
subnets 3
0
4
2
0
9
7
1
5
2
1
0
4
8
5
7
6
5
2
4
2
8
8
2
6
2
1
4
4
1
3
1
0
7
2
6
5
5
3
6
3
2
7
6
8
1
6
3
8
4
8
1
9
2
4
0
9
6
2
0
4
8
8
7
6
5
4
3
2
1
0
1 5 2 1 6 3 1 8 4 2 1
0 1 5 2 4 2 6
2 2 6 8
4
The Powers of 2 table again!
25
Why a mask is necessary

A 32 bit address may be interpreted many
ways.

10101100 01111011 00101100 01111000
172.123.44.120/16 (no subnet)

10101100 01111011 00101100 01111000
172.123.44.120/19 (subnetted using 3 bits)

10101100 01111011 00101100 01111000
172.123.44.120/21 (subnetted using 5 bits)

IP address is meaningless without a
mask!
26
Masking

Subnet mask: every network bit is 1 and every
host bit is 0.


Binary Address:
10101100.01111011.00101100.01111000
Binary Mask:
11111111.11111111.00000000.00000000
position 1 1 1 1 1 1 1 1
value 1 6 3 1 8 4 2 1
2 4 2 6
8


Dotted Decimal Address: 172.123.44.120
Dotted Decimal Mask:
255.255.0.0
This is the default mask of a class B network.
27
Masking a 3 bit Subnet




Network, Subnet, & Host Bits
Binary Address:
10101100 01111011 00101100 01111000
Binary Mask:
11111111.11111111.11100000.00000000
Prefix:
position 1 1 1 0
11111111.11111111.111
count 1’s



19
0
0
0
0
value 1 6 3 1 8 4 2 1
2 4 2 6
8
Dotted Decimal Address: 172.123.44.120
Dotted Decimal Mask:
255.255.224.0
Prefix:
/19
The mask does not distinguish between network and subnetwork bits!
28
Masking a 4 bit Subnet



Network, Subnet, & Host Bits
Binary Address:
10101100 01111011 00101100 01111000
Binary Mask:
11111111.11111111.11110000.00000000
position 1 1 1 1 0 0 0 0
value 1 6 3 1 8 4 2 1
2 4 2 6
8

Dotted Decimal Address: 172.123.44.120
Dotted Decimal Mask:
255.255.240.0 Prefix: /_ _

Only 9 possible mask values:


0, 128, 192, 224, 240, 248, 252, 254 and 255
29
How many subnet bits?


A mask has only network and host bits.
The number of subnet bits must be
calculated.
Number of subnet bits =
Number of actual mask network bits –
Number of default (class) mask
network bits
30
Example Subnet bits
calculation.

Address: 172.123.44.120
10101100 01111011 00101100 01111000

Mask: 255.255.240.0 or /20
11111111.11111111.11110000.00000000

Address begins 10… so it is a Class B address
which has a /16 default mask.
20 mask bits – 16 default mask bits =
4 subnet bits
31
How a Mask works.


The IP address and the mask are ANDed to
determine the network address.
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
The mask acts as a filter which keeps only
the network bits, sets all others to 0.
32
Sample Mask Application

What is the network address of
Address: 172.123.44.120
10101100 01111011 00101100 01111000
Mask: 255.255.240.0 or /20
11111111.11111111.11110000.00000000

Apply the mask:
10101100 01111011 00101100 01111000
AND 11111111.11111111.11110000.00000000
10101100 01111011 00100000 00000000

Network Address: 172.123.32.0
Applying a Mask to an IP address leaves the network address!
33
Determining the Broadcast
Address for a network

Start with a network address and mask



Apply the mask; network bits remain unchanged!


10101100 01111011 0010
Set all host bits to 1’s


10101100 01111011 00100000 00000000
(172.123.32.0)
11111111.11111111.11110000.00000000
(255.255.240.0)
1111 11111111
Put them together and you have the broadcast address

10101100 01111011 00101111 11111111

172.23.47.255 is the broadcast address for the
172.123.32.0 /20 network
The mask is necessary!
34
Interpreting IP Addresses
To get the network address from a specific host
address and mask.
1. Convert Address and Mask to binary
2. AND the Address and Mask to get the
Network Address
3. Convert the Network Address to decimal
35
Determining a Broadcast
address
To get the broadcast address from a specific
network address and mask.
1. Convert Network Address and Mask to
binary
2. Use the Mask to identify the network and
host bits
3. Copy the network bits from the Network
Address and make the remaining host bits
all 1’s.
4. Convert to dotted decimal.
36
HAPPY NETWORKING!
37
Related documents