You are on page 1of 35

Data & Computer Communications

MSCEG 425

Lecture 8
Network Layer: Logical addressing

Fall 2007
Dr. L. Christofi Fall 2007 1

0. Overview
In this lecture we will cover the following topics:

14.Network Layer: Logical addressing


14.1 IPv4 Addresses
14.2 IPv6 Addresses
14.3 Summary (part 14)

Dr. L. Christofi Fall 2007 2

1.#
Position of Network Layer

Dr. L. Christofi Fall 2007 3

Duties of Network Layer


• Internetworking
— Logically connecting heterogeneous networks to look like single network to upper
transport and application layers.
• Addressing
— Each device (a computer or a router) over the Internet must have unique and
universally accepted address.
• Routing
— Packet can not choose its route to the destination. The routers connecting LANs
and WANs make this decision.
• Packetizing
— The network layer encapsulates datagram/segments received from upper layers
and makes packets out of them.
• Fragmenting
— Each router de-capsulates the IP datagram from the received frame, process it and
encapsulates it into another frame.

Dr. L. Christofi Fall 2007 4

1.#
14.1 IPv4 ADDRESSES

An IPv4 address is a 32- 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)

Dr. L. Christofi Fall 2007 5

Note

An IPv4 address is 32 bits long.

Note

The address space of IPv4 is


232 or 4,294,967,296.

Dr. L. Christofi Fall 2007 6

1.#
Note

The IPv4 addresses are unique


and universal.

Dr. L. Christofi Fall 2007 7

Dotted-decimal notation and binary


notation for an IPv4 address
• Binary Notation
• Dotted-Decimal Notation
— Identifier used in network layer to identify each device connected
to the Internet
— 32-bit binary address that uniquely and universally defines the
connection of a host or a router to the Internet.
— In Internet, no two devices can have the same IP
— For readability, we divide the IP address into 4 bytes.
— Dotted-decimal notation: Each byte is separated by dots.

Dr. L. Christofi Fall 2007 8

1.#
Example

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 (see Appendix B) and add dots for separation.

Dr. L. Christofi Fall 2007 9

Example

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Solution
We replace each decimal number with its binary equivalent

Dr. L. Christofi Fall 2007 10

1.#
Example

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.

Dr. L. Christofi Fall 2007 11

Note

In classful addressing, the address


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

Dr. L. Christofi Fall 2007 12

1.#
Classful addressing

• The address space is divided into five classes: A, B, C, D and E

Dr. L. Christofi Fall 2007 13

Example

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.

Dr. L. Christofi Fall 2007 14

1.#
Number of blocks and block size in
classful IPv4 addressing

Dr. L. Christofi Fall 2007 15

Note

In classful addressing, a large part of the available


addresses were wasted.

Dr. L. Christofi Fall 2007 16

1.#
Default masks for classful addressing

Dr. L. Christofi Fall 2007 17

Note

Classful addressing, which is almost obsolete, is


replaced with classless addressing.

Dr. L. Christofi Fall 2007 18

1.#
Example

The figure below shows a block of addresses, in both binary and dotted-
decimal notation, granted to a small business that needs 16 addresses.

We can see that the restrictions are applied to this block. The addresses
are contiguous. The number of addresses is a power of 2 (16 = 24), and the
first address is divisible by 16. The first address, when converted to a
decimal number, is 3,440,387,360, which when divided by 16 results in
215,024,210.

Dr. L. Christofi Fall 2007 19

Note

In IPv4 addressing, 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.

Dr. L. Christofi Fall 2007 20

1.#
Note

The first address in the block can be found by setting


the rightmost
32 − n bits to 0s.

Dr. L. Christofi Fall 2007 21

Example

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


of the addresses is 205.16.37.39/28. What is the first address in the block?

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
This is actually the block shown in figure below.

Dr. L. Christofi Fall 2007 22

1.#
Note

The last address in the block can be found by setting


