IP address

Network Protocols
Chapter 5 (TCP/IP Suite Book):
IPv4 Addresses
Copyright © Lopamudra Roychoudhuri
1
Agenda

IPv4 Addresses:
 IPv4 addresses and classes
 Classful addressing
 Network addresses and masks
 Network Address Translation (NAT)
2
Network Layer




The network layer is designed as a packetswitched network.
Packet-switched network can provide either a
connectionless service or a connection-oriented
service.
When the network layer provides a
connectionless service, each packet traveling in
the Internet is an independent entity; there is no
relationship between packets belonging to the
same message.
In a connection-oriented service, there is a virtual
connection between all packets belonging to a
3
message.
Network Layer




This means that the packet at the source is
divided into manageable packets, normally
called datagrams.
Individual datagrams are then transferred
from the source to the destination.
The received datagrams are assembled at
the destination before recreating the original
message.
The packet-switched network layer of the
Internet was originally designed as a
connectionless service.
4
Figure 4.3 A connectionless
packet-switched network
Network
A connectionless
packet-swtiched network
R1
4
3
2
R2
1
2
1
Sender
Network
4
2
3
3
R4
1
3
1
4
R3

R5
3
4
2
Out of order
The network layer is responsible for delivery of
packets from the source to the destination.
Receiver
5
Figure 4.4 Forwarding process in a
connectionless network
Legend
Routing table
Destination Output
address
interface
A
1
B
2
H
3
Destination
address
SA DA Data
2
1
3


SA: Source address
DA: Destination address
Send the packet
out of interface 2
SA DA Data
4
The source address may be used to send an error
message to the source if the packet is discarded.
The forwarding decision is based on the destination
address of the packet.
6
IP Addresses



The identifier used in the IP layer of the TCP/IP
protocol suite to identify each device connected to the
Internet
Uniquely and universally defines the connection of a
host or a router to the Internet
32 bits, 4 bytes long

dotted decimal notation


Each of the 4 values is in range 0 – 255, such as, 150.21.39.52
The address space of IPv4 is 232 or 4,294,967,296.
7
IP Addresses cont.


How does every device on the Internet
get a different IP address?
IP Address Prefixes assigned to
organizations by the Internet Assigned
Numbers Authority (IANA)
 Distributes IP address pools to Regional
Internet Registry (RIR) organizations, such
as Réseaux IP Européens Network
Coordination Centre (RIPE NCC)
http://www.iana.org/numbers/
8
IP Addresses cont.




RIPE NCC hands over IP address prefixes to
Organizations: ISPs, Universities, large
businesses
These organizations then control all IP
addresses starting with that prefix
Small businesses are loaned a group of IP
addresses by ISP
Individual PCs get a dynamically assigned IP
address from ISP each time they dial up.
9
IP Addresses cont.
Hexadecimal notation
0x80
0x0B
0x03
0x3F
Binary notation
Dotted Decimal notation
•An IP address can also be thought of as a number in base 256.
•i.e., 128.11.3.31 is nothing but
•128*256^3 + 11*256^2 + 3*256^1 + 31*256^0
•(See TCP/IP Textbook appendix B, Page 898)
10
IP Addresses

IP address is designed to identify

A particular IP Network that this packet
should be delivered to by Internet routers

A particular IP host machine on that
network that this packet should be delivered
to by local router at the destination site
11
Classful IP Addresses
IP addresses, when started a few decades ago, used the concept of classes.
This architecture is called classful addressing.
Class A: for Large networks
Class B: for Medium networks
Class C: for Small networks
Class D: Multicast
12
Figure 5.7 Finding the class of an address using
continuous checking
1
1
Start
0
Class: A
0
Class: B
1
0
Class: C
1
0
Class: D
Class: E
13
00000000 0 ……0
01111111 1 ……1
10000000 0 ……0
10111111 1 ……1
11000000 0 ……0
11011111 1 ……1
11100000 0 ……0
11101111 1 ……1
11110000 0 ……0
11111111 1 ……1
14
Occupation of the address
space
15
Figure 5.15
Information extraction in classful addressing
netid
000 ... 0
First address
16
Example 19.1
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 (see Appendix B) and add dots for
separation.
17
Example 19.2
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Solution
We replace each decimal number with its binary
equivalent .
18
Example 19.3
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.
19
Example 19.4
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.
20
Note
In classful addressing, a large part of the
available addresses were wasted.
21
Note
Classful addressing, which is almost
obsolete, is replaced with classless
addressing.
22
Example 5.5
Find the number of addresses in a range if the first address is
146.102.29.0 and the last address is 146.102.32.255.
Solution
We can subtract the first address from the last address in base
256 (see Appendix B). The result is 0.0.3.255 in this base. To
find the number of addresses in the range (in decimal), we
convert this number to base 10 and add 1 to the result.
= 255 * 256^0 + 3 * 256^1 = 1023 + 1 = 1024
23
Net Address



