Sunteți pe pagina 1din 63

Layer 3

Routing and Addressing

Layer 3 Responsibilities
Move data through a set of networks. Use a hierarchical addressing scheme. Segment network and control flow of traffic. Talk to other networks with services offered by ISPs (Internet Service Providers).

Layer 3 Devices

Routers

Interconnect network segments or entire networks. Make logical decisions based on IP addresses. Determines best path for data on an internetwork.

A.K.A Layer 3 Switching

Path Determination

The process the router uses to choose the next hop in the path the packet travels. The router uses the network address to identify the destination network of a packet within an internetwork. IP addresses can be assigned by a network administrator or automatically (dynamically.)

Layer 3 Packet/Datagram
VERS HLEN Service Type Total Length

Identification
Time to Live Protocol

Flags

Fragment Offset

Header Checksum

Source IP Address Destination IP Address IP Options (if any) Data Padding

Network Layer Addresses


Network layer addresses are 32 bits long. They are represented as four octets in dotted decimal format.

233.14.17.0
The IP address has two components:

The Network ID
The Host Id

IP Addressing

IP Addresses can be notated in Dotted Decimal and/or Binary, but you must understand both Dotted Decimal is what we are familiar with

eg. 128.41.230.65 To find out what the value of the dotted decimal octet is we must know what the binary format is
1 indicates that the binary place is on 0 indicates that the binary place is off

Binary bits are shown by a 1 or a 0


IP Addressing

IP addresses in dotted decimal contain 4 octets


Add up the number of locations contained by the dots : xxx.xxx.xxx.xxx = 4 octets Each octet contains 8 binary bits that tell us what the value of the octet in the dotted decimal notation

Binary as it relates to the Octet

XXX.XXX.XXX.XXX

Each octet is made up of 8 binary bit places Calculate 4 octets X 8 bits = 32 bits total

Binary Place Values


128 64 0 0 0 0 1 0 0 0 1 0 32 0 0 0 0 0 16 0 0 0 0 0 8 0 0 0 0 0 4 0 0 0 0 0 2 0 0 1 1 0 1 0 1 1 1 0

=255
=0 =1 =3 = 67 =128

! Remember a binary bit is either on or off 1 or 0 !

Converting Dotted Decimal to Binary


Lets convert the dotted decimal address shown here to binary

128.41.230.65

Converting Dotted Decimal to Binary


Take the value of the first Octet Binary would look something like this

128
1 0 0 0 0 0 0 0

! Remember the value of the first binary bit place is 128 and the first bit place is turned on !

128.41.230.65

Converting Dotted Decimal to Binary


Take the value of the second Octet Binary would look something like this

41
0 0 1 0 1 0 0 1

! Remember the values of the bit places turned on 32, 8, and 1 32+8+1=41 !

128.41.230.65

Converting Dotted Decimal to Binary


Take the value of the third Octet Binary would look something like this

230
1 1 1 0 0 1 1 0

! Remember the values of the bit places turned on 128, 64, 32, 4, and 2 128+64+32+4+2=230 !

128.41.230.65

Converting Dotted Decimal to Binary


Take the value of the forth Octet Binary would look something like this

65
0 1 0 0 0 0 0 1

! Remember the values of the bit places turned on 64, and 1 64+1=65 !

128.41.230.65

Converting Dotted Decimal to Binary

128.41.230.65
The whole thing in binary would look like this

10000000.00101001.11100110.01000001

Layer 3 Addresses

Network ID

Host ID

Assigned by ARIN (www.arin.net) Identifies the network to which a device is attached. May be identified by one, two, or three of the first three octets.

Assigned by a network administrator. Identifies the specific device on that network. May be identified by one, two, or three of the last three octets.

IP Addresses
32 bit address represented as 8 bit dotted decimals. Different class addresses reserve different amounts of bits for the Network and Host portions of the address.

Class A

Class B
Class C

N
N

N
N

H
N

H
H

Number of Hosts

Maximum number of hosts vary for each class.

Class A has 16,777,214 available hosts (224 2) Class B has 65,534 available hosts (216 2) Class C has 254 available hosts (28 2)

The first address in each network is reserved for the network address and the last address is reserved for the broadcast address.

Classes
How do you know what class an IP address is in? If the first octet is between:

0 127 it is a class A address 128-191 it is a class B address 192 223 it is a class C address

Recognizing Class in Binary Format


128s place Class A Class B 0 1 0 64s place 32s place
Initial bit pattern in first octet of IP address.

Class C

Reserved Addresses

Network Address (wire address) This is an IP address that ends with binary 0s in all host bits. Class A Network Address example:

113.0.0.0

