Anda di halaman 1dari 140

Network Layer

McGraw-Hill

1
The McGraw-Hill Companies, Inc., 2000

Position of the Network


Layer

19.2

Issues at the Network Layer

Addressing
IP addresses on the Internet

Switching
Datagram packet switching
Virtual circuit packet switching

19.3

19.4

19.5

19.6

19.7

19.8

How Networks
Differ

Some of the many ways networks can differ.

19.9

IPv4ADDRESSES
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.
Topics discussed in this section:
Address Space
Notations
Classful Addressing
Classless Addressing
Network Address Translation (NAT)
19.10

Note

An IPv4 address is 32 bits long.

19.11

Note

The IPv4 addresses are unique


and universal.

19.12

Note

The address space of IPv4 is


232 or 4,294,967,296.

19.13

Dotted-decimal notation and binary notation for an IPv4 address

19.14

Classful
Addressing
Note

In classful addressing, the address


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

19.15

Finding the classes in binary and dotted-decimal notation

19.16

Number of blocks and block size in classful IPv4 addressing

19.17

Note

In classful addressing, a large part of


the available addresses were wasted.

19.18

Default masks for classful addressing

19.19

Note

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.

19.20

Classless Addressing

To overcome address depletion, classless


addressing was designed.
No classes, but addresses are granted in
blocks.
Rules

19.21

Addressees in blocks must be contiguous


The number of addresses in block must be power of 2
(1,2,4,8,16,)
The first address must be evenly divisible by the
number of addresses.

A block of 16 addresses granted to a small organization

19.22

Mask

19.23

A mask is 32 bit number in which n leftmost


bits are 1s and the 32-n rightmost bits are 0s.
Range from 0 to 32.
A block of addresses can be defined as
x.y.z.t /n , in which x.y.z.t defines one of the
addresses and the /n defines the mask.

Note

The first address in the block can be


found by setting the rightmost
32 n bits to 0s.

19.24

Note

The last address in the block can be


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

19.25

Example
Ex. A block of addresses is granted to small organization.
One of the address is 205.16.37.39/28
Find the last address for the block.
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.16.37.47
This is actually the block shown in Figure 19.3.
19.26

Note

The number of addresses in the block


can be found by using the formula
232n.

19.27

Example 19.9
Another way to find the first address, the last address, and
the number of addresses is to represent the mask as a 32bit binary (or 8-digit hexadecimal) number. This is
particularly useful when we are writing a program to find
these pieces of information. In Example 19.5 the /28 can
be represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).
Find
a. The first address
b. The last address
c. The number of addresses.
19.28

Example 19.9 (continued)


Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
the result is 0 otherwise.

19.29

Example 19.9 (continued)


b. The last address can be found by ORing the given
addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; the result is 1 otherwise. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.

19.30

Example 19.9 (continued)


c. The number of addresses can be found by
complementing the mask, interpreting it as a decimal
number, and adding 1 to it.

19.31

A network configuration for the block 205.16.37.32/28

19.32

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.

19.33

Two levels of heirachy in an IPv4 Address

19.34

Note

Each address in the block can be


considered as a two-level
hierarchical structure:
the leftmost n bits (prefix) define
the network;
the rightmost 32 n bits define
the host.
19.35

Subnetting:

What are the major reasons for subnetting or


segmenting your network?
1.

2.
3.

4.

19.36

To divide a large network into smaller segments to


reduce traffic and speed up the sections of your
network.
To connect networks across geographical areas.
To connect different topologies such as Ethernet, Token
Ring, and FDDI together via routers.
To avoid physical limitations such as maximum cable
lengths or exceeding the maximum number of
computers on a segment.

Example Network

The ABCD University is planning to deploy an IP


network in their main campus .Its main campus
location includes only a single physical building
with 4 floors and 8 total departments.
Each of the different departments needs to be
separate and have their own IP address space.
The address space that has been allocated to the
University by their Internet Service Provider (ISP) is
172.16.0.0/23.
Each of the different departments requires at least
40 different usable addresses and at least 10 extra
addresses allocated for future growth.
Design the IP address range for the Network