First address in the block
Network address defines the network to
rest of Internet
Given network address we can find the
class of the address, the block, and
range of addresses in the block
24
Network Address
25
Blocks in class A
26
Class A Address

First byte value between 1 and 127

ICANN specifies value of 1st byte


Organization chooses IP address for each device by
assigning value in last 3 bytes.
Organization may have (256 * 256 * 256) = 16
million different IP addresses for devices!!
 Millions of class A addresses are wasted.
 List of Assigned class A addresses
27
Blocks in class B
28
Class B Address

First byte has value between 128 and 191

ICANN specifies value of 1st and 2nd bytes


Organization chooses IP address for each device by
assigning value in last 2 bytes.
Organization has (256 * 256) = 65,536 different IP
addresses for devices!!

Many class B addresses are wasted.
29
Blocks in class C
30
Class C Address

First byte has value between 192 and 223

ICANN specifies value of 1st, 2nd and 3rd bytes


Organization chooses particular IP address for each
device by assigning value in last byte.
Organization gets 256 different IP addresses for its
devices


The number of addresses in class C is smaller than the
needs of most organizations
Example: IP addresses 207.46.232.x are all
controlled by Microsoft Corporation
31
Unicast, Multicast, and
Broadcast Addresses
Unicast communication is one-to-one.
Multicast communication is one-to-many.
Broadcast communication is one-to-all.
32
Class D Address





First byte has value between 224 and 239
There is no Network ID or Host ID. The entire
address is used for multicasting
Each address represents a group of hosts that all
listen to one sender
Example: Address 224.0.0.9 can be used to
send routing information to all RIP2-aware
routers on a network segment.
List of used multicast addresses
33
Multicast Category addresses
Distance Vector Multicast
Routing Protocol
Open Shortest Path First
Internet Stream Protocol
Routing Information Protocol
Interior Gateway Routing Protocol
34
IP Special Addresses
Address
Netid
Hostid
Src/Dest
Network
Address
Specific
All 0s
None
Direct
Broadcast
Specific
All 1s
Dest
Limited
Broadcast
All 1s
All 1s
Dest
This host
All 0s
All 0s
Source
Host on this
network
All 0s
Specific
Dest
Loopback
127
Any
Dest
35
Direct Broadcast
Direct broadcast address is used by a router to
send a message to every host on a local network
36
Limited Broadcast
Limited broadcast address is used by a host to send a packet
to every host on the same network
However, the packet is blocked by routers
37
This Host
A host that does not know its IP address uses the IP address
0.0.0.0 as the source address and 255.255.255.255 as the
destination address to send a message to a boot strap server
Can be used only as a source address
38
Loopback
A packet with loopback address will not reach the network
Can be used by a client process to send a message to a server
process on the same machine
Can only be used as a destination address
39
Private Addresses
A number of blocks in each class are
assigned for private use.
They are not recognized globally, hence
cannot be used on public Internet
40
Multihomed devices
A device that has more than one Internet address;
a different address for each network connected to it
41
Sample internet
1. A LAN with nw address
220.3.6.0 (class C)
2. A LAN with nw address
134.18.0.0 (class B)
3. A LAN with nw address
124.0.0.0 (class A)
4. A point-to-point WAN
5. A switched WAN
Note: The book does not show any IP address for point-to-point link end-points
But in reality point-to-point WAN interfaces are also assigned IP addresses.
42
Question


How can you determine if an IP address
belongs to a particular network?
Answer:

Apply a netmask
A mask is a 32-bit binary number that
gives the first address in the block, i.e. the
network address when bitwise ANDed with
an address in the block
43
Network Address
 The network address is the beginning
