Вы находитесь на странице: 1из 22

n Computer Networks

n Al-Mustansiryah University
n Elec. Eng. Department College of Engineering
Fourth Year Class

Chapter 3
Network Layer:
Logical Addressing

3.1

3-1 IPv4 ADDRESSES

An IPv4 address is a 32-bit address that uniquely and


universally defines the connection of a device (for
example, a computer or a router) to the Internet.

3.2
Note

An IPv4 address is 32 bits long.

The IPv4 addresses are unique


and universal.

The address space of IPv4 is


232 or 4,294,967,295.

3.3

Figure 3.1 Dotted-decimal notation and binary notation for an IPv4 address

3.4
Example 3.1

Change the following IPv4 addresses from binary notation


to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.

3.5

Example 3.2

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Solution
We replace each decimal number with its binary equivalent
.

3.6
Example 3.3

Find the error, if any, in the following IPv4 addresses.

Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
3.7

In classful addressing, the address


space is divided into five classes:
A, B, C, D, and E.

3.8
Figure 3.2 Finding the classes in binary and dotted-decimal notation

3.9

Example 3.4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.

3.10
Table 3.1 Number of blocks and block size in classful IPv4 addressing

In classful addressing, a large part of the


available addresses were wasted.

3.11

Table 3.2 Default masks for classful addressing

CIDR :Classless Inter-Domain Routing

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.

3.12
Example

What is the subnetwork address if the destination address is


200.45.34.56 and the subnet mask is 255.255.240.0?
Solution

11001000 00101101 00100010 00111000


11111111 11111111 11110000 00000000
11001000 00101101 00100000 00000000

The subnetwork address is 200.45.32.0.

3.13

Example

What is the subnetwork address if the destination address is


19.30.84.5 and the mask is 255.255.192.0?

Solution

3.14
Example 3.6

A block of addresses is granted to a small organization. We


know that one of the addresses is 205.15.37.39/28. What is
the first address (subnet address)in the block?

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 3228 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.15.37.32.
This is actually the block shown in Figure 5.3.
3.15

Note

The last address(broadcast) in the block


can be found by setting the rightmost
32 n bits to 1s.

3.16
Example 3.7

Find the last address (broadcast)for the block in Example


3.5.

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.15.37.47
This is actually the block shown in Figure 5.3.

3.17

Example 3.8

Find the number of addresses in Example 3.5.

Solution
The value of n is 28, which means that number
of addresses is 2 3228 or 16.

The number of addresses in the block


can be found by using the formula
232n.

3.18
Note

The first address in a block is


normally not assigned to any device;
it is used as the network address that
represents the organization
to the rest of the world.

3.19

Subnetting Example
n Host IP Address: 138.101.114.250
n Network Mask: 255.255.0.0
n Subnet Mask: 255.255.255.192

Given the following Host IP Address, Network Mask and Subnet mask find the
following information:
n Major Network Information
n Major Network Address
n Major Network Broadcast Address
n Range of Hosts if not subnetted
n Subnet Information
n Subnet Address
n Range of Host Addresses (first host and last host)
n Broadcast Address
n Other Subnet Information
n Total number of subnets
n Number of hosts per subnet

3.20
Major Network Information
n Host IP Address: 138.101.114.250
n Network Mask: 255.255.0.0
n Subnet Mask: 255.255.255.192

n Major Network Address: 138.101.0.0


n Major Network Broadcast Address: 138.101.255.255
n Range of Hosts if not Subnetted: 138.101.0.1 to
138.101.255.254

3.21

Step 1: Convert to Binary


128 64 32 16 8 4 2 1

138. 101. 114. 250


IP Address 10001010 01100101 01110010 11111010
Mask 11111111 11111111 11111111 11000000
255. 255. 255. 192

Step 1:
Translate Host IP Address and Subnet Mask into binary notation

3.22
Step 2: Find the Subnet Address
138. 101. 114. 250
IP Address 10001010 01100101 01110010 11111010
Mask 11111111 11111111 11111111 11000000
Network 10001010 01100101 01110010 11000000
138 101 114 192

Step 2:
Determine the Network (or Subnet) where this Host address
lives:
1. Draw a line under the mask
2. Perform a bit-wise AND operation on the IP Address and the Subnet
Mask
Note: 1 AND 1 results in a 1, 0 AND anything results in a 0
3. Express the result in Dotted Decimal Notation
4. The result is the Subnet Address of this Subnet or Wire which is
138.101.114.192

3.23

Step 3: Subnet Range / Host Range


G.D. S.D.

IP Address 10001010 01100101 01110010 11 111010


Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range
Step 3:
Determine which bits in the address contain Network (subnet)
information and which contain Host information:
n Use the Network Mask: 255.255.0.0 and divide (Great Divide) the
from the rest of the address.
n Use Subnet Mask: 255.255.255.192 and divide (Small Divide) the
subnet from the hosts between the last 1 and the first 0 in the
subnet mask.

3.24
Step 4: First Host / Last Host
G.D. S.D.

IP Address 10001010 01100101 01110010 11 111010


Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range

First Host 10001010 01100101 01110010 11 000001


138 101 114 193

Last Host 10001010 01100101 01110010 11 111110


138 101 114 254

Broadcast 10001010 01100101 01110010 11 111111


138 101 114 255

Host Portion
n Subnet Address: all 0s
n First Host: all 0s and a 1
n Last Host: all 1s and a 0
n Broadcast: all 1s
3.25

