Upload
winfred-webb
View
219
Download
3
Tags:
Embed Size (px)
Citation preview
1
Real Networkers don’t use Decimal! Part 1.
Binary & Interpreting IP Addresses
October 19, 2004
2
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.
3
Counting in Binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
4
Powers of 2power 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.
5
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
6
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
value
2147483648
1073741824
536870912
268435456
134217728
67108864
33554432
16777216
8388608
4194304
2097152
1048576
524288
262144
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8 4 2 1
power 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
7
Conversion sample 1
1101101101 Add the value of each bit position containing a one.
position 1 1 0 1 1 0 1 1 0 1
value
2147483648
1073741824
536870912
268435456
134217728
67108864
33554432
16777216
8388608
4194304
2097152
1048576
524288
262144
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8 4 2 1
power 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
= 512 + 256 + 64 + 32 + 8 + 4 + 1 = 877
8
Conversion sample 2
11011011011101101101 Add the value of each bit position containing a one.
position 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1
value
2147483648
1073741824
536870912
268435456
134217728
67108864
33554432
16777216
8388608
4194304
2097152
1048576
524288
262144
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8 4 2 1
power 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
= 524288 + 262144 + 65536 + 32768 + 8192 + 4096 + 1024 + 512 + 256 + 64 + 32 + 8 + 4 + 1 = 898,925
9
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
10
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
11
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.
11011110 00100001 00000100 11111111 is the broadcast address for that network.
11011110 00100001 00000100 00100100 is a host address on that network.
All 0’s
All 1’s
12
Address Ranges
32 bits on every device 10101100 01111011 10101100 01111011
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
Class C: 24 network bits, 8 host bits, starts 110… 11001100 01111011 10101100 01111011
Does this address identify a host or a network?
13
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.
14
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
15
Special Address Ranges
Private Class A
10.0.0.0 - 10.255.255.255
Private Class B
172.16.0.0 - 172.31.255.255
Private Class C
192.168.0.0 - 192.168.255.255
Local Loopback
127.0.0.0 - 127.255.255.255
Automatic Private IP
Addressing 169.254.0.0 - 169.254.255.255
16
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!
17
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
2147483648
1073741824
536870912
268435456
134217728
67108864
33554432
16777216
8388608
4194304
2097152
1048576
524288
262144
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8 4 2 1
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
18
Sample Address, dotted decimal
Same address using octets 10101100.01111011.00101100.01111000
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
position 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
value128
64
32
16
8 4 2 1 128
64
32
16
8 4 2 1 128
64
32
16
8 4 2 1 128
64
32
16
8 4 2 1
power 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
19
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.
20
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.
21
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!
22
Possible subnets in Binary
3 bits are borrowed in a Class B network SN# 0: 10101100 01111011 000 00000 00000000 SN# 1: 10101100 01111011 001 00000 00000000 SN# 2: 10101100 01111011 010 00000 00000000 SN# 3: 10101100 01111011 011 00000 00000000 SN# 4: 10101100 01111011 100 00000 00000000 SN# 5: 10101100 01111011 101 00000 00000000 SN# 6: 10101100 01111011 110 00000 00000000 SN# 7: 10101100 01111011 111 00000 00000000
Subnet number is decimal of subnet bits
23
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
24
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) ?
25
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 8 7 6 5 4 3 2 1 0
number of
subnets
4194304
2097152
1048576
524288
262144
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8 4 2 1
The Powers of 2 table again!
26
Why a mask is necessary
A 32 bit address may be interpreted many ways.
10101100 01111011 00101100 01111000172.123.44.120/16 (no subnet)
10101100 01111011 00101100 01111000172.123.44.120/19 (subnetted using 3 bits)
10101100 01111011 00101100 01111000172.123.44.120/21 (subnetted using 5 bits)
IP address is meaningless without a mask!
27
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
Dotted Decimal Address: 172.123.44.120 Dotted Decimal Mask: 255.255.0.0
position 1 1 1 1 1 1 1 1
value 128
64
32
16
8 4 2 1
This is the default mask of a class B network.
28
Masking a 3 bit Subnet Network, Subnet, & Host Bits Binary Address: 10101100 01111011 00101100 01111000
Binary Mask: 11111111.11111111.11100000.00000000
Prefix:11111111.11111111.111 count 1’s 19
position 1 1 1 0 0 0 0 0
value 128
64
32
16
8 4 2 1
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!
29
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 128
64
32
16
8 4 2 1
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
30
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
31
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
32
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.
33
Sample Mask Application
What is the network address ofAddress: 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 0111100011111111.11111111.11110000.0000000010101100 01111011 00100000 00000000
Network Address: 172.123.32.0
AND
Applying a Mask to an IP address leaves the network address!
34
Determining the Broadcast Address for a network Start with a network address and mask
10101100 01111011 00100000 00000000 (172.123.32.0)
11111111.11111111.11110000.00000000 (255.255.240.0)
Apply the mask; network bits remain unchanged! 10101100 01111011 0010
Set all host bits to 1’s 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!
35
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
36
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.
37
HAPPY NETWORKING!HAPPY NETWORKING!