0% found this document useful (0 votes)
19 views64 pages

11-13 Network Layer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views64 pages

11-13 Network Layer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 64

Network Layer

Fundamentals of Data Communications and Networking

INT205

Data Communications & Networking by Behrouz A Forouzan. Copyright © The McGraw-Hill Companies, Inc.
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.
Note

An IPv4 address is 32 bits long.

The IPv4 addresses are unique


and universal (all nodes connecting
Internet must have IP addresses).

The address space of IPv4 is


232 or 4,294,967,296.
Dotted-decimal notation and binary notation for an IPv4 address
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 and add dots for separation.
Example

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Solution
We replace each decimal number with its binary
equivalent.
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.
Note

In classful addressing, the address


space is divided into five classes:
A, B, C, D, and E.
Finding the classes in binary and dotted-decimal notation

Class D: multicast

Class E: reserved
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.
Number of blocks and block size in classful IPv4 addressing
Note

In classful addressing, a large part of


the available addresses were wasted.
Note

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.
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.

Usually, x.y.z.t is the first address in the address block


Note

The first address in the block can be


found by setting the rightmost
32 − n bits to 0s.
A block of 16 addresses granted to a small organization

We can see that the restrictions are applied to this block. The
addresses are continuous. The number of addresses is a power of 2
(16 = 24). This block of IP addresses is represented by:
205.16.37.32/28
Example

A /28 block of addresses is granted to a small


organization. We know that one of the addresses is
205.16.37.39. What is the first address in the block? What
is its x.y.z.t/n representation?

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 00100000
or
205.16.37.32
The block representation is 205.16.37.32/28
Note

The last address in the block can be


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

Find the last address for the block in the 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
Note

The number of addresses in the block


can be found by using the formula
232−n.
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 the previous example, /28
can be represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).