Step 5: Total Number of Subnets


G.D. S.D.

IP Address 10001010 01100101 01110010 11 111010


Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range

n Total
First number
Host of subnets
10001010 01100101 01110010 11 000001
138 101 114 193
n Number
Last Host
of subnet
10001010
bits 10
01100101 01110010 11 111110
n 210 = 1,024 138 101 114 254

n 1,024 total 10001010


Broadcast
subnets
138
01100101
101
01110010
114
11 111111
255
n Subtract one if all-zeros subnet cannot be used
n Subtract one if all-ones subnet cannot be used
3.26 n 1,022 total subnets
Step 6: Total Number of Hosts per
Subnet G.D. S.D.

IP Address 10001010 01100101 01110010 11 111010


Mask 11111111 11111111 11111111 11 000000
Network 10001010 01100101 01110010 11 000000
subnet host
counting range counting
range

n Total
Firstnumber
Host of hosts01100101
10001010 per subnet
01110010 11 000001
138 101 114 193
n Number of host bits 6
Last Host 10001010 01100101 01110010 11 111110
n 26 = 64 138 101 114 254

n 64 host per subnets


Broadcast 10001010 01100101 01110010 11 111111
n Subtract one 138
for the 101 address 114
subnet 255

n Subtract one for the broadcast address


n 62 hosts per subnet
3.27

Example 3.10

An ISP is granted a block of addresses starting with


190.100.0.0/16 (65,536 addresses). The ISP needs to
distribute these addresses to three groups of customers as
follows:
a. The first group has 64 customers; each needs 256
addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs 64
addresses.
Design the subblocks and find out how many addresses are
still available after these allocations.
3.28
Example 3.10 (continued)

Solution
Figure 3.9 shows the situation.
Group 1
For this group, each customer needs 256 addresses. This
means that 8 (log2 256) bits are needed to define each host.
The prefix length is then 32 8 = 24. The addresses are

3.29

Example 3.10 (continued)

Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each host.
The prefix length is then 32 7 = 25. The addresses are

3.30
Example 3.10 (continued)
Group 3
For this group, each customer needs 64 addresses. This
means that 6 (log264) bits are needed to each host. The
prefix length is then 32 6 = 26. The addresses are

Number of granted addresses to the ISP: 65,536


Number of allocated addresses by the ISP: 40,960
Number of available addresses: 24,576
3.31

Figure 3.9 An example of address allocation and distribution by an ISP

3.32
Table 3.3 Addresses for private networks

3.33

Example 3.11 :A company is granted the site address 211.80.64.0 .The company
needs six subnets. Design the subnets?

Solution:
No. of subnet must be power of 2 therefore we design 8 subnets
No.of subnet bits=Log2(8)=3 bits

Ip address 211.80.64.0 is class c

Net Sub Host

24 Bit 3 Bit 8 Bit

3.34
Subnet NET . Subnet . Host Subnet IP
211.80.64 000 00000 211.80.64.0
Subnet 0
211.80.64 000 11111 211.80.64.31
211.80.64 001 00000 211.80.64.32
Subnet 1
211.80.64 001 11111 211.80.64. 63
211.80.64 010 00000 211.80.64.64
Subnet 2
211.80.64 010 11111 211.80.64. 95
Subnet 3 211.80.64 011 00000 211.80.64.96
211.80.64 011 11111 211.80.64. 127
Subnet 4 211.80.64 100 00000 211.80.64. 128

211.80.64 100 11111 211.80.64. 159


Subnet 5 211.80.64 101 00000 211.80.64. 160

211.80.64 101 11111 211.80.64. 191


Subnet 6 211.80.64 110 00000 211.80.64. 192

211.80.64 110 11111 211.80.64. 223


Subnet 7 211.80.64 111 00000 211.80.64. 224

211.80.64 111 11111 211.80.64. 255

3.35

Broadcast Address

172.16.3.0

172.16.4.0

172.16.1.0
17

172.16.3.255 172.16.2.0
(Directed Broadcast)

25
255.255.255.255 X
(Local Network Broadcast)
172.16.255.255
(All Subnets Broadcast)

3.36
3-2 IPv6 ADDRESSES

Despite all short-term solutions, address depletion is


still a long-term problem for the Internet. This and other
problems in the IP protocol itself have been the
motivation for IPv5.

3.37

Features of IPv6
n Larger Address Space
n Efficient and Extensible IP datagram
n Security

3.38
Major Improvements of
IPv6 Header
n No option field: Replaced by extension
header. Result in a fixed length, 40-byte IP
header.
n No header checksum: Result in fast
processing.
n No fragmentation at intermediate nodes:
Result in fast IP forwarding.

3.39

An IPv6 address is 128 bits long.

Figure 3.14 IPv6 address in binary and hexadecimal colon notation

3.40
128-bit IPv6 Address

3FFE:085B:1F1F:0000:0000:0000:00A9:1234

8 groups of 16-bit hexadecimal numbers separated by :


Leading zeros can be removed

3FFE:85B:1F1F::A9:1234

:: = all zeros in one or more group of 16-bit hexadecimal numbers

3.41

Figure 3.15 Abbreviated IPv6 addresses

3.42
Example 3.12

Expand the address 0:15::1:12:1213 to its original.

Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find how
many 0s we need to replace the double colon.

This means that the original address is.

3.43

Вам также может понравиться