Hosts on a network can only communicate directly with other hosts if they have the same network ID. If they dont, they will not be able to communicate unless there is another device connecting the networks.

Reserved Addresses

Broadcast Address is used to send data to all of the devices on a network. Broadcast IP addresses end with binary 1s in the host part of the address. Class B Broadcast Address example:

176.10.255.255

(Remember decimal 255 = binary 11111111)

Special Addresses
A few addresses are set aside for specific purposes. Network addresses that are all binary zeros, all binary ones & Network addresses beginning with 127 are special Network addresses.

Special Addresses

(Cont.)

Special Addresses

(Cont.)

Within each address class is a set of addresses that are set aside for use in local networks sitting behind a firewall or NAT (Network Address Translation) device or Networks not connected to the Internet.

Special Addresses

(Cont.)

A list of these addresses for each IP address class:

Basics of Subnetting
Subnetworks are smaller divisions of networks. They provide addressing flexibility. A.K.A. subnets Subnet addresses are assigned locally, usually by a network administrator. Subnets reduce a broadcast domain.

Subnet Addresses
Include Class A, B, or C network portion plus a subnet field and a host field. Bits are borrowed from the host field and are designated as the subnet field.

Network

Subnet

Host

How many bits can I borrow?


The minimum number of bits you can borrow is two.

Size of Host Field


Class A 24

Maximum # of borrowed bits


22

Class B
Class C

16
8

14
6

Default Subnet Masks

Class A Class B Class C

255.0.0.0 255.255.0.0 255.255.255.0

Class C Subnets
Network Network Network Host

Two Bits Borrowed from the Host Field to form a third layer of hierarchy - A Subnet Field Two Bits must always remain so a maximum of 6 Bits may be borrowed from a Class C network How many bits can be borrowed from a Class B network? From a Class A network?

Class C Subnets
Network Network Network Host

The number of Subnets Created is calculated using the following formula:

# Subnets Created = 2# Borrowed Bits -2

How Many Subnets?


Borrow 2 Bits = 22 = 4 Subnets
If you Borrow 2 Host Bits you do NOT get 4 Subnets. Why? Remember the Network Address and Broadcast Address - Neither of these addresses can be used!

Class C Subnets
S S H H H H H H

Borrow 2 Bits = 22-2 = 2 Subnets


S S S H H H H H

Borrow 3 Bits = 23-2 = 6 Subnets


S S S S H H H H

Borrow 4 Bits = 24-2 = 14 Subnets

Class C Subnets
S S S S S H H H

Borrow 5 Bits = 25-2 = 30 Subnets


S S S S S S H H

Borrow 6 Bits = 26-2 = 62 Subnets

Borrow 7 Bits = Cannot Two Host Bits Must Remain

How Many Subnets?


Borrowed Class Bits
A,B,C A,B,C A,B,C A,B,C A,B,C A,B A,B A,B A,B A,B A,B A,B A,B A A A A A A A 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

#Subnets
4 8 16 32 64 128 256 512 1,024 2,048 4,096 8,192 16,384 32,768 65,536 131,072 262,144 524,288 1,048,576 2,097,152

Available Subnets
2 6 14 30 62 126 254 510 1,022 2,046 4,094 8,190 16,382 32,766 65,534 131,070 262,142 524,286 ######## ########

How Many Hosts/Subnet?


Network Network Network Host

How is the number of Hosts per subnet is calculated?

# Hosts = 26 = 64 hosts/subnet?

How Many Hosts/Subnet?


6 Host Bits Remain = 26 = 64 Hosts

If there are 6 Host Bits remaining you do NOT get 64 Hosts/Subnet. Why? Each subnet has its own Subnet Address and Broadcast Address - Both of these addresses are Reserved and cannot be used! Thus only 62 Hosts are available.

6 Host Bits Remain = 26-2 = 62 Hosts

Borrowed Remaining Class Bits Host Bits #Hosts


C C C C C B B B B B B B B 2 3 4 5 6 7 8 9 10 11 12 13 14 6 5 4 3 2 9 8 7 6 5 4 3 2

How Many Hosts/Subnet?


64 32 16 8 4 512 256 128 64 32 16 8 4

Available Hosts
62 30 14 6 2 510 254 126 62 30 14 6 2

Formulas to Remember!
# Subnets Created = 2# Borrowed Bits-2

Remember to subtract 2 for the Network Address and Broadcast Address.

# Hosts/Subnet = 2# Host Bits Remaining-2

Remember to subtract 2 for the Subnetwork Address and Subnetwork Broadcast Address.

177.56.45.13
What class is this address? Class B What is the default subnet mask? 255.255.0.0 Borrow 2 bits for the subnet mask

NNNNNNNN.NNNNNNNN.SShhhhhh.hhhhhhhh