the rightmost
32 − n bits to 1s.

Dr. L. Christofi Fall 2007 23

Example

Find the last address for the block in previous example.

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 below.

Dr. L. Christofi Fall 2007 24

1.#
Note

The number of addresses in the block can be found


by using the formula
232−n.

Dr. L. Christofi Fall 2007 25

Example

Find the number of addresses in previous example.

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

Dr. L. Christofi Fall 2007 26

1.#
Example

Another way to find the first address, the last address, and the number of
addresses is to represent the mask as a 32-bit 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.

Dr. L. Christofi Fall 2007 27

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

Dr. L. Christofi Fall 2007 28

1.#
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.

c. The number of addresses can be found by complementing the mask,


interpreting it as a decimal number, and adding 1 to it.

Dr. L. Christofi Fall 2007 29

A network configuration for the block


205.16.37.32/28

Dr. L. Christofi Fall 2007 30

1.#
Network address
• Network address is an address that defines the network itself; it
cannot be assigned to a host.
— All hostid bytes are 0s
— Defines the network to the rest of the Internet.
— First address in the block
— Given the network address, we can find the class of the address.

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.

Dr. L. Christofi Fall 2007 31

Levels of hierarchy

• Levels of Hierarchy
— To reach a host on the Internet, we must first reach the network by
using the first portion of the address (netid)
— Then we must reach the host itself by using the second portion
(hostid)
— IP addresses are designed with two levels of hierarchy.

Dr. L. Christofi Fall 2007 32

1.#
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.

Dr. L. Christofi Fall 2007 33

Netid, Hostid

• Netid: Network address.


• Hostid: Node address

Dr. L. Christofi Fall 2007 34

1.#
Hierarchy in telephone numbers

Dr. L. Christofi Fall 2007 35

Three-level hierarchy in an IPv4 address


• Adding subnetworks creates an intermediate level of hierarchy
in the IP addressing system. Now we have three levels: site,
subnet, and host.
• The site is the first level.
• The second level is the subnet.
• The host is the third level.

Dr. L. Christofi Fall 2007 36

1.#
Subnetting

• Sub-netting
— We can divide a network into sub-networks while making
the world knows only the main network.
— In sub-netting, a network is divided into several smaller
groups with each sub-network (or subnet) having its own
sub-network address.

Dr. L. Christofi Fall 2007 37

Example

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.

Dr. L. Christofi Fall 2007 38

1.#
Example 19.10 (continued)

Solution
Figure in slide 42 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:

Dr. L. Christofi Fall 2007 39

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

Dr. L. Christofi Fall 2007 40

1.#
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

Dr. L. Christofi Fall 2007 41

An example of address allocation and


distribution by an ISP

Dr. L. Christofi Fall 2007 42

1.#
Mask

• A router routes the packet based on network address and


subnetwork address.
• A router inside a network routes based on subnetwork address
but a router outside a network routes based on network
address.
• Router uses the 32-bit mask to identify the network address.
• Routers outside an organization use a default mask; the routers
inside an organization use a subnet mask
• Default mask
— 32-bit binary number that gives the network address when ANDed
with an address in the block.

Dr. L. Christofi Fall 2007 43

Default masks

Class In Binary In Dotted-Decimal Using Slash

A 11111111 00000000 00000000 00000000 255.0.0.0 /8

B 11111111 11111111 00000000 00000000 255.255.0.0 /16

C 11111111 111111111 11111111 00000000 255.255.255.0 /24

Netid is retained and hostid sets to 0s.

Dr. L. Christofi Fall 2007 44

1.#
Example

A router outside the organization receives a packet with


destination address 190.240.7.91. Show how it finds the
network address to route the packet.

Solution:
The router follows three steps:
1. The router looks at the first byte of the address to find the
class. It is class B.
2. The default mask for class B is 255.255.0.0. The router
ANDs this mask with the address to get 190.240.0.0.
3. The router looks in its routing table to find out how to
route the packet to this destination. Later, we will see
what happens if this destination does not exist.
Dr. L. Christofi Fall 2007 45

