IP Addressing and Subnets
Textbook: Ch.18
SEHH2238 Computer Networking
SEHH2238 Lecture 7 1
Copyright By PowCoder代写 加微信 powcoder
SEHH2238 Computer Networking
1. IPv4 Address
Main Topics
Classful and Classless Addressing 2. Network/Address Mask
3. Subnets
4. Design Examples
SEHH2238 Lecture 7 2
SEHH2238 Computer Networking
Internet Protocol (IPv4) Address
Internet Protocol version 4 (IPv4)
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. (It is a logical address.)
IPv4 address is commonly called IP address
The IP address is the address of the connection, not the
host or the router
All hosts on a given network have a common prefix in their IP address
SEHH2238 Lecture 7 3
SEHH2238 Computer Networking
IP Address
An IPv4 address is 32 bits long.
The address space of IPv4 is 232 or 4,294,967,296.
SEHH2238 Lecture 7 4
SEHH2238 Computer Networking
IP Addresses in Dotted-Decimal Notation
Dotted Decimal Notation is for human memory and communication
Dotted-Decimal Notation
10000001 00001011 00001011 11101111 11111001 10011011 11111011 00001111
129.11.11.239 249.155.251.15
SEHH2238 Lecture 7
SEHH2238 Computer Networking
Change the following IP addresses from dotted-decimal notation to binary notation.
a. 111.56.45.78
b. 75.45.34.79
We replace each decimal number with its binary equivalent:
a. 01101111 00111000 00101101 01001110
b. 01001011 00101101 00100010 01001111
SEHH2238 Lecture 7 6
SEHH2238 Computer Networking
Find the error, if any, in the following IPv4 addresses.
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.
SEHH2238 Lecture 7 7
SEHH2238 Computer Networking
Figure 18.17: Hierarchy in addressing
SEHH2238 Lecture 7 8
SEHH2238 Computer Networking
Classful Addressing
In classful addressing, the address space is divided into five classes:
A, B, C, D, and E.
SEHH2238 Lecture 7 9
SEHH2238 Computer Networking
Class Ranges of Internet Addresses
(IP for hosts in Class A: 1.0.0.1 to 126.255.255.254)
(127.X.X.X is for loopback testing and should never be used for normal IP address)
SEHH2238 Lecture 7 10
SEHH2238 Computer Networking
Number of blocks and block size in classful IPv4 addressing
SEHH2238 Lecture 7 11
SEHH2238 Computer Networking
Find the class of each address:
a. Binary: 00000001 00001011 00001011 11101111
b. DDN: 252.5.15.111
c. DDN: 134.11.78.56
a. The first bit is 0; this is a class A address.
b. The first byte is 252 (between 240 and 255); the class is E.
c. The first byte is 134 (between 128 and 191); the class is B.
Another method (besides memorizing) is to convert the first number to binary digits and then check the first few bits
SEHH2238 Lecture 7 12
SEHH2238 Computer Networking
Network Address and Broadcast Address
• The network address (which represents the whole network) is assigned by the Internet Corporation for Assigned Names and Addresses (ICANN)
Note: a network address is different from a netid A network address has both netid and hostid,
with all “0”s for the hostid.
Broadcast Address
In the destination address, if the hostid of the IP address contains all “1”s, it means that all hosts within this network are the target destinations.
SEHH2238 Lecture 7 13
SEHH2238 Computer Networking
Network/Address Mask
A 32-bit number made of contiguous 1s followed by contiguous 0s
It is used to find the netid and hostid Default masks for classful addressing
SEHH2238 Lecture 7 14
SEHH2238 Computer Networking
Given the address, find the default class, the network mask, the network address and the broadcast address of :
a) 23.56.7.91 b) 132.6.17.85
a) The class is A.
The network mask :255.0.0.0 (Only the first byte defines the netid.)
By replacing the hostid bytes (56.7.91) with 0s, the network address is 23.0.0.0. The broadcast address is 23.255.255.255
b) The class is B.
The network mask :255.255.0.0 (The first 2 bytes defines the
By replacing the hostid bytes (17.85) with 0s, the network
address is 132.6.0.0. The broadcast address is 132.6.255.255 SEHH2238 Lecture 7 15
SEHH2238 Computer Networking
The IP address in red color is the network address
Network and Host Addresses
SEHH2238 Lecture 7 16
SEHH2238 Computer Networking
Problems of Classful Addressing
Small no. of Class A and B addresses, but too large in size in each class.
In classful addressing, a large part of the available addresses were wasted.
Class C block is too small for most mid-size organization.
Classful addressing is replaced with classless addressing.
SEHH2238 Lecture 7 17
SEHH2238 Computer Networking
Classless Addressing
With the growth of the Internet, it was clear that a larger address space was needed
It requires that the length of IP addresses be increased, which means the format of the IP packets needs to be changed
Although the long-range solution has already been devised and is called IPv6 (128-bit address)
A short-term solution, classless addressing, was also devised to use the same IPv4 address space but to change the distribution of addresses to provide a fair share to each organization
SEHH2238 Lecture 7 18
SEHH2238 Computer Networking
Classless Addressing
The addresses are still granted in blocks.
There are no classes. The network mask is more
An address block is a group of IP address, in which:
1. Addresses in a block must be contiguous, one after another.
2. Number of addresses in a block must be a power of 2 (1, 2, 4, 8..).
3. … (skip the details)
SEHH2238 Lecture 7 19
SEHH2238 Computer Networking
(Classless) Network Mask
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.
A mask is used to define an address block
n can be 1 to 30 – it is the length of the net-id
The notation (/n) is called Classless Interdomain Routing (CIDR) notation
SEHH2238 Lecture 7 20
SEHH2238 Computer Networking
Figure 18.20: Slash notation (CIDR)
SEHH2238 Lecture 7 21
SEHH2238 Computer Networking
Figure 18.21:
Information extraction in classless addressing
– Network address
– Broadcast address
SEHH2238 Lecture 7 22
SEHH2238 Computer Networking
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 (network address) in the block? Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
We get the mask of 28 “1”s at the leftmost,
11111111 11111111 11111111 11110000
We get the network address (1st 28 bits + “0000”)
11001101 00010000 00100101 00100000 or
205.16.37.32
(What is the last address? What is the usage?)
SEHH2238 Lecture 7 23
SEHH2238 Computer Networking
Example 18.1
A classless address is given as 167.199.170.82/27.
The number of addresses in the network is 232− n = 25 = 32 addresses. The first address can be found by keeping the first 27 bits and changing the rest of the bits to 0s.
The last address can be found by keeping the first 27 bits and changing the rest of the bits to 1s.
SEHH2238 Lecture 7
SEHH2238 Computer Networking
(Classless) Network Mask
For /n, the address mask is a 32-bit number in which
the n leftmost bits are 1s and the rest are 0s Use bit-wise logical operation to extract
information from the IP address in a block
First Address = IP address AND mask
Last Address = IP address OR (NOT mask)
SEHH2238 Lecture 7 25
Example 18.2
We repeat Example 18.1 using the mask. The mask in dotted-decimal notation is 255.255.255.224 The AND, OR, and NOT operations can be applied to individual bytes using calculators and applets at the book website.
(The mask should be 255.255.255.224 !)
The AND, OR, NOT operation should be done in binary numbers “bit-by-bit”
SEHH2238 Lecture 7 26
SEHH2238 Computer Networking
IP address 167.199.170.82/27
Example 18.2 (Cont.)
The binary representation of the given address is
10100111 11000111 10101010 01010010
We get the mask of 27 “1”s at the leftmost,
11111111 11111111 11111111 11100000
(NOT mask) is
00000000 00000000 00000000 00011111
OR 10100111 11000111 10101010 01010010 (IP)
—————————————-
10100111 11000111 10101010 01011111 After (address)OR(NOT mask)operation
We get the broadcast address 167.199.170.95/27
SEHH2238 Lecture 7 27
Figure 18.22: Network address
The network address is the identifier of the network and it is used by the forwarding (or routing) table in the Internet
SEHH2238 Lecture 7 28
SEHH2238: Computer Networking
How does a host get IP address Hard-coded by system admin in a file
The network administrator can manually assign addresses to the individual hosts or routers
DHCP: Dynamic Host Configuration Protocol
An application-layer program which allows a host to dynamically (and automatically) get address from a server
Useful when the no. of hosts is more than the no. of available IP addresses but the no. of “active” hosts is not high
SEHH2238 Lecture 7
CC3209Lect09 29
SEHH2238: Computer Networking
IP Subnetworks (Subnets)
For transferal of data on the Internet, one network sees another as a single network and has no detailed knowledge of its internal structure
The reason for this is that it helps keep routing tables small
However large networks are often divided into smaller networks called subnetworks (subnets)
SEHH2238 Lecture 7 30
SEHH2238: Computer Networking
Subnets also improve the efficiency of addressing
The primary reason for using a subnet is to reduce the size of a broadcast domain (and hence reduce collisions)
Adding subnets does not change how the outside world sees the network. Thus, a device on an outside network only sees the network ID and host ID of a device on another network.
However, internally, networks can view themselves as being a series of smaller subnets.
SEHH2238 Lecture 7 31
SEHH2238: Computer Networking
SEHH2238 Lecture 7 32
SEHH2238: Computer Networking
Addresses in a network with and without subnetting
SEHH2238 Lecture 7 33
SEHH2238: Computer Networking
Subnet Address
Subnet addresses include a network ID, a subnet ID within the network, and a host ID within the subnet.
To create a subnet address, a network administrator “borrows” bits from the host field and designates them as the subnet field.
Network devices use subnet masks to identify which part of the address is considered as subnet ID and which part represents host addressing.
SEHH2238 Lecture 7 34
SEHH2238: Computer Networking
Length of Subnet ID (1)
For a network without subnets, when the host field of an IP address is all 0s, it is a network address.
When the host field is all 1s, it is a broadcast address.
Therefore, when we consider a network with subnets, the combined field
{
should NOT be all 0s or all 1s
SEHH2238 Lecture 7 35
SEHH2238: Computer Networking
Length of Subnet ID (2)
The minimum number of bits that can be borrowed for subnet is 2
The maximum number of bits that can be borrowed for subnet can be any number that leaves at least 2 bits for hosts
(If only 1 bit for host, a 0-host number or
a 1-host number will occur, which may cause a all-0 network address or a all-1 broadcast address.)
SEHH2238 Lecture 7 36
SEHH2238: Computer Networking
Example Subnets
With each subnet, you cannot use the first and last address (i.e. the network and the broadcast address).
A class B network has 16 bits in the host field. Therefore up to 14 bits can be borrowed to create subnets.
A class C network has only 8 bits in the host field. Therefore, only up to 6 bits can be borrowed to create subnets.
SEHH2238 Lecture 7 37
SEHH2238: Computer Networking
Subnet Mask
Once a packet has arrived at an organization’s gateway with its unique network ID, it can be routed within the organization’s internal routers using the subnet ID, which is found by a subnet mask.
The subnet mask identifies which part of an IP address is the network address (net-ID), which part is the subnet ID, and which part is the host ID.
A subnet mask is 32 bits long.
It contains all 1s in the network portion and the subnet portion, and contains all 0s in the host portion.
SEHH2238 Lecture 7 38
SEHH2238: Computer Networking
Subnet Mask Examples
By default, if no bits are borrowed (i.e. no subnet), the subnet mask for a class “B” network would be 255.255.0.0
However, if 8 bits are borrowed to form subnets, the subnet mask for the same class “B” network would be 255.255.255.0
All networks have default subnet masks (for no subnet).
E.g. For the network, 172.16.0.0, the default subnet mask is 255.255.0.0
SEHH2238 Lecture 7 39
SEHH2238: Computer Networking
SEHH2238 Lecture 7 40
SEHH2238: Computer Networking
Use of Subnet Mask
In order to find the address of a subnet, a router must take the incoming IP address and the subnet mask, and then apply the logical “AND” operation between their binary forms.
The resulting number is the network or subnet address.
SEHH2238 Lecture 7 41
SEHH2238: Computer Networking
Default mask and subnet mask
SEHH2238 Lecture 7
(for a class B network)
Subnet address
SEHH2238: Computer Networking
SEHH2238 Lecture 7 43
SEHH2238: Computer Networking
SEHH2238 Lecture 7 44
SEHH2238: Computer Networking
Consider a Class B network, 16 bits are used for network ID, and the remaining 16 bits are used for subnet and host ID:
#bits borrow
subnet mask
255.255.0.0
n/a (min. 2 bits)
255.255.192.0
255.255.240.0
255.255.252.0
255.255.255.0
255.255.255.252
n/a (at least 2 bits left for host id) n/a (not applicable)
In each subnet, the total number of hosts is 2 less than the maximum number of possible host IDs.
SEHH2238 Lecture 7 45
SEHH2238: Computer Networking
Finding the Subnet Address
Straight Method
Use binary notation for both the address and the mask and then apply the AND operation to find the subnet address
SEHH2238 Lecture 7 46
SEHH2238: Computer Networking
What is the subnet address if the destination address is 200.45.34.56 and the subnet mask is 255.255.240.0?
SEHH2238 Lecture 7 47
SEHH2238: Computer Networking
Short-Cut Method
** If the byte in the mask is 255, copy the byte in the address.
** If the byte in the mask is 0, replace the byte in the address with 0.
** If the byte in the mask is neither 255 nor 0, we write the mask and the address in binary and apply the AND operation.
SEHH2238 Lecture 7 48
SEHH2238: Computer Networking
What is the subnet address if the destination address is 19.30.80.5 and the mask is 255.255.192.0?
SEHH2238 Lecture 7 49
SEHH2238: Computer Networking
A company is granted the site (network) address 201.70.64.0 (class C). The company needs six subnets. Design the subnets.
The number of 1s in the default mask is 24 (class C).
The company needs six subnets. This number 6 is not a power of 2. The next number that is a power of 2 is 8 (23). We need 3 more 1s in the subnet mask. The total number of 1s in the subnet mask is 27 (24 + 3).
The total number of 0s is 5 (32 − 27). The mask is
SEHH2238 Lecture 7 50
SEHH2238: Computer Networking
E.g. 3 Solution (Continued)
11111111 11111111 11111111 11100000 or 255.255.255.224
The number of subnets is 8.
The number of addresses in each subnet is 25 (5 is the number of 0s) or 32 (but only 30 are host addresses).
See next slide
SEHH2238 Lecture 7 51
SEHH2238: Computer Networking
Usually the first and the last subnets are not used
SEHH2238 Lecture 7 52
SEHH2238: Computer Networking
IPv4 Address – 32 bits
Classful: 5 classes A to E (phase out)
Classless: \n (currently use)
IPv6: 128 bits (long term solution)
Network/Address Mask
Use logical “AND” to find the network address
Subnets – smaller networks within the same organization (network)
Revision Quiz
http://highered.mheducation.com/sites/0073376221/stu
dent_view0/chapter18/quizzes.html
SEHH2238 Lecture 7 53
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com