0% found this document useful (0 votes)
5 views44 pages

Introduction to IPv4 Basics

The document covers the basics of IPv4, including its definition, structure, and addressing methods. It explains the importance of subnetting, the difference between classful and classless addressing, and provides examples of converting between binary and dotted-decimal notation. Additionally, it discusses the waste of addresses in classful addressing and introduces CIDR as a solution.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views44 pages

Introduction to IPv4 Basics

The document covers the basics of IPv4, including its definition, structure, and addressing methods. It explains the importance of subnetting, the difference between classful and classless addressing, and provides examples of converting between binary and dotted-decimal notation. Additionally, it discusses the waste of addresses in classful addressing and introduces CIDR as a solution.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Week 1: Basics of IPv4

What is IPv4
• Internet Protocol version 4.
• We start to talk about IPv4 addresses because it is essential
to make today's Internet manageable. And this management
is done by subnetting.
• We need to understand why subnetting was firstly
implemented in classful fashion and why later it was
changed to classless fashion.
• Public and Private addresses must be also clarified.

03/23/2025 Chao Gao ([Link].), VAMK 2


How are the hosts connected to the Internet?
• The structure of today's Internet is very complex. But we
start from where we are sitting, which is always a Local
Area Network (LAN).

Host/User/Client
Internet
Internet
LAN
LAN Wide Area Network (WAN)

Hub/Switch

High quality links


Router/Gateway

LAN
LAN

A Local Area Network (LAN)

03/23/2025 Chao Gao ([Link].), VAMK 3


Hub, Switch, Router
• Hubs and Switches are used to connect PCs to make a LAN,
so usually they have many interfaces (ports).
• A router is used to connect two (or a few more) different
LANs, so usually it has much less number of ports.

HP ProCurve 10base-T
hub

Cisco Catalyst 2960


switch

TP-LINK 300 Mbps Wi-Fi Router


Cisco 2811
router

03/23/2025 Chao Gao ([Link].), VAMK 4


Equipment Room
• MER/SER/DER: Network equipment are located/protected
from public access in Equipment Rooms. (
[Link]
ser-en-der/
)
• Cable connections are distributed to other places
(classroom, office, etc.). This cables are called permanent
links or horizontal links.

03/23/2025 Chao Gao ([Link].), VAMK 5


How do hosts know each other?
• The hosts know each other by unique Internet address
called IP address.
• IP address is similar to telephone number in a telephony
network:
• Each telephone has a unique address in the telephone
network
• Phones in the same area (Local Area) have the same leading
number (prefix).
• Example: all telephone numbers in Vaasa have prefix 358 6
326 xxxx (Country code + Region code + Exchange code +
xxxx), 3586326 is called prefix.

03/23/2025 Chao Gao ([Link].), VAMK 6


Address Space
• An address space defines a range of discrete addresses,
each of which may correspond to a network host
[wikipedia].
• For computer networks, we use a limited number of bits to
address a host.
• Each host must have unique address.
• Thus, the number of bits defines the address space.
• It is clear to see: where

• Example 1: Bluetooth uses 3 bits to address a device, so address


space of BT is , i.e., each BT network can host up to 8 devices.
• Example 2: A hotel uses 4 digits to address a room, so address
space of this hotel is
• Example 3: A vehicle registration system uses 2 capital letters
and 4 digits. Address space
03/23/2025
=?
Chao Gao ([Link].), VAMK 7
IPv4 address
• IPv4: Internet Protocol version 4
• IPv4 address has 32 bits. (Address Space = ?)
• In computers it is always interpreted as 32-bit binary, for
example:
• 11110001000100100011000000101011
• As human beings, we prefer more decimal values. However, the
above value in decimal is 4044501035, still too complicated. So,
we divide 32 bits into 4 bytes, and convert each byte to a
decimal value and separate them by 3 dots.
• This notation is called "Dotted Decimal Notation". The
range ofByte
one1 byte inByte
decimal
2 is between
Byte 3 0 to Byte
255.4
11110001 00010010 00110000 00101011
This address in dotted decimal is
[Link]
Please refer to "Computer Number System"
to know more about binary to decimal
conversions.

03/23/2025 Chao Gao ([Link].), VAMK 8