address of each block.
 It can be found by applying the default
mask to any of the addresses in the block
(including itself).
 It keeps the netid of the block and sets
the hostid to zero.
44
Masking concept
bit
bit
45
Anding & Oring Tables
Anding
0
0
0
0
1
0
1
0
0
1
1
1
Oring
0
0
0
0
1
1
1
0
1
1
1
1
46
Default Masks
11111111 11111111 00000000 00000000
10001101 00001110 01001000 00011000
10001101 00001110 00000000 00000000
47
Example 19.6
A block of addresses is granted to a small organization.
We know that one of the addresses is 205.16.37.39/24.
What is the first address in the block?
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we used the default mask and And it with the IP
address, we get
11001101 00010000 00100101 00000000
or
205.16.37.0.
48
Note
The last address in the block can be
found by setting the rightmost
32 − n bits to 1s.
49
Example 5.13
An address in a block is given as 73.22.17.25. Find the number
of addresses in the block, the first address, and the last
address.
Solution
Figure 5.16 shows a possible configuration of the network that
uses this block.
1. From the 1st byte we know that this is a class A address.
Hence number of network bits (n) is 8. The number of
addresses in this block is N = 232−n=232−8=224 =16,777,216.
2. To find the first address, we keep the leftmost 8 bits and set
the rightmost 24 bits all to 0s. The first address is 73.0.0.0, in
which 8 is the value of n.
3. To find the last address, we keep the leftmost 8 bits and set
the rightmost 24 bits all to 1s. The last address is
73.255.255.255.
50
Figure 5.16
Solution to Example 5.13
51
Example 5.14
An address in a block is given as 180.8.17.9. Find the number
of addresses in the block, the first address, and the last
address.
Solution
Figure 5.17 shows a possible configuration of the network that
uses this block.
1. The number of addresses in this block is N = 232−n =
65,536.
2. To find the first address, we keep the leftmost 16 bits and set
the rightmost 16 bits all to 0s. The first address is 180.8.0.0, in
which 16 is the value of n.
3. To find the last address, we keep the leftmost 16 bits and set
the rightmost 16 bits all to 1s. The last address is
180.8.255.255.
52
Figure 5.17
Solution to Example 5.14
53
Example 5.15
An address in a block is given as 200.11.8.45. Find the number
of addresses in the block, the first address, and the last
address.
Solution
Figure 5.17 shows a possible configuration of the network that
uses this block.
1. The number of addresses in this block is N = 232−n = 256.
2. To find the first address, we keep the leftmost 24 bits and set
the rightmost 8 bits all to 0s. The first address is
200.11.8.0, in which 24 is the value of n.
3. To find the last address, we keep the leftmost 24 bits and set
the rightmost 8 bits all to 1s. The last address is
200.11.8.255.
54
Figure 5.18
Solution to Example 5.15
55
Example 5.16 (Note that the book’s solution is incorrect)
A router receives a packet with the destination address
201.24.67.32. Show how the router finds the network address of
the packet.
Solution
Since the class of the address is C, we assume that the router
applies the default mask for class C, 255.255.255.0 to find the
network address.
255
67
56
Another way to find the first address, last address,
, and the number of addresses
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 8digit hexadecimal) number.
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.
b. The last address can be found by ORing the given
addresses with the complement of the mask
 The complement of a number is found by changing each 1 to 0
and each 0 to 1.
c. The number of addresses can be found by complementing the
mask, interpreting it as a decimal number, and adding 1 to it.
57
Network Address Translation (NAT)
 Network Address Translation (NAT): is the process of modifying
IP address information in IPv4 headers while in transit across a traffic
routing device.
 NAT is necessary when the number of IP addresses assigned to you by
your ISP is less than the total number of computers that you wish to provide
Internet access for.
 The simplest type of NAT provides a one-to-one translation of
IP addresses. This refers to this type of NAT as basic NAT, which is
often also called a one-to-one NAT.
 Another way to map an entire network (or networks) to a single IP
address (Security wise).
 NAT allows you to take advantage of the reserved address blocks.
58
Figure 19.10 A NAT implementation
59
Figure 19.11 Addresses in a NAT
60
Figure 19.12 NAT address translation
61
Table 19.4 Five-column translation table
62
Figure 19.13 An ISP and NAT
63