1.#
1Dr. L. Christofi Fall 2007
Lecture 8
Network Layer: Logical addressing
MSCEG 425
Data & Computer CommunicationsData & Computer CommunicationsData & Computer CommunicationsData & Computer Communications
Fall 2007
2Dr. L. Christofi Fall 2007
0. Overview0. 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)
1.#
3Dr. L. Christofi Fall 2007
Position of Network Layer
4Dr. L. Christofi Fall 2007
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.
1.#
5Dr. L. Christofi Fall 2007
14.1 IPv4 ADDRESSES14.1 IPv4 ADDRESSES
An An IPv4 addressIPv4 address is a is a 3232--bitbit address that uniquely and address that uniquely and
universally defines the connection of a device (for example, universally defines the connection of a device (for example,
a computer or a router) to the Internet.a computer or a router) to the Internet.
Address Space
Notations
Classful Addressing
Classless Addressing
Network Address Translation (NAT)
Topics discussed in this section:Topics discussed in this section:
6Dr. L. Christofi Fall 2007
An IPv4 address is 32 bits long.
Note
The address space of IPv4 is 232 or 4,294,967,296.
Note
1.#
7Dr. L. Christofi Fall 2007
The IPv4 addresses are unique
and universal.
Note
8Dr. L. Christofi Fall 2007
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.
1.#
9Dr. L. Christofi Fall 2007
Change the following IPv4 addresses from binary notation to
dotted-decimal notation.
Example
Solution
We replace each group of 8 bits with its equivalent decimal number (see Appendix B) and add dots for separation.
10Dr. L. Christofi Fall 2007
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Example
SolutionWe replace each decimal number with its binary equivalent
1.#
11Dr. L. Christofi Fall 2007
Find the error, if any, in the following IPv4 addresses.
Example
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.
12Dr. L. Christofi Fall 2007
In classful addressing, the address
space is divided into five classes:
A, B, C, D, and E.
Note
1.#
13Dr. L. Christofi Fall 2007
Classful addressing
• The address space is divided into five classes: A, B, C, D and E
14Dr. L. Christofi Fall 2007
Find the class of each address.
a. 00000001 00001011 00001011 11101111b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Example
Solutiona. 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.
1.#
15Dr. L. Christofi Fall 2007
Number of blocks and block size in
classful IPv4 addressing
16Dr. L. Christofi Fall 2007
In classful addressing, a large part of the available addresses were wasted.
Note
1.#
17Dr. L. Christofi Fall 2007
Default masks for classful addressing
18Dr. L. Christofi Fall 2007
Classful addressing, which is almost obsolete, is replaced with classless addressing.
Note
1.#
19Dr. L. Christofi Fall 2007
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.
Example
20Dr. L. Christofi Fall 2007
In IPv4 addressing, a block of addresses can be defined as
x.y.z.t /nin which x.y.z.t defines one of the addresses and the
/n defines the mask.
Note
1.#
21Dr. L. Christofi Fall 2007
The first address in the block can be found by setting
the rightmost
32 − n bits to 0s.
Note
22Dr. L. Christofi Fall 2007
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.
Example
1.#
23Dr. L. Christofi Fall 2007
The last address in the block can be found by setting
the rightmost
32 − n bits to 1s.
Note
24Dr. L. Christofi Fall 2007
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.
Example
1.#
25Dr. L. Christofi Fall 2007
The number of addresses in the block can be found
by using the formula
232−n.
Note
26Dr. L. Christofi Fall 2007
Find the number of addresses in previous example.
Example
SolutionThe value of n is 28, which means that numberof addresses is 2 32−28 or 16.
1.#
27Dr. L. Christofi Fall 2007
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.
Example
28Dr. L. Christofi Fall 2007
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.
Example (continued)
1.#
29Dr. L. Christofi Fall 2007
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.
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.
30Dr. L. Christofi Fall 2007
A network configuration for the block
205.16.37.32/28
1.#
31Dr. L. Christofi Fall 2007
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.
Note
• 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.
Network address
32Dr. L. Christofi Fall 2007
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.
1.#
33Dr. L. Christofi Fall 2007
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.
Note
34Dr. L. Christofi Fall 2007
Netid, Hostid
• Netid: Network address.
• Hostid: Node address
1.#
35Dr. L. Christofi Fall 2007
Hierarchy in telephone numbers
36Dr. L. Christofi Fall 2007
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.
1.#
37Dr. L. Christofi Fall 2007
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.
38Dr. L. Christofi Fall 2007
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.
Example
1.#
39Dr. L. Christofi Fall 2007
Solution
Figure in slide 42 shows the situation.
Example 19.10 (continued)
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:
40Dr. L. Christofi Fall 2007
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
1.#
41Dr. L. Christofi Fall 2007
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
42Dr. L. Christofi Fall 2007
An example of address allocation and
distribution by an ISP
1.#
43Dr. L. Christofi Fall 2007
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 ANDedwith an address in the block.
44Dr. L. Christofi Fall 2007
Default masks
11111111 111111111 11111111 00000000
11111111 11111111 00000000 00000000
11111111 00000000 00000000 00000000
In Binary
/24255.255.255.0C
/16255.255.0.0B
/8255.0.0.0A
Using SlashIn Dotted-DecimalClass
Netid is retained and hostid sets to 0s.
1.#
45Dr. L. Christofi Fall 2007
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.
Example
46Dr. L. Christofi Fall 2007
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.
1.#
47Dr. L. Christofi Fall 2007
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.
Example
48Dr. L. Christofi Fall 2007
• 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.
Supernetting
1.#
49Dr. L. Christofi Fall 2007
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)
50Dr. L. Christofi Fall 2007
• 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.
Dynamic Address Configuration
1.#
51Dr. L. Christofi Fall 2007
Addresses for private networks
52Dr. L. Christofi Fall 2007
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.
1.#
53Dr. L. Christofi Fall 2007
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.
54Dr. L. Christofi Fall 2007
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.
1.#
55Dr. L. Christofi Fall 2007
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.
56Dr. L. Christofi Fall 2007
An ISP and NAT
1.#
57Dr. L. Christofi Fall 2007
14.2 IPv6 ADDRESSES14.2 IPv6 ADDRESSES
Despite all shortDespite all short--term solutions, address depletion is still a term solutions, address depletion is still a
longlong--term problem for the Internet. This and other problems term problem for the Internet. This and other problems
in the IP protocol itself have been the motivation for IPv6. in the IP protocol itself have been the motivation for IPv6.
StructureAddress Space
Topics discussed in this section:Topics discussed in this section:
58Dr. L. Christofi Fall 2007
An IPv6 address is 128 bits long.
Note
1.#
59Dr. L. Christofi Fall 2007
IPv6 address in binary and hexadecimal
colon notation
60Dr. L. Christofi Fall 2007
Abbreviated IPv6 addresses
1.#
61Dr. L. Christofi Fall 2007
Expand the address 0:15::1:12:1213 to its original.
Example
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.
62Dr. L. Christofi Fall 2007
Type prefixes for IPv6 addresses
1.#
63Dr. L. Christofi Fall 2007
Type prefixes for IPv6 addresses
(continued)
64Dr. L. Christofi Fall 2007
Prefixes for provider-based unicast
address
1.#
65Dr. L. Christofi Fall 2007
Multicast address in IPv6
66Dr. L. Christofi Fall 2007
Reserved addresses in IPv6
1.#
67Dr. L. Christofi Fall 2007
Local addresses in IPv6
68Dr. L. Christofi Fall 2007
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.
1.#
69Dr. L. Christofi Fall 2007
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.
70Dr. L. Christofi Fall 2007
References
• W. Stalling, Local and Metropolitan Area Networks, 6th edition, Prentice Hall, 2000
• F. Halsall, Data Communications, Computer Networks and Open Systems, 4th edition, Addison Wesley, 1995
• B.A. Forouzan, Data Communications and Networking, 4th edition, McGraw-Hill, 2007
• W. Stallings, Data and Computer Communications, 7th edition, Prentice Hall, 2004