Example 1:
• IP address in binary is
• 00101101 01001001 11111111 10010011

• Convert each byte (8-bit) into decimal:


• 00101101 is 45
• 01001001 is 73
• 11111111 is 255
• 10010011 is 147
• So the dotted decimal notation of this address is
[Link]

03/23/2025 Chao Gao ([Link].), VAMK 9


Example 2
Change the following IPv4 addresses from binary
notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111

Solution
We replace each group of 8 bits with its equivalent
decimal number and add dots for separation.

a. [Link]
b. [Link]

03/23/2025 Chao Gao ([Link].), VAMK 19.10


Example 3
Convert the following IPv4 addresses from dotted-decimal
notation to binary notation.
a. [Link]
b. [Link]

Solution

a. 01101111 00111000 00101101 01001110


b. 11011101 00100010 00000111 01010010

03/23/2025 Chao Gao ([Link].), VAMK 19.11


Example 4
Find the error, if any, in the following IPv4 addresses.

a. [Link]
b. [Link].20
c. [Link]
d. 11100010.23.14.67

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.

03/23/2025 Chao Gao ([Link].), VAMK 19.12


IPv4 Networking

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.
• An IPv4 address is 32 bits
long.
Topics discussed in this section: • The IPv4 addresses are
unique and universal.
• The address space of IPv4
Classful Addressing
is 232 or 4,294,967,296.
Classless Addressing
Public Networks and Private Networks
Network Address Translation (NAT)
Short Introduction to IPv6

03/23/2025 Chao Gao ([Link].), VAMK 19.13


Classful addressing
• In classful addressing, the address space is divided into five
classes: A, B, C, D, and E.

• Why classful addressing scheme? Consider a telephone


number system:
• Unique address to each host/phone
• Hosts in a local network should have same network prefix (e.g,
+358 6 xxxxxxx for Vaasa, Finland),
• this is also called "Logical Address", which is different from
"hardware address".
• The size of networks are different from each other (e.g., in a
small country we can use less "x" digits)

03/23/2025 Chao Gao ([Link].), VAMK 19.14


IPv4 Classes
• In Classful addressing, a network prefix takes 1-3 bytes of
32-bit (byte-wise).
• Classes A, B, C are unicast, prefix length for A is 8 bits, B is 16
bits, C is 24 bits.
• The classes are identified by the leading bits in prefix.
• Finding the classes in binary and dotted-decimal notation

Byte Byte
1 2 3 4 1 2 3 4
Class A 0 Class A 0-127

Class B 10 Class B 128-191

Class C 110 Class C 192-223

Class D 1110 Class D 224-239

Class E 1111 Class E 240-255

Binary notation Decimal notation

03/23/2025 Chao Gao ([Link].), VAMK 15


Example 19.4
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. [Link]
d. [Link]

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.

03/23/2025 Chao Gao ([Link].), VAMK 19.16


Class A 0

Net prefix Host ID

1 Prefix byte, but the first bit has to be 0, so the rest 7 bits
varies between 0000000 to 1111111 (0-127), totally 128 blocks
For each block there are 3 bytes (24 bits) as host ID, so we can
address hosts in one block from 0…0 to 1…1, totally 16 million ()
variations.

Class AClass
is for very large
Number networks.
of Blocks Block size Application
A 128 16777216 Unicast
B 16384 65536 Unicast
C 2097152 256 Unicast
DEach network
1 is regarded as268435456
a “block” of hosts.
Multicast
E 1 268435456 Reserved

03/23/2025 Chao Gao ([Link].), VAMK 19.17


Class C 110

Net prefix Host ID

A class C block has 3 bytes as prefix. The last byte defines the
individual host in the block.
E.g., 193.166.140 is the prefix of VAMK block. "[Link]"
has hostID=68.
Conclusion: in classful addressing, a prefix can be
read in 1-3 dotted decimal values.

03/23/2025 Chao Gao ([Link].), VAMK 18


Waste of addresses
• In classful addressing, a large number of the available
addresses were wasted.
• E.g., a small company which needs ~10 addresses has to apply a
class C block, over 200 addresses are wasted.
• A middle size company/school needs ~1000 addresses has to
apply a class B block, over 60000 addresses are wasted.