What is the subnet mask? 27+26 = 128+64 = 192 255.255.192.0

Calculating a Subnet

We will subnet the IP address:

223.14.17.0 Class C

What class IP address is this?

Step #1

Determine the default subnet mask

Class C default subnet mask:

255.255.255.0

Step #2
Determine the number of subnets needed and hosts on each to determine how many bits to borrow from the host ID. Need:

13 subnets 10 hosts on each subnet

Step #3
Figure the actual number of subnets and hosts by borrowing bits from host ID. Lets see how many subnets and hosts we will have by borrowing 4 bits from the host.

Step #3 continued
223.14.17.0

XXXX

HHHH

16 possible subnets

16 possible hosts for each subnet

Step #3 continued

We get 16 possible subnets and 16 possible hosts for each subnet because:

For the 4 bits borrowed each bit can be a 1 or a 0 leaving you with 24 or 16 possible combinations. The same goes for the 4 leftover host bits.

Important: There are only 14 available subnets and hosts on each subnet. Why?

Step #3 continued
Because you cannot use the first and last subnet. Because you cannot use the first and last address within each subnet. For each, one is the broadcast address and one is the network address.

Step #4

Determine the subnet mask. 223.14.17.0

XXXX

HHHH

Where X represents the borrowed bits for subnetting.

Step #4 continued

Add the place values of X together to get the last octet decimal value of the subnet mask.
128 + 64 + 32 + 16 = 240

The subnet mask is: 255.255.255.240 The subnet mask is used to reveal the subnet and host address fields in IP addresses.

Step 5

Determine the ranges of host addresses for each subnet.

Step 5 continued
Subnet # 1 2 3 4 5 6 7 8 Subnet Bits Host Bits In Decimal 0000 0000-1111 .0 -.15 0001 0000-1111 .16 - .31 0010 0000-1111 .32 - .47 0011 0000-1111 .48 - .63 0100 0000-1111 .64 - .79 0101 0000-1111 .80 - .95 0110 0000-1111 .96 - .111 0111 0000-1111 .112 - .127

Step 5 continued
Subnet # 9 10 11 12 13 14 15 16 Subnet Bits Host Bits In Decimal 1000 0000-1111 .128 -.143 1001 0000-1111 .144 - .159 1010 0000-1111 .160 - .175 1011 0000-1111 .176 - .191 1100 0000-1111 .192 - .207 1101 0000-1111 .208 - .223 1110 0000-1111 .224 - .239 1111 0000-1111 .240 - .255

Step 5 continued
There are 16 possible subnets. There are 16 possible hosts on each subnet. That equals 256 possible hosts. What are our available subnets? What are our available hosts on each subnet? Why?????

Figuring Subnet Network Addresses


Step #1: Change the IP host address to binary. Step #2: Change the subnet mask to binary. Step #3: Use the boolean operator AND to combine the two. Step #4:Convert the network binary address to dotted decimal.

Figuring Subnet Network Addresses


IP Host
Subnet Mask

172.16.2.120
255.255.255.0

10101100.00010000.00000010.01111000
AND 11111111.11111111.11111111.00000000

10101100.00010000.00000010.00000000
172.16.2.0 This is the subnet network address. It is the lowest numbered address on the subnet network. It can help determine path.

Subnetting a Class B

Your Class B network is 146.98.0.0 You have been told to subnet this into at least 40 subnets and at least 600 hosts each How can you decide if this is possible? First, calculate the number of bits you must borrow using 2n-2 Second, calculate the number of hosts possible with the remaining bits using 2n-2

Solution in Binary

Borrow 6 bits (26-2) results in 62 subnets Remaining 10 host bits (210-2) results in 1022 possible hosts Subnet Mask is 11111111.11111111.11111100.00000000 Always note the value of the last bit - in this case it is 4

Range of Network IP Addresses


Lowest 146.98.0.0 - Highest 146.98.252.0 But neither of these are usable Usable range is 146.98.4.0 146.98.248.0 The number increments by the value of the last bit borrowed - in this case is 4 62 x 4 = 248

Determine the Network


IP Address 146.98.5.12 255.255.252.0 Network 146.98.4.0

IP Address 146.98.114.47 255.255.252.0 Network 146.98.112.0

Determine Usability

Is 146.98.5.255 255.255.252.0 a usable host IP address? Yes. 10010010.01100010.00000101.11111111 11111111.11111111.11111100.00000000 Are all the host bits one? No, so it is not a broadcast address. It is usable

Determine Broadcast Address


What is the broadcast address for network 146.98.4.0/22? Broadcast is 146.98.7.255

10010010.01100010.00000100.00000000 10010010.01100010.00000111.11111111

S-ar putea să vă placă și