Subnet mask

• Number of 1s in a subnet mask is more than the number of 1s


in the corresponding default mask.
• In a subnet mask, we change some of the leftmost 0s in the
default mask to make a subnet mask.

Dr. L. Christofi Fall 2007 46

1.#
Example

A router inside the organization receives the same packet


with destination address 190.240.33.91. Show how it finds
the subnetwork address to route the packet.

Solution:
The router follows three steps:
1. The router must know the mask. We assume it is /19, as
shown in Figure 19.23.
2. The router applies the mask to the address,
190.240.33.91. The subnet address is 190.240.32.0.
3. The router looks in its routing table to find how to route
the packet to this destination. Later, we will see what
happens if this destination does not exist.

Dr. L. Christofi Fall 2007 47

Supernetting

• Although class A and B addresses are almost


depleted, class C addresses are still available.
• In supernetting, an organization can combine several
class C blocks to create a larger range of addresses.
• Several networks are combined to create a
supernetwork.

Dr. L. Christofi Fall 2007 48

1.#
Classless Addressing

• A range of addresses meant a block of addresses in class


A, B, or C.
• What about a small business that needed only 16
addresses? Or a household that needed only two
addresses?
— ISPs provide IP; people connect via dial-up modem, DSL, or
cable modem to the ISP.
— Variable-length blocks: No class boundaries.
— Mask: Provide a block, it is given the first address and mask.
— Subnetting
— Classless InterDomain Routing (CIDR)

Dr. L. Christofi Fall 2007 49

Dynamic Address Configuration

• Each computer has IP address, subnet mask, IP address of a router, IP


address of a name server; This information is usually stored in a
configuration file and accessed by the computer during the bootstrap (boot)
process.
• Dynamic Host Configuration Protocol (DHCP) is a protocol designed to
provide the information dynamically (based on demand).
• DHCP is a client-server program.
• When a DHCP client requests a temporary IP address, the DHCP server goes
to the pool of available (unused) IP addresses and assigns an IP address for
a negotiable period of time.
• When a DHCP client sends a request to a DHCP server, the server first checks
its static database. If an entry with the requested physical address exists in
the static database, the permanent IP address of the client is returned. On
the other hand, if the entry does not exist in the static database, the server
selects an IP address from the available pool, assigns the address to the
client, and adds the entry to the dynamic database.

Dr. L. Christofi Fall 2007 50

1.#
Addresses for private networks

Dr. L. Christofi Fall 2007 51

A Network Address Translation (NAT)


implementation

• NAT enables a user to have a large set of addresses internally


and one address, or a small set of addresses, externally.
• The traffic inside can use the large set; the traffic outside, the
small set.

Dr. L. Christofi Fall 2007 52

1.#
Address Translation
• All the outgoing packets go through the NAT router, which
replaces the source address in the packet with the global NAT
address.
• All incoming packets also pass through the NAT router, which
replaces the destination address in the packet (the NAT router
global address) with the appropriate private address.

Dr. L. Christofi Fall 2007 53

NAT address translation


• Using one IP address: private address to external address mapping.
• Limitation is that only the private network can initiate a connection and
not vice-versa.
• Only one request at a time.

Dr. L. Christofi Fall 2007 54

1.#
Five-column translation table

• Using a pool of IP addresses


— More than one global address is there and we map to one of them.
— Limited by the number of global IP.

• Using both IP and port numbers


— Mapping with IPs and Port numbers.

Dr. L. Christofi Fall 2007 55

An ISP and NAT

Dr. L. Christofi Fall 2007 56

1.#
14.2 IPv6 ADDRESSES

Despite all short-


short-term solutions, address depletion is still a
long-
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

Dr. L. Christofi Fall 2007 57

Note

An IPv6 address is 128 bits long.