• To overcome this problem, a classless addressing scheme


called CIDR (Classless Inter-Domain Routing) is introduced
and used by today's Internet.

03/23/2025 Chao Gao ([Link].), VAMK 19.19


CIDR and Default Masking
• In CIDR, we use any length of bits as network prefix, and
the length is denoted as an integer value
• A block of addresses belonging to the same network have
the same n-bits.
• Traditional classes A/B/C have n=8/16/24 respectively. And
we call these numbers default masking. We will talk
masking soon.
Class Binary Dotted-Decimal CIDR
Mask
Notation
A 11111111 00000000 00000000 [Link] /8
00000000
B 11111111 11111111 00000000 [Link] /16
00000000
C 11111111 11111111 11111111 [Link] /24
00000000

03/23/2025 Chao Gao ([Link].), VAMK 19.20


Example 19.5
Figure 19.3 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 block has some features. 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.

03/23/2025 Chao Gao ([Link].), VAMK 19.21


Figure 19.3 A block of 16 addresses granted to a small organization

Network Prefix 28 bits

03/23/2025 Chao Gao ([Link].), VAMK 19.22


Note
In IPv4 classless addressing, a block of
addresses can be defined as x.y.z.t /n
in which x.y.z.t is one of the addresses and
the /n defines the mask.

The first address in the block can be found


by setting the rightmost 32 − n bits to 0s.

03/23/2025 Chao Gao ([Link].), VAMK 19.23


Example 19.6
A block of addresses is granted to a small organization. We know that
one of the addresses is [Link]/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 00100000
or
[Link].
This is actually the block shown in Figure 19.3.

03/23/2025 Chao Gao ([Link].), VAMK 19.24


Note

The last address in the block can be found


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

The number of addresses in the block can


be found by using the formula .

03/23/2025 Chao Gao ([Link].), VAMK 19.25


Example 19.7
Find the last address for the block in Example 19.6.

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
[Link]
This is actually the block shown in Figure 19.3.

03/23/2025 Chao Gao ([Link].), VAMK 19.26


Example 19.8
Find the number of addresses in Example 19.6.

Solution
The value of n is 28, which means that number of addresses is .

03/23/2025 Chao Gao ([Link].), VAMK 19.27


Example 19.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
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.

03/23/2025 Chao Gao ([Link].), VAMK 19.28


Example 19.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.

ddress: 11001101 00010000 00100101 00100111