Find
a. The first address
b. The last address
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.
Example (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.
Example (continued)

c. The number of addresses can be found by


complementing the mask, interpreting it as a decimal
number, and adding 1 to it.
A network configuration for the block 205.16.37.32/28
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.
hierarchy in telephone numbers
hierarchy in IP addressing
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.
Subnetting
 Subnetting is the process of borrowing bits from the HOST bits, in order
to divide the larger network into small subnets.
 Subnetting does NOT give you more hosts, but actually costs you
hosts.
 You lose two host IP Addresses for each subnet, and perhaps one for
the subnet IP address and one for the subnet broadcast IP address.
 You lose the last subnet and all of it’s hosts’ IP addresses as the
broadcast for that subnet is the same as the broadcast for the network.
 In older networks, you would have lost the first subnet, as the subnet IP
address is the same as the network IP address.
 We don’t lose the first and last subnets anymore.
Configuration and addresses in a subnetted network
Three-level hierarchy in an IPv4 address
Why subnet?

• Divide larger network into smaller network.


• Limit layer 2 and layer 3 broadcasts to their
subnet.
• Better management of traffic.
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.
Assume the blocks of IPs are sequentially assigned. Design the
subblocks and find out how many addresses are still available after
these allocations.
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
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
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
Figure 19.9 An example of address allocation and distribution by an ISP
Another Example on Subnetting

An ISP needs to allocate three subnets: Subnet 1, Subnet


2, and Subnet 3 with its acquired IP block of
223.1.17.0/24. Subnet 1 is required to support 63
interfaces, Subnet 2 is to support at least 40 interfaces,
and Subnet 3 is to support at least 95 interfaces. In
addition, values of IP addresses have the relationship:
Subnet 1 < Subnet 2 < Subnet 3.
Provide three network addresses ( of the form a.b.c.d/x)
that satisfy these constraints.
Subnetting

223.1.17.0/24, ip addresses are 2^(32-24) = 256

Subnet 1 needs 2^6=64, 223.1.17.0/26


last address: 223.1.17.63
Subnet 2 needs 2^6=64, 223.1.17.64/26
last address: 223.1.17.127

Subnet 3 needs 2^7 = 128, 223.1.17.128/25


Subnetting practice (Lab 5)

For more details and practice of subnetting, please follow


LAB 5.
Public and Private IP addresses

• Public IP address: A Public IP address (External) is


assigned to every device that connects to the Internet
and each IP address is unique.
• Private IP address: Private IP address (Internal) is
only used by devices communicating to each other on
the same network. Devices with private IP addresses
cannot connect to the Internet directly.
Static, Dynamic, and shared IP addresses

• Static/ Dedicated - means the IP address never


changes and is tied to a single user, device, server or
website.
• Dynamic - means the IP address can change from
time-to-time (for example, when you lose connection
and re-connect or the ISP might change the address
periodically).
• Shared - in some cases, an ISP can assign a public IP
address to a group of users, and then employ NAT to
isolate their traffic.
Addresses for private networks

Home used wireless router usually uses 192.168.1.0/24


or 192.168.0.0/24 IP block
NAT

• The number of Internet connected devices are


increasing rapidly and we have limited public IP
addresses in IPv4.
• IPv6 can resolve this issue because the size of an IPv6
address is 128 bits, compared to 32 bits in IPv4.
• However, not all devices can support/or currently
using IPv6.
• To overcome this issue, one of the potential solutions
is Network Address Translation (NAT).
NAT

• Network Address Translation (NAT) is designed for IP address


conservation.
• It enables private IP networks that use unregistered IP
addresses to connect to the Internet.
• NAT operates on a router, usually connecting two networks
together, and translates the private (not globally unique)
addresses in the internal network into legal addresses, before
packets are forwarded to another network.
• As part of this capability, NAT can be configured to advertise
only one address for the entire network to the outside world.
A NAT implementation
Addresses in a NAT
NAT: Network Address Translation

NAT translation table


1: host 10.0.0.1
2: NAT router
WAN side addr LAN side addr
sends datagram to
changes datagram 138.76.29.7, 5001 10.0.0.1, 3345
128.119.40.186, 80
source addr from …… ……
S: 10.0.0.1, 3345
10.0.0.1, 3345 to
D: 128.119.40.186, 80
10.0.0.1
138.76.29.7, 5001,
1
S: 138.76.29.7, 5001
updates table
2 D: 128.119.40.186, 80
10.0.0.4
10.0.0.2

138.76.29.7 S: 128.119.40.186, 80

D: 10.0.0.1, 3345 4
S: 128.119.40.186, 80

D: 138.76.29.7, 5001 3 10.0.0.3


4: NAT router
3: Reply arrives
changes datagram
dest. address:
dest addr from
138.76.29.7, 5001
138.76.29.7, 5001 to 10.0.0.1, 3345
NAT: Network Address Translation

 16-bit port-number field:


 60,000 simultaneous connections with a single
LAN-side address!
 NAT is controversial:
 violates end-to-end argument

Internal computers not visible to outside

Outside hosts have trouble to request service from
local computers, e.g., P2P, video conference, web
hosting.
 address shortage should instead be solved by
IPv6
• Using Both IP Addresses and Port Numbers to allow a many-to-many

relationship between private-network hosts and external server

programs, we need more information in the translation table.


• For example, suppose two hosts with addresses 172.18.3.1 and

172.18.3.2 inside a private network need to access the HTTP server on

external host 25.8.3.2. If the translation table has five columns, instead

of two, that include the sourcetranslation


Five-column and destination
table port numbers of the
transport layer protocol, the ambiguity is eliminated.
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 IPv6.

Note

An IPv6 address is 128 bits long.


IPv4

• The Internet Protocol version 4 (IPv4) is the delivery


mechanism used by the TCP/IP protocols.
• IPv4 is an unreliable and connectionless datagram
protocol - a best-effort delivery service.
• The term best-effort means that IPv4 provides no error
control or flow control (except for error detection on
the header).
Position of IPv4 in TCP/IP protocol suite
ADDRESS MAPPING

The delivery of a packet to a host or a router requires two levels of

addressing: logical and physical. We need to be able to map a

logical address to its corresponding

physical address and vice versa. This can be done by using either

static or dynamic mapping.


Mapping Logical to Physical Address

ARP (address resolution protocol)


Note

ARP can be useful if the ARP reply is cached (kept in cache memory

for a while).
Four cases using ARP
Note

An ARP request is broadcast;

an ARP reply is unicast.


Reverse Address Resolution
Protocol (RARP)
 A machine can use the phy address to get
the logical address using RARP.
 A RARP messages is created and brodcast
on the local network.
 The machine on the local network that
knows the logical address will respond
with a RARP reply.
 Broadcasting is done at data link layer.
 Broadcast requests does not pass the
boundaries of a network.
Note

DHCP provides static and dynamic address allocation that can be

manual or automatic.
DHCP: Dynamic Host Configuration
Protocol
Goal: allow host to dynamically obtain its IP address from
network server when it joins network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connected an “on”
Support for mobile users who want to join network (more shortly)
DHCP overview:
 host broadcasts “DHCP discover” msg
 DHCP server responds with “DHCP offer” msg
 host requests IP address: “DHCP request” msg
 DHCP server sends address: “DHCP ack” msg
DHCP IP allocation
 Manual IP allocation – the network administrator
assigns users with IP addresses from the DHCP
server and then the DHCP server communicates
this information to the clients.
 Automatic IP allocation – the DHCP server
assigns static IP addresses to clients from a
pool. These addresses do not change unless the
administrator configures it differently.
 Dynamic IP allocation – the administrator
configures a pool of addresses which can be
assigned to clients. The clients then request for
IP addresses which are assigned for a particular
time period, and released on time expiry.

You might also like