19.37

below shows the allocated space given by the ISP and how it is
displayed in binary.

19.38

The requirements stated that each of the 8 departments needed at a


minimum 40 addresses with an additional 10 allocated for future
growth for a total of 50 required addresses assigned per department.
Given this requirement, what is the smallest subnet that would be
required?Figure below shows that the smallest subnet available
would be allocating each network 64 total addresses.

19.39

19.40

The next thing to Figure out is


whether the number of the addresses
allocated by the ISP is enough to
meet the requirements of the
organization. The ISP allocated the
range from 172.16.0.0 through
172.16.1.255 which equals 512 total
addresses; 512 8 (departments) =
64 addresses.

Network Range Calculation


Now that it has been calculated that the ISPs allocation of addresses is enough to meet the
requirements of the organization, the next task is to come up with the different ranges that will be used
to
allocate
to each department.
shows
the calculation
of the first range using the 255.255.255.192 (/26) subnet mask calculated

19.41
First Subnetwork Range

The first department (Administration) will be allocated addresses from 172.16.0.0


through 172.16.0.63. The next thing to calculate is which of these addresses are usable
and which are reserved for the subnet and broadcast addresses. As the subnet address is
the lowest number in the range, it is 172.16.0.0; as the broadcast address is the highest
address in the range, it is 172.16.0.63, leaving the addresses from 172.16.0.1 through
172.16.0.62 as usable

19.42

The second subnetwork will begin where the first left off at 172.16.0.64 and go
up to 172.16.0.127; this range is shown.

19.44

The third department: 172.16.0.128 through


172.16.0.191

19.45

And so on..

19.46

The Eighth department: 172.16.1.192 and go up to


172.16.1.255

19.47

Three level hierarchy

Suppose an organization has three offices and


needs to divide the addresses into 3 subblocks
of 32,16,16 addresses. Organization is given
the block 17.12.14.0/26

19.48

Three level hierarchy


1.

Suppose the mask for 1st subnet is n1 then 232-n1 must be


32, which means n1=27

2.

Mask for 2nd subnet is n2 then 232-n2 must be 16, hence


n2=28

3.

Mask for 3rd subnet is n3 then 232-n3 must be 16, hence


n3=28

19.49

19.50

Note: We have the masks 27, 28, 28


for subnets with the organization
mask being 26

Figure 19.8 Three-level hierarchy in an IPv4 address


Subnetting

19.51

Configuration and addresses in a subnetted network

19.52

More levels of hierarchy

19.53

Example 19.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.
19.54

Example 19.10 (continued)


Solution
Figure 19.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

19.55

Example 19.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

19.56

Example 19.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
19.57

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

19.58

Network Address Translation

Number of Internet users are


increasing.
There is short fall of addresses.
Solution?

Network Address Translation

19.59

Large addresses internally


Single or small set of addresses globally.

Unique inside , but not globally.

Table Addresses for private networks

19.60

NAT implementation

19.61

Figure 19.11 Addresses in a NAT

19.62

Figure 19.12 NAT address translation

19.63

Table 19.4 Five-column translation table

19.64

Figure 19.13 An ISP and NAT

19.65

INTERNETWORKING

In this section, we discuss internetworking, connecting networks


together to make an internetwork or an internet.

Topics discussed in this section:


Need for Network Layer
Internet as a Datagram Network
Internet as a Connectionless Network

20.66

Figure 20.1 Links between two hosts

20.67

Network layer in an internetwork

Network layer at the source, router, and destination

Note

Switching at the network layer in the Internet uses the datagram


approach to packet switching.

20.70

Note

Communication at the network layer in the Internet is connectionless.

20.71

IPv4
The Internet Protocol version 4 (IPv4) is the delivery mechanism
used by the TCP/IP protocols.

Topics discussed in this section:


Datagram
Fragmentation
Checksum
Options

20.72

Figure 20.4 Position of IPv4 in TCP/IP protocol suite

20.73

IPv4 datagram format

Figure 20.6 Service type or differentiated services

