Subnetting - Lecture Slides..
Subnetting - Lecture Slides..
Outline –Unit II
IP Subnetting
Subnets & Subnet Masks,
Network Prefix Notation
Default Subnets
IP Block Addresses
Private/Public IP Addresses
Network Address Translation
(NAT)
IPv6
Network Layer
IP Subnetting
Subnetting is a technique Subnetting provides a more
that lets network flexible way to designate
administrators use the 32 which portion of an IP
bits available in an IP address represents the
address more efficiently by network ID and which
creating networks that aren't portion represents the host
limited to the scales ID.
provided by Class A, B, and With standard IP address
C IP addresses. classes, only three possible
With subnetting, you can network ID sizes exist: 8 bits
create networks with more for Class A, 16 bits for Class
realistic host limits. B, and 24 bits for Class C.
Network Layer
IP Subnetting…
Subnetting lets you select an Although many networks
arbitrary number of bits to with more than 254 devices
use for the network ID. exist, few (if any) exist with
Two reasons compel people 64 thousand, let alone 16
to use subnetting. million.
• The first is to allocate the Unfortunately, any network
limited IP address space more
efficiently. with more than 254 devices
would need a Class B
If the Internet were limited
allocation and probably
to Class A, B, or C
addresses, every network waste tens of thousands of IP
would be allocated 254, 64 addresses.
thousand, or 16 million IP
addresses for host devices.
Network Layer
IP Subnetting…
• The second reason for The physical network
subnetting is that even if a comprises a single broadcast
single organization has
thousands of network devices, domain, which means that a
operating all those devices single network medium must
with the same network ID carry all the traffic for the
would slow the network to a network.
crawl.
For performance reasons,
The way TCP/IP works networks are usually
dictates that all the segmented into broadcast
computers with the same domains that are smaller than
network ID must be on the even Class C addresses
same physical network. provide
Network Layer
Subnets and Subnet Masks
A subnet is a network that For subnetting to work, the
falls within a Class A, B, or router must be told which
C network. portion of the host ID
Subnets are created by should be used for the
using one or more of the subnet network ID.
Class A, B, or C host bits to This is accomplished by
extend the network ID. using another 32-bit
Thus, instead of the number, known as a subnet
standard 8-, 16-, or 24-bit mask.
network ID, subnets can Those IP address bits that
have network IDs of any represent the network ID
length. are represented by a 1 in
the mask, and those bits
that represent the host ID
appear as a 0 in the mask.
Network Layer
Subnets and Subnet Masks…
As a result, a subnet mask In other words, the first 20
always has a consecutive bits are ones, and the
string of ones on the left, remaining 12 bits are zeros.
followed by a string of Thus, the complete network
zeros ID is 20 bits in length, and
For example, the network the actual host ID portion
ID consists of the 16-bit of the subnetted address is
network ID plus an 12 bits in length.
additional 4-bit subnet ID,
would look like this:
11111111 11111111 11110000 00000000
Network Layer
Subnets and Subnet Masks…
To determine the network To perform a logical AND,
ID of an IP address, the each bit in the IP address is
router must have both the compared with the
IP address and the subnet corresponding bit in the
mask. subnet mask.
The router then performs a If both bits are 1, the
bitwise operation called a resulting bit in the network
logical AND on the IP ID is set to 1.
address in order to extract If either of the bits is 0, the
the network ID. resulting bit is set to 0.
Network Layer
Subnets and Subnet Masks…
For example, here's how the network address is extracted
from an IP address using the 20-bit subnet mask from the
previous example:
144 . 28 . 16 . 17
IP address: 10010000 00011100 00010000 00010001
Subnet mask: 11111111 11111111 11110000 00000000
Network ID: 10010000 00011100 00010000 00000000
144 . 28 . 16 . 0
Network Layer
Subnets and Subnet Masks…
The subnet mask itself is usually represented in dotted-
decimal notation. As a result, the 20-bit subnet mask used
in the previous example would be represented as
255.255.240.0:
Network Layer
Network Prefix Notation
Because a subnet mask The network prefix is
always begins with a indicated with a slash
consecutive sequence of immediately after the IP
ones to indicate which address, followed by the
bits to use for the number of network ID
network ID, you can use bits to use.
a shorthand notation - a For example, the IP
network prefix - to address 144.28.16.17
indicate how many bits with the subnet mask
of an IP address 255.255.240.0 can be
represent the network represented as
ID. 144.28.16.17/20 because
the subnet mask
255.255.240.0 has 20
network ID bits.
Network Layer
Network Prefix Notation…
Network Prefix notation
is also called Classless
InterDomain Routing
notation (CIDR, for
short) because it
provides a way of
indicating which portion
of an address is the
network ID and which is
the host ID without
relying on standard
address classes.
Network Layer
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.
Network Layer
Default Subnets
The default subnet masks are three subnet masks
that correspond to the standard Class A, B, and C
address assignments. These default masks are
summarized in Table-2.
Network Layer
Default Subnets…
Keep in mind that a subnet mask is not actually
required to use one of these defaults because the
IP address class can be determined by examining
the first three bits of the IP address.
Network Layer
Restrictions on Subnets and Masks
You should know about a few additional
restrictions that are placed on subnets and subnet
masks. In particular:
• The minimum number of network ID bits is eight. As a
result, the first octet of a subnet mask is always 255.
• Because the network ID portion of a subnet mask is
always composed of consecutive bits set to 1, only
eight values are possible for each octet of a subnet
mask: 0, 128, 192, 224, 248, 252, 254, and 255.
Network Layer
Restrictions on Subnets and Masks…
• The maximum number of network ID bits is 30.
Why?
• You have to leave at least two bits for the host ID
portion of the address to allow for at least two hosts.
If you use all 32 bits for the network ID, that leaves
no bits for the host ID. Obviously, that won't work.
Leaving just one bit for the host ID won't work,
either, because a host ID of all ones is reserved for a
broadcast address, and all zeros refers to the
network itself.
• Thus, if you use 31 bits for the network ID and leave
only 1 for the host ID, host ID 1 would be used for
the broadcast address, and host ID 0 would be the
network itself, leaving no room for actual hosts.
That's why the maximum network ID size is 30 bits.
Network Layer
Restrictions on Subnets and Masks…
• A subnet address can't be all zeros or all ones.
Network Layer
IP Block Addresses
Network Layer
IP Block Addresses…
Network Layer
Note
Network Layer
Example 6
Network Layer
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.
Network Layer
IP Block Addresses…
Network Layer
Note
Network Layer
Example 7
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
Network Layer
Note
Network Layer
Example 8
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
Network Layer
Example 9
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 6 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.
Network Layer
Example 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.
Network Layer
Example 9 (continued)
Network Layer
Example 9 (continued)
Network Layer
Figure 4 A network configuration for the block 205.16.37.32/28
Network Layer
Note
Network Layer
Figure 6 A frame in a character-oriented protocol
Network Layer
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.
Network Layer
Figure 7 Configuration and addresses in a subnetted network
Network Layer
Figure 8 Three-level hierarchy in an IPv4 address
Network Layer
Example 10
Solution
Figure 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
Network Layer
Example 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
Network Layer
Example 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
Network Layer
Private and Public Addresses
Network Layer
Table 6 Addresses for private networks
Network Layer
Network Address Translation (NAT)
Network Layer
Network Address Translation (NAT)…
Network Layer
Network Address Translation (NAT)…
To understand how this works, consider the
following sequence of steps:
1. A host whose private address is 192.168.1.100 sends a
request to 216.239.57.99, which happens to be
www.google.com. The NAT device changes the source
IP address of the packet to 208.23.110.22, the IP
address of the firewall. That way, Google will send its
reply back to the firewall router. The NAT records that
192.168.1.100 sent a request to 216.239.57.99.
Cont…
3. A few seconds later, the firewall receives a reply from
216.239.57.99. The destination address in the reply is
208.23.110.22, the address of the firewall. To
determine to whom to forward the reply, the firewall
checks its records to see who is waiting for a reply from
216.239.57.99. It discovers that 192.168.1.100 is
waiting for that reply, so it changes the destination
address to 192.168.1.100 and sends the packet on.
Actually, the process is a little more complicated than that,
because it's very likely that two or more users may have
pending requests from the same public IP. In that case, the
NAT device uses other techniques to figure out to which
user each incoming packet should be delivered.
Network Layer
Figure 10 A NAT implementation
Network Layer
Figure 11 Addresses in a NAT
Network Layer
Figure 12 NAT address translation
Network Layer
Table 4 Five-column translation table
Network Layer
An ISP and NAT
Network Layer
IPv6 ADDRESSES
Network Layer
Note
Network Layer
IPv6 address in binary and hexadecimal
colon notation
Network Layer
Figure 19.15 Abbreviated IPv6 addresses
Network Layer
Example 11
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.
Network Layer
Table 5 Type prefixes for IPv6 addresses
Network Layer
Table 5 Type prefixes for IPv6 addresses (continued)
Network Layer
Prefixes for provider-based unicast address
Network Layer
Figure 17 Multicast address in IPv6
Network Layer
Figure 18 Reserved addresses in IPv6
Network Layer
Figure 19 Local addresses in IPv6
Network Layer
IPv6 Notes continues……