Dr. L. Christofi Fall 2007 58

1.#
IPv6 address in binary and hexadecimal
colon notation

Dr. L. Christofi Fall 2007 59

Abbreviated IPv6 addresses

Dr. L. Christofi Fall 2007 60

1.#
Example

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.

Dr. L. Christofi Fall 2007 61

Type prefixes for IPv6 addresses

Dr. L. Christofi Fall 2007 62

1.#
Type prefixes for IPv6 addresses
(continued)

Dr. L. Christofi Fall 2007 63

Prefixes for provider-based unicast


address

Dr. L. Christofi Fall 2007 64

1.#
Multicast address in IPv6

Dr. L. Christofi Fall 2007 65

Reserved addresses in IPv6

Dr. L. Christofi Fall 2007 66

1.#
Local addresses in IPv6

Dr. L. Christofi Fall 2007 67

14.3 SUMMARY (part 14)


• There are two popular approaches to packet switching: the datagram approach and the virtual
circuit approach.
• In the datagram approach, each packet is treated independently of all other packets.
• At the network layer, a global addressing system that uniquely identifies every host and router is
necessary for delivery of a packet from network to network.
• The Internet address (or IP address) is 32 bits (for IPv4) that uniquely and universally defines a
host or router on the internet.
• The portion of the IP address that identifies the network is called the netid.
• The portion of the IP address that identifies the host or router on the network is called the
hostid.
• There are five classes of IP addresses. Classes A, B, and C differ in the number of hosts allowed
per network. Class D is for multicasting, and class E is reserved.
• The class of a network is easily determined by examination of the first byte.
• Unicast communication is one source sending a packet to one destination.
• Multicast communication is one source sending a packet to multiple destinations.
• Subetting divides one large network into several smaller ones.
• Subnetting adds an intermediate level of hierarchy in IP addressing.
• Default masking is a process that extracts the network address from an IP address.
• Subnet masking is a process that extracts the subnetwork address from an IP address
• Supernetting combines several networks into one large one.

Dr. L. Christofi Fall 2007 68

1.#
14.3 SUMMARY continued (part 14)
• In classless addressing, there are variable-length blocks that belong to no class. The entire
address space is divided into blocks based on organization needs.
• The first address and the mask in classless addressing can define the whole block.
• A mask can be expressed in slash notation which is a slash followed by the number of 1s in the
mask.
• Every computer attached to the Internet must know its IP address, the IP address of a router,
the IP address of a name server, and its subnet mask (if it is part of a subnet).
• DHCP is a dynamic configuration protocol with two databases.
• The DHCP server issues a lease for an IP address to a client for a specific period of time.
• Network address translation (NAT) allows a private network to use a set of private addresses for
internal communication and a set of global Internet addresses for external communication.
• NAT uses translation tables to route messages.
• The IP protocol is a connectionless protocol. Every packet is independent and has no relationship
to any other packet.
• Every host or router has a routing table to route IP packets.
• In next-hop routing, instead of a complete list of the stops the packet must make, only the
address of the next hop is listed in the routing table.
• In network-specific routing, all hosts on a network share one entry in the routing table.
• In host-specific routing, the full IP address of a host is given in the routing table.
• In default routing, a router is assigned to receive all packets with no match in the routing table.
• A static routing table's entries are updated manually by an administrator.
• Classless addressing requires hierarchial and geographic routing to prevent immense routing
tables.

Dr. L. Christofi Fall 2007 69

References

• B.A. Forouzan, Data Communications and Networking,


4th edition, McGraw-Hill, 2007

• W. Stalling, Local and Metropolitan Area Networks,


6th edition, Prentice Hall, 2000

• W. Stallings, Data and Computer Communications,


7th edition, Prentice Hall, 2004

• F. Halsall, Data Communications, Computer Networks and


Open Systems, 4th edition, Addison Wesley, 1995

Dr. L. Christofi Fall 2007 70

1.#

You might also like