0% found this document useful (0 votes)
6 views

Chapter 2 - IP Addressing and Subnet Mask - 2022

Uploaded by

fluffynoob1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter 2 - IP Addressing and Subnet Mask - 2022

Uploaded by

fluffynoob1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Chapter 2

IP Addressing and Subnet Mask

Official (Open), Non-sensitive 1


Objectives
• Explain the need of IP address.
• Perform the conversion between binary and
decimal formats of IP addresses.
• Describe the use of subnet masks.
• Derive subnet mask.
• Describe Class A, B, C, D, E IP addresses.
• Explain the limitation of Classful IP addresses.
• Explain Classless IP addresses and corresponding
subnet mask.

Official (Open), Non-sensitive 2


Outline
• Format of IP addresses
• Network Portion and Host Portion of IP addresses
• Subnet mask
• Classes of IP addresses
• Classes A, B, C, D and E
• Number of host IP addresses
• Limitations of Classful IP addresses
• CIDR, the Classes IP addresses

Official (Open), Non-sensitive 3


Why do we need IP Addresses?
Message
Laptop B
Laptop A Network

Laptop C
Laptop D

• In one-to-one communications, the “message”


coming from the source is expected to be
delivered only to the destination.
• E.g. Laptop A wishes to send a message to Laptop
C (not Laptops B and D). Mr Peter Lim
500 Dover Road
• This is analogue to sending a letter. We need to Singapore 139651
specify the postal address of the recipient.
• Therefore, every end device in a computer
network must have an unique “address”.
• Since the network uses “Internet Protocol” (IP)
for communications, the address is “IP address”.

Official (Open), Non-sensitive 4


Format of IP Address
Network
Medium
192.168.1.5 59.73.188.33
Send a message from 192.168.1.5 to 59.73.188.33.

• IP addresses are generally expressed in the


dotted decimal format, x.x.x.x, where x is
any integer from 0 to 255.
• Example 1: 153.234.166.200
• Example 2: 5.6.78.99

Official (Open), Non-sensitive 5


Exercise:
• Determine whether the following are valid IP
addresses:
• (a) 123.234.0.1
• (b) 5.0.1.2
• (c) 58.246.111.259
• Answer:
• (a) Valid
• (b) Valid
• (c) Invalid (‘259’ of “58.246.111.259” exceeds 255.)

Official (Open), Non-sensitive 6


Why do we use “Dotted Decimal”
format?
• IP addresses are actually 32-bit binary numbers.
• Example:
• 11010001000110000100110000110101
• Unfortunately, long strings of ‘0’s and ‘1’s are
difficult to read.
• Solution:
• Use decimal instead of binary numbers.
• That involves some binary to decimal
conversion.
Official (Open), Non-sensitive 7
Conversion between Binary and
Decimal Formats
• Conversion between binary and decimal Formats is
covered in ET1003 Digital Electronics I.
• It will not be discussed in this module.
• If you have learnt it in ET1003, you may do the
conversion manually.
• Else, you may
• make use of your scientific calculator, or
• make use of the Excel file Binary_Decimal_Converter.xlsx
provided on ET0730’s Black Board site (under Chapter 02’s
folder).

Official (Open), Non-sensitive 8