ask: 11111111 11111111 11111111 11110000
-------------------------------------------------(bitwise AN
irst address: 11001101 00010000 00100101 00100000

03/23/2025 Chao Gao ([Link].), VAMK 19.29


Example 19.9 (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.
Address: 11001101 00010000 00100101 00100111
Mask complement: 00000000 00000000 00000000 00001111
----------------------------------------------------(OR)
Last address: 11001101 00010000 00100101 00101111

c. The number of addresses can be found by complementing the


mask, interpreting it as a decimal number, and adding 1 to it.
Mask complement: 00000000 00000000 00000000 00001111
Number of addresses: 15+1 = 16

03/23/2025 Chao Gao ([Link].), VAMK 19.30


Figure 19.4 A network configuration for the block [Link]/28

03/23/2025 Chao Gao ([Link].), VAMK 19.31


Note

The first address in a block shall NOT be


assigned to any device; it is denoted as
network address (also called as network
ID, or NetID) that represents the
organization to the
The last address rest
in a of the
block Internet.
is called subnet-
broadcasting address, and shall NOT be
assigned to any device.

03/23/2025 Chao Gao ([Link].), VAMK 19.32


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.

03/23/2025 Chao Gao ([Link].), VAMK 19.33


Dividing a block into smaller ones
• An organization now can apply for a suitable size of block.
The value n can be calculated by formula:
, where denotes ceiling function

• For example, a middle size company needs to host 600


computers, then

• If the company has departments, the network admin then


can further divide this block into smaller subnetworks
(subnets).

03/23/2025 Chao Gao ([Link].), VAMK 34


Figure 19.7 Configuration and addresses in a subnetted network

There is a mistake in this figure.


03/23/2025 Chao Gao ([Link].), VAMK 19.35
Figure 19.8 Three-level hierarchy in an IPv4 address

03/23/2025 Chao Gao ([Link].), VAMK 19.36


Exercise:
• You are given a block as [Link]/23, please make 4
subnets as one /24, two /26, and one /27.
• Show after the subnet allocation, how many addresses are
still un-allocated.
• Solution: for the given value [Link]/23, we know n=23, size
of this block = So the first address is to turn rightmost 9 bits as
0, we get [Link]; the last address is to turn rightmost 9 bits
as 1, we get [Link].
• Subnet 1: n=24, we can start from the first address in the block,
which is [Link], the last address is to set rightmost 8 bits to
1, we get [Link]
• Subnet 2: n=26, the first un-allocated address in the block is
[Link]/26, we know the last address of this block is
[Link],
• Subnet 3: n=26, the scope of the block is [Link]-127.
• Subnet 4: n=27, the scope is [Link]-159,
• After this allocation, we still have addresses from [Link]-
255 unallocated.
03/23/2025 Chao Gao ([Link].), VAMK 37
Private IP: Short of address problem:
• The number of Internet users and Internet devices has
increased dramatically in recent years, and using out all the
available IPv4 addresses.
• A quick solution is to make Private Networks, and deploy
Network Address Translator (NAT).
• Ultimate solution is IPv6.

• RFC1918 allocates 3 blocks for private networks.

Table 19.3 Addresses for private networks


Private network range Total
[Link] to [Link]
[Link] to [Link]
[Link] to [Link]

03/23/2025 Chao Gao ([Link].), VAMK 19.38


Private networks & NAT
• A NAT is a special router, on one side it connects to a
private network, on the other side it connects to Internet.
• The rest of Internet sees only public IP of the NAT.

[Link] [Link] [Link]

Internet
[Link] [Link]

Private network: [Link]/27

03/23/2025 Chao Gao ([Link].), VAMK 19.39


How a NAT works
• A NAT remembers the source and destination IP addresses
when a packet is going out, by creating a new entry in its
"translation table".
• NAT replaces the source IP (which is private) by its public
IP.
• When a reply comes from the remote host, the NAT knows
which private host has communicated with this Internet
host, it replaces the destination address from its own public
IP to thePrivate
corresponding private IP.
network: [Link]/27

Source [Link]
[Link] Source [Link]

Internet
[Link]

Destination [Link] Destination [Link]

03/23/2025 Chao Gao ([Link].), VAMK 19.40


Figure 19.12 NAT address translation

Source [Link] Source [Link]


Dest: [Link] Dest: [Link]

private public
[Link]

Private External

[Link] [Link]
… …
… …
An entry is
created when this
package goes out
When the remote
host reply comes
back, the table is
Source [Link] Source [Link] looked up.
Dest [Link] Dest [Link]

private public
[Link]

03/23/2025 Chao Gao ([Link].), VAMK 19.41


NAT vs PAT
• NAT works by a translation table, which is dynamic.
• Port number may be used to distinguish the connections to
the same remote host. The table below shows how a NAT
distinguishes connections from 2 private host to the same
public host.
• In this case Port numbers are used to distinguish the
connections, somebody calls such a device a PAT (Port
Address Translator).
Private Private Remote Remote Transport
address port address port protocol
172.18.3. 1400 [Link] 80 TCP
1
172.18.3. 2394 [Link] 80 TCP
2
… … … … …

03/23/2025 Chao Gao ([Link].), VAMK 19.42


home configuration
[Link]/26
Cable
HTPC ([Link])

net
r public
[Link]/29 I nte
To

[Link]
WiFi

[Link]
[Link]
WAN:
[Link]

Laptop 1 ([Link])
Wireless router (NAT)
ADSL/fiber/4G5G modem (NAT)

Desktop 2 ([Link])
PS3 ([Link])

Desktop 1 ([Link])

03/23/2025 Chao Gao ([Link].), VAMK 19.43


Problem of NAT
• A connection to public has to be initiated by the private
host.
• Because of this, we cannot set up a server behind a NAT.

• Peer-to-peer communication is difficult, because the hosts


behind a NAT cannot act as a server.

• Final solution is IPv6, which has an address space of

03/23/2025 Chao Gao ([Link].), VAMK 19.44

You might also like