20.75

Note

The precedence subfield was part of version 4, but never used.

20.76

Table 20.1 Types of service

20.77

Table 20.2 Default types of service

20.78

Table 20.3 Values for codepoints

20.79

Note

The total length field defines the total length of the datagram including
the header.

20.80

Figure 20.7 Encapsulation of a small datagram in an Ethernet frame

20.81

Protocol field and encapsulated data

20.82

Protocol values

20.83

Example 20.1

An IPv4 packet has arrived with the first 8 bits as shown:


01000010
The receiver discards the packet. Why?

Solution
Thereisanerrorinthispacket.The4leftmostbits(0100)showtheversion,whichiscorrect.The
next4bits(0010)showaninvalidheaderlength(24=8).Theminimumnumberofbytesinthe
headermustbe20.Thepackethasbeencorruptedintransmission.

20.84

Example 20.2

In an IPv4 packet, the value of HLEN is 1000 in binary. How many bytes of options are being
carried by this packet?

Solution
The HLEN value is 8, which means the total number of bytes in the header is 8 4, or 32 bytes.
The first 20 bytes are the base header, the next 12 bytes are the options.

20.85

Example 20.3

In an IPv4 packet, the value of HLEN is 5, and the value of the total length field is 0x0028. How
many bytes of data are being carried by this packet?

Solution
TheHLENvalueis5,whichmeansthetotalnumberofbytesintheheaderis54,or20bytes(no
options).Thetotallengthis40bytes,whichmeansthepacketiscarrying20bytesofdata(4020).

20.86

Example 20.4

An IPv4 packet has arrived with the first few hexadecimal digits as shown.
0x45000028000100000102 . . .
How many hops can this packet travel before being dropped? The data belong to what upper-layer
protocol?

Solution
Tofindthetimetolivefield,weskip8bytes.Thetimetolivefieldistheninthbyte,whichis01.
Thismeansthepacketcantravelonlyonehop.Theprotocolfieldisthenextbyte(02),whichmeans
thattheupperlayerprotocolisIGMP.

20.87

Figure 20.9 Maximum transfer unit (MTU)

20.88

Table 20.5 MTUs for some networks

20.89

20.90

Identification

19.91

Identifies the datagram originating from the


source
Combination of identification and IP address
uniquely identifies the datagram.
Uses a counter to label.
When a datagram is fragmented, value in the
identification field is copied in all the fragments.
Helps in re-assembly

Flags
M=1- more fragments follows
0- last fragment

Fragmentation Offset: Defines the relative position of the fragment


with respect to datagram.

20.92

20.93

RE-ASSEMBLE?

19.94

19.95

Re-assemble

19.96

First fragment has offset equal to Zero


Divide the length of first fragment by 8, to get
2nd fragment offset.
Divide the total length of 1st and 2nd by 8 to get
3rd fragment offset.
Continue the process, last fragment has more
value set to 0.

19.97

Example 20.5

A packet has arrived with an M bit value of 0. Is this the first fragment, the last fragment, or a
middle fragment? Do we know if the packet was fragmented?

Solution
IftheMbitis0,itmeansthattherearenomorefragments;thefragmentisthelastone.However,
wecannotsayiftheoriginalpacketwasfragmentedornot.Anonfragmentedpacketisconsidered
thelastfragment.

20.98

Example 20.6

A packet has arrived with an M bit value of 1. Is this the first fragment, the last fragment, or a
middle fragment? Do we know if the packet was fragmented?

Solution
IftheMbitis1,itmeansthatthereisatleastonemorefragment.Thisfragmentcanbethefirst
oneoramiddleone,butnotthelastone.Wedontknowifitisthefirstoneoramiddleone;we
needmoreinformation(thevalueofthefragmentationoffset).

20.99

Example 20.7

A packet has arrived with an M bit value of 1 and a fragmentation offset value of 0. Is this the first
fragment, the last fragment, or a middle fragment?

Solution
BecausetheMbitis1,itiseitherthefirstfragmentoramiddleone.Becausetheoffsetvalueis0,it
isthefirstfragment.

20.100

Example 20.8

A packet has arrived in which the offset value is 100. What is the number of the first byte? Do we
know the number of the last byte?

Solution
To find the number of the first byte, we multiply the offset value by 8. This means that the first byte
number is 800. We cannot determine the number of the last byte unless we know the length.

20.101

Example 20.9

A packet has arrived in which the offset value is 100, the value of HLEN is 5, and the value of the
total length field is 100. What are the numbers of the first byte and the last byte?

Solution
Thefirstbytenumberis1008=800.Thetotallengthis100bytes,andtheheaderlengthis20
bytes(54),whichmeansthatthereare80bytesinthisdatagram.Ifthefirstbytenumberis800,
thelastbytenumbermustbe879.

20.102

Example 20.10

Figure 20.13 shows an example of a checksum calculation for an IPv4 header without options. The
header is divided into 16-bit sections. All the sections are added and the sum is complemented. The
result is inserted in the checksum field.

20.105

Example of checksum calculation in IPv4

20.106

Taxonomy of options in IPv4


Options field is used for network testing and debugging

A record route option is used to record the Internet routers that


handle the datagram.
It can list up to nine router addresses. It can be used for debugging
and management purposes.

20.107

Taxonomy of options in IPv4


Options field is used for network testing and debugging

A strict source route option is used by the source to


predetermine a route for the datagram as it travels
through the Internet

20.108

Taxonomy of options in IPv4


Options field is used for network testing and debugging

Each router in the list must be visited, but the datagram


can visit other routers as well.

20.109

Taxonomy of options in IPv4


Options field is used for network testing and debugging

A timestamp option is used to record the time of


datagram processing by a router.

20.110

Limitations of IPv4

19.111

IPv6ADDRESSES
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 IPv6.
Topics discussed in this section:
Structure
Address Space

19.112

Advantages of IPv6

19.113

Larger Address Space


Better Header Format
New Options
Allowance for extensions
Support for resource Allocation
Support for more Security

Note

An IPv6 address is 128 bits long.

19.114

Figure 19.14 IPv6 address in binary and hexadecimal colon notation

19.115

Figure 19.15 Abbreviated IPv6 addresses

19.116

Example 19.11
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.

19.117

Address Space

2128
3.4 x1038
19.118

Type prefixes for IPv6 addresses

Type prefixes for IPv6 addresses: Defines the category.


19.119

Table 19.5 Type prefixes for IPv6 addresses (continued)

19.120

Unicast Address:Provider based address: used for


global communication over the Internet.
16

24

32

North

Type code (3 Bit)


010- Provider based identifier

19.121

America

48

Unicast Address:Provider based address

16

24

32

Europe

19.122

48

Unicast Address:Provider based address

16

24

32

Assia

Multicast Address

19.123

Pacific

48

Anycast Address: Packet is delivered to any one of the


group. Possibly nearest node in that group.
Researved Address

19.124

Figure 19.19 Local addresses in IPv6


Used when an organization wants to use these addresses
without connecting to the internet.

19.125

IPv6 Packet Format

McGraw-Hill

19.126
The McGraw-Hill Companies, Inc., 2000

Figure 20.15 IPv6 datagram header and payload

20.127

Format of an IPv6 datagram

Priorities
congestion-controlled traffic

Non-congestion-controlled traffic

Next header codes for IPv6

Flow Label

Extension header types

Comparison between IPv4 and IPv6 packet headers

Comparison between IPv4 options and IPv6 extension headers

TRANSITIONFROMIPv4TOIPv6
Because of the huge number of systems on the Internet, the transition
from IPv4 to IPv6 cannot happen suddenly. It takes a considerable
amount of time before every system in the Internet can move from IPv4
to IPv6. The transition must be smooth to prevent any problems between
IPv4 and IPv6 systems.

Topics discussed in this section:

Dual Stack
Tunneling
Header Translation
20.135

Three transition strategies

Dual stack

Tunneling strategy

Header translation strategy

Header translation

Anda mungkin juga menyukai