How to obtain IP address in “Dotted
Decimal” format?
• Example: Given the 32-bit IP address below:
• 11010001000110000100110000110101
• How to obtain the “Dotted Decimal” IP address?
• Step 1: Divide the 32 bits into 4 groups of 8 bits.
• 11010001 00011000 01001100 00110101
• Step 2: Each group of 8-bit binary number is converted
into decimal value.
• 11010001 00011000 01001100 00110101
• 209 24 76 53
• Step 3: Insert dot (period) between the decimal values.
• Result: IP address = 209.24.76.53 (easier to read
compared to binary format. Agree?).
Official (Open), Non-sensitive 9
Why is there a limit of “0 to 255”?
• Each group of 8-bit binary number can be any
combination of ‘0’s and ‘1’s.
• Example:
• 00000000 (lowest)
• 00000001
• 00000010
• …….. (other combinations of ‘0’s and ‘1’s)
• 11111101
• 11111110
• 11111111 (highest)
• The lowest is 00000000, which equals 0 in decimal.
• The highest is 11111111, which equals 255 in decimal.
• Therefore, the decimal value of the integers
representing an IP address must be between 0 to 255
(both inclusive).
Official (Open), Non-sensitive 10
Exercise: Binary → Decimal
• Convert the following IP address from binary
format to decimal format.
00110011 11110000 00001111 00001001
• Answer:
• 00110011 = 51
• 11110000 =240
• 00001111 = 15
• 00001001 = 9
• Therefore, IP address in decimal format is 51.240.15.9.

Official (Open), Non-sensitive 11


Exercise: Decimal → Binary
• Convert the following IP address from decimal
format to binary format.
34.56.168.251
• Answer:
• 34 = 00100010
• 56 = 00111000
• 168 = 10101000
**DO NOT OMIT THE ZEROES,
• 251 = 11111011 MUST BE 32 BIT BINARY NUMBER
• Therefore, IP address in binary format is
00100010001110001010100011111011.

Official (Open), Non-sensitive 12


Network Portion & Host Portion
• An 32-bit IP address consists of two portions:
• Network portion 32 bits
• Host portion
Network portion Host portion

• The “Network portion” represent a groups of IP


addresses.
• The “Host portion” is used to uniquely define each IP
address within that group of IP addresses.

• The number of bits in the Network portion and Host


portion depends on the number of unique IP addresses
needed in a group of IP addresses.
• This will be covered in a later chapter.
Official (Open), Non-sensitive 13
How to indicate the “Network
portion” and “Host portion” of an IP
address? (Well, not by colour...)
• To indicate how the 32 bits of an IP addresses are
divided between the “Network” and “Host” portions,
we use the “Subnet Masks”.
• Just like the IP addresses, subnet masks are 32-bit
binary numbers too.
• Subnet Masks are also generally given in dotted
decimal format.
• Four examples of Subnet Masks:
• 255.255.255.0
• 255.255.0.0
• 255.0.0.0

Official (Open), Non-sensitive 14


How to derive the Subnet Masks? (1)
• A subnet mask consists of a string of ‘1’s, followed
by a string of ‘0’s.
• In a subnet mask,
• Binary number ‘1’s represent the Network portion.
• Binary number ‘0’s represent the Host portion.
• Example:
• Network portion=24 bits + Host portion=8 bits
32 bits Thus , either 255 or 0 in decimal

Network portion Host portion

11111111111111111111 111100000000
24 bits 8 bits
Official (Open), Non-sensitive 15
How to derive the Subnet Masks? (2)
• To present a subnet mask in dotted decimal format,
follow the steps of converting IP addresses from
binary format to decimal format.
• Example:
• Subnet mask = 11111111111111111111111100000000
• Divide into groups of 8 bits:
• 11111111 11111111 11111111 00000000
• Convert each group of 8-bits into decimal number:
• 255 255 255 0
• Insert dots in between the decimal numbers:
• Result:
• Subnet mask in dotted decimal format = 255.255. 255.0

Official (Open), Non-sensitive 16


Exercise: Construct a Subnet Mask
• Construct a subnet mask for indicating the following:
• Network portion = 16 bits
• Host portion = 16 bits

• Answer:
• Subnet mask = 11111111 11111111 00000000 00000000
• Decimal format = 255 255 0 0
• Subnet mask = 255.255.0.0

Official (Open), Non-sensitive 17


IP Classes
• The Internet Assigned Numbers Authority (IANA)
devised the hierarchical IP addressing structure.
• The American Registry of Internet Numbers (ARIN)
assigns IP addresses to public, private, and government
organisations.

• Five different groups of IP addresses (classes A, B, C, D


and E) exist on the Internet.
• Classes A, B, and C are assigned to governments,
companies, schools, and public entities for use on the
Internet.
• Classes D and E are reserved for multicasting and
experimentation.

Official (Open), Non-sensitive 18


Formats of IP Classes (1)
• Class A IP addresses start with ‘0’.
• Class B IP addresses start with ‘10’.
• Class C IP addresses start with ‘110’.
• Class D IP addresses start with ‘1110’.
• Class E IP addresses start with ‘11110’.

Official (Open), Non-sensitive 19


Formats of IP Classes (2)
Keep adding 1 infront for each
Class additional class Range of Net ID Subnet Mask
A 0 7 bits Host: 24 bits 1 - 126 255.0.0.0

B 1 0 14 bits Host: 16 bits 128.0 – 191.255 255.255.0.0

C 1 1 0 21 bits Host: 8 bits 192.0 – 223.255.255 255.255.255.0

D 1 1 1 0 28bits
224 - 239 -
1 1 1 1 0 27 bits
E 240 - 247 -

• Network portion of Class A = 00000001 to 01111110 (i.e. 1 to 126).


• Network portion of Class B = 10000000 00000000 to 10111111 11111111
(i.e. 128.0 to 191.255)
• Network portion of Class C can be derived using same approach as Classes A
and B.
• Classes D and E have no Host portion.
Official (Open), Non-sensitive 20
Class A
• ARIN reserves Class A IP addresses for governments
throughout the world.
• It seems 127.x.x.x (decimal) is the highest
assignable Class A address, but that particular
address range is reserved for the loopback address.
• Hence, Class A will have 1 to 126 for first octet
(octet = byte = 8 bits).

Official (Open), Non-sensitive 21


Class B
• Class B IP addresses are assigned to large- and
medium-sized companies.
• Class B addresses will lead with pattern “10” when
written in binary format.
• This means that the range in decimal notation for
the first octet of Class B addresses is 128 through
191.

Official (Open), Non-sensitive 22


Class C
• Class C IP addresses are assigned to groups that do
not meet the qualifications to obtain Class A or B
addresses.
• The first three binary digits of a Class C address
must be “110”.
• Hence the first octet of Class C addresses can range
from 192 through 223 in decimal notation.

Official (Open), Non-sensitive 23


Class D
• Class D addresses (also known as “Multicast
Addresses”) are reserved for multicasting.
• Class D addresses must have “1110” as their first
four binary digits.
• Hence the range for Class D starts with decimal 224
and ends at 239 in the first octet.

Official (Open), Non-sensitive 24


Class E
• The IANA reserves Class E addresses for research,
testing, and experimentation.
• Class E is everything above and including 240
(decimal) as the first octet.

Official (Open), Non-sensitive 25


Exercise:
• What class does IP address 166.74.105.106 belong
to?
• Answer:
• The first octet of the IP address, 166 = 10100110 in
binary format.
• Since the IP address starts with “10”, it is a Class B IP
address.

Official (Open), Non-sensitive 26


Standard (default) Subnet Masks
for IP Classes A, B and C
• Standard (default) subnet masks are as
follows:
• Class A subnet mask is 255.0.0.0.
• 8 bits for Network portion, 24 bits for Host portion.
• Class B subnet mask is 255.255.0.0.
• 16 bits for Network portion, 16 bits for Host portion.
• Class C subnet mask is 255.255.255.0.
• 24 bits for Network portion, 8 bits for Host portion.

Official (Open), Non-sensitive 27


Number of Host Addresses for
Classes A, B and C
• If the number of bits in the Host portion is n, the
number of different Host Addresses = 2n – 2.
• Although n bits can give up to 2n different patterns,
there are two patterns cannot be used (therefore there
is a “substrate 2” in the formula) as host IP addresses:
• All bits of the Host portion are ‘0’s.
• All bits of the Host portion are ‘1’s.
• Host IP addresses of all ‘0’s and all ‘1’s (i.e. 000…00
and 111…11) are reserved as “Network Address”
and “Broadcast Address” respectively.
• “Network Address” and “Broadcast Address” will
be introduced in a later chapter,

Official (Open), Non-sensitive 28


Exercise:
• How many different host IP addresses can a
Class B IP address have?
• Answer:
• Class B’s subnet mask = 255.255.0.0, showing
that there are 16 bits in the Host portion (i.e.
n=16).
• Number of different host IP address
= 216 – 2
= 65534

Official (Open), Non-sensitive 29


Exercise:
• How many different Class A IP addresses can we have?
• How many different host IP addresses can a Class A IP
address have?
• Answer:
• Class A is from 1 to 126, so we have 126 Class A IP addresses.
• There are about 196 countries in the world (+/- a few, depending on political
reasons). Hence, we don’t really have enough Class A IP address for each
country in this world.
• Class A’s subnet mask = 255.0.0.0, showing that there are 24 bits in
the Host portion (i.e. n=24).
• Number of different host IP address
= 224 – 2
= 16,777,214 (16.7 millions)
• Some countries’ (e.g. Singapore) population is even less than the number of
host IP addresses assigned to the government of that country.

Official (Open), Non-sensitive 30


Limitations of Classful IP
Addresses
• Classes A, B and C are also called Classful IP
Addresses.
• The previous exercise demonstrates that Class A IP
addresses are very wasteful.
• Some countries do not need 16.7 million host IP
addresses.
• Root cause:
• The standard subnet masks of Classful IP Addresses
define Network portion as “multiple of 8-bits”.
• Question:
• How about we allow more flexible number of bits in the
Network portion? (See next slide for the answer.)
Official (Open), Non-sensitive 31
Classless Inter-Domain Routing
(CIDR)
• CIDR replaced the old process of assigning IP
addresses based on Class A, B and C addresses, by
breaking away from the restriction of using
Network portion of multiple of 8-bits.
• Advantage of Classless IP Addressing:
• Replacement of classful addressing with a more flexible
and less wasteful class scheme.
• If the Network portion of a Classless IP address is
27 bits long (not a multiple of 8), the CIDR notation
for this address is x.x.x.x/27.
• “/27” is the Network Prefix.

Official (Open), Non-sensitive 32


How to derive the Subnet Masks for a
Classless IP Address? (1)
• There is no change in the way we derive the subnet
masks.
• Binary number ‘1’s represent the Network portion.
• Binary number ‘0’s represent the Host portion.
• m and n do not need to be multiple of 8.
m + n = 32 bits

Network portion Host portion

11111111….1111111111 0000…….00000
m bits n bits

Official (Open), Non-sensitive 33


How to derive the Subnet Masks for a
Classless IP Address? (2)
• Example:
• If the Network Prefix is /20, derive the corresponding subnet
mask.
• Solution:
• Network portion=20 bits + Host portion=12 bits
• Subnet mask = 11111111111111111111000000000000
• Divide into groups of 8 bits:
• 11111111 11111111 11110000 00000000
• Convert each group of 8-bits into decimal number:
• 255 255 240 0
• Result:
• Subnet mask in dotted decimal format = 255.255.240.0
• Notice that the subnet mask now may contain decimal
number other than 255 and 0.
Official (Open), Non-sensitive 34
Exercise: Construct a Subnet Mask
• Construct a subnet mask for an IP address having
Network Prefix of /13.
**Make sure network prefix is
written with /
• Answer:
• Network portion=13 bits + Host portion=19 bits
• Subnet mask = 11111111 11111000 00000000 00000000
• Decimal format = 255 248 0 0
• Subnet mask = 255.248.0.0

Official (Open), Non-sensitive